feat:web模块包名调整
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.tiesheng.web;
|
||||
|
||||
import com.tiesheng.database.DatabaseAutoConfigurer;
|
||||
import com.tiesheng.encrypt.EncryptAutoConfigurer;
|
||||
import com.tiesheng.login.LoginAutoConfigurer;
|
||||
import com.tiesheng.message.MessageAutoConfigurer;
|
||||
import com.tiesheng.util.UtilAutoConfigurer;
|
||||
import com.tiesheng.web.service.TieshengWebConfigurer;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
@Documented
|
||||
@Import({
|
||||
UtilAutoConfigurer.class,
|
||||
MessageAutoConfigurer.class,
|
||||
WebAutoConfigurer.class,
|
||||
LoginAutoConfigurer.class,
|
||||
DatabaseAutoConfigurer.class,
|
||||
EncryptAutoConfigurer.class,
|
||||
})
|
||||
public @interface EnableTieshengWeb {
|
||||
|
||||
Class<? extends TieshengWebConfigurer> webConfigurer();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.tiesheng.web;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
|
||||
@ComponentScan({
|
||||
"com.tiesheng.web.**.*",
|
||||
"com.tiesheng.role.**.*",
|
||||
})
|
||||
@MapperScan(value = {"com.tiesheng.web.mapper", "com.tiesheng.role.mapper"})
|
||||
public class WebAutoConfigurer {
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.tiesheng.web.config.exception;
|
||||
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.tiesheng.web.service.TieshengWebConfigurer;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.exception.ApiRespEnum;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.MultipartProperties;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author huang
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
public class SpringExceptionHandler {
|
||||
|
||||
@Autowired
|
||||
TieshengWebConfigurer tieshengWebConfigurer;
|
||||
|
||||
|
||||
/**
|
||||
* 全局异常捕获
|
||||
*
|
||||
* @param e
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ApiResp<String> handle(Exception e) {
|
||||
|
||||
// 自定义异常
|
||||
if (e instanceof ApiException) {
|
||||
return ((ApiException) e).getApiResp();
|
||||
}
|
||||
|
||||
// 请求异常
|
||||
if (e instanceof ValidateException) {
|
||||
return ApiResp.respCust(ApiRespEnum.BadRequest.getCode(), e.getMessage());
|
||||
}
|
||||
if (e instanceof BindException) {
|
||||
FieldError error = ((BindException) e).getFieldError();
|
||||
String msg = "请求参数不合法";
|
||||
if (error != null) {
|
||||
msg = error.getDefaultMessage();
|
||||
}
|
||||
return ApiResp.respCust(ApiRespEnum.BadRequest.getCode(), msg);
|
||||
}
|
||||
if (e instanceof MethodArgumentTypeMismatchException) {
|
||||
return ApiResp.respCust(ApiRespEnum.BadRequest.getCode(), "请求参数不合法");
|
||||
}
|
||||
if (e instanceof HttpRequestMethodNotSupportedException) {
|
||||
return ApiResp.respCust(ApiRespEnum.BadRequest.getCode(), "不支持的请求方式");
|
||||
}
|
||||
if (e instanceof NoHandlerFoundException) {
|
||||
return ApiResp.respCust(ApiRespEnum.BadRequest.getCode(), "请求路径不存在");
|
||||
}
|
||||
if (e instanceof MaxUploadSizeExceededException) {
|
||||
MultipartProperties property = SpringUtil.getBean(MultipartProperties.class);
|
||||
return ApiResp.respCust(ApiRespEnum.BadRequest.getCode(), String.format("上传文件不得超过%dMB", property.getMaxFileSize().toMegabytes()));
|
||||
}
|
||||
|
||||
// 服务器内部异常
|
||||
if (e instanceof IOException) {
|
||||
return ApiResp.respCust(ApiRespEnum.ServerError.getCode(), "IO异常");
|
||||
}
|
||||
|
||||
return tieshengWebConfigurer.addExceptionHandler(e);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.tiesheng.web.config.json;
|
||||
|
||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||
import com.tiesheng.util.CommonUtil;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@Configuration
|
||||
public class FastJsonMessageConverter {
|
||||
|
||||
/**
|
||||
* 配置FastJson
|
||||
*
|
||||
* @return HttpMessageConverters
|
||||
*/
|
||||
@Bean
|
||||
public HttpMessageConverters fastJsonHttpMessageConverters() {
|
||||
|
||||
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
||||
fastConverter.setFastJsonConfig(CommonUtil.fastJsonConfig());
|
||||
fastConverter.setDefaultCharset(StandardCharsets.UTF_8);
|
||||
|
||||
List<MediaType> mediaTypes = new ArrayList<>();
|
||||
mediaTypes.add(MediaType.APPLICATION_JSON);
|
||||
fastConverter.setSupportedMediaTypes(mediaTypes);
|
||||
|
||||
return new HttpMessageConverters(fastConverter);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.tiesheng.web.config.mybatis;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@Configuration
|
||||
public class MybatisPlusCustomizer {
|
||||
|
||||
/**
|
||||
* 分页器配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
|
||||
interceptor.addInnerInterceptor(paginationInnerInterceptor);
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* map对象自动转驼峰
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public ConfigurationCustomizer configurationCustomizer() {
|
||||
return i -> {
|
||||
i.setObjectWrapperFactory(new MybatisMapWrapperFactory());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* map中保留null值
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public MybatisConfiguration mybatisConfiguration() {
|
||||
MybatisConfiguration configuration = new MybatisConfiguration();
|
||||
configuration.setCallSettersOnNulls(true);
|
||||
return configuration;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.tiesheng.web.config.mybatis;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@Component
|
||||
public class MybatisTimeMetaHandler implements MetaObjectHandler {
|
||||
|
||||
/**
|
||||
* 在执行mybatisPlus的insert()时,为我们自动给某些字段填充值,这样的话,我们就不需要手动给insert()里的实体类赋值了
|
||||
*
|
||||
* @param metaObject
|
||||
*/
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
// 其中方法参数中第一个是前面自动填充所对应的字段,第二个是要自动填充的值。第三个是指定实体类的对象
|
||||
Object createTime = getFieldValByName("createTime", metaObject);
|
||||
if (createTime == null) {
|
||||
createTime = DateUtil.date();
|
||||
}
|
||||
this.setFieldValByName("createTime", createTime, metaObject);
|
||||
this.setFieldValByName("updateTime", DateUtil.date(), metaObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在执行mybatisPlus的update()时,为我们自动给某些字段填充值,这样的话,我们就不需要手动给update()里的实体类赋值了
|
||||
*
|
||||
* @param metaObject
|
||||
*/
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
this.setFieldValByName("updateTime", DateUtil.date(), metaObject);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.tiesheng.web.config.operation;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tiesheng.annotation.operation.OperationIgnore;
|
||||
import com.tiesheng.annotation.operation.OperationLog;
|
||||
import com.tiesheng.web.service.CoreLogService;
|
||||
import com.tiesheng.util.ServletKit;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
* @ProjectName CmccSpring
|
||||
* @Copyright Hangzhou ShuoChuang Technology Co.,Ltd All Right Reserved
|
||||
* @Description 这里是对文件的描述
|
||||
* @data 2019-07-15
|
||||
* @note 这里写文件的详细功能和改动
|
||||
* @note
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class OperationAspect {
|
||||
|
||||
@Autowired
|
||||
CoreLogService coreLogService;
|
||||
|
||||
|
||||
@Pointcut("execution(* com..controller..*.*(..))")
|
||||
public void methodArgs() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取操作日志说明
|
||||
*
|
||||
* @param joinPoint
|
||||
*/
|
||||
@Around("methodArgs()")
|
||||
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
|
||||
// GET请求不处理
|
||||
HttpServletRequest request = ServletKit.getRequest();
|
||||
if (StrUtil.equalsIgnoreCase(request.getMethod(), "GET")) {
|
||||
return joinPoint.proceed(joinPoint.getArgs());
|
||||
}
|
||||
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
|
||||
// 当存在忽略注解时,不添加操作日志
|
||||
if (method.getAnnotation(OperationIgnore.class) != null) {
|
||||
return joinPoint.proceed(joinPoint.getArgs());
|
||||
}
|
||||
|
||||
String title = "", subject = "";
|
||||
String insertKey = "";
|
||||
OperationLog operationLog = method.getAnnotation(OperationLog.class);
|
||||
if (operationLog != null) {
|
||||
title = operationLog.title();
|
||||
subject = operationLog.subject();
|
||||
insertKey = operationLog.insertKey();
|
||||
}
|
||||
|
||||
Map<String, Object> reqMaps = null;
|
||||
ConcurrentHashMap<String, Object> allParams = new ConcurrentHashMap<>(16);
|
||||
if (joinPoint.getArgs().length > 0) {
|
||||
reqMaps = BeanUtil.beanToMap(joinPoint.getArgs()[0], false, true);
|
||||
allParams.putAll(reqMaps);
|
||||
}
|
||||
|
||||
Object response = joinPoint.proceed(joinPoint.getArgs());
|
||||
allParams.putAll(BeanUtil.beanToMap(response, false, true));
|
||||
|
||||
if (!StrUtil.isEmpty(subject)) {
|
||||
// 添加、编辑关键字处理
|
||||
if (!StrUtil.isEmpty(insertKey)) {
|
||||
String insertVal = MapUtil.getStr(allParams, insertKey);
|
||||
subject = (StrUtil.isEmpty(insertVal) ? "添加" : "编辑") + subject;
|
||||
}
|
||||
|
||||
// 占位符处理
|
||||
subject = StrUtil.format(subject, allParams);
|
||||
} else {
|
||||
title = method.getName();
|
||||
subject = ServletKit.getRequest().getRequestURI();
|
||||
}
|
||||
|
||||
// 指定字段脱敏
|
||||
if (reqMaps != null && operationLog != null
|
||||
&& ArrayUtil.isNotEmpty(operationLog.desensitize())) {
|
||||
for (String key : operationLog.desensitize()) {
|
||||
reqMaps.put(key, "******");
|
||||
}
|
||||
}
|
||||
|
||||
coreLogService.addOperationLog(title, subject, reqMaps);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.tiesheng.web.config.template;
|
||||
|
||||
import com.tiesheng.web.pojos.dto.TemplateDealDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class TieshengTemplateHandler implements ToolTemplateHandler {
|
||||
@Override
|
||||
public String handler(TemplateDealDTO dto) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateUrl() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getParms(Object params) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getAction() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.tiesheng.web.config.template;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tiesheng.web.pojos.dto.TemplateDealDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public interface ToolTemplateHandler {
|
||||
|
||||
|
||||
/**
|
||||
* 处理对象
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
String handler(TemplateDealDTO dto);
|
||||
|
||||
|
||||
/**
|
||||
* 获取模版地址
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getTemplateUrl();
|
||||
|
||||
Object getParms(Object params);
|
||||
|
||||
|
||||
/**
|
||||
* 动作说明(唯一)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getAction();
|
||||
|
||||
|
||||
/**
|
||||
* 排序,如果action相同,只会使用sort大的来处理
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getSort();
|
||||
|
||||
/**
|
||||
* 获取模版ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default String getTeamplateId() {
|
||||
return StrUtil.format("{}_{}", getAction(), getSort());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.tiesheng.web.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.tiesheng.annotation.token.TokenIgnore;
|
||||
import com.tiesheng.web.pojos.dao.CoreConfigEnum;
|
||||
import com.tiesheng.web.pojos.dao.CoreConfigSystem;
|
||||
import com.tiesheng.web.pojos.dto.config.ConfigSystemDTO;
|
||||
import com.tiesheng.web.pojos.dto.config.EnumTypeDTO;
|
||||
import com.tiesheng.web.service.CoreConfigService;
|
||||
import com.tiesheng.web.service.TieshengWebConfigurer;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.util.pojos.PageDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/config")
|
||||
public class ConfigController {
|
||||
|
||||
@Autowired
|
||||
CoreConfigService coreConfigService;
|
||||
@Autowired
|
||||
TieshengWebConfigurer tieshengWebConfigurer;
|
||||
|
||||
|
||||
/**
|
||||
* 系统配置列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/system/page")
|
||||
@TokenIgnore
|
||||
public ApiResp<List<CoreConfigSystem>> systemPage(PageDTO dto) {
|
||||
|
||||
QueryWrapper<CoreConfigSystem> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("is_deleted", 0);
|
||||
dto.likeColumns(queryWrapper, "config_key", "remark");
|
||||
queryWrapper.orderByAsc("config_key");
|
||||
|
||||
Page<CoreConfigSystem> page = dto.pageObj();
|
||||
coreConfigService.page(page, queryWrapper);
|
||||
|
||||
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/system/update")
|
||||
public ApiResp<String> systemUpdate(@RequestBody ConfigSystemDTO dto) {
|
||||
|
||||
CoreConfigSystem configKey = coreConfigService.getOneByColumn("config_key", dto.getConfigKey());
|
||||
if (configKey == null) {
|
||||
throw new ApiException("该配置不存在,请检查");
|
||||
}
|
||||
if (configKey.getReadOnly() == 1) {
|
||||
throw new ApiException("该配置只读,不可修改");
|
||||
}
|
||||
configKey.setConfigVal(dto.getConfigVal());
|
||||
configKey.setRemark(dto.getRemark());
|
||||
configKey.setExtra(dto.getExtra());
|
||||
|
||||
tieshengWebConfigurer.configSystemCheck(configKey);
|
||||
coreConfigService.updateById(configKey);
|
||||
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取枚举列表
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/enum/list")
|
||||
@TokenIgnore
|
||||
public ApiResp<List<CoreConfigEnum>> enumList(EnumTypeDTO dto) {
|
||||
|
||||
QueryWrapper<CoreConfigEnum> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("is_deleted", 0);
|
||||
if (!StrUtil.isEmpty(dto.getType())) {
|
||||
queryWrapper.eq("type", dto.getType());
|
||||
}
|
||||
List<CoreConfigEnum> selectList = coreConfigService.getEnumMapper().selectList(queryWrapper);
|
||||
|
||||
return ApiResp.respOK(selectList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.tiesheng.web.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogLogin;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogMessage;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogOperation;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogProcess;
|
||||
import com.tiesheng.util.pojos.PageDTO;
|
||||
import com.tiesheng.web.pojos.vo.ProcessDetailVo;
|
||||
import com.tiesheng.web.service.CoreLogService;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/manager/log")
|
||||
public class LogController {
|
||||
|
||||
@Autowired
|
||||
CoreLogService coreLogService;
|
||||
|
||||
|
||||
/**
|
||||
* 操作日志列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/operation/page")
|
||||
public ApiResp<List<CoreLogOperation>> operationPage(@Valid PageDTO dto) {
|
||||
|
||||
QueryWrapper<CoreLogOperation> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("is_deleted", 0);
|
||||
dto.likeColumns(queryWrapper, "user_name", "title", "subject");
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
|
||||
Page<CoreLogOperation> page = dto.pageObj();
|
||||
coreLogService.getBaseMapper().page(page, queryWrapper);
|
||||
|
||||
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登录日志列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/login/page")
|
||||
public ApiResp<List<CoreLogLogin>> loginPage(@Valid PageDTO dto) {
|
||||
|
||||
QueryWrapper<CoreLogLogin> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("is_deleted", 0);
|
||||
dto.likeColumns(queryWrapper, "user_name", "ip", "address");
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
|
||||
Page<CoreLogLogin> page = dto.pageObj();
|
||||
coreLogService.getLogLoginMapper().selectPage(page, queryWrapper);
|
||||
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登录日志列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/message/page")
|
||||
public ApiResp<List<CoreLogMessage>> messagePage(String result, @Valid PageDTO dto) {
|
||||
|
||||
QueryWrapper<CoreLogMessage> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("is_deleted", 0);
|
||||
if (!StrUtil.isEmpty(result)) {
|
||||
queryWrapper.eq("result", result);
|
||||
}
|
||||
dto.likeColumns(queryWrapper, "type", "target", "content", "resp_body");
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
|
||||
Page<CoreLogMessage> page = dto.pageObj();
|
||||
coreLogService.getLogMessageMapper().selectPage(page, queryWrapper);
|
||||
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 过程日志列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/process/page")
|
||||
public ApiResp<List<CoreLogProcess>> processPage(String type, @Valid PageDTO dto) {
|
||||
|
||||
QueryWrapper<CoreLogProcess> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("is_deleted", 0);
|
||||
if (!StrUtil.isEmpty(type)) {
|
||||
queryWrapper.eq("type", type);
|
||||
}
|
||||
dto.likeColumns(queryWrapper, "title");
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
|
||||
Page<CoreLogProcess> page = dto.pageObj();
|
||||
coreLogService.getCoreLogProcessMapper().selectPage(page, queryWrapper);
|
||||
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
* 过程日志详情
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/process/detail")
|
||||
public ApiResp<ProcessDetailVo> processPage(String id) {
|
||||
ProcessDetailVo processDetail = coreLogService.getProcessDetail(id);
|
||||
return ApiResp.respOK(processDetail);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package com.tiesheng.web.controller;
|
||||
|
||||
|
||||
import cn.hutool.captcha.LineCaptcha;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.tiesheng.annotation.token.TokenIgnore;
|
||||
import com.tiesheng.web.config.template.ToolTemplateHandler;
|
||||
import com.tiesheng.web.pojos.dto.*;
|
||||
import com.tiesheng.web.pojos.vo.TemplateInfoVO;
|
||||
import com.tiesheng.web.pojos.vo.PicVerifyVo;
|
||||
import com.tiesheng.web.service.FileUploadService;
|
||||
import com.tiesheng.web.service.TimedCacheService;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 工具类
|
||||
*
|
||||
* @author hao
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/tool")
|
||||
public class ToolController {
|
||||
|
||||
@Autowired
|
||||
TimedCacheService timedCacheService;
|
||||
@Autowired
|
||||
FileUploadService fileUploadService;
|
||||
@Autowired
|
||||
List<ToolTemplateHandler> templateHandlerList;
|
||||
|
||||
|
||||
/**
|
||||
* 图片验证码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@TokenIgnore
|
||||
@GetMapping("/code/image")
|
||||
public ApiResp<PicVerifyVo> picVerifyV2(ImageCodeDTO dto) {
|
||||
|
||||
LineCaptcha lineCaptcha = dto.lineCaptcha();
|
||||
PicVerifyVo vo = new PicVerifyVo();
|
||||
vo.setBase64(lineCaptcha.getImageBase64Data());
|
||||
vo.setKey(IdUtil.simpleUUID());
|
||||
timedCacheService.setImageCode(vo.getKey(), lineCaptcha.getCode());
|
||||
|
||||
return ApiResp.respOK(vo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传整个文件
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@TokenIgnore
|
||||
@PostMapping("/file/whole_upload")
|
||||
public ApiResp<String> fileWholeUpload(@RequestParam("file") MultipartFile file) {
|
||||
String filePath = fileUploadService.saveMultipartFile(file);
|
||||
return ApiResp.respOK(filePath);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传超大文件,建议超过20M的使用这个方法
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@TokenIgnore
|
||||
@PostMapping(value = "/file/chunk_start")
|
||||
public ApiResp<String> fileChunkStart(@RequestBody ChunkStartDTO dto) {
|
||||
fileUploadService.chunkStart(dto.getFileExt());
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验文件块
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@TokenIgnore
|
||||
@PostMapping("/file/chunk_check")
|
||||
public ApiResp<Boolean> fileChunkCheck(@RequestBody ChunkCheckDTO dto) {
|
||||
boolean exist = fileUploadService.chunkCheck(dto.getFileMd5(), dto.getChunk());
|
||||
return ApiResp.respOK(exist);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件块
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@TokenIgnore
|
||||
@PostMapping("/file/chunk_upload")
|
||||
public ApiResp<String> fileChunkUpload(@RequestParam("file") MultipartFile file, String fileMd5, Integer chunk) {
|
||||
fileUploadService.chunkUpload(file, fileMd5, chunk);
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 合并文件
|
||||
*
|
||||
* @param fileMd5
|
||||
* @return
|
||||
*/
|
||||
@TokenIgnore
|
||||
@PostMapping("/file/chunk_merge")
|
||||
public ApiResp<String> fileChunkMerge(@RequestBody ChunkMergeDTO dto) {
|
||||
String path = fileUploadService.chunkMerge(dto.getFileMd5(), dto.getFileExt());
|
||||
return ApiResp.respOK(path);
|
||||
}
|
||||
|
||||
|
||||
@TokenIgnore
|
||||
@GetMapping("/template/info")
|
||||
public ApiResp<TemplateInfoVO> templateInfo(TemplateInfoDTO dto) {
|
||||
|
||||
List<ToolTemplateHandler> collect = templateHandlerList.stream()
|
||||
.filter(it -> Objects.equals(it.getAction(), dto.getAction()))
|
||||
.sorted((it, it2) -> it2.getSort() - it.getSort())
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(collect)) {
|
||||
throw new ApiException("没有找到对应的模版");
|
||||
}
|
||||
|
||||
ToolTemplateHandler toolTemplateHandler = collect.get(0);
|
||||
|
||||
TemplateInfoVO template = new TemplateInfoVO();
|
||||
template.setTemplateUrl(toolTemplateHandler.getTemplateUrl());
|
||||
template.setParams(toolTemplateHandler.getParms(dto.getParams()));
|
||||
template.setTemplateId(toolTemplateHandler.getTeamplateId());
|
||||
|
||||
return ApiResp.respOK(template);
|
||||
}
|
||||
|
||||
@TokenIgnore
|
||||
@PostMapping("/template/deal")
|
||||
public ApiResp<String> templateDeal(@RequestBody TemplateDealDTO dto) {
|
||||
|
||||
List<ToolTemplateHandler> collect = templateHandlerList.stream().
|
||||
filter(it -> Objects.equals(it.getTeamplateId(), dto.getTemplateId()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(collect)) {
|
||||
throw new ApiException("模版ID不存在");
|
||||
}
|
||||
|
||||
return ApiResp.respOK(collect.get(0).handler(dto));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tiesheng.web.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tiesheng.web.pojos.dao.CoreConfigEnum;
|
||||
|
||||
public interface CoreConfigEnumMapper extends BaseMapper<CoreConfigEnum> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tiesheng.web.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tiesheng.web.pojos.dao.CoreConfigSystem;
|
||||
|
||||
public interface CoreConfigSystemMapper extends BaseMapper<CoreConfigSystem> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tiesheng.web.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogLogin;
|
||||
|
||||
public interface CoreLogLoginMapper extends BaseMapper<CoreLogLogin> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tiesheng.web.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogMessage;
|
||||
|
||||
public interface CoreLogMessageMapper extends BaseMapper<CoreLogMessage> {
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.tiesheng.web.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogOperation;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface CoreLogOperationMapper extends BaseMapper<CoreLogOperation> {
|
||||
|
||||
|
||||
/**
|
||||
* 获取日志列表
|
||||
*
|
||||
* @param page
|
||||
* @param queryWrapper
|
||||
* @return
|
||||
*/
|
||||
Page<CoreLogOperation> page(IPage<CoreLogOperation> page, @Param("ew") QueryWrapper<CoreLogOperation> queryWrapper);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tiesheng.web.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogProcess;
|
||||
|
||||
public interface CoreLogProcessMapper extends BaseMapper<CoreLogProcess> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tiesheng.web.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tiesheng.web.pojos.dao.CorePlatformUnique;
|
||||
|
||||
public interface CorePlatformUniqueMapper extends BaseMapper<CorePlatformUnique> {
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.tiesheng.web.pojos;
|
||||
|
||||
/**
|
||||
* 当前token的数据
|
||||
*
|
||||
* @author hao
|
||||
*/
|
||||
public class RequestUserInfo {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private Object data;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.tiesheng.web.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
|
||||
/**
|
||||
* 配置-枚举
|
||||
*/
|
||||
@TableName(value = "core_config_enum")
|
||||
public class CoreConfigEnum extends DaoBase {
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@TableField(value = "`type`")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField(value = "`name`")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField(value = "remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 扩展字段
|
||||
*/
|
||||
@TableField(value = "ext")
|
||||
private String ext;
|
||||
|
||||
/**
|
||||
* 获取类型
|
||||
*
|
||||
* @return type - 类型
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置类型
|
||||
*
|
||||
* @param type 类型
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取名称
|
||||
*
|
||||
* @return name - 名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置名称
|
||||
*
|
||||
* @param name 名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取备注
|
||||
*
|
||||
* @return remark - 备注
|
||||
*/
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置备注
|
||||
*
|
||||
* @param remark 备注
|
||||
*/
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展字段
|
||||
*
|
||||
* @return ext - 扩展字段
|
||||
*/
|
||||
public String getExt() {
|
||||
return ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展字段
|
||||
*
|
||||
* @param ext 扩展字段
|
||||
*/
|
||||
public void setExt(String ext) {
|
||||
this.ext = ext;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.tiesheng.web.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
|
||||
/**
|
||||
* 配置-系统
|
||||
*/
|
||||
@TableName(value = "core_config_system")
|
||||
public class CoreConfigSystem extends DaoBase {
|
||||
@TableField(value = "config_key")
|
||||
private String configKey;
|
||||
|
||||
@TableField(value = "config_val")
|
||||
private String configVal;
|
||||
|
||||
/**
|
||||
* 类型:0-文本,1-图片,2-文件
|
||||
*/
|
||||
@TableField(value = "config_type")
|
||||
private Integer configType;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
@TableField(value = "remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 额外配置
|
||||
*/
|
||||
@TableField(value = "extra")
|
||||
private String extra;
|
||||
|
||||
/**
|
||||
* 0-否,1-是
|
||||
*/
|
||||
@TableField(value = "read_only")
|
||||
private Integer readOnly;
|
||||
|
||||
/**
|
||||
* @return config_key
|
||||
*/
|
||||
public String getConfigKey() {
|
||||
return configKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param configKey
|
||||
*/
|
||||
public void setConfigKey(String configKey) {
|
||||
this.configKey = configKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return config_val
|
||||
*/
|
||||
public String getConfigVal() {
|
||||
return configVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param configVal
|
||||
*/
|
||||
public void setConfigVal(String configVal) {
|
||||
this.configVal = configVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型:0-文本,1-图片,2-文件
|
||||
*
|
||||
* @return config_type - 类型:0-文本,1-图片,2-文件
|
||||
*/
|
||||
public Integer getConfigType() {
|
||||
return configType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置类型:0-文本,1-图片,2-文件
|
||||
*
|
||||
* @param configType 类型:0-文本,1-图片,2-文件
|
||||
*/
|
||||
public void setConfigType(Integer configType) {
|
||||
this.configType = configType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取说明
|
||||
*
|
||||
* @return remark - 说明
|
||||
*/
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置说明
|
||||
*
|
||||
* @param remark 说明
|
||||
*/
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取额外配置
|
||||
*
|
||||
* @return extra - 额外配置
|
||||
*/
|
||||
public String getExtra() {
|
||||
return extra;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置额外配置
|
||||
*
|
||||
* @param extra 额外配置
|
||||
*/
|
||||
public void setExtra(String extra) {
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取0-否,1-是
|
||||
*
|
||||
* @return read_only - 0-否,1-是
|
||||
*/
|
||||
public Integer getReadOnly() {
|
||||
return readOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置0-否,1-是
|
||||
*
|
||||
* @param readOnly 0-否,1-是
|
||||
*/
|
||||
public void setReadOnly(Integer readOnly) {
|
||||
this.readOnly = readOnly;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.tiesheng.web.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
|
||||
/**
|
||||
* 日志-登录
|
||||
*/
|
||||
@TableName(value = "core_log_login")
|
||||
public class CoreLogLogin extends DaoBase {
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField(value = "user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField(value = "user_name")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* ip
|
||||
*/
|
||||
@TableField(value = "platform")
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* ip
|
||||
*/
|
||||
@TableField(value = "ip")
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* ip地址
|
||||
*/
|
||||
@TableField(value = "address")
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 获取用户id
|
||||
*
|
||||
* @return user_id - 用户id
|
||||
*/
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户id
|
||||
*
|
||||
* @param userId 用户id
|
||||
*/
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ip
|
||||
*
|
||||
* @return ip - ip
|
||||
*/
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置ip
|
||||
*
|
||||
* @param ip ip
|
||||
*/
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ip地址
|
||||
*
|
||||
* @return address - ip地址
|
||||
*/
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置ip地址
|
||||
*
|
||||
* @param address ip地址
|
||||
*/
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.tiesheng.web.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
|
||||
/**
|
||||
* 日志-消息
|
||||
*/
|
||||
@TableName(value = "core_log_message")
|
||||
public class CoreLogMessage extends DaoBase {
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@TableField(value = "`type`")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 发送对象
|
||||
*/
|
||||
@TableField(value = "target")
|
||||
private String target;
|
||||
|
||||
/**
|
||||
* 发送内容
|
||||
*/
|
||||
@TableField(value = "content")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 返回结果
|
||||
*/
|
||||
@TableField(value = "resp_body")
|
||||
private String respBody;
|
||||
|
||||
/**
|
||||
* 结果
|
||||
*/
|
||||
@TableField(value = "`result`")
|
||||
private Integer result;
|
||||
|
||||
/**
|
||||
* 获取类型
|
||||
*
|
||||
* @return type - 类型
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置类型
|
||||
*
|
||||
* @param type 类型
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发送对象
|
||||
*
|
||||
* @return target - 发送对象
|
||||
*/
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置发送对象
|
||||
*
|
||||
* @param target 发送对象
|
||||
*/
|
||||
public void setTarget(String target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发送内容
|
||||
*
|
||||
* @return content - 发送内容
|
||||
*/
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置发送内容
|
||||
*
|
||||
* @param content 发送内容
|
||||
*/
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取返回结果
|
||||
*
|
||||
* @return resp_body - 返回结果
|
||||
*/
|
||||
public String getRespBody() {
|
||||
return respBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置返回结果
|
||||
*
|
||||
* @param respBody 返回结果
|
||||
*/
|
||||
public void setRespBody(String respBody) {
|
||||
this.respBody = respBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取结果
|
||||
*
|
||||
* @return result - 结果
|
||||
*/
|
||||
public Integer getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置结果
|
||||
*
|
||||
* @param result 结果
|
||||
*/
|
||||
public void setResult(Integer result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.tiesheng.web.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
|
||||
/**
|
||||
* 日志-操作
|
||||
*/
|
||||
@TableName(value = "core_log_operation")
|
||||
public class CoreLogOperation extends DaoBase {
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField(value = "user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
@TableField(value = "user_name")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@TableField(value = "title")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 小标题
|
||||
*/
|
||||
@TableField(value = "subject")
|
||||
private String subject;
|
||||
|
||||
/**
|
||||
* 其他参数
|
||||
*/
|
||||
@TableField(value = "params")
|
||||
private String params;
|
||||
|
||||
/**
|
||||
* 获取用户id
|
||||
*
|
||||
* @return user_id - 用户id
|
||||
*/
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户id
|
||||
*
|
||||
* @param userId 用户id
|
||||
*/
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户名称
|
||||
*
|
||||
* @return user_name - 用户名称
|
||||
*/
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户名称
|
||||
*
|
||||
* @param userName 用户名称
|
||||
*/
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标题
|
||||
*
|
||||
* @return title - 标题
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置标题
|
||||
*
|
||||
* @param title 标题
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小标题
|
||||
*
|
||||
* @return subject - 小标题
|
||||
*/
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置小标题
|
||||
*
|
||||
* @param subject 小标题
|
||||
*/
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取其他参数
|
||||
*
|
||||
* @return params - 其他参数
|
||||
*/
|
||||
public String getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置其他参数
|
||||
*
|
||||
* @param params 其他参数
|
||||
*/
|
||||
public void setParams(String params) {
|
||||
this.params = params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package com.tiesheng.web.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
|
||||
/**
|
||||
* 日志-过程
|
||||
*/
|
||||
@TableName(value = "core_log_process")
|
||||
public class CoreLogProcess extends DaoBase {
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@TableField(value = "title")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 总数
|
||||
*/
|
||||
@TableField(value = "total")
|
||||
private Integer total;
|
||||
|
||||
/**
|
||||
* 成功数
|
||||
*/
|
||||
@TableField(value = "success_num")
|
||||
private Integer successNum;
|
||||
|
||||
/**
|
||||
* 失败数
|
||||
*/
|
||||
@TableField(value = "fail_num")
|
||||
private Integer failNum;
|
||||
|
||||
/**
|
||||
* 类型(import-导入,sync-同步)
|
||||
*/
|
||||
@TableField(value = "`type`")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 状态(0-未完成,1-已完成)
|
||||
*/
|
||||
@TableField(value = "`status`")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 失败的文件
|
||||
*/
|
||||
@TableField(value = "fail_file")
|
||||
private String failFile;
|
||||
|
||||
/**
|
||||
* 异常说明
|
||||
*/
|
||||
@TableField(value = "error")
|
||||
private String error;
|
||||
|
||||
/**
|
||||
* 进度
|
||||
*/
|
||||
@TableField(value = "`process`")
|
||||
private Integer process;
|
||||
|
||||
/**
|
||||
* 获取标题
|
||||
*
|
||||
* @return title - 标题
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置标题
|
||||
*
|
||||
* @param title 标题
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取总数
|
||||
*
|
||||
* @return total - 总数
|
||||
*/
|
||||
public Integer getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置总数
|
||||
*
|
||||
* @param total 总数
|
||||
*/
|
||||
public void setTotal(Integer total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成功数
|
||||
*
|
||||
* @return success_num - 成功数
|
||||
*/
|
||||
public Integer getSuccessNum() {
|
||||
return successNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置成功数
|
||||
*
|
||||
* @param successNum 成功数
|
||||
*/
|
||||
public void setSuccessNum(Integer successNum) {
|
||||
this.successNum = successNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取失败数
|
||||
*
|
||||
* @return fail_num - 失败数
|
||||
*/
|
||||
public Integer getFailNum() {
|
||||
return failNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置失败数
|
||||
*
|
||||
* @param failNum 失败数
|
||||
*/
|
||||
public void setFailNum(Integer failNum) {
|
||||
this.failNum = failNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型(import-导入,sync-同步)
|
||||
*
|
||||
* @return type - 类型(import-导入,sync-同步)
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置类型(import-导入,sync-同步)
|
||||
*
|
||||
* @param type 类型(import-导入,sync-同步)
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态(0-未完成,1-已完成)
|
||||
*
|
||||
* @return status - 状态(0-未完成,1-已完成)
|
||||
*/
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态(0-未完成,1-已完成)
|
||||
*
|
||||
* @param status 状态(0-未完成,1-已完成)
|
||||
*/
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取失败的文件
|
||||
*
|
||||
* @return fail_file - 失败的文件
|
||||
*/
|
||||
public String getFailFile() {
|
||||
return failFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置失败的文件
|
||||
*
|
||||
* @param failFile 失败的文件
|
||||
*/
|
||||
public void setFailFile(String failFile) {
|
||||
this.failFile = failFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取异常说明
|
||||
*
|
||||
* @return error - 异常说明
|
||||
*/
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异常说明
|
||||
*
|
||||
* @param error 异常说明
|
||||
*/
|
||||
public void setError(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取进度
|
||||
*
|
||||
* @return process - 进度
|
||||
*/
|
||||
public Integer getProcess() {
|
||||
return process;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进度
|
||||
*
|
||||
* @param process 进度
|
||||
*/
|
||||
public void setProcess(Integer process) {
|
||||
this.process = process;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.tiesheng.web.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
|
||||
/**
|
||||
* 平台-唯一值
|
||||
*/
|
||||
@TableName(value = "core_platform_unique")
|
||||
public class CorePlatformUnique extends DaoBase {
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField(value = "user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* appId
|
||||
*/
|
||||
@TableField(value = "app_id")
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* 唯一值
|
||||
*/
|
||||
@TableField(value = "unique_id")
|
||||
private String uniqueId;
|
||||
|
||||
/**
|
||||
* 平台
|
||||
*/
|
||||
@TableField(value = "platform")
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* 其他参数
|
||||
*/
|
||||
@TableField(value = "info")
|
||||
private String info;
|
||||
|
||||
/**
|
||||
* 获取用户id
|
||||
*
|
||||
* @return user_id - 用户id
|
||||
*/
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户id
|
||||
*
|
||||
* @param userId 用户id
|
||||
*/
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取appId
|
||||
*
|
||||
* @return app_id - appId
|
||||
*/
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置appId
|
||||
*
|
||||
* @param appId appId
|
||||
*/
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取唯一值
|
||||
*
|
||||
* @return unique_id - 唯一值
|
||||
*/
|
||||
public String getUniqueId() {
|
||||
return uniqueId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置唯一值
|
||||
*
|
||||
* @param uniqueId 唯一值
|
||||
*/
|
||||
public void setUniqueId(String uniqueId) {
|
||||
this.uniqueId = uniqueId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取平台
|
||||
*
|
||||
* @return platform - 平台
|
||||
*/
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置平台
|
||||
*
|
||||
* @param platform 平台
|
||||
*/
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取其他参数
|
||||
*
|
||||
* @return info - 其他参数
|
||||
*/
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置其他参数
|
||||
*
|
||||
* @param info 其他参数
|
||||
*/
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.tiesheng.web.pojos.dto;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
public class ChunkCheckDTO {
|
||||
|
||||
private String fileMd5;
|
||||
private Integer chunk;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getFileMd5() {
|
||||
return fileMd5;
|
||||
}
|
||||
|
||||
public void setFileMd5(String fileMd5) {
|
||||
this.fileMd5 = fileMd5;
|
||||
}
|
||||
|
||||
public Integer getChunk() {
|
||||
return chunk;
|
||||
}
|
||||
|
||||
public void setChunk(Integer chunk) {
|
||||
this.chunk = chunk;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.tiesheng.web.pojos.dto;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
public class ChunkMergeDTO {
|
||||
|
||||
private String fileMd5;
|
||||
private String fileExt;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getFileMd5() {
|
||||
return fileMd5;
|
||||
}
|
||||
|
||||
public void setFileMd5(String fileMd5) {
|
||||
this.fileMd5 = fileMd5;
|
||||
}
|
||||
|
||||
public String getFileExt() {
|
||||
return fileExt;
|
||||
}
|
||||
|
||||
public void setFileExt(String fileExt) {
|
||||
this.fileExt = fileExt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.tiesheng.web.pojos.dto;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
public class ChunkStartDTO {
|
||||
|
||||
private String fileExt;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getFileExt() {
|
||||
return fileExt;
|
||||
}
|
||||
|
||||
public void setFileExt(String fileExt) {
|
||||
this.fileExt = fileExt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.tiesheng.web.pojos.dto;
|
||||
|
||||
import cn.hutool.captcha.CaptchaUtil;
|
||||
import cn.hutool.captcha.LineCaptcha;
|
||||
import cn.hutool.captcha.generator.RandomGenerator;
|
||||
|
||||
public class ImageCodeDTO {
|
||||
|
||||
private Integer lineCount;
|
||||
private Integer width;
|
||||
private Integer height;
|
||||
|
||||
|
||||
/**
|
||||
* 构建线条图形码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public LineCaptcha lineCaptcha() {
|
||||
if (lineCount == null || lineCount < 100) {
|
||||
lineCount = 100;
|
||||
}
|
||||
if (width == null) {
|
||||
width = 220;
|
||||
}
|
||||
if (height == null) {
|
||||
height = 62;
|
||||
}
|
||||
LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(width, height, 4, lineCount);
|
||||
lineCaptcha.setGenerator(new RandomGenerator("0123456789", 4));
|
||||
|
||||
return lineCaptcha;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public Integer getLineCount() {
|
||||
return lineCount;
|
||||
}
|
||||
|
||||
public void setLineCount(Integer lineCount) {
|
||||
this.lineCount = lineCount;
|
||||
}
|
||||
|
||||
public Integer getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(Integer width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public Integer getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(Integer height) {
|
||||
this.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.tiesheng.web.pojos.dto;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
public class TemplateDealDTO {
|
||||
|
||||
@NotEmpty(message = "模版ID")
|
||||
private String templateId;
|
||||
@NotEmpty(message = "文件路径必填")
|
||||
private String file;
|
||||
private Object params;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public void setTemplateId(String templateId) {
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(String file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public Object getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(Object params) {
|
||||
this.params = params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.tiesheng.web.pojos.dto;
|
||||
|
||||
|
||||
public class TemplateInfoDTO {
|
||||
|
||||
private String action;
|
||||
private Object params;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public Object getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(Object params) {
|
||||
this.params = params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.tiesheng.web.pojos.dto.config;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
public class ConfigSystemDTO {
|
||||
|
||||
@NotEmpty(message = "请输入key")
|
||||
private String configKey;
|
||||
private String configVal;
|
||||
private String remark;
|
||||
private String extra;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getConfigKey() {
|
||||
return configKey;
|
||||
}
|
||||
|
||||
public void setConfigKey(String configKey) {
|
||||
this.configKey = configKey;
|
||||
}
|
||||
|
||||
public String getConfigVal() {
|
||||
return configVal;
|
||||
}
|
||||
|
||||
public void setConfigVal(String configVal) {
|
||||
this.configVal = configVal;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getExtra() {
|
||||
return extra;
|
||||
}
|
||||
|
||||
public void setExtra(String extra) {
|
||||
this.extra = extra;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.tiesheng.web.pojos.dto.config;
|
||||
|
||||
public class EnumTypeDTO {
|
||||
|
||||
private String type;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.tiesheng.web.pojos.vo;
|
||||
|
||||
public class PicVerifyVo {
|
||||
|
||||
private String base64;
|
||||
private String key;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getBase64() {
|
||||
return base64;
|
||||
}
|
||||
|
||||
public void setBase64(String base64) {
|
||||
this.base64 = base64;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.tiesheng.web.pojos.vo;
|
||||
|
||||
/**
|
||||
* @author lgc
|
||||
*/
|
||||
public class ProcessDetailVo {
|
||||
|
||||
private String title;
|
||||
|
||||
private Integer total;
|
||||
|
||||
private Integer successNum;
|
||||
|
||||
private Integer failNum;
|
||||
|
||||
private Integer process;
|
||||
|
||||
private String type;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String failFile;
|
||||
|
||||
private String error;
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Integer getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(Integer total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public Integer getSuccessNum() {
|
||||
return successNum;
|
||||
}
|
||||
|
||||
public void setSuccessNum(Integer successNum) {
|
||||
this.successNum = successNum;
|
||||
}
|
||||
|
||||
public Integer getFailNum() {
|
||||
return failNum;
|
||||
}
|
||||
|
||||
public void setFailNum(Integer failNum) {
|
||||
this.failNum = failNum;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getFailFile() {
|
||||
return failFile;
|
||||
}
|
||||
|
||||
public void setFailFile(String failFile) {
|
||||
this.failFile = failFile;
|
||||
}
|
||||
|
||||
public Integer getProcess() {
|
||||
return process;
|
||||
}
|
||||
|
||||
public void setProcess(Integer process) {
|
||||
this.process = process;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.tiesheng.web.pojos.vo;
|
||||
|
||||
|
||||
public class TemplateInfoVO {
|
||||
|
||||
private String templateId;
|
||||
private String templateUrl;
|
||||
private Object params;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public void setTemplateId(String templateId) {
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public String getTemplateUrl() {
|
||||
return templateUrl;
|
||||
}
|
||||
|
||||
public void setTemplateUrl(String templateUrl) {
|
||||
this.templateUrl = templateUrl;
|
||||
}
|
||||
|
||||
public Object getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(Object params) {
|
||||
this.params = params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.tiesheng.web.service;
|
||||
|
||||
import com.tiesheng.web.mapper.CoreConfigEnumMapper;
|
||||
import com.tiesheng.web.mapper.CoreConfigSystemMapper;
|
||||
import com.tiesheng.web.pojos.dao.CoreConfigSystem;
|
||||
import com.tiesheng.util.service.TsServiceBase;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@Service
|
||||
public class CoreConfigService extends TsServiceBase<CoreConfigSystemMapper, CoreConfigSystem> {
|
||||
|
||||
@Autowired
|
||||
CoreConfigEnumMapper coreConfigEnumMapper;
|
||||
|
||||
public CoreConfigEnumMapper getEnumMapper() {
|
||||
return coreConfigEnumMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取(或创建)一个文本类型的配置
|
||||
*
|
||||
* @param configKey
|
||||
* @param defaultValue
|
||||
* @return
|
||||
*/
|
||||
public CoreConfigSystem getTextOrCreate(String configKey, String defaultValue) {
|
||||
CoreConfigSystem oneByColumn = getOneByColumn("config_key", configKey);
|
||||
if (oneByColumn == null) {
|
||||
oneByColumn = new CoreConfigSystem();
|
||||
oneByColumn.setId(configKey);
|
||||
oneByColumn.setConfigKey(configKey);
|
||||
oneByColumn.setConfigVal(defaultValue);
|
||||
oneByColumn.setRemark(defaultValue);
|
||||
oneByColumn.setConfigType(0);
|
||||
save(oneByColumn);
|
||||
}
|
||||
return oneByColumn;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package com.tiesheng.web.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.tiesheng.web.mapper.CoreLogLoginMapper;
|
||||
import com.tiesheng.web.mapper.CoreLogMessageMapper;
|
||||
import com.tiesheng.web.mapper.CoreLogOperationMapper;
|
||||
import com.tiesheng.web.mapper.CoreLogProcessMapper;
|
||||
import com.tiesheng.web.pojos.RequestUserInfo;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogLogin;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogOperation;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogProcess;
|
||||
import com.tiesheng.web.pojos.dao.CorePlatformUnique;
|
||||
import com.tiesheng.web.pojos.vo.ProcessDetailVo;
|
||||
import com.tiesheng.web.util.ProcessImportConsumer;
|
||||
import com.tiesheng.web.util.ProcessSyncConsumer;
|
||||
import com.tiesheng.util.config.TsTokenConfig;
|
||||
import com.tiesheng.util.pojos.TokenBean;
|
||||
import com.tiesheng.util.ServletKit;
|
||||
import com.tiesheng.util.config.Ip2regionConfig;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.service.TsServiceBase;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@Service
|
||||
public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLogOperation> {
|
||||
|
||||
@Autowired
|
||||
TieshengWebConfigurer tieshengWebConfigurer;
|
||||
@Autowired
|
||||
CoreLogLoginMapper coreLogLoginMapper;
|
||||
@Autowired
|
||||
CoreLogMessageMapper coreLogMessageMapper;
|
||||
@Autowired
|
||||
Ip2regionConfig ip2regionConfig;
|
||||
@Autowired
|
||||
CoreLogProcessMapper coreLogProcessMapper;
|
||||
|
||||
public CoreLogLoginMapper getLogLoginMapper() {
|
||||
return coreLogLoginMapper;
|
||||
}
|
||||
|
||||
public CoreLogMessageMapper getLogMessageMapper() {
|
||||
return coreLogMessageMapper;
|
||||
}
|
||||
|
||||
public CoreLogProcessMapper getCoreLogProcessMapper() {
|
||||
return coreLogProcessMapper;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 导入日志
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 添加导入过程
|
||||
*
|
||||
* @param title 标题
|
||||
* @param list 要导入的数据
|
||||
*/
|
||||
public <T> CoreLogProcess addProcess(String title, List<T> list, ProcessImportConsumer<T> consumer) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw new ApiException("文件中不存在数据");
|
||||
}
|
||||
CoreLogProcess coreLogProcess = new CoreLogProcess();
|
||||
coreLogProcess.setTitle(title);
|
||||
coreLogProcess.setTotal(list.size());
|
||||
coreLogProcess.setType("import");
|
||||
coreLogProcess.setSuccessNum(0);
|
||||
coreLogProcess.setFailNum(0);
|
||||
coreLogProcess.setProcess(0);
|
||||
coreLogProcess.setError("");
|
||||
coreLogProcessMapper.insert(coreLogProcess);
|
||||
|
||||
ThreadUtil.execute(() -> {
|
||||
List<Exception> errorList = new ArrayList<>();
|
||||
CollUtil.split(list, 100).forEach((it) -> {
|
||||
int accept = 0;
|
||||
try {
|
||||
accept = consumer.accept(it);
|
||||
} catch (Exception e) {
|
||||
errorList.add(e);
|
||||
}
|
||||
coreLogProcess.setProcess(coreLogProcess.getProcess() + it.size());
|
||||
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + accept);
|
||||
coreLogProcess.setFailNum(coreLogProcess.getFailNum() + it.size() - accept);
|
||||
coreLogProcess.setError(JSONUtil.toJsonStr(errorList));
|
||||
coreLogProcessMapper.updateById(coreLogProcess);
|
||||
});
|
||||
|
||||
// 执行结束
|
||||
coreLogProcess.setFailFile(consumer.getFailFile());
|
||||
coreLogProcess.setStatus(1);
|
||||
coreLogProcess.setError(JSONUtil.toJsonStr(errorList));
|
||||
coreLogProcessMapper.updateById(coreLogProcess);
|
||||
});
|
||||
|
||||
|
||||
return coreLogProcess;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加同步过程
|
||||
*
|
||||
* @param title
|
||||
* @param consumer
|
||||
* @return
|
||||
*/
|
||||
public CoreLogProcess addProcess(String title, ProcessSyncConsumer consumer) {
|
||||
CoreLogProcess coreLogProcess = new CoreLogProcess();
|
||||
coreLogProcess.setTitle(title);
|
||||
|
||||
coreLogProcess.setType("sync");
|
||||
coreLogProcess.setSuccessNum(0);
|
||||
coreLogProcess.setFailNum(0);
|
||||
coreLogProcess.setTotal(0);
|
||||
coreLogProcess.setProcess(0);
|
||||
coreLogProcess.setError("");
|
||||
coreLogProcessMapper.insert(coreLogProcess);
|
||||
|
||||
ThreadUtil.execute(() -> {
|
||||
int pageSize = 1000;
|
||||
int pageNum = 1, lastCount = pageSize;
|
||||
List<Exception> errorList = new ArrayList<>();
|
||||
while (lastCount == pageSize) {
|
||||
try {
|
||||
lastCount = consumer.accept(pageNum, pageSize);
|
||||
coreLogProcess.setTotal(coreLogProcess.getTotal() + lastCount);
|
||||
coreLogProcess.setProcess(coreLogProcess.getTotal());
|
||||
coreLogProcess.setError(JSONUtil.toJsonStr(errorList));
|
||||
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + lastCount);
|
||||
} catch (Exception e) {
|
||||
errorList.add(e);
|
||||
}
|
||||
coreLogProcessMapper.updateById(coreLogProcess);
|
||||
pageNum++;
|
||||
}
|
||||
|
||||
// 执行结束
|
||||
coreLogProcess.setError(JSONUtil.toJsonStr(errorList));
|
||||
coreLogProcess.setStatus(1);
|
||||
coreLogProcessMapper.updateById(coreLogProcess);
|
||||
});
|
||||
|
||||
return coreLogProcess;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id 获取过程详情
|
||||
*/
|
||||
public ProcessDetailVo getProcessDetail(String id) {
|
||||
QueryWrapper<CoreLogProcess> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("id", id);
|
||||
CoreLogProcess coreLogProcess = coreLogProcessMapper.selectOne(wrapper);
|
||||
return BeanUtil.copyProperties(coreLogProcess, ProcessDetailVo.class);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 操作日志
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* 添加操作日志
|
||||
*/
|
||||
public void addOperationLog(String title, String subject, Object params) {
|
||||
TokenBean tokenBean = TsTokenConfig.getWithoutThr();
|
||||
if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
RequestUserInfo requestUserInfo = tieshengWebConfigurer.getCurrentUserName(tokenBean);
|
||||
CoreLogOperation operation = new CoreLogOperation();
|
||||
operation.setUserId(requestUserInfo.getId());
|
||||
operation.setUserName(requestUserInfo.getName());
|
||||
operation.setTitle(title);
|
||||
operation.setSubject(subject);
|
||||
if (params != null) {
|
||||
operation.setParams(JSONUtil.toJsonStr(params));
|
||||
}
|
||||
save(operation);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 登录日志
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 添加登录日志
|
||||
*
|
||||
* @param platformUnique
|
||||
* @param tokenBean
|
||||
*/
|
||||
public void addLoginLog(CorePlatformUnique platformUnique, TokenBean tokenBean) {
|
||||
|
||||
HttpServletRequest request = ServletKit.getRequest();
|
||||
String ip = ServletUtil.getClientIP(request);
|
||||
|
||||
CoreLogLogin login = new CoreLogLogin();
|
||||
login.setUserId(tokenBean.getId());
|
||||
login.setPlatform(platformUnique.getPlatform());
|
||||
|
||||
RequestUserInfo requestUserInfo = tieshengWebConfigurer.getCurrentUserName(tokenBean);
|
||||
login.setUserName(requestUserInfo.getName());
|
||||
|
||||
login.setIp(ip);
|
||||
login.setAddress(ip2regionConfig.search(login.getIp()));
|
||||
coreLogLoginMapper.insert(login);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.tiesheng.web.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.tiesheng.web.mapper.CoreLogMessageMapper;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogMessage;
|
||||
import com.tiesheng.message.pojos.MessageReqResp;
|
||||
import com.tiesheng.message.pojos.UserChannel;
|
||||
import com.tiesheng.message.service.TieshengMessageSender;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@Service
|
||||
public class CoreMessageService {
|
||||
|
||||
@Autowired
|
||||
List<TieshengMessageSender> messageSenderList;
|
||||
@Autowired
|
||||
CoreLogMessageMapper coreLogMessageMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 插入数据
|
||||
*
|
||||
* @param reqResp
|
||||
*/
|
||||
private void insertMessageLog(MessageReqResp reqResp) {
|
||||
if (reqResp == null) {
|
||||
return;
|
||||
}
|
||||
coreLogMessageMapper.insert(BeanUtil.copyProperties(reqResp, CoreLogMessage.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送所有消息
|
||||
*
|
||||
* @param userIds
|
||||
* @param body
|
||||
*/
|
||||
public void all(List<String> userIds, JSONObject body) {
|
||||
messageSenderList.stream().filter(TieshengMessageSender::support)
|
||||
.forEach(sender -> {
|
||||
for (String user : userIds) {
|
||||
insertMessageLog(sender.send(user, body));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param channels
|
||||
* @param body
|
||||
* @param channels 消息通道,如果为all时,表示发送全部通道
|
||||
*/
|
||||
public void multiple(List<UserChannel> channels, JSONObject body) {
|
||||
if (ArrayUtil.isEmpty(channels)) {
|
||||
return;
|
||||
}
|
||||
|
||||
messageSenderList.stream().filter(TieshengMessageSender::support)
|
||||
.forEach(sender -> channels.stream().filter(it -> Objects.equals(it.getChannel(), sender.getChannel()))
|
||||
.forEach(it -> insertMessageLog(sender.send(it.getUser(), body))));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param userChannel
|
||||
* @param body
|
||||
*/
|
||||
public MessageReqResp send(UserChannel userChannel, JSONObject body) {
|
||||
|
||||
if (StrUtil.isEmpty(userChannel.getUser()) || StrUtil.isEmpty(userChannel.getChannel())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TieshengMessageSender messageSender = CollUtil.findOne(messageSenderList,
|
||||
sender -> Objects.equals(sender.getChannel(), userChannel.getChannel()) && sender.support());
|
||||
if (messageSender != null) {
|
||||
MessageReqResp reqResp = messageSender.send(userChannel.getUser(), body);
|
||||
insertMessageLog(reqResp);
|
||||
return reqResp;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.tiesheng.web.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tiesheng.web.mapper.CorePlatformUniqueMapper;
|
||||
import com.tiesheng.web.pojos.dao.CorePlatformUnique;
|
||||
import com.tiesheng.util.pojos.TokenBean;
|
||||
import com.tiesheng.login.pojos.DoLoginInfo;
|
||||
import com.tiesheng.login.service.TieshengLoginConfigurer;
|
||||
import com.tiesheng.util.service.TsServiceBase;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@Service
|
||||
public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueMapper, CorePlatformUnique> implements TieshengLoginConfigurer {
|
||||
|
||||
@Autowired
|
||||
TieshengWebConfigurer tieshengWebConfigurer;
|
||||
@Autowired
|
||||
CoreLogService coreLogService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TokenBean doLogin(DoLoginInfo loginInfo) {
|
||||
|
||||
CorePlatformUnique platformUnique = getOneByColumn("unique_id", loginInfo.getUnique());
|
||||
if (platformUnique == null) {
|
||||
platformUnique = new CorePlatformUnique();
|
||||
platformUnique.setAppId(loginInfo.getAppId());
|
||||
platformUnique.setUniqueId(loginInfo.getUnique());
|
||||
}
|
||||
platformUnique.setPlatform(loginInfo.getPlatform());
|
||||
platformUnique.setInfo(loginInfo.getInfo());
|
||||
saveOrUpdate(platformUnique);
|
||||
|
||||
String oldUserId = platformUnique.getUserId();
|
||||
TokenBean tokenBean = tieshengWebConfigurer.login(platformUnique);
|
||||
if (tokenBean != null) {
|
||||
|
||||
// 添加登录日志
|
||||
coreLogService.addLoginLog(platformUnique, tokenBean);
|
||||
|
||||
// 更新唯一值
|
||||
if (!StrUtil.isEmpty(tokenBean.getId()) &&
|
||||
!Objects.equals(oldUserId, tokenBean.getId())) {
|
||||
platformUnique.setUserId(tokenBean.getId());
|
||||
saveOrUpdate(platformUnique);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return tokenBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoginRedirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
|
||||
tieshengWebConfigurer.redirect(bean, to, extra, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSignError(HttpServletResponse response) {
|
||||
tieshengWebConfigurer.onSignError(response);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package com.tiesheng.web.service;
|
||||
|
||||
import cn.hutool.core.io.FileTypeUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.pojos.FileUploadPath;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@Service
|
||||
public class FileUploadService {
|
||||
|
||||
@Autowired
|
||||
TieshengWebConfigurer tieshengWebConfigurer;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 保存文件
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
public String saveMultipartFile(MultipartFile file) {
|
||||
try {
|
||||
|
||||
String fileHttpPath = tieshengWebConfigurer.uploadFileCustomize(file);
|
||||
if (!StrUtil.isEmpty(fileHttpPath)) {
|
||||
return fileHttpPath;
|
||||
}
|
||||
|
||||
String fileType = FileTypeUtil.getType(file.getInputStream(), file.getOriginalFilename());
|
||||
tieshengWebConfigurer.uploadFileCheck(fileType);
|
||||
|
||||
FileUploadPath filePath = FileUploadPath.random(fileType);
|
||||
|
||||
InputStream stream = file.getInputStream();
|
||||
FileUtil.writeFromStream(stream, filePath.getAbsolutePath());
|
||||
IoUtil.close(stream);
|
||||
|
||||
return tieshengWebConfigurer.uploadFileDeal(filePath.getHttpPath());
|
||||
} catch (Exception e) {
|
||||
throw new ApiException("文件流读取失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 文件分包上传
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 检查待上传文件是否存在
|
||||
*
|
||||
* @param fileExt
|
||||
*/
|
||||
public void chunkStart(String fileExt) {
|
||||
tieshengWebConfigurer.uploadFileCheck(fileExt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查块文件
|
||||
*
|
||||
* @param fileMd5
|
||||
* @param chunk
|
||||
* @return
|
||||
*/
|
||||
public boolean chunkCheck(String fileMd5, Integer chunk) {
|
||||
FileUploadPath folder = FileUploadPath.folder(fileMd5);
|
||||
File chunkFile = FileUtil.file(folder.getAbsolutePath(), chunk.toString());
|
||||
return chunkFile.exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 块文件上传
|
||||
*
|
||||
* @param file
|
||||
* @param fileMd5
|
||||
* @param chunk
|
||||
*/
|
||||
public void chunkUpload(MultipartFile file, String fileMd5, Integer chunk) {
|
||||
if (file == null) {
|
||||
throw new ApiException("请选择文件后上传");
|
||||
}
|
||||
|
||||
try {
|
||||
// 块文件
|
||||
FileUploadPath folder = FileUploadPath.folder(fileMd5);
|
||||
File chunkfile = new File(folder.getAbsolutePath(), chunk.toString());
|
||||
InputStream stream = file.getInputStream();
|
||||
FileUtil.writeFromStream(stream, chunkfile);
|
||||
IoUtil.close(stream);
|
||||
} catch (Exception ignored) {
|
||||
throw new ApiException("块文件上传失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并块文件
|
||||
*
|
||||
* @param fileMd5
|
||||
*/
|
||||
public String chunkMerge(String fileMd5, String fileExt) {
|
||||
|
||||
// 1,获取文件块的目录
|
||||
FileUploadPath folder = FileUploadPath.folder(fileMd5);
|
||||
|
||||
// 2,如果目录不存在
|
||||
if (!FileUtil.exist(folder.getAbsolutePath())) {
|
||||
throw new ApiException("请先上传文件块");
|
||||
}
|
||||
|
||||
// 3,生成保存文件的路径
|
||||
FileUploadPath uploadPath = FileUploadPath.random(fileExt);
|
||||
|
||||
// 4,获取块文件,此列表是已经排好序的列表
|
||||
List<File> chunkFiles = getSortedChunkFiles(new File(folder.getAbsolutePath()));
|
||||
|
||||
// 5,合并文件
|
||||
File newFile = FileUtil.newFile(uploadPath.getAbsolutePath());
|
||||
for (File file : chunkFiles) {
|
||||
byte[] bytes = FileUtil.readBytes(file);
|
||||
FileUtil.writeBytes(bytes, newFile, 0, bytes.length, true);
|
||||
}
|
||||
|
||||
// 6,删除块文件目录
|
||||
FileUtil.del(folder.getAbsolutePath());
|
||||
|
||||
return tieshengWebConfigurer.uploadFileDeal(uploadPath.getHttpPath());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有块文件
|
||||
*
|
||||
* @param chunkFileFolder
|
||||
* @return
|
||||
*/
|
||||
private List<File> getSortedChunkFiles(File chunkFileFolder) {
|
||||
|
||||
//获取路径下的所有块文件
|
||||
File[] chunkFiles = chunkFileFolder.listFiles();
|
||||
if (chunkFiles == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
//将文件数组转成list,并排序
|
||||
List<File> chunkFileList = new ArrayList<>(Arrays.asList(chunkFiles));
|
||||
//排序
|
||||
chunkFileList.sort(Comparator.comparingInt(o -> Integer.parseInt(o.getName())));
|
||||
return chunkFileList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.tiesheng.web.service;
|
||||
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.tiesheng.web.pojos.RequestUserInfo;
|
||||
import com.tiesheng.web.pojos.dao.CoreConfigSystem;
|
||||
import com.tiesheng.web.pojos.dao.CorePlatformUnique;
|
||||
import com.tiesheng.util.pojos.TokenBean;
|
||||
import com.tiesheng.util.ServletKit;
|
||||
import com.tiesheng.util.exception.ApiRespEnum;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* WEB配置
|
||||
*
|
||||
* @author hao
|
||||
*/
|
||||
public interface TieshengWebConfigurer {
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前用户的姓名
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
RequestUserInfo getCurrentUserName(TokenBean userId);
|
||||
|
||||
|
||||
/**
|
||||
* 添加其他异常处理
|
||||
*
|
||||
* @param e 异常
|
||||
*/
|
||||
default ApiResp<String> addExceptionHandler(Exception e) {
|
||||
ApiResp<String> apiResp = ApiResp.respCust(ApiRespEnum.ServerError);
|
||||
apiResp.setException(e);
|
||||
LogFactory.get().info(apiResp.getException());
|
||||
return apiResp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加文件校验
|
||||
*/
|
||||
default void uploadFileCheck(String fileExt) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自定义文件上传
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default String uploadFileCustomize(MultipartFile file) {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件后处理文件
|
||||
*
|
||||
* @param uploadPath
|
||||
* @return
|
||||
*/
|
||||
default String uploadFileDeal(String uploadPath) {
|
||||
return uploadPath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 系统配置验证
|
||||
* 如果不符合规则,可以抛出异常
|
||||
*/
|
||||
default void configSystemCheck(CoreConfigSystem configSystem) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录逻辑
|
||||
*
|
||||
* @param platformUnique
|
||||
* @return
|
||||
*/
|
||||
TokenBean login(CorePlatformUnique platformUnique);
|
||||
|
||||
/**
|
||||
* 登录重定向
|
||||
*
|
||||
* @param bean
|
||||
* @param extra
|
||||
* @param response
|
||||
*/
|
||||
void redirect(TokenBean bean, String to, String extra, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 签名错误的时候
|
||||
*/
|
||||
default void onSignError(HttpServletResponse response) {
|
||||
ServletKit.write(response, "404", "text");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.tiesheng.web.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import com.tiesheng.util.ServletKit;
|
||||
import com.tiesheng.util.TimedCacheHelper;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
* @ProjectName cmcc
|
||||
* @Copyright Hangzhou ShuoChuang Technology Co.,Ltd All Right Reserved
|
||||
* @Description 这里是对文件的描述
|
||||
* @data 2019-06-19
|
||||
* @note 这里写文件的详细功能和改动
|
||||
* @note
|
||||
*/
|
||||
@Service
|
||||
public class TimedCacheService {
|
||||
|
||||
|
||||
/**
|
||||
* 清空数据
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public void clearByKey(String key) {
|
||||
TimedCacheHelper.getTimedCache().remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 放入缓存
|
||||
*
|
||||
* @param key
|
||||
* @param val
|
||||
*/
|
||||
public void putCache(String key, String val) {
|
||||
TimedCacheHelper.getTimedCache().put(key, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public String getCache(String key) {
|
||||
return TimedCacheHelper.getTimedCache().get(key);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 图片验证码缓存
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* 缓存 图片验证码
|
||||
*
|
||||
* @param session
|
||||
* @param value
|
||||
*/
|
||||
public void setImageCode(String captcha, String value) {
|
||||
putCache(captcha, value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验证 图片验证码
|
||||
*/
|
||||
public void verifyImage(String value) {
|
||||
String captchaKey = ServletUtil.getHeader(ServletKit.getRequest(), "captcha", "utf-8");
|
||||
String cache = getCache(captchaKey);
|
||||
if (StrUtil.isEmpty(cache) || !StrUtil.equals(cache, value)) {
|
||||
throw new ApiException("验证码不正确");
|
||||
}
|
||||
clearByKey(captchaKey);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.tiesheng.web.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProcessImportConsumer<T> {
|
||||
|
||||
|
||||
/**
|
||||
* 处理数据
|
||||
*
|
||||
* @param list
|
||||
* @param <T>
|
||||
* @return 返回成功的数量
|
||||
*/
|
||||
int accept(List<T> list);
|
||||
|
||||
|
||||
/**
|
||||
* 获取失败的文件路径
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getFailFile();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.tiesheng.web.util;
|
||||
|
||||
public interface ProcessSyncConsumer {
|
||||
|
||||
|
||||
/**
|
||||
* 分页数据
|
||||
*
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return 返回成功的数量
|
||||
*/
|
||||
int accept(Integer pageNum, Integer pageSize);
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user