系统异常日志模块的迁移

This commit is contained in:
YunaiV
2020-07-16 09:04:18 +08:00
parent 42e30bf380
commit 02dda60e60
35 changed files with 814 additions and 428 deletions

View File

@@ -1,41 +0,0 @@
package cn.iocoder.mall.system.api.bo.systemlog;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* @author:ycjx
* @descriptio
* @create:2019-06-23 17:26
*/
@Data
@Accessors(chain = true)
public class AccessLogBO implements Serializable {
private String traceId;
private Integer userId;
private Integer userType;
private String applicationName;
private String uri;
private String queryString;
private String method;
private String userAgent;
private String ip;
private Date startTime;
private Integer responseTime;
private Integer errorCode;
}

View File

@@ -1,27 +0,0 @@
package cn.iocoder.mall.system.api.bo.systemlog;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* @author:ycjx
* @descriptio
* @create:2019-06-23 17:26
*/
@Data
@Accessors(chain = true)
public class AccessLogPageBO implements Serializable {
/**
* 日志数组
*/
private List<AccessLogBO> list;
/**
* 总量
*/
private Integer total;
}

View File

@@ -1,36 +0,0 @@
package cn.iocoder.mall.system.api.dto.datadict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@ApiModel("数据字典添加 DTO")
@Data
@Accessors(chain = true)
public class DataDictAddDTO implements Serializable {
@ApiModelProperty(value = "大类枚举值", required = true, example = "gender")
@NotEmpty(message = "大类枚举值不能为空")
private String enumValue;
@ApiModelProperty(value = "小类数值", required = true, example = "1")
@NotEmpty(message = "小类数值不能为空")
private String value;
@ApiModelProperty(value = "展示名", required = true, example = "")
@NotEmpty(message = "展示名不能为空")
private String displayName;
@ApiModelProperty(required = true, value = "排序值", example = "123")
@NotNull(message = "排序值不能为空")
private Integer sort;
@ApiModelProperty(value = "备注", example = "你猜我猜不猜")
private String memo;
}

View File

@@ -1,41 +0,0 @@
package cn.iocoder.mall.system.api.dto.datadict;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 数据字典更新 DTO
*/
@Data
@Accessors(chain = true)
public class DataDictUpdateDTO implements Serializable {
@ApiModelProperty(value = "数据字典编号", required = true, example = "1")
@NotNull(message = "数据字典编号不能为空")
private Integer id;
@ApiModelProperty(value = "大类枚举值", required = true, example = "gender")
@NotEmpty(message = "大类枚举值不能为空")
private String enumValue;
@ApiModelProperty(value = "小类数值", required = true, example = "1")
@NotEmpty(message = "小类数值不能为空")
private String value;
@ApiModelProperty(value = "展示名", required = true, example = "")
@NotEmpty(message = "展示名不能为空")
private String displayName;
@ApiModelProperty(required = true, value = "排序值", example = "123")
@NotNull(message = "排序值不能为空")
private Integer sort;
@ApiModelProperty(value = "备注", example = "你猜我猜不猜")
private String memo;
}

View File

@@ -1,28 +0,0 @@
package cn.iocoder.mall.system.api.dto.systemlog;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @author:ycjx
* @descriptio
* @create:2019-06-23 16:53
*/
@Data
@Accessors(chain = true)
public class AccessLogPageDTO {
/**
* 用户id
*/
private Integer userId;
@NotNull(message = "页码不能为空")
private Integer pageNo;
@NotNull(message = "每页条数不能为空")
private Integer pageSize;
}

View File

@@ -1,31 +0,0 @@
package cn.iocoder.mall.admin.convert;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.system.api.bo.systemlog.AccessLogBO;
import cn.iocoder.mall.system.api.dto.systemlog.AccessLogAddDTO;
import cn.iocoder.mall.system.api.dto.systemlog.ExceptionLogAddDTO;
import cn.iocoder.mall.admin.dataobject.AccessLogDO;
import cn.iocoder.mall.admin.dataobject.ExceptionLogDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
@Mapper
public interface AccessLogConvert {
AccessLogConvert INSTANCE = Mappers.getMapper(AccessLogConvert.class);
@Mappings({})
AccessLogDO convert(AccessLogAddDTO accessLogAddDTO);
@Mappings({})
ExceptionLogDO convert(ExceptionLogAddDTO exceptionLogAddDTO);
@Mappings({
@Mapping(source = "records", target = "list"),
})
PageResult<AccessLogBO> convert(IPage<AccessLogDO> page);
}

View File

@@ -1,25 +0,0 @@
package cn.iocoder.mall.admin.convert;
import cn.iocoder.mall.system.api.bo.datadict.DataDictBO;
import cn.iocoder.mall.system.api.dto.datadict.DataDictAddDTO;
import cn.iocoder.mall.system.api.dto.datadict.DataDictUpdateDTO;
import cn.iocoder.mall.admin.dataobject.DataDictDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface DataDictConvert {
DataDictConvert INSTANCE = Mappers.getMapper(DataDictConvert.class);
DataDictDO convert(DataDictAddDTO dataDictAddDTO);
DataDictDO convert(DataDictUpdateDTO dataDictUpdateDTO);
DataDictBO convert(DataDictDO dataDictDO);
List<DataDictBO> convert(List<DataDictDO> dataDictDOs);
}

View File

@@ -1,15 +0,0 @@
package cn.iocoder.mall.system.application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.system"})
@EnableAsync(proxyTargetClass = true)
public class SystemApplication {
public static void main(String[] args) {
SpringApplication.run(SystemApplication.class, args);
}
}

View File

@@ -1,21 +0,0 @@
package cn.iocoder.mall.system.application.config;
import com.qiniu.util.Auth;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class QiniuConfiguration {
@Value("${qiniu.access-key}")
private String accessKey;
@Value("${qiniu.secret-key}")
private String secretKey;
@Bean
public Auth auth() {
return Auth.create(accessKey, secretKey);
}
}

View File

@@ -1,114 +0,0 @@
package cn.iocoder.mall.system.application.controller.admins;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.system.api.DeptmentService;
import cn.iocoder.mall.system.api.bo.deptment.DeptmentBO;
import cn.iocoder.mall.system.api.constant.ResourceConstants;
import cn.iocoder.mall.system.api.dto.depetment.DeptmentAddDTO;
import cn.iocoder.mall.system.api.dto.depetment.DeptmentPageDTO;
import cn.iocoder.mall.system.api.dto.depetment.DeptmentUpdateDTO;
import cn.iocoder.mall.system.application.convert.DeptmentConvert;
import cn.iocoder.mall.system.application.vo.deptment.DeptmentVO;
import cn.iocoder.mall.system.sdk.context.AdminSecurityContextHolder;
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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* Description:
*
* @author: zhenxianyimeng
* @date: 2019-06-14
* @time: 19:07
*/
@RestController
@RequestMapping("admins/dept")
@Api("部门模块")
public class DeptmentController {
@Autowired
private DeptmentService deptmentService;
@GetMapping("tree/all")
@ApiOperation(value = "根部门的部门树")
public CommonResult<List<DeptmentVO>> treeAll(){
List<DeptmentBO> list = deptmentService.getAllDeptments();
List<DeptmentVO> voList = DeptmentConvert.INSTANCE.convert(list);
Map<Integer, DeptmentVO> nodeMap = calcNodeMap(voList);
// 获得到所有的根节点
List<DeptmentVO> rootNodes = nodeMap.values().stream()
.filter(node -> node.getPid().equals(ResourceConstants.PID_ROOT))
.collect(Collectors.toList());
return success(rootNodes);
}
@GetMapping("tree/page")
@ApiOperation(value = "根部门分页的部门树")
public CommonResult<PageResult<DeptmentVO>> treePage(@Validated DeptmentPageDTO deptmentPageDTO){
PageResult<DeptmentBO> pageResult = deptmentService.getPageRootDeptment(deptmentPageDTO);
PageResult<DeptmentVO> voPageResult = DeptmentConvert.INSTANCE.convert(pageResult);
List<DeptmentBO> list = deptmentService.getAllDeptments();
List<DeptmentVO> voList = DeptmentConvert.INSTANCE.convert(list);
Map<Integer, DeptmentVO> nodeMap = calcNodeMap(voList);
voPageResult.getList().forEach(d->{
d.setChildren(nodeMap.get(d.getId()).getChildren());
});
return success(voPageResult);
}
@PostMapping("add")
@ApiOperation(value = "新增部门", notes = "选择部门名称,父级部门")
public CommonResult<DeptmentBO> add(@RequestBody DeptmentAddDTO deptmentAddDTO){
return success(deptmentService.addDeptment(
AdminSecurityContextHolder.getContext().getAdminId(), deptmentAddDTO));
}
@PostMapping("delete")
@ApiOperation(value = "删除部门")
@ApiImplicitParam(name = "id", value = "部门id", required = true, example = "1")
public CommonResult<Boolean> delete(@RequestParam("id") Integer id){
return success(deptmentService.deleteDeptment(
AdminSecurityContextHolder.getContext().getAdminId(), id
));
}
@PostMapping("update")
@ApiOperation(value = "更新部门")
public CommonResult<Boolean> update(@RequestBody DeptmentUpdateDTO deptmentUpdateDTO){
return success(deptmentService.updateDeptment(
AdminSecurityContextHolder.getContext().getAdminId(), deptmentUpdateDTO
));
}
private Map<Integer, DeptmentVO> calcNodeMap(List<DeptmentVO> voList){
Map<Integer, DeptmentVO> nodeMap = voList.stream().collect(Collectors.toMap(e->e.getId(), e->e));
nodeMap.values().stream()
.filter(node -> !node.getPid().equals(ResourceConstants.PID_ROOT))
.forEach((childNode) -> {
// 获得父节点
DeptmentVO parentNode = nodeMap.get(childNode.getPid());
if (parentNode.getChildren() == null) { // 初始化 children 数组
parentNode.setChildren(new ArrayList<>());
}
// 将自己添加到父节点中
parentNode.getChildren().add(childNode);
});
return nodeMap;
}
}

View File

@@ -1,34 +0,0 @@
package cn.iocoder.mall.system.application.vo.datadict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@ApiModel("数据字典枚举 VO")
@Data
@Accessors(chain = true)
public class DataDictEnumVO {
@ApiModelProperty(value = "大类枚举值", required = true, example = "gender")
private String enumValue;
@ApiModelProperty(value = "小类数值数组", required = true)
private List<Value> values;
@ApiModel("数据字典枚举值 VO")
@Data
@Accessors(chain = true)
public static class Value {
@ApiModelProperty(value = "小类数值", required = true, example = "1")
private String value;
@ApiModelProperty(value = "展示名", required = true, example = "")
private String displayName;
}
}