Browse Source

农场日志信息

zyh
小久哥 3 years ago
parent
commit
ca489012f5
  1. 6
      yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java
  2. 21
      yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java
  3. 16
      zsw-farm/zsw-farm-api/pom.xml
  4. 5
      zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java
  5. 17
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsg.java
  6. 76
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgAspect.java
  7. 112
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/LogMsgController.java
  8. 15
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/dto/LogMsgDTO.java
  9. 24
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/vo/LogMsgBaseVO.java
  10. 14
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/vo/LogMsgCreateReqVO.java
  11. 32
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/vo/LogMsgExcelVO.java
  12. 32
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/vo/LogMsgExportReqVO.java
  13. 34
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/vo/LogMsgPageReqVO.java
  14. 19
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/vo/LogMsgRespVO.java
  15. 18
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/vo/LogMsgUpdateReqVO.java
  16. 4
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java
  17. 4
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java
  18. 34
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/convert/logMsg/LogMsgConvert.java
  19. 40
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/logMsg/LogMsgDO.java
  20. 38
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/logMsg/LogMsgMapper.java
  21. 79
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/logMsg/LogMsgService.java
  22. 137
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/logMsg/LogMsgServiceImpl.java
  23. 12
      zsw-farm/zsw-farm-impl/src/main/resources/mapper/logMsg/LogMsgMapper.xml

6
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java

@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfi
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import javax.validation.Valid;
@ -200,4 +201,9 @@ public interface AdminUserService {
*/
List<AdminUserDO> getUsersByStatus(Integer status);
/**
* 根据系统用户id获取cpUser用户
**/
List<CpUserDO> getCpUserByAdminUser(List<Long> adminUserIdList);
}

21
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.service.user;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
@ -12,13 +13,16 @@ import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfi
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.*;
import cn.iocoder.yudao.module.system.convert.user.UserConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.CpUser.CpUserMapper;
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
import cn.iocoder.yudao.module.system.service.dept.DeptService;
import cn.iocoder.yudao.module.system.service.dept.PostService;
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
import cn.iocoder.yudao.module.system.service.tenant.TenantService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.annotations.VisibleForTesting;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
@ -29,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
@ -61,6 +66,8 @@ public class AdminUserServiceImpl implements AdminUserService {
@Resource
private FileApi fileApi;
@Resource
private CpUserMapper cpUserMapper;
@Override
@ -398,4 +405,18 @@ public class AdminUserServiceImpl implements AdminUserService {
return adminUserMapper.selectListByStatus(status);
}
public List<CpUserDO> getCpUserByAdminUser(List<Long> adminUserIdList){
List<AdminUserDO> adminUserList = adminUserMapper.selectList(Wrappers.<AdminUserDO>lambdaQuery().in(AdminUserDO::getId, adminUserIdList));
if (ObjectUtil.isEmpty(adminUserList)){
return new ArrayList<>();
}
List<String> usernameList = adminUserList.stream().map(AdminUserDO::getUsername).collect(Collectors.toList());
List<CpUserDO> cpUserList = cpUserMapper.selectList(Wrappers.<CpUserDO>lambdaQuery().in(CpUserDO::getUserId, usernameList));
if (ObjectUtil.isEmpty(cpUserList)){
return new ArrayList<>();
}
return cpUserList;
}
}

16
zsw-farm/zsw-farm-api/pom.xml

@ -27,6 +27,22 @@
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-mybatis</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.5</version>
</dependency>
</dependencies>

5
zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java

@ -24,7 +24,10 @@ public interface ErrorCodeConstants{
ErrorCode CROP_RECORD_NOT_EXISTS = new ErrorCode(1000007009, "农场作物出入记录不存在");
ErrorCode WORK_HOUR_NOT_EXISTS = new ErrorCode(1000007010, "工时不存在");
ErrorCode TASK_CATE_NOT_EXISTS = new ErrorCode(1000007010, "任务类型不存在");
ErrorCode TASK_CATE_NOT_EXISTS = new ErrorCode(1000007011, "任务类型不存在");
ErrorCode LOG_MSG_NOT_EXISTS = new ErrorCode(1000007012, "农场日志信息不存在");
}

17
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsg.java

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.farm.annotation;
import java.lang.annotation.*;
/**
* @Created by jiu on 2022/6/13.
*/
@Target({ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface FarmMsg {
String type() default "";
String title() default "";
}

76
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgAspect.java

@ -0,0 +1,76 @@
package cn.iocoder.yudao.module.farm.annotation;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.farm.dal.dataobject.logMsg.LogMsgDO;
import cn.iocoder.yudao.module.farm.dal.mysql.logMsg.LogMsgMapper;
import cn.iocoder.yudao.module.farm.service.logMsg.LogMsgService;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
/**
* @Created by jiu on 2022/6/13.
*/
@Aspect
@Component
@Slf4j
public class FarmMsgAspect {
@Resource
private LogMsgMapper logMsgMapper;
/**
* 定义切入点 @PointCut
* 使用了@FarmMsg注解的地方切入
*
**/
@Pointcut("@annotation(cn.iocoder.yudao.module.farm.annotation.FarmMsg)")
public void farmMsgPointCut(){
}
/**
* 拦截用户操作日志, 连接点执行完成后记录 如果连接点异常,则不会执行
* @param jointPoint 切入点
* @param result 返回结果
**/
@AfterReturning(value = "farmMsgPointCut()", returning = "result")
public void saveFarmMsg(JoinPoint jointPoint, Object result){
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
HttpServletRequest request = (HttpServletRequest) requestAttributes.resolveReference(RequestAttributes.REFERENCE_REQUEST);
//从切入点通过反射获取切入点方法
MethodSignature signature = (MethodSignature) jointPoint.getSignature();
//获取切入点的方法
Method method = signature.getMethod();
//获取操作的type, title
FarmMsg farmMsg = method.getAnnotation(FarmMsg.class);
//插入农场日志信息
LogMsgDO msg = LogMsgDO.builder()
.type(farmMsg.type())
.title(farmMsg.title())
.userId(getLoginUserId())
.build();
logMsgMapper.insert(msg);
}
}

112
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/LogMsgController.java

@ -0,0 +1,112 @@
package cn.iocoder.yudao.module.farm.controller.admin.logMsg;
import cn.iocoder.yudao.framework.common.page.PageDTO;
import cn.iocoder.yudao.framework.common.page.PageVO;
import cn.iocoder.yudao.module.farm.controller.admin.logMsg.dto.LogMsgDTO;
import cn.iocoder.yudao.module.farm.controller.admin.statistical.dto.WorkStaticDTO;
import cn.iocoder.yudao.module.farm.controller.admin.workHour.dto.WorkTotalDTO;
import com.zsw.base.R;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.farm.controller.admin.logMsg.vo.*;
import cn.iocoder.yudao.module.farm.dal.dataobject.logMsg.LogMsgDO;
import cn.iocoder.yudao.module.farm.convert.logMsg.LogMsgConvert;
import cn.iocoder.yudao.module.farm.service.logMsg.LogMsgService;
@Api(tags = "管理后台 - 农场日志信息")
@RestController
@RequestMapping("/farm/log-msg")
@Validated
public class LogMsgController {
@Resource
private LogMsgService logMsgService;
@PostMapping("/create")
@ApiOperation("创建")
@PreAuthorize("@ss.hasPermission('farm:log-msg:create')")
public CommonResult<Long> createLogMsg(@Valid @RequestBody LogMsgCreateReqVO createReqVO) {
return success(logMsgService.createLogMsg(createReqVO));
}
@PutMapping("/update")
@ApiOperation("更新")
@PreAuthorize("@ss.hasPermission('farm:log-msg:update')")
public CommonResult<Boolean> updateLogMsg(@Valid @RequestBody LogMsgUpdateReqVO updateReqVO) {
logMsgService.updateLogMsg(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@ApiOperation("删除")
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('farm:log-msg:delete')")
public CommonResult<Boolean> deleteLogMsg(@RequestParam("id") Long id) {
logMsgService.deleteLogMsg(id);
return success(true);
}
@GetMapping("/get")
@ApiOperation("获得")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('farm:log-msg:query')")
public CommonResult<LogMsgRespVO> getLogMsg(@RequestParam("id") Long id) {
LogMsgDO logMsg = logMsgService.getLogMsg(id);
return success(LogMsgConvert.INSTANCE.convert(logMsg));
}
@GetMapping("/list")
@ApiOperation("获得列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
@PreAuthorize("@ss.hasPermission('farm:log-msg:query')")
public CommonResult<List<LogMsgRespVO>> getLogMsgList(@RequestParam("ids") Collection<Long> ids) {
List<LogMsgDO> list = logMsgService.getLogMsgList(ids);
return success(LogMsgConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@ApiOperation("获得分页")
@PreAuthorize("@ss.hasPermission('farm:log-msg:query')")
public CommonResult<PageResult<LogMsgRespVO>> getLogMsgPage(@Valid LogMsgPageReqVO pageVO) {
PageResult<LogMsgDO> pageResult = logMsgService.getLogMsgPage(pageVO);
return success(LogMsgConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@ApiOperation("导出 Excel")
@PreAuthorize("@ss.hasPermission('farm:log-msg:export')")
@OperateLog(type = EXPORT)
public void exportLogMsgExcel(@Valid LogMsgExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<LogMsgDO> list = logMsgService.getLogMsgList(exportReqVO);
// 导出 Excel
List<LogMsgExcelVO> datas = LogMsgConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, ".xls", "数据", LogMsgExcelVO.class, datas);
}
@PostMapping("/logMsgList")
@ApiOperation("农场日志信息")
public R<PageVO<LogMsgDTO>> logMsgList(@RequestBody PageDTO pageDTO){
return logMsgService.logMsgList(pageDTO);
}
}

15
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/dto/LogMsgDTO.java

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.farm.controller.admin.logMsg.dto;
import cn.iocoder.yudao.module.farm.dal.dataobject.logMsg.LogMsgDO;
import lombok.Data;
/**
* @Created by jiu on 2022/6/14.
*/
@Data
public class LogMsgDTO extends LogMsgDO {
private String userName;
private String userIcon;
}

24
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/vo/LogMsgBaseVO.java

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.farm.controller.admin.logMsg.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
/**
* Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data
public class LogMsgBaseVO {
@ApiModelProperty(value = "类型")
private String type;
@ApiModelProperty(value = "标题")
private String title;
@ApiModelProperty(value = "用户id")
private Long userId;
}

14
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/vo/LogMsgCreateReqVO.java

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.farm.controller.admin.logMsg.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
@ApiModel("管理后台 - 创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class LogMsgCreateReqVO extends LogMsgBaseVO {
}

32
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/vo/LogMsgExcelVO.java

@ -0,0 +1,32 @@
package cn.iocoder.yudao.module.farm.controller.admin.logMsg.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import com.alibaba.excel.annotation.ExcelProperty;
/**
* Excel VO
*
* @author 尚筱璇
*/
@Data
public class LogMsgExcelVO {
@ExcelProperty("")
private Long id;
@ExcelProperty("类型")
private String type;
@ExcelProperty("标题")
private String title;
@ExcelProperty("用户id")
private Long userId;
@ExcelProperty("创建时间")
private Date createTime;
}

32
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/vo/LogMsgExportReqVO.java

@ -0,0 +1,32 @@
package cn.iocoder.yudao.module.farm.controller.admin.logMsg.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel(value = "管理后台 - Excel 导出 Request VO", description = "参数和 LogMsgPageReqVO 是一致的")
@Data
public class LogMsgExportReqVO {
@ApiModelProperty(value = "类型")
private String type;
@ApiModelProperty(value = "标题")
private String title;
@ApiModelProperty(value = "用户id")
private Long userId;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
}

34
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/vo/LogMsgPageReqVO.java

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.farm.controller.admin.logMsg.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel("管理后台 - 分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class LogMsgPageReqVO extends PageParam {
@ApiModelProperty(value = "类型")
private String type;
@ApiModelProperty(value = "标题")
private String title;
@ApiModelProperty(value = "用户id")
private Long userId;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
}

19
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/vo/LogMsgRespVO.java

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.farm.controller.admin.logMsg.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
@ApiModel("管理后台 - Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class LogMsgRespVO extends LogMsgBaseVO {
@ApiModelProperty(value = "", required = true)
private Long id;
@ApiModelProperty(value = "创建时间", required = true)
private Date createTime;
}

18
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/logMsg/vo/LogMsgUpdateReqVO.java

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.farm.controller.admin.logMsg.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
@ApiModel("管理后台 - 更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class LogMsgUpdateReqVO extends LogMsgBaseVO {
@ApiModelProperty(value = "", required = true)
@NotNull(message = "不能为空")
private Long id;
}

4
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.farm.controller.admin.project;
import cn.iocoder.yudao.framework.common.page.PageVO;
import cn.iocoder.yudao.module.farm.annotation.FarmMsg;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectListDTO;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO;
import com.zsw.base.R;
@ -38,6 +39,7 @@ public class ProjectController {
@Resource
private ProjectService projectService;
@FarmMsg(type = "项目", title = "创建项目")
@PostMapping("/create")
@ApiOperation("创建农场项目")
@PreAuthorize("@ss.hasPermission('farm:project:create')")
@ -45,6 +47,7 @@ public class ProjectController {
return success(projectService.createProject(createReqVO));
}
@FarmMsg(type = "项目", title = "更新项目")
@PutMapping("/update")
@ApiOperation("更新农场项目")
@PreAuthorize("@ss.hasPermission('farm:project:update')")
@ -62,6 +65,7 @@ public class ProjectController {
return success(true);
}
@FarmMsg(type = "项目", title = "查看项目#{id}")
@GetMapping("/get")
@ApiOperation("获得农场项目")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)

4
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.farm.controller.admin.task;
import cn.iocoder.yudao.module.farm.annotation.FarmMsg;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@ -35,6 +36,7 @@ public class TaskController {
@Resource
private TaskService taskService;
@FarmMsg(type = "任务", title = "创建任务")
@PostMapping("/create")
@ApiOperation("创建农场项目")
@PreAuthorize("@ss.hasPermission('farm:task:create')")
@ -42,6 +44,7 @@ public class TaskController {
return success(taskService.createTask(createReqVO));
}
@FarmMsg(type = "任务", title = "更新任务")
@PutMapping("/update")
@ApiOperation("更新农场项目")
@PreAuthorize("@ss.hasPermission('farm:task:update')")
@ -59,6 +62,7 @@ public class TaskController {
return success(true);
}
@FarmMsg(type = "任务", title = "查看任务")
@GetMapping("/get")
@ApiOperation("获得农场项目")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)

34
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/convert/logMsg/LogMsgConvert.java

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.farm.convert.logMsg;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.farm.controller.admin.logMsg.vo.*;
import cn.iocoder.yudao.module.farm.dal.dataobject.logMsg.LogMsgDO;
/**
* Convert
*
* @author 尚筱璇
*/
@Mapper
public interface LogMsgConvert {
LogMsgConvert INSTANCE = Mappers.getMapper(LogMsgConvert.class);
LogMsgDO convert(LogMsgCreateReqVO bean);
LogMsgDO convert(LogMsgUpdateReqVO bean);
LogMsgRespVO convert(LogMsgDO bean);
List<LogMsgRespVO> convertList(List<LogMsgDO> list);
PageResult<LogMsgRespVO> convertPage(PageResult<LogMsgDO> page);
List<LogMsgExcelVO> convertList02(List<LogMsgDO> list);
}

40
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/logMsg/LogMsgDO.java

@ -0,0 +1,40 @@
package cn.iocoder.yudao.module.farm.dal.dataobject.logMsg;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* DO
*
* @author 尚筱璇
*/
@TableName("farm_log_msg")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class LogMsgDO extends BaseDO {
/**
*
*/
@TableId
private Long id;
/**
* 类型
*/
private String type;
/**
* 标题
*/
private String title;
/**
* 用户id
*/
private Long userId;
}

38
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/logMsg/LogMsgMapper.java

@ -0,0 +1,38 @@
package cn.iocoder.yudao.module.farm.dal.mysql.logMsg;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.farm.dal.dataobject.logMsg.LogMsgDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.farm.controller.admin.logMsg.vo.*;
/**
* Mapper
*
* @author 尚筱璇
*/
@Mapper
public interface LogMsgMapper extends BaseMapperX<LogMsgDO> {
default PageResult<LogMsgDO> selectPage(LogMsgPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<LogMsgDO>()
.eqIfPresent(LogMsgDO::getType, reqVO.getType())
.eqIfPresent(LogMsgDO::getTitle, reqVO.getTitle())
.eqIfPresent(LogMsgDO::getUserId, reqVO.getUserId())
.betweenIfPresent(LogMsgDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(LogMsgDO::getId));
}
default List<LogMsgDO> selectList(LogMsgExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<LogMsgDO>()
.eqIfPresent(LogMsgDO::getType, reqVO.getType())
.eqIfPresent(LogMsgDO::getTitle, reqVO.getTitle())
.eqIfPresent(LogMsgDO::getUserId, reqVO.getUserId())
.betweenIfPresent(LogMsgDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(LogMsgDO::getId));
}
}

79
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/logMsg/LogMsgService.java

@ -0,0 +1,79 @@
package cn.iocoder.yudao.module.farm.service.logMsg;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.framework.common.page.PageDTO;
import cn.iocoder.yudao.framework.common.page.PageVO;
import cn.iocoder.yudao.module.farm.controller.admin.logMsg.dto.LogMsgDTO;
import cn.iocoder.yudao.module.farm.controller.admin.logMsg.vo.*;
import cn.iocoder.yudao.module.farm.dal.dataobject.logMsg.LogMsgDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import com.zsw.base.R;
import org.springframework.web.bind.annotation.RequestBody;
/**
* Service 接口
*
* @author 尚筱璇
*/
public interface LogMsgService {
/**
* 创建
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createLogMsg(@Valid LogMsgCreateReqVO createReqVO);
/**
* 更新
*
* @param updateReqVO 更新信息
*/
void updateLogMsg(@Valid LogMsgUpdateReqVO updateReqVO);
/**
* 删除
*
* @param id 编号
*/
void deleteLogMsg(Long id);
/**
* 获得
*
* @param id 编号
* @return
*/
LogMsgDO getLogMsg(Long id);
/**
* 获得列表
*
* @param ids 编号
* @return 列表
*/
List<LogMsgDO> getLogMsgList(Collection<Long> ids);
/**
* 获得分页
*
* @param pageReqVO 分页查询
* @return 分页
*/
PageResult<LogMsgDO> getLogMsgPage(LogMsgPageReqVO pageReqVO);
/**
* 获得列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 列表
*/
List<LogMsgDO> getLogMsgList(LogMsgExportReqVO exportReqVO);
R<PageVO<LogMsgDTO>> logMsgList(PageDTO pageDTO);
}

137
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/logMsg/LogMsgServiceImpl.java

@ -0,0 +1,137 @@
package cn.iocoder.yudao.module.farm.service.logMsg;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.db.Page;
import cn.hutool.system.oshi.CpuInfo;
import cn.iocoder.yudao.framework.common.page.PageDTO;
import cn.iocoder.yudao.framework.common.page.PageUtil;
import cn.iocoder.yudao.framework.common.page.PageVO;
import cn.iocoder.yudao.module.farm.controller.admin.logMsg.dto.LogMsgDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.CpUser.CpUserMapper;
import cn.iocoder.yudao.module.system.service.CpUser.CpUserService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zsw.base.R;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import java.util.stream.Collectors;
import cn.iocoder.yudao.module.farm.controller.admin.logMsg.vo.*;
import cn.iocoder.yudao.module.farm.dal.dataobject.logMsg.LogMsgDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.farm.convert.logMsg.LogMsgConvert;
import cn.iocoder.yudao.module.farm.dal.mysql.logMsg.LogMsgMapper;
import org.springframework.web.bind.annotation.RequestBody;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*;
/**
* Service 实现类
*
* @author 尚筱璇
*/
@Service
@Validated
public class LogMsgServiceImpl implements LogMsgService {
@Resource
private LogMsgMapper logMsgMapper;
@Resource
private CpUserMapper cpUserMapper;
@Resource
private CpUserService cpUserService;
@Resource
private AdminUserService adminUserService;
@Override
public Long createLogMsg(LogMsgCreateReqVO createReqVO) {
// 插入
LogMsgDO logMsg = LogMsgConvert.INSTANCE.convert(createReqVO);
logMsgMapper.insert(logMsg);
// 返回
return logMsg.getId();
}
@Override
public void updateLogMsg(LogMsgUpdateReqVO updateReqVO) {
// 校验存在
this.validateLogMsgExists(updateReqVO.getId());
// 更新
LogMsgDO updateObj = LogMsgConvert.INSTANCE.convert(updateReqVO);
logMsgMapper.updateById(updateObj);
}
@Override
public void deleteLogMsg(Long id) {
// 校验存在
this.validateLogMsgExists(id);
// 删除
logMsgMapper.deleteById(id);
}
private void validateLogMsgExists(Long id) {
if (logMsgMapper.selectById(id) == null) {
throw exception(LOG_MSG_NOT_EXISTS);
}
}
@Override
public LogMsgDO getLogMsg(Long id) {
return logMsgMapper.selectById(id);
}
@Override
public List<LogMsgDO> getLogMsgList(Collection<Long> ids) {
return logMsgMapper.selectBatchIds(ids);
}
@Override
public PageResult<LogMsgDO> getLogMsgPage(LogMsgPageReqVO pageReqVO) {
return logMsgMapper.selectPage(pageReqVO);
}
@Override
public List<LogMsgDO> getLogMsgList(LogMsgExportReqVO exportReqVO) {
return logMsgMapper.selectList(exportReqVO);
}
public R<PageVO<LogMsgDTO>> logMsgList(PageDTO pageDTO){
PageUtil.startPage(pageDTO);
List<LogMsgDO> list = logMsgMapper.selectList();
List<LogMsgDTO> dtoList = BeanUtil.copyToList(list, LogMsgDTO.class);
List<Long> systemUserIdList = dtoList.stream().map(LogMsgDTO::getUserId).collect(Collectors.toList());
List<AdminUserDO> adminUserList = adminUserService.getUsers(systemUserIdList);
List<CpUserDO> cpUserList = adminUserService.getCpUserByAdminUser(systemUserIdList);
Map<Long, CpUserDO> map = new HashMap<>();
adminUserList.forEach(systemUser ->{
cpUserList.forEach(cpUser ->{
if (systemUser.getUsername().equals(cpUser.getUserId())){
map.put(systemUser.getId(), cpUser);
}
});
});
dtoList.forEach(msg ->{
if (map.containsKey(msg.getUserId())){
CpUserDO user = map.get(msg.getUserId());
msg.setUserName(user.getName());
msg.setUserIcon(user.getAvatar());
}
});
PageVO<LogMsgDTO> returnList = PageUtil.convertPageInfo(dtoList);
return R.success(returnList);
}
}

12
zsw-farm/zsw-farm-impl/src/main/resources/mapper/logMsg/LogMsgMapper.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.farm.dal.mysql.logMsg.LogMsgMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
Loading…
Cancel
Save