mirror of https://github.com/elunez/eladmin
parent
3095f3730e
commit
3f7c8332da
|
@ -140,7 +140,9 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||
File dest = new File(path).getCanonicalFile();
|
||||
// 检测是否存在目录
|
||||
if (!dest.getParentFile().exists()) {
|
||||
dest.getParentFile().mkdirs();
|
||||
if (!dest.getParentFile().mkdirs()) {
|
||||
System.out.println("was not successful.");
|
||||
}
|
||||
}
|
||||
// 文件写入
|
||||
file.transferTo(dest);
|
||||
|
@ -220,7 +222,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||
try {
|
||||
InputStream in = new FileInputStream(file);
|
||||
try {
|
||||
in.read(b);
|
||||
System.out.println(in.read(b));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -50,9 +50,13 @@ public class ZipUtils {
|
|||
System.out.println("file unzip : " + newFile.getAbsoluteFile());
|
||||
//大部分网络上的源码,这里没有判断子目录
|
||||
if (ze.isDirectory()) {
|
||||
newFile.mkdirs();
|
||||
if (!newFile.mkdirs()) {
|
||||
System.out.println("was not successful.");
|
||||
}
|
||||
} else {
|
||||
new File(newFile.getParent()).mkdirs();
|
||||
if (!new File(newFile.getParent()).mkdirs()) {
|
||||
System.out.println("was not successful.");
|
||||
}
|
||||
FileOutputStream fos = new FileOutputStream(newFile);
|
||||
int len;
|
||||
while ((len = zis.read(buffer)) != -1) {
|
||||
|
@ -80,12 +84,16 @@ public class ZipUtils {
|
|||
File file = new File(out, entry.getName());
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
file.mkdirs();
|
||||
if (!file.mkdirs()) {
|
||||
System.out.println("was not successful.");
|
||||
}
|
||||
} else {
|
||||
File parent = file.getParentFile();
|
||||
|
||||
if (!parent.exists()) {
|
||||
parent.mkdirs();
|
||||
if (!parent.mkdirs()) {
|
||||
System.out.println("was not successful.");
|
||||
}
|
||||
}
|
||||
|
||||
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) {
|
||||
|
@ -115,7 +123,9 @@ public class ZipUtils {
|
|||
public static void upZipFile(File zipFile, String folderPath) throws ZipException, IOException {
|
||||
File desDir = new File(folderPath);
|
||||
if (!desDir.exists()) {
|
||||
desDir.mkdirs();
|
||||
if (!desDir.mkdirs()) {
|
||||
System.out.println("was not successful.");
|
||||
}
|
||||
}
|
||||
ZipFile zf = new ZipFile(zipFile);
|
||||
for (Enumeration<?> entries = zf.entries(); entries.hasMoreElements(); ) {
|
||||
|
@ -127,7 +137,9 @@ public class ZipUtils {
|
|||
if (!desFile.exists()) {
|
||||
File fileParentDir = desFile.getParentFile();
|
||||
if (!fileParentDir.exists()) {
|
||||
fileParentDir.mkdirs();
|
||||
if (!fileParentDir.mkdirs()) {
|
||||
System.out.println("was not successful.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,9 +29,6 @@ import me.zhengjie.utils.PageUtil;
|
|||
import me.zhengjie.utils.QueryHelp;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import org.quartz.CronExpression;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
|
@ -46,7 +43,6 @@ import java.util.*;
|
|||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service(value = "quartzJobService")
|
||||
@CacheConfig(cacheNames = "quartzJob")
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class QuartzJobServiceImpl implements QuartzJobService {
|
||||
|
||||
|
@ -55,7 +51,6 @@ public class QuartzJobServiceImpl implements QuartzJobService {
|
|||
private final QuartzManage quartzManage;
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public Object queryAll(JobQueryCriteria criteria, Pageable pageable){
|
||||
return PageUtil.toPage(quartzJobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
|
||||
}
|
||||
|
@ -76,7 +71,6 @@ public class QuartzJobServiceImpl implements QuartzJobService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#p0")
|
||||
public QuartzJob findById(Long id) {
|
||||
QuartzJob quartzJob = quartzJobRepository.findById(id).orElseGet(QuartzJob::new);
|
||||
ValidationUtil.isNull(quartzJob.getId(),"QuartzJob","id",id);
|
||||
|
@ -84,7 +78,6 @@ public class QuartzJobServiceImpl implements QuartzJobService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public QuartzJob create(QuartzJob resources) {
|
||||
if (!CronExpression.isValidExpression(resources.getCronExpression())){
|
||||
|
@ -96,7 +89,6 @@ public class QuartzJobServiceImpl implements QuartzJobService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(QuartzJob resources) {
|
||||
if (!CronExpression.isValidExpression(resources.getCronExpression())){
|
||||
|
@ -107,7 +99,6 @@ public class QuartzJobServiceImpl implements QuartzJobService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
public void updateIsPause(QuartzJob quartzJob) {
|
||||
if (quartzJob.getIsPause()) {
|
||||
quartzManage.resumeJob(quartzJob);
|
||||
|
@ -125,7 +116,6 @@ public class QuartzJobServiceImpl implements QuartzJobService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Set<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
|
|
|
@ -51,7 +51,6 @@ public class ExecutionJob extends QuartzJobBean {
|
|||
private final static ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void executeInternal(JobExecutionContext context) {
|
||||
QuartzJob quartzJob = (QuartzJob) context.getMergedJobDataMap().get(QuartzJob.JOB_KEY);
|
||||
// 获取spring bean
|
||||
|
|
|
@ -190,6 +190,7 @@ public class MenuServiceImpl implements MenuService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public Object getMenus(Long pid) {
|
||||
List<Menu> menus;
|
||||
if(pid != null && !pid.equals(0L)){
|
||||
|
@ -201,6 +202,7 @@ public class MenuServiceImpl implements MenuService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public List<MenuDto> getSuperior(MenuDto menuDto, List<Menu> menus) {
|
||||
if(menuDto.getPid() == null){
|
||||
menus.addAll(menuRepository.findByPidIsNull());
|
||||
|
@ -291,6 +293,7 @@ public class MenuServiceImpl implements MenuService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public Menu findOne(Long id) {
|
||||
Menu menu = menuRepository.findById(id).orElseGet(Menu::new);
|
||||
ValidationUtil.isNull(menu.getId(),"Menu","id",id);
|
||||
|
|
|
@ -37,7 +37,9 @@ public class MultipartConfig {
|
|||
String location = System.getProperty("user.home") + "/.eladmin/file/tmp";
|
||||
File tmpFile = new File(location);
|
||||
if (!tmpFile.exists()) {
|
||||
tmpFile.mkdirs();
|
||||
if (!tmpFile.mkdirs()) {
|
||||
System.out.println("create was not successful.");
|
||||
}
|
||||
}
|
||||
factory.setLocation(location);
|
||||
return factory.createMultipartConfig();
|
||||
|
|
|
@ -26,9 +26,6 @@ import me.zhengjie.exception.BadRequestException;
|
|||
import me.zhengjie.utils.*;
|
||||
import me.zhengjie.repository.LocalStorageRepository;
|
||||
import me.zhengjie.service.LocalStorageService;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -49,7 +46,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "localStorage")
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
|
||||
|
@ -57,22 +53,18 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
|||
private final LocalStorageMapper localStorageMapper;
|
||||
private final FileProperties properties;
|
||||
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public Object queryAll(LocalStorageQueryCriteria criteria, Pageable pageable){
|
||||
Page<LocalStorage> page = localStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(localStorageMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public List<LocalStorageDto> queryAll(LocalStorageQueryCriteria criteria){
|
||||
return localStorageMapper.toDto(localStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#p0")
|
||||
public LocalStorageDto findById(Long id){
|
||||
LocalStorage localStorage = localStorageRepository.findById(id).orElseGet(LocalStorage::new);
|
||||
ValidationUtil.isNull(localStorage.getId(),"LocalStorage","id",id);
|
||||
|
@ -80,7 +72,6 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public LocalStorageDto create(String name, MultipartFile multipartFile) {
|
||||
FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
|
||||
|
@ -108,7 +99,6 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(LocalStorage resources) {
|
||||
LocalStorage localStorage = localStorageRepository.findById(resources.getId()).orElseGet(LocalStorage::new);
|
||||
|
@ -118,7 +108,6 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
|
|
|
@ -29,7 +29,6 @@ import me.zhengjie.service.dto.PictureQueryCriteria;
|
|||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.utils.*;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
|
@ -47,7 +46,6 @@ import java.util.*;
|
|||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service(value = "pictureService")
|
||||
@CacheConfig(cacheNames = "picture")
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class PictureServiceImpl implements PictureService {
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ import me.zhengjie.utils.QueryHelp;
|
|||
import me.zhengjie.utils.ValidationUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
@ -86,7 +85,7 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@CachePut(cacheNames = "qiNiuConfig", key = "'1'")
|
||||
@CachePut(key = "'1'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public QiniuConfig update(QiniuConfig qiniuConfig) {
|
||||
String http = "http://", https = "https://";
|
||||
|
@ -98,7 +97,6 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public QiniuContent upload(MultipartFile file, QiniuConfig qiniuConfig) {
|
||||
FileUtil.checkSize(maxSize, file.getSize());
|
||||
|
@ -138,7 +136,6 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public QiniuContent findByContentId(Long id) {
|
||||
QiniuContent qiniuContent = qiniuContentRepository.findById(id).orElseGet(QiniuContent::new);
|
||||
ValidationUtil.isNull(qiniuContent.getId(),"QiniuContent", "id",id);
|
||||
|
@ -146,7 +143,6 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public String download(QiniuContent content,QiniuConfig config){
|
||||
String finalUrl;
|
||||
String type = "公开";
|
||||
|
@ -162,7 +158,6 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(QiniuContent content, QiniuConfig config) {
|
||||
//构造一个带指定Zone对象的配置类
|
||||
|
@ -178,7 +173,6 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void synchronize(QiniuConfig config) {
|
||||
if(config.getId() == null){
|
||||
|
@ -216,7 +210,6 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
public void deleteAll(Long[] ids, QiniuConfig config) {
|
||||
for (Long id : ids) {
|
||||
delete(findByContentId(id), config);
|
||||
|
@ -224,7 +217,6 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(String type) {
|
||||
qiNiuConfigRepository.update(type);
|
||||
|
|
|
@ -23,20 +23,20 @@ package me.zhengjie.utils;
|
|||
public enum AliPayStatusEnum {
|
||||
|
||||
/** 交易成功 */
|
||||
FINISHED("交易成功", "TRADE_FINISHED"),
|
||||
FINISHED("TRADE_FINISHED"),
|
||||
|
||||
/** 支付成功 */
|
||||
SUCCESS("支付成功", "TRADE_SUCCESS"),
|
||||
SUCCESS("TRADE_SUCCESS"),
|
||||
|
||||
/** 交易创建 */
|
||||
BUYER_PAY("交易创建", "WAIT_BUYER_PAY"),
|
||||
BUYER_PAY("WAIT_BUYER_PAY"),
|
||||
|
||||
/** 交易关闭 */
|
||||
CLOSED("交易关闭", "TRADE_CLOSED");
|
||||
CLOSED("TRADE_CLOSED");
|
||||
|
||||
private String value;
|
||||
private final String value;
|
||||
|
||||
AliPayStatusEnum(String name, String value) {
|
||||
AliPayStatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,10 +61,10 @@ public class AlipayUtils {
|
|||
|
||||
// 获取支付宝POST过来反馈信息
|
||||
Map<String,String> params = new HashMap<>(1);
|
||||
Map requestParams = request.getParameterMap();
|
||||
Map<String, String[]> requestParams = request.getParameterMap();
|
||||
for (Object o : requestParams.keySet()) {
|
||||
String name = (String) o;
|
||||
String[] values = (String[]) requestParams.get(name);
|
||||
String[] values = requestParams.get(name);
|
||||
String valueStr = "";
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
valueStr = (i == values.length - 1) ? valueStr + values[i]
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
package me.zhengjie.utils;
|
||||
|
||||
import com.qiniu.storage.Region;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
|
|
Loading…
Reference in New Issue