访问日志的管理功能的迁移
This commit is contained in:
@@ -6,6 +6,7 @@ import cn.iocoder.mall.managementweb.controller.datadict.dto.DataDictUpdateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.datadict.vo.DataDictSimpleVO;
|
||||
import cn.iocoder.mall.managementweb.controller.datadict.vo.DataDictVO;
|
||||
import cn.iocoder.mall.managementweb.manager.datadict.DataDictManager;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -22,7 +23,7 @@ import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
* 数据字典 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/data_dict")
|
||||
@RequestMapping("/data-dict")
|
||||
@Api(tags = "数据字典")
|
||||
@Validated
|
||||
public class DataDictController {
|
||||
@@ -32,12 +33,14 @@ public class DataDictController {
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建数据字典")
|
||||
@RequiresPermissions("system:data-dict:create")
|
||||
public CommonResult<Integer> createDataDict(@Valid DataDictCreateDTO createDTO) {
|
||||
return success(dataDictManager.createDataDict(createDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新数据字典")
|
||||
@RequiresPermissions("system:data-dict:update")
|
||||
public CommonResult<Boolean> updateDataDict(@Valid DataDictUpdateDTO updateDTO) {
|
||||
dataDictManager.updateDataDict(updateDTO);
|
||||
return success(true);
|
||||
@@ -46,6 +49,7 @@ public class DataDictController {
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除数据字典")
|
||||
@ApiImplicitParam(name = "dataDictId", value = "数据字典编号", required = true)
|
||||
@RequiresPermissions("system:data-dict:delete")
|
||||
public CommonResult<Boolean> deleteDataDict(@RequestParam("dataDictId") Integer dataDictId) {
|
||||
dataDictManager.deleteDataDict(dataDictId);
|
||||
return success(true);
|
||||
@@ -54,6 +58,7 @@ public class DataDictController {
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得数据字典")
|
||||
@ApiImplicitParam(name = "dataDictId", value = "数据字典编号", required = true)
|
||||
@RequiresPermissions("system:data-dict:list")
|
||||
public CommonResult<DataDictVO> getDataDict(@RequestParam("dataDictId") Integer dataDictId) {
|
||||
return success(dataDictManager.getDataDict(dataDictId));
|
||||
}
|
||||
@@ -61,18 +66,21 @@ public class DataDictController {
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得数据字典列表")
|
||||
@ApiImplicitParam(name = "dataDictIds", value = "数据字典编号列表", required = true)
|
||||
@RequiresPermissions("system:data-dict:list")
|
||||
public CommonResult<List<DataDictVO>> listDataDicts(@RequestParam("dataDictIds") List<Integer> dataDictIds) {
|
||||
return success(dataDictManager.listDataDicts(dataDictIds));
|
||||
}
|
||||
|
||||
@GetMapping("/list-all")
|
||||
@ApiOperation("获得全部数据字典列表")
|
||||
@RequiresPermissions("system:data-dict:list")
|
||||
public CommonResult<List<DataDictVO>> listDataDicts() {
|
||||
return success(dataDictManager.listDataDicts());
|
||||
}
|
||||
|
||||
@GetMapping("/list-all-simple")
|
||||
@ApiOperation(value = "获得全部数据字典列表", notes = "一般用于管理后台缓存数据字典在本地")
|
||||
// 无需添加权限认证,因为前端全局都需要
|
||||
public CommonResult<List<DataDictSimpleVO>> listSimpleDataDicts() {
|
||||
return success(dataDictManager.listSimpleDataDicts());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
### /system-access-log/page 成功
|
||||
GET {{baseUrl}}/system-access-log/page?pageNo=1&pageSize=10
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer {{accessToken}}
|
||||
|
||||
###
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.iocoder.mall.managementweb.controller.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemAccessLogPageDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemAccessLogVO;
|
||||
import cn.iocoder.mall.managementweb.manager.systemlog.SystemAccessLogManager;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 系统访问日志 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system-access-log")
|
||||
@Api(tags = "系统访问日志")
|
||||
@Validated
|
||||
public class SystemAccessLogController {
|
||||
|
||||
@Autowired
|
||||
private SystemAccessLogManager systemAccessLogManager;
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得系统访问日志分页")
|
||||
public CommonResult<PageResult<SystemAccessLogVO>> pageSystemAccessLog(SystemAccessLogPageDTO pageDTO) {
|
||||
return success(systemAccessLogManager.pageSystemAccessLog(pageDTO));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.iocoder.mall.managementweb.controller.systemlog.dto;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel("系统访问日志分页 DTO")
|
||||
@Data
|
||||
public class SystemAccessLogPageDTO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "用户编号")
|
||||
private Integer userId;
|
||||
@ApiModelProperty(value = "用户类型")
|
||||
private Integer userType;
|
||||
@ApiModelProperty(value = "应用名", required = true)
|
||||
private String applicationName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.iocoder.mall.managementweb.controller.systemlog.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.*;
|
||||
|
||||
@ApiModel("系统访问日志 VO")
|
||||
@Data
|
||||
public class SystemAccessLogVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true)
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "用户编号", example = "1024")
|
||||
private Integer userId;
|
||||
@ApiModelProperty(value = "用户类型", example = "1")
|
||||
private Integer userType;
|
||||
@ApiModelProperty(value = "链路追踪编号", example = "89aca178-a370-411c-ae02-3f0d672be4ab")
|
||||
private String traceId;
|
||||
@ApiModelProperty(value = "应用名", required = true, example = "user-shop-application")
|
||||
private String applicationName;
|
||||
@ApiModelProperty(value = "访问地址", required = true, example = "/management-api/system-access-log/page")
|
||||
private String uri;
|
||||
@ApiModelProperty(value = "参数", required = true, example = "pageNo=1&pageSize=10")
|
||||
private String queryString;
|
||||
@ApiModelProperty(value = "http 方法", required = true, example = "GET")
|
||||
private String method;
|
||||
@ApiModelProperty(value = "userAgent", required = true, example = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
|
||||
private String userAgent;
|
||||
@ApiModelProperty(value = "ip", required = true, example = "127.0.0.1")
|
||||
private String ip;
|
||||
@ApiModelProperty(value = "请求时间", required = true)
|
||||
private Date startTime;
|
||||
@ApiModelProperty(value = "响应时长 -- 毫秒级", required = true, example = "1024")
|
||||
private Integer responseTime;
|
||||
@ApiModelProperty(value = "错误码", required = true, example = "0")
|
||||
private Integer errorCode;
|
||||
@ApiModelProperty(value = "错误提示", example = "你的昵称过长~")
|
||||
private String errorMessage;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.iocoder.mall.managementweb.convert.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemAccessLogVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogPageDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface SystemAccessLogConvert {
|
||||
|
||||
SystemAccessLogConvert INSTANCE = Mappers.getMapper(SystemAccessLogConvert.class);
|
||||
|
||||
SystemAccessLogPageDTO convert(cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemAccessLogPageDTO bean);
|
||||
|
||||
PageResult<SystemAccessLogVO> convertPage(PageResult<cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO> page);
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class DataDictManager {
|
||||
|
||||
private static final Comparator<cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO> COMPARATOR_ENUM_VALUE_SORT = (o1, o2) -> {
|
||||
int cmp = o1.getEnumValue().compareTo(o2.getEnumValue());
|
||||
if (cmp == 0) {
|
||||
if (cmp != 0) {
|
||||
return cmp;
|
||||
}
|
||||
return o1.getSort().compareTo(o2.getSort());
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.iocoder.mall.managementweb.manager.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemAccessLogPageDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemAccessLogVO;
|
||||
import cn.iocoder.mall.managementweb.convert.systemlog.SystemAccessLogConvert;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.SystemAccessLogRpc;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 系统访问日志 Manager
|
||||
*/
|
||||
@Service
|
||||
public class SystemAccessLogManager {
|
||||
|
||||
@Reference(version = "${dubbo.consumer.SystemAccessLogRpc.version}", validation = "false")
|
||||
private SystemAccessLogRpc systemAccessLogRpc;
|
||||
|
||||
/**
|
||||
* 获得系统访问日志分页
|
||||
*
|
||||
* @param pageDTO 系统访问日志分页查询
|
||||
* @return 系统访问日志分页结果
|
||||
*/
|
||||
public PageResult<SystemAccessLogVO> pageSystemAccessLog(SystemAccessLogPageDTO pageDTO) {
|
||||
CommonResult<PageResult<cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO>> pageSystemAccessLogResult =
|
||||
systemAccessLogRpc.pageSystemAccessLog(SystemAccessLogConvert.INSTANCE.convert(pageDTO));
|
||||
pageSystemAccessLogResult.checkError();
|
||||
return SystemAccessLogConvert.INSTANCE.convertPage(pageSystemAccessLogResult.getData());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user