parent
4312cd627e
commit
c80c2b572a
@ -0,0 +1,82 @@
|
||||
package com.ruoyi.web.controller.manager;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.ShiroUtils;
|
||||
import com.ruoyi.system.domain.record.SysUserAfter;
|
||||
import com.ruoyi.system.domain.record.SysUserBefore;
|
||||
import com.ruoyi.system.domain.record.dto.UserRecordDTO;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.system.service.record.SysUserAfterService;
|
||||
import com.ruoyi.system.service.record.SysUserBeforeService;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* packageName com.ruoyi.web.controller.manager
|
||||
*
|
||||
* @author wangxy
|
||||
* @version JDK 8
|
||||
* @className UserRecordManager
|
||||
* @date 2024/8/21
|
||||
* @description 用户变更记录
|
||||
*/
|
||||
@Component
|
||||
public class UserRecordManager {
|
||||
|
||||
@Resource
|
||||
private SysUserBeforeService userBeforeService;
|
||||
|
||||
|
||||
@Resource
|
||||
private SysUserAfterService userAfterService;
|
||||
|
||||
|
||||
@Resource
|
||||
private ISysUserService userService;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 人员修改记录
|
||||
* @param user
|
||||
* @return boolean
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean saveOrUpdate(SysUser user) {
|
||||
if(Objects.isNull(user)){
|
||||
throw new ServiceException("人员信息不能为空");
|
||||
}
|
||||
SysUser sysUser = userService.selectUserById(user.getUserId());
|
||||
SysUserBefore userBefore = Convert.convert(SysUserBefore.class, sysUser);
|
||||
userBefore.setCreateTime(new Date());
|
||||
userBefore.setCreateBy(ShiroUtils.getSysUser().getLoginName());
|
||||
userBeforeService.save(userBefore);
|
||||
SysUserAfter userAfter = Convert.convert(SysUserAfter.class, user);
|
||||
userAfter.setCreateTime(new Date());
|
||||
userAfter.setCreateBy(ShiroUtils.getSysUser().getLoginName());
|
||||
return userAfterService.save(userAfter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public UserRecordDTO getUserRecordDTO( Long userId) {
|
||||
UserRecordDTO userRecordDTO = new UserRecordDTO();
|
||||
List<SysUserAfter> userAfters = userAfterService.lambdaQuery()
|
||||
.eq(SysUserAfter::getUserId, userId)
|
||||
.orderByDesc(SysUserAfter::getCreateTime).list();
|
||||
userRecordDTO.setUserAfterList(userAfters);
|
||||
List<SysUserBefore> userBefores = userBeforeService.lambdaQuery().eq(SysUserBefore::getUserId, userId)
|
||||
.orderByDesc(SysUserBefore::getCreateTime).list();
|
||||
userRecordDTO.setUserBeforeList(userBefores);
|
||||
return userRecordDTO;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.ruoyi.system.domain.record.dto;
|
||||
|
||||
import com.ruoyi.system.domain.record.SysUserAfter;
|
||||
import com.ruoyi.system.domain.record.SysUserBefore;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* packageName com.ruoyi.system.domain.record.dto
|
||||
*
|
||||
* @author wangxy
|
||||
* @version JDK 8
|
||||
* @className UserRecordDTO
|
||||
* @date 2024/8/21
|
||||
* @description 人员记录信息
|
||||
*/
|
||||
@Data
|
||||
public class UserRecordDTO {
|
||||
|
||||
@ApiModelProperty(value = "变更前人员信息")
|
||||
private List<SysUserBefore> userBeforeList;
|
||||
|
||||
@ApiModelProperty(value = "变更后人员信息")
|
||||
private List<SysUserAfter> userAfterList;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.ruoyi.system.mapper.record;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.system.domain.record.SysUserAfter;
|
||||
|
||||
/**
|
||||
* @author 13560
|
||||
* @description 针对表【sys_user_after(用户变更后信息表)】的数据库操作Mapper
|
||||
* @createDate 2024-08-21 11:06:44
|
||||
* @Entity generator.domain.SysUserAfter
|
||||
*/
|
||||
public interface SysUserAfterMapper extends BaseMapper<SysUserAfter> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.ruoyi.system.mapper.record;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.system.domain.record.SysUserBefore;
|
||||
|
||||
/**
|
||||
* @author 13560
|
||||
* @description 针对表【sys_user_before(用户变更前信息表)】的数据库操作Mapper
|
||||
* @createDate 2024-08-21 11:06:44
|
||||
* @Entity generator.domain.SysUserBefore
|
||||
*/
|
||||
public interface SysUserBeforeMapper extends BaseMapper<SysUserBefore> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.ruoyi.system.service.record;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.system.domain.record.SysUserAfter;
|
||||
|
||||
/**
|
||||
* @author 13560
|
||||
* @description 针对表【sys_user_after(用户变更后信息表)】的数据库操作Service
|
||||
* @createDate 2024-08-21 11:06:44
|
||||
*/
|
||||
public interface SysUserAfterService extends IService<SysUserAfter> {
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.ruoyi.system.service.record;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.system.domain.record.SysUserBefore;
|
||||
|
||||
/**
|
||||
* @author 13560
|
||||
* @description 针对表【sys_user_before(用户变更前信息表)】的数据库操作Service
|
||||
* @createDate 2024-08-21 11:06:44
|
||||
*/
|
||||
public interface SysUserBeforeService extends IService<SysUserBefore> {
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.ruoyi.system.service.record.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.system.domain.record.SysUserAfter;
|
||||
import com.ruoyi.system.mapper.record.SysUserAfterMapper;
|
||||
import com.ruoyi.system.service.record.SysUserAfterService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 13560
|
||||
* @description 针对表【sys_user_after(用户变更后信息表)】的数据库操作Service实现
|
||||
* @createDate 2024-08-21 11:06:44
|
||||
*/
|
||||
@Service
|
||||
public class SysUserAfterServiceImpl extends ServiceImpl<SysUserAfterMapper, SysUserAfter>
|
||||
implements SysUserAfterService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.ruoyi.system.service.record.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.system.domain.record.SysUserBefore;
|
||||
import com.ruoyi.system.mapper.record.SysUserBeforeMapper;
|
||||
import com.ruoyi.system.service.record.SysUserBeforeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 13560
|
||||
* @description 针对表【sys_user_before(用户变更前信息表)】的数据库操作Service实现
|
||||
* @createDate 2024-08-21 11:06:44
|
||||
*/
|
||||
@Service
|
||||
public class SysUserBeforeServiceImpl extends ServiceImpl<SysUserBeforeMapper, SysUserBefore>
|
||||
implements SysUserBeforeService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
<?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.ruoyi.system.mapper.record.SysUserAfterMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.ruoyi.system.domain.record.SysUserAfter">
|
||||
<id property="afterId" column="after_id" jdbcType="VARCHAR"/>
|
||||
<result property="userName" column="user_name" jdbcType="VARCHAR"/>
|
||||
<result property="phonenumber" column="phonenumber" jdbcType="VARCHAR"/>
|
||||
<result property="sex" column="sex" jdbcType="CHAR"/>
|
||||
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="userarea" column="userarea" jdbcType="VARCHAR"/>
|
||||
<result property="politics" column="politics" jdbcType="VARCHAR"/>
|
||||
<result property="shemichengdu" column="shemichengdu" jdbcType="VARCHAR"/>
|
||||
<result property="havePassport" column="have_passport" jdbcType="VARCHAR"/>
|
||||
<result property="entryexitFiling" column="entryexit_filing" jdbcType="VARCHAR"/>
|
||||
<result property="cerno" column="cerno" jdbcType="VARCHAR"/>
|
||||
<result property="userId" column="user_id" jdbcType="BIGINT"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
after_id,user_name,phonenumber,
|
||||
sex,create_by,create_time,
|
||||
userarea,politics,shemichengdu,
|
||||
have_passport,entryexit_filing,cerno,
|
||||
user_id
|
||||
</sql>
|
||||
</mapper>
|
@ -0,0 +1,30 @@
|
||||
<?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.ruoyi.system.mapper.record.SysUserBeforeMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.ruoyi.system.domain.record.SysUserBefore">
|
||||
<id property="beforeId" column="before_id" jdbcType="VARCHAR"/>
|
||||
<result property="userName" column="user_name" jdbcType="VARCHAR"/>
|
||||
<result property="phonenumber" column="phonenumber" jdbcType="VARCHAR"/>
|
||||
<result property="sex" column="sex" jdbcType="CHAR"/>
|
||||
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="userarea" column="userarea" jdbcType="VARCHAR"/>
|
||||
<result property="politics" column="politics" jdbcType="VARCHAR"/>
|
||||
<result property="shemichengdu" column="shemichengdu" jdbcType="VARCHAR"/>
|
||||
<result property="havePassport" column="have_passport" jdbcType="VARCHAR"/>
|
||||
<result property="entryexitFiling" column="entryexit_filing" jdbcType="VARCHAR"/>
|
||||
<result property="cerno" column="cerno" jdbcType="VARCHAR"/>
|
||||
<result property="userId" column="user_id" jdbcType="BIGINT"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
before_id,user_name,phonenumber,
|
||||
sex,create_by,create_time,
|
||||
userarea,politics,shemichengdu,
|
||||
have_passport,entryexit_filing,cerno,
|
||||
user_id
|
||||
</sql>
|
||||
</mapper>
|
Loading…
Reference in new issue