forked from YunaiV/yudao-cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of gitee.com:zhijiantianya/onemall
- Loading branch information
Showing
12 changed files
with
346 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
...rc/main/java/cn/iocoder/mall/admin/application/controller/admins/SystemLogController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package cn.iocoder.mall.admin.application.controller.admins; | ||
|
||
import cn.iocoder.common.framework.vo.CommonResult; | ||
import cn.iocoder.mall.admin.api.SystemLogService; | ||
import cn.iocoder.mall.admin.api.bo.systemlog.AccessLogPageBO; | ||
import cn.iocoder.mall.admin.api.dto.systemlog.AccessLogPageDTO; | ||
import cn.iocoder.mall.admin.application.convert.AccessLogConvert; | ||
import cn.iocoder.mall.admin.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)); | ||
|
||
} | ||
|
||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...application/src/main/java/cn/iocoder/mall/admin/application/convert/AccessLogConvert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package cn.iocoder.mall.admin.application.convert; | ||
|
||
import cn.iocoder.common.framework.vo.PageResult; | ||
import cn.iocoder.mall.admin.api.bo.admin.AdminBO; | ||
import cn.iocoder.mall.admin.api.bo.systemlog.AccessLogBO; | ||
import cn.iocoder.mall.admin.api.bo.systemlog.AccessLogPageBO; | ||
import cn.iocoder.mall.admin.application.vo.log.AccessLogPageVo; | ||
import cn.iocoder.mall.admin.application.vo.log.AccessLogVo; | ||
import cn.iocoder.mall.admin.dataobject.AccessLogDO; | ||
import cn.iocoder.mall.admin.dataobject.AdminDO; | ||
import com.baomidou.mybatisplus.core.metadata.IPage; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
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); | ||
|
||
|
||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...m-application/src/main/java/cn/iocoder/mall/admin/application/vo/log/AccessLogPageVo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package cn.iocoder.mall.admin.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; | ||
} |
58 changes: 58 additions & 0 deletions
58
...ystem-application/src/main/java/cn/iocoder/mall/admin/application/vo/log/AccessLogVo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package cn.iocoder.mall.admin.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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
.../system-service-api/src/main/java/cn/iocoder/mall/admin/api/bo/systemlog/AccessLogBO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package cn.iocoder.mall.admin.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; | ||
} |
27 changes: 27 additions & 0 deletions
27
...tem-service-api/src/main/java/cn/iocoder/mall/admin/api/bo/systemlog/AccessLogPageBO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package cn.iocoder.mall.admin.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; | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...m-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/systemlog/AccessLogPageDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package cn.iocoder.mall.admin.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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
system/system-service-impl/src/main/java/cn/iocoder/mall/admin/dao/AccessLogMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
package cn.iocoder.mall.admin.dao; | ||
|
||
import cn.iocoder.common.framework.mybatis.QueryWrapperX; | ||
import cn.iocoder.mall.admin.api.dto.admin.AdminPageDTO; | ||
import cn.iocoder.mall.admin.api.dto.systemlog.AccessLogPageDTO; | ||
import cn.iocoder.mall.admin.dataobject.AccessLogDO; | ||
import cn.iocoder.mall.admin.dataobject.AdminDO; | ||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
import com.baomidou.mybatisplus.core.metadata.IPage; | ||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface AccessLogMapper extends BaseMapper<AccessLogDO> { | ||
|
||
default IPage<AccessLogDO> selectPage(AccessLogPageDTO accessLogPageDTO) { | ||
return selectPage(new Page<>(accessLogPageDTO.getPageNo(), accessLogPageDTO.getPageSize()), | ||
new QueryWrapperX<AccessLogDO>().eqIfPresent("user_id", accessLogPageDTO.getUserId())); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.