最经添加人

This commit is contained in:
lijiaqi 2022-08-15 13:37:49 +08:00
parent 676fc1eba8
commit 568e0da097
8 changed files with 225 additions and 2 deletions

View File

@ -0,0 +1,58 @@
package com.ydool.boot.api.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
import com.github.xiaoymin.knife4j.annotations.DynamicResponseParameters;
import com.ydool.boot.common.result.Ret;
import com.ydool.boot.modules.rddb.entity.AddUserLog;
import com.ydool.boot.modules.rddb.entity.AuditUser;
import com.ydool.boot.modules.rddb.service.AddUserLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
@RequestMapping("/api/addUser")
@Api(value = "最近添加人", tags = "最近添加人")
public class ApiAddUserLogController extends ApiBaseController {
@Autowired
private AddUserLogService addUserLogService;
@ApiOperation("最近添加人列表")
@GetMapping("")
@ResponseBody
@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "类型zjspr最近审批人", required = true),
})
@DynamicResponseParameters(properties = {
@DynamicParameter(name = "data", value = "最近添加人", dataTypeClass = AddUserLog.class)
})
public void addUserList(String type) {
//当前用户ID
String userId = getApiUserId();
List<AddUserLog> addUserLogList = addUserLogService.list(new LambdaQueryWrapper<AddUserLog>().eq(AddUserLog::getType, type).eq(AddUserLog::getCreatedId, userId));
render(Ret.ok().data(addUserLogList));
}
@ApiOperation("最近添加人保存")
@GetMapping("/save")
@ResponseBody
@ApiImplicitParams({
@ApiImplicitParam(name = "addUserIds", value = "最近添加人ID多个以英文逗号间隔", required = true),
@ApiImplicitParam(name = "addUserNames", value = "最近添加人姓名,多个以英文逗号间隔", required = true),
@ApiImplicitParam(name = "type", value = "类型zjspr最近审批人", required = true),
})
public void insertAddUser(String addUserIds, String addUserNames, String type) {
String userId = getApiUserId();
boolean flag = addUserLogService.saveOrUpdate(addUserIds, addUserNames, type, userId);
render(!flag ? Ret.fail("操作失败") : Ret.ok());
}
}

View File

@ -0,0 +1,58 @@
package com.ydool.boot.modules.rddb.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ydool.boot.core.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
/**
* <p>
* 最近添加人
* </p>
*
* @author zhouyuan
* @since 2022-08-15
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("t_add_user_log")
@ApiModel(value = "最近添加人")
public class AddUserLog extends BaseEntity{
private static final long serialVersionUID = 1L;
/**
* 创建者
*/
private String createdId;
/**
* 更新者
*/
private String updatedId;
/**
* 最经添加人id
*/
@ApiModelProperty(value = "最经添加人id")
@NotBlank(message = "最经添加人id不能为空")
private String addUserId;
/**
* 最近添加人姓名
*/
@ApiModelProperty(value = "最近添加人姓名")
@NotBlank(message = "最近添加人姓名不能为空")
private String addUserName;
/**
* 类型zjspr最近审批人
*/
@ApiModelProperty(value = "类型zjspr最近审批人")
@NotBlank(message = "类型不能为空")
private String type;
}

View File

@ -20,7 +20,7 @@ public class MyGenerator {
public static void main(String[] args) {
//表名
String tableName = "t_rd_notice_attachment";
String tableName = "t_add_user_log";
//表前缀
String tablePrefix = "t_";
@ -47,7 +47,7 @@ public class MyGenerator {
dsc.setUrl("jdbc:mysql://127.0.0.1:3306/ydool_rd?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8");
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
dsc.setUsername("root");
dsc.setPassword("123456");
dsc.setPassword("Wang09211108");
dsc.setDbType(DbType.MYSQL);
mpg.setDataSource(dsc);

View File

@ -0,0 +1,16 @@
package com.ydool.boot.modules.rddb.mapper;
import com.ydool.boot.modules.rddb.entity.AddUserLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 最近添加人 Mapper 接口
* </p>
*
* @author zhouyuan
* @since 2022-08-15
*/
public interface AddUserLogMapper extends BaseMapper<AddUserLog> {
}

View File

@ -0,0 +1,5 @@
<?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="com.ydool.boot.modules.rddb.mapper.AddUserLogMapper">
</mapper>

View File

@ -0,0 +1,49 @@
package com.ydool.boot.modules.rddb.service;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ydool.boot.modules.rddb.entity.AddUserLog;
import com.ydool.boot.modules.rddb.mapper.AddUserLogMapper;
import com.ydool.boot.modules.rddb.service.inter.IAddUserLogService;
import com.ydool.boot.core.service.BaseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 最近添加人 服务实现类
* </p>
*
* @author zhouyuan
* @since 2022-08-15
*/
@Service
public class AddUserLogService extends BaseService<AddUserLogMapper, AddUserLog> {
@Transactional
public boolean saveOrUpdate(String addUserIds, String addUserNames, String type, String userId) {
boolean flag;
List<AddUserLog> addUserLogList = new ArrayList<>();
remove(new LambdaQueryWrapper<AddUserLog>().eq(AddUserLog::getCreatedId, userId));
String[] addUserIdArr = addUserIds.split(",");
String[] addUserNameArr = addUserNames.split(",");
for (int i = 0; i < addUserNameArr.length; i++) {
AddUserLog addUserLog = new AddUserLog();
addUserLog.setAddUserId(addUserIdArr[i]);
addUserLog.setAddUserName(addUserNameArr[i]);
addUserLog.setCreatedId(userId);
addUserLog.setType(type);
addUserLog.setUpdatedId(userId);
addUserLog.setCreatedAt(LocalDateTime.now());
addUserLog.setUpdatedAt(LocalDateTime.now());
addUserLogList.add(addUserLog);
}
flag = this.saveBatch(addUserLogList);
return flag;
}
}

View File

@ -0,0 +1,16 @@
package com.ydool.boot.modules.rddb.service.inter;
import com.ydool.boot.modules.rddb.entity.AddUserLog;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 最近添加人 服务类
* </p>
*
* @author zhouyuan
* @since 2022-08-15
*/
public interface IAddUserLogService extends IService<AddUserLog> {
}

View File

@ -0,0 +1,21 @@
package com.ydool.boot.modules.rddb.web;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import com.ydool.boot.core.web.BaseController;
/**
* <p>
* 最近添加人 前端控制器
* </p>
*
* @author zhouyuan
* @since 2022-08-15
*/
@Controller
@RequestMapping("${ydool.path}/rddb/addUserLog")
public class AddUserLogController extends BaseController {
}