访问日志的管理功能的迁移
This commit is contained in:
@@ -1,80 +0,0 @@
|
||||
package cn.iocoder.mall.system.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.system.api.DataDictService;
|
||||
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.system.application.convert.DataDictConvert;
|
||||
import cn.iocoder.mall.system.application.vo.datadict.DataDictEnumVO;
|
||||
import cn.iocoder.mall.system.sdk.annotation.RequiresPermissions;
|
||||
import cn.iocoder.mall.system.sdk.context.AdminSecurityContextHolder;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/data_dict")
|
||||
@Api("数据字典模块")
|
||||
public class DataDictController {
|
||||
|
||||
@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,56 +0,0 @@
|
||||
package cn.iocoder.mall.system.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.system.api.SystemLogService;
|
||||
import cn.iocoder.mall.system.api.bo.systemlog.AccessLogPageBO;
|
||||
import cn.iocoder.mall.system.api.dto.systemlog.AccessLogPageDTO;
|
||||
import cn.iocoder.mall.system.application.convert.AccessLogConvert;
|
||||
import cn.iocoder.mall.system.application.vo.log.AccessLogPageVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
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;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* @author:ycjx
|
||||
* @descriptio
|
||||
* @create:2019-06-23 16:42
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admins/system/logs")
|
||||
@Api("系统日志")
|
||||
public class SystemLogController {
|
||||
|
||||
@Reference(validation = "true", version = "${dubbo.provider.AdminAccessLogService.version}")
|
||||
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<AccessLogPageVo> page(@RequestParam(value = "userId", required = false) Integer userId,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
|
||||
|
||||
AccessLogPageDTO accessLogPageDTO = new AccessLogPageDTO().setUserId(userId)
|
||||
.setPageNo(pageNo).setPageSize(pageSize);
|
||||
// 查询分页
|
||||
AccessLogPageBO result = systemLogService.getAccessLogPage(accessLogPageDTO);
|
||||
// 转换结果
|
||||
return success(AccessLogConvert.INSTANCE.convert(result));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package cn.iocoder.mall.system.application.convert;
|
||||
|
||||
import cn.iocoder.mall.system.api.bo.systemlog.AccessLogBO;
|
||||
import cn.iocoder.mall.system.api.bo.systemlog.AccessLogPageBO;
|
||||
import cn.iocoder.mall.system.application.vo.log.AccessLogPageVo;
|
||||
import cn.iocoder.mall.system.application.vo.log.AccessLogVo;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* @author:ycjx
|
||||
* @descriptio
|
||||
* @create:2019-06-23 17:36
|
||||
*/
|
||||
@Mapper
|
||||
public interface AccessLogConvert {
|
||||
|
||||
|
||||
AccessLogConvert INSTANCE = Mappers.getMapper(AccessLogConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
AccessLogPageVo convert(AccessLogPageBO result);
|
||||
|
||||
@Mappings({})
|
||||
AccessLogVo convert(AccessLogBO result);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package cn.iocoder.mall.system.application.convert;
|
||||
|
||||
import cn.iocoder.mall.system.api.bo.datadict.DataDictBO;
|
||||
import cn.iocoder.mall.system.application.vo.datadict.DataDictEnumVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DataDictConvert {
|
||||
|
||||
DataDictConvert INSTANCE = Mappers.getMapper(DataDictConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
List<DataDictEnumVO.Value> convert2(List<DataDictBO> dataDictBOs);
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package cn.iocoder.mall.system.application.vo.log;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:ycjx
|
||||
* @descriptio
|
||||
* @create:2019-06-23 17:03
|
||||
*/
|
||||
@ApiModel("访问日志分页 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AccessLogPageVo {
|
||||
|
||||
|
||||
@ApiModelProperty(value = "访问数据")
|
||||
private List<AccessLogVo> list;
|
||||
@ApiModelProperty(value = "访问总数")
|
||||
private Integer total;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package cn.iocoder.mall.system.application.vo.log;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author:yuxj
|
||||
* @descriptio
|
||||
* @create:2019-06-23 17:04
|
||||
*/
|
||||
|
||||
@ApiModel("访问日志 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AccessLogVo {
|
||||
|
||||
|
||||
@ApiModelProperty(value = "链路追踪编号", required = true, example = "1")
|
||||
private String traceId;
|
||||
|
||||
@ApiModelProperty(value = "用户编号", required = true, example = "1")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "用户类型", required = true, example = "1")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "应用名", required = true, example = "1")
|
||||
private String applicationName;
|
||||
|
||||
@ApiModelProperty(value = "访问地址", required = true, example = "1")
|
||||
private String uri;
|
||||
|
||||
@ApiModelProperty(value = "请求参数", required = true, example = "1")
|
||||
private String queryString;
|
||||
|
||||
@ApiModelProperty(value = "http 请求方法", required = true, example = "1")
|
||||
private String method;
|
||||
|
||||
@ApiModelProperty(value = "User-Agent ", required = true, example = "1")
|
||||
private String userAgent;
|
||||
|
||||
@ApiModelProperty(value = "ip", required = true, example = "1")
|
||||
private String ip;
|
||||
|
||||
@ApiModelProperty(value = "请求时间", required = true, example = "1")
|
||||
private Date startTime;
|
||||
|
||||
@ApiModelProperty(value = "响应时长", required = true, example = "1")
|
||||
private Integer responseTime;
|
||||
|
||||
@ApiModelProperty(value = "错误码", required = true, example = "1")
|
||||
private Integer errorCode;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user