Dubbo 路由规则的过滤器实现
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
package cn.iocoder.mall.system.rest.controller.datadict;
|
||||
|
||||
import cn.iocoder.common.framework.enums.MallConstants;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(MallConstants.ROOT_PATH_ADMIN + "/data-dict")
|
||||
@Api(tags = "管理员 - 数据字典 API")
|
||||
public class AdminsDataDictController {
|
||||
|
||||
// @Reference(validation = "true", version = "${dubbo.provider.DataDictService.version}")
|
||||
// private DataDictService dataDictService;
|
||||
|
||||
// @GetMapping("/list")
|
||||
// @ApiOperation(value = "数据字典全列表")
|
||||
// @RequiresPermissions("system.dataDict.list")
|
||||
// public CommonResult<List<DataDictBO>> list() {
|
||||
// return success( dataDictService.selectDataDictList());
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/tree")
|
||||
// @RequiresPermissions // 因为是通用的接口,所以无需权限标识
|
||||
// @ApiOperation(value = "数据字典树结构", notes = "该接口返回的信息更为精简。一般用于前端缓存数据字典到本地。")
|
||||
// public CommonResult<List<DataDictEnumVO>> tree() {
|
||||
// // 查询数据字典全列表
|
||||
// List<DataDictBO> dataDicts = dataDictService.selectDataDictList();
|
||||
// // 构建基于 enumValue 聚合的 Multimap
|
||||
// ImmutableListMultimap<String, DataDictBO> dataDictMap = Multimaps.index(dataDicts, DataDictBO::getEnumValue); // KEY 是 enumValue ,VALUE 是 DataDictBO 数组
|
||||
// // 构建返回结果
|
||||
// List<DataDictEnumVO> dataDictEnumVOs = new ArrayList<>(dataDictMap.size());
|
||||
// dataDictMap.keys().forEach(enumValue -> {
|
||||
// DataDictEnumVO dataDictEnumVO = new DataDictEnumVO().setEnumValue(enumValue)
|
||||
// .setValues(DataDictConvert.INSTANCE.convert2(dataDictMap.get(enumValue)));
|
||||
// dataDictEnumVOs.add(dataDictEnumVO);
|
||||
// });
|
||||
// return success(dataDictEnumVOs);
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/add")
|
||||
// @RequiresPermissions("system.dataDict.add")
|
||||
// @ApiOperation(value = "创建数据字典")
|
||||
// public CommonResult<DataDictBO> add(DataDictAddDTO dataDictAddDTO) {
|
||||
// return success(dataDictService.addDataDict(AdminSecurityContextHolder.getContext().getAdminId(), dataDictAddDTO));
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/update")
|
||||
// @RequiresPermissions("system.dataDict.update")
|
||||
// @ApiOperation(value = "更新数据字典")
|
||||
// public CommonResult<Boolean> update(DataDictUpdateDTO dataDictUpdateDTO) {
|
||||
// return success(dataDictService.updateDataDict(AdminSecurityContextHolder.getContext().getAdminId(), dataDictUpdateDTO));
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/delete")
|
||||
// @RequiresPermissions("system.dataDict.delete")
|
||||
// @ApiOperation(value = "删除数据字典")
|
||||
// @ApiImplicitParam(name = "id", value = "编号", required = true, example = "100")
|
||||
// public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
|
||||
// return success(dataDictService.deleteDataDict(AdminSecurityContextHolder.getContext().getAdminId(), id));
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package cn.iocoder.mall.system.rest.controller.errorCode;
|
||||
|
||||
import cn.iocoder.common.framework.enums.MallConstants;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.security.core.annotation.RequiresPermissions;
|
||||
import cn.iocoder.mall.system.biz.bo.errorcode.ErrorCodeBO;
|
||||
import cn.iocoder.mall.system.biz.dto.errorcode.ErrorCodeAddDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.errorcode.ErrorCodeDeleteDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.errorcode.ErrorCodePageDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.errorcode.ErrorCodeUpdateDTO;
|
||||
import cn.iocoder.mall.system.biz.service.errorcode.ErrorCodeService;
|
||||
import cn.iocoder.mall.system.rest.convert.errorcode.ErrorCodeConvert;
|
||||
import cn.iocoder.mall.system.rest.request.errorcode.ErrorCodeAddRequest;
|
||||
import cn.iocoder.mall.system.rest.request.errorcode.ErrorCodePageRequest;
|
||||
import cn.iocoder.mall.system.rest.response.errorcode.ErrorCodePageResponse;
|
||||
import cn.iocoder.mall.system.rest.request.errorcode.ErrorCodeUpdateRequest;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
*
|
||||
* @author youyusi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(MallConstants.ROOT_PATH_ADMIN + "/errorcode") // TODO FROM 芋艿 to 鱿鱼须:error-code
|
||||
@Api("错误码")
|
||||
public class SystemErrorCodeController { // TODO FROM 芋艿 to 鱿鱼须:变量要空行
|
||||
@Autowired
|
||||
private ErrorCodeService errorCodeService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation(value = "错误码分页")
|
||||
@RequiresPermissions("system:errorcode:page")
|
||||
public CommonResult<PageResult<ErrorCodePageResponse>> page(ErrorCodePageRequest request) {
|
||||
ErrorCodePageDTO pageDTO = ErrorCodeConvert.INSTANCE.convert(request);
|
||||
PageResult<ErrorCodeBO> pageResult = errorCodeService.getErrorCodePage(pageDTO);
|
||||
return CommonResult.success(ErrorCodeConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "创建错误码")
|
||||
@RequiresPermissions("system:errorcode:add")
|
||||
public CommonResult<Integer> add(ErrorCodeAddRequest request) {
|
||||
ErrorCodeAddDTO addDTO = ErrorCodeConvert.INSTANCE.convert(request);
|
||||
return CommonResult.success(errorCodeService.addErrorCode(addDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "更新错误码")
|
||||
@RequiresPermissions("system:errorcode:update")
|
||||
public CommonResult<Boolean> update(ErrorCodeUpdateRequest request) {
|
||||
ErrorCodeUpdateDTO updateDTO = ErrorCodeConvert.INSTANCE.convert(request);
|
||||
errorCodeService.updateErrorCode(updateDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除错误码")
|
||||
@RequiresPermissions("system:errorcode:delete")
|
||||
@ApiImplicitParam(name = "id", value = "错误码编号", required = true, example = "1")
|
||||
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
|
||||
ErrorCodeDeleteDTO deleteDTO = new ErrorCodeDeleteDTO().setId(id);
|
||||
errorCodeService.deleteErrorCode(deleteDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package cn.iocoder.mall.system.rest.controller.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.system.biz.bo.systemlog.AccessLogBO;
|
||||
import cn.iocoder.mall.system.biz.dto.system.AccessLogPageDTO;
|
||||
import cn.iocoder.mall.system.biz.service.systemlog.SystemLogService;
|
||||
import cn.iocoder.mall.system.rest.convert.systemlog.AccessLogConvert;
|
||||
import cn.iocoder.mall.system.rest.response.systemlog.AccessLogPageResponse;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author:ycjx
|
||||
* @descriptio
|
||||
* @create:2019-06-23 16:42
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admins/system/logs")
|
||||
@Api("系统日志")
|
||||
public class SystemLogController {
|
||||
|
||||
@Autowired
|
||||
private SystemLogService systemLogService;
|
||||
|
||||
@GetMapping("/access/page")
|
||||
@ApiOperation(value = "访问日志分页")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "userId", value = "用户id", example = "1"),
|
||||
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"),
|
||||
})
|
||||
public CommonResult<PageResult<AccessLogPageResponse>> page(@RequestParam(value = "accountId", required = false) Integer accountId,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
|
||||
// TODO FROM 芋艿 to 2447007062:不要留这么大的空行;
|
||||
// TODO FROM 芋艿 to 2447007062:使用 Request 接收参数噢;
|
||||
AccessLogPageDTO accessLogPageDTO = new AccessLogPageDTO().setAccountId(accountId)
|
||||
.setPageNo(pageNo).setPageSize(pageSize);
|
||||
// 查询分页
|
||||
PageResult<AccessLogBO> result = systemLogService.getAccessLogPage(accessLogPageDTO);
|
||||
// 转换结果
|
||||
return CommonResult.success(AccessLogConvert.INSTANCE.convert(result));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package cn.iocoder.mall.system.rest.convert.errorcode;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.system.biz.bo.errorcode.ErrorCodeBO;
|
||||
import cn.iocoder.mall.system.biz.dto.errorcode.ErrorCodeAddDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.errorcode.ErrorCodePageDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.errorcode.ErrorCodeUpdateDTO;
|
||||
import cn.iocoder.mall.system.rest.request.errorcode.ErrorCodeAddRequest;
|
||||
import cn.iocoder.mall.system.rest.request.errorcode.ErrorCodePageRequest;
|
||||
import cn.iocoder.mall.system.rest.response.errorcode.ErrorCodePageResponse;
|
||||
import cn.iocoder.mall.system.rest.request.errorcode.ErrorCodeUpdateRequest;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* @author ding
|
||||
*/
|
||||
@Mapper
|
||||
public interface ErrorCodeConvert {
|
||||
ErrorCodeConvert INSTANCE = Mappers.getMapper(ErrorCodeConvert.class);
|
||||
|
||||
ErrorCodeAddDTO convert(ErrorCodeAddRequest bean);
|
||||
|
||||
ErrorCodeUpdateDTO convert(ErrorCodeUpdateRequest bean);
|
||||
|
||||
ErrorCodePageDTO convert(ErrorCodePageRequest bean);
|
||||
|
||||
PageResult<ErrorCodePageResponse> convertPage(PageResult<ErrorCodeBO> bean);
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package cn.iocoder.mall.system.rpc.api.errorcode;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.system.rpc.request.errorcode.ErrorCodeAddRequest;
|
||||
import cn.iocoder.mall.system.rpc.request.systemlog.ExceptionLogAddRequest;
|
||||
import cn.iocoder.mall.system.rpc.response.errorcode.ErrorCodeResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ErrorCode RPC 接口
|
||||
* 提供其他服务初始化加载错误码到db中,同时提供读取该服务的错误码信息,
|
||||
* 同时提供删除接口,
|
||||
* @author ding
|
||||
*/
|
||||
public interface ErrorCodeRPC {
|
||||
|
||||
CommonResult<List<ErrorCodeResponse>> getErrorCodeByGroup(Integer group);
|
||||
|
||||
CommonResult<Boolean> addErrorCode(ErrorCodeAddRequest errorCodeAddRequest);
|
||||
|
||||
CommonResult<Boolean> addErrorCodeList(List<ErrorCodeAddRequest> list);
|
||||
|
||||
CommonResult<Boolean> deleteErrorCodeByGroup(Integer group, Integer type);
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package cn.iocoder.mall.system.rpc.request.errorcode;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 错误码模块,枚举初始化错误码时使用
|
||||
* @author ding
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ErrorCodeAddRequest implements Serializable {
|
||||
@ApiModelProperty(value = "错误码信息", required = true)
|
||||
@NotEmpty(message = "错误码信息不能为空")
|
||||
private String message;
|
||||
|
||||
@ApiModelProperty(value = "错误码编码")
|
||||
@NotEmpty(message = "错误码编码不能为空")
|
||||
private Integer code;
|
||||
|
||||
@ApiModelProperty(value = "错误码分组,字典表获取")
|
||||
@NotEmpty(message = "错误码分组不能为空")
|
||||
private Integer group;
|
||||
|
||||
@ApiModelProperty(value = "错误码角色,系统内置(枚举)还是自定义")
|
||||
@NotEmpty(message = "错误码角色不能空")
|
||||
private Integer type;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package cn.iocoder.mall.system.rpc.response.errorcode;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 类 描 述:错误码模块
|
||||
* @author ding
|
||||
*/
|
||||
@ApiModel("管理员 - 错误码模块 - 查询错误码")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ErrorCodeResponse {
|
||||
/**
|
||||
* 错误码编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 错误码编码
|
||||
*/
|
||||
private Integer code;
|
||||
/**
|
||||
* 错误码错误信息
|
||||
*/
|
||||
private String message;
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private Date createTime;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package cn.iocoder.mall.system.rpc.convert.errorcode;
|
||||
|
||||
import cn.iocoder.mall.system.biz.bo.errorcode.ErrorCodeBO;
|
||||
import cn.iocoder.mall.system.biz.dto.errorcode.ErrorCodeAddDTO;
|
||||
import cn.iocoder.mall.system.rpc.request.errorcode.ErrorCodeAddRequest;
|
||||
import cn.iocoder.mall.system.rpc.response.errorcode.ErrorCodeResponse;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ErrorCodeConvert {
|
||||
|
||||
ErrorCodeConvert INSTANCE = Mappers.getMapper(ErrorCodeConvert.class);
|
||||
|
||||
List<ErrorCodeResponse> convert(List<ErrorCodeBO> bean);
|
||||
|
||||
ErrorCodeAddDTO convert(ErrorCodeAddRequest errorCodeAddRequest);
|
||||
|
||||
List<ErrorCodeAddDTO> convertList(List<ErrorCodeAddRequest> bean);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package cn.iocoder.mall.system.rpc.convert.systemlog;
|
||||
|
||||
import cn.iocoder.mall.system.biz.dto.system.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.system.ExceptionLogAddDTO;
|
||||
import cn.iocoder.mall.system.rpc.request.systemlog.AccessLogAddRequest;
|
||||
import cn.iocoder.mall.system.rpc.request.systemlog.ExceptionLogAddRequest;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface SystemLogConvert {
|
||||
|
||||
SystemLogConvert INSTANCE = Mappers.getMapper(SystemLogConvert.class);
|
||||
|
||||
AccessLogAddDTO convert(AccessLogAddRequest bean);
|
||||
|
||||
ExceptionLogAddDTO convert(ExceptionLogAddRequest bean);
|
||||
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package cn.iocoder.mall.system.rpc.rpc.errorcode;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.system.biz.bo.errorcode.ErrorCodeBO;
|
||||
import cn.iocoder.mall.system.biz.service.errorcode.ErrorCodeService;
|
||||
import cn.iocoder.mall.system.rpc.api.errorcode.ErrorCodeRPC;
|
||||
import cn.iocoder.mall.system.rpc.convert.errorcode.ErrorCodeConvert;
|
||||
import cn.iocoder.mall.system.rpc.convert.user.UserConvert;
|
||||
import cn.iocoder.mall.system.rpc.request.errorcode.ErrorCodeAddRequest;
|
||||
import cn.iocoder.mall.system.rpc.response.errorcode.ErrorCodeResponse;
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ding
|
||||
*/
|
||||
@Service(version = "${dubbo.provider.ErrorCodeRPC.version}", validation = "true")
|
||||
public class ErrorCodeRPCImpl implements ErrorCodeRPC {
|
||||
|
||||
@Autowired
|
||||
private ErrorCodeService errorCodeService;
|
||||
|
||||
/**
|
||||
* 根据分组获取错误码信息
|
||||
* @param group 分组
|
||||
* @return 错误码信息
|
||||
*/
|
||||
@Override
|
||||
public CommonResult<List<ErrorCodeResponse>> getErrorCodeByGroup(Integer group) {
|
||||
List<ErrorCodeBO> list = errorCodeService.getErrorCodeByGroup(group);
|
||||
return CommonResult.success(ErrorCodeConvert.INSTANCE.convert(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加错误码信息,如果是枚举错误码,角色一定是系统内置
|
||||
* @param errorCodeAddRequest 错误码
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public CommonResult<Boolean> addErrorCode(ErrorCodeAddRequest errorCodeAddRequest) {
|
||||
errorCodeService.addErrorCode(ErrorCodeConvert.INSTANCE.convert(errorCodeAddRequest));
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加错误码信息
|
||||
* @param list 错误码信息集合
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public CommonResult<Boolean> addErrorCodeList(List<ErrorCodeAddRequest> list) {
|
||||
errorCodeService.addErrorCodeList(ErrorCodeConvert.INSTANCE.convertList(list));
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分组和角色条件删除错误码信息,只能删除db信息,删除后会进行校验,刷新utils
|
||||
* @param group 分组
|
||||
* @param type 角色
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteErrorCodeByGroup(Integer group, Integer type) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package cn.iocoder.mall.system.api;
|
||||
|
||||
import cn.iocoder.mall.system.api.bo.systemlog.AccessLogPageBO;
|
||||
import cn.iocoder.mall.system.api.dto.systemlog.AccessLogPageDTO;
|
||||
|
||||
/**
|
||||
* 系统日志 Service 接口
|
||||
*
|
||||
* 例如说,访问日志、错误日志、操作日志等等
|
||||
*/
|
||||
public interface SystemLogService {
|
||||
|
||||
AccessLogPageBO getAccessLogPage(AccessLogPageDTO accessLogPageDTO);
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package cn.iocoder.mall.admin.service;
|
||||
|
||||
import cn.iocoder.common.framework.util.StringUtil;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.system.api.SystemLogService;
|
||||
import cn.iocoder.mall.system.api.bo.systemlog.AccessLogBO;
|
||||
import cn.iocoder.mall.system.api.bo.systemlog.AccessLogPageBO;
|
||||
import cn.iocoder.mall.system.api.dto.systemlog.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.system.api.dto.systemlog.AccessLogPageDTO;
|
||||
import cn.iocoder.mall.system.api.dto.systemlog.ExceptionLogAddDTO;
|
||||
import cn.iocoder.mall.admin.convert.AccessLogConvert;
|
||||
import cn.iocoder.mall.admin.dao.AccessLogMapper;
|
||||
import cn.iocoder.mall.admin.dao.ExceptionLogMapper;
|
||||
import cn.iocoder.mall.admin.dataobject.AccessLogDO;
|
||||
import cn.iocoder.mall.admin.dataobject.ExceptionLogDO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.AdminAccessLogService.version}")
|
||||
public class SystemLogServiceImpl implements SystemLogService {
|
||||
|
||||
/**
|
||||
* 请求参数最大长度。
|
||||
*/
|
||||
private static final Integer QUERY_STRING_MAX_LENGTH = 4096;
|
||||
/**
|
||||
* 请求地址最大长度。
|
||||
*/
|
||||
private static final Integer URI_MAX_LENGTH = 4096;
|
||||
/**
|
||||
* User-Agent 最大长度。
|
||||
*/
|
||||
private static final Integer USER_AGENT_MAX_LENGTH = 1024;
|
||||
|
||||
@Autowired
|
||||
private AccessLogMapper accessLogMapper;
|
||||
@Autowired
|
||||
private ExceptionLogMapper exceptionLogMapper;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void addAccessLog(AccessLogAddDTO adminAccessLogAddDTO) {
|
||||
// 创建 AdminAccessLogDO
|
||||
AccessLogDO accessLog = AccessLogConvert.INSTANCE.convert(adminAccessLogAddDTO);
|
||||
accessLog.setCreateTime(new Date());
|
||||
// 截取最大长度
|
||||
if (accessLog.getUri().length() > URI_MAX_LENGTH) {
|
||||
accessLog.setUri(StringUtil.substring(accessLog.getUri(), URI_MAX_LENGTH));
|
||||
}
|
||||
if (accessLog.getQueryString().length() > QUERY_STRING_MAX_LENGTH) {
|
||||
accessLog.setQueryString(StringUtil.substring(accessLog.getQueryString(), QUERY_STRING_MAX_LENGTH));
|
||||
}
|
||||
if (accessLog.getUserAgent().length() > USER_AGENT_MAX_LENGTH) {
|
||||
accessLog.setUserAgent(StringUtil.substring(accessLog.getUserAgent(), USER_AGENT_MAX_LENGTH));
|
||||
}
|
||||
// 插入
|
||||
accessLogMapper.insert(accessLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void addExceptionLog(ExceptionLogAddDTO exceptionLogAddDTO) {
|
||||
// 创建 AdminAccessLogDO
|
||||
ExceptionLogDO exceptionLog = AccessLogConvert.INSTANCE.convert(exceptionLogAddDTO);
|
||||
exceptionLog.setCreateTime(new Date());
|
||||
// 截取最大长度
|
||||
if (exceptionLog.getUri().length() > URI_MAX_LENGTH) {
|
||||
exceptionLog.setUri(StringUtil.substring(exceptionLog.getUri(), URI_MAX_LENGTH));
|
||||
}
|
||||
if (exceptionLog.getQueryString().length() > QUERY_STRING_MAX_LENGTH) {
|
||||
exceptionLog.setQueryString(StringUtil.substring(exceptionLog.getQueryString(), QUERY_STRING_MAX_LENGTH));
|
||||
}
|
||||
if (exceptionLog.getUserAgent().length() > USER_AGENT_MAX_LENGTH) {
|
||||
exceptionLog.setUserAgent(StringUtil.substring(exceptionLog.getUserAgent(), USER_AGENT_MAX_LENGTH));
|
||||
}
|
||||
// 插入
|
||||
exceptionLogMapper.insert(exceptionLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("Duplicates")
|
||||
public AccessLogPageBO getAccessLogPage(AccessLogPageDTO accessLogPageDTO) {
|
||||
AccessLogPageBO accessLogPageBO = new AccessLogPageBO();
|
||||
PageResult<AccessLogBO> accessLogPageBOPageResult = AccessLogConvert.INSTANCE.convert(
|
||||
accessLogMapper.selectPage(accessLogPageDTO));
|
||||
accessLogPageBO.setList(accessLogPageBOPageResult.getList());
|
||||
accessLogPageBO.setTotal(accessLogPageBOPageResult.getTotal());
|
||||
return accessLogPageBO;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user