代码提交

This commit is contained in:
luozhun 2024-09-13 15:19:16 +08:00
parent cc73564ed5
commit 366adf8e02
14 changed files with 416 additions and 2 deletions

View File

@ -1,8 +1,12 @@
package com.changhu.module.miniProgram.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.changhu.common.annotation.JsonBody;
import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams;
import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams;
import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo;
import com.changhu.module.miniProgram.service.MiniProgramUserService;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
@ -29,4 +33,10 @@ public class MiniProgramUserController {
public void register(@RequestBody @Valid MiniProgramUserRegisterParams params) {
miniProgramUserService.register(params);
}
@Operation(summary = "服务项目保安人员分页")
@PostMapping("/securityUserPager")
public Page<ServiceProjectSecurityUserPagerVo> securityUserPager(@RequestBody PageParams<ServiceProjectSecurityUserPagerQueryParams, ServiceProjectSecurityUserPagerVo> queryParams) {
return miniProgramUserService.securityUserPager(queryParams);
}
}

View File

@ -3,13 +3,14 @@ package com.changhu.module.miniProgram.controller;
import com.changhu.common.annotation.CheckUserType;
import com.changhu.common.annotation.JsonBody;
import com.changhu.common.annotation.UserType;
import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams;
import com.changhu.module.miniProgram.pojo.vo.IndexServiceProjectListVo;
import com.changhu.module.miniProgram.service.ProjectManageIndexService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -32,4 +33,16 @@ public class ProjectManageIndexController {
public List<IndexServiceProjectListVo> getMyServiceProjectList() {
return projectManageIndexService.getMyServiceProjectList();
}
@Operation(summary = "根据id删除保安人员")
@DeleteMapping("/deleteSecurityUserByServiceProjectId")
public void deleteSecurityUserById(@RequestParam @Schema(description = "保安人员id") Long securityUserId) {
projectManageIndexService.deleteSecurityUserByServiceProjectId(securityUserId);
}
@Operation(summary = "保存或更新保安人员")
@PostMapping("/saveOrUpdateSecurityUser")
public void saveOrUpdateSecurityUser(@RequestBody SaveOrUpdateSecurityUserParams params) {
projectManageIndexService.saveOrUpdateSecurityUser(params);
}
}

View File

@ -0,0 +1,27 @@
package com.changhu.module.miniProgram.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.changhu.module.miniProgram.pojo.entity.SecurityUser;
import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams;
import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* security_user (保安人员) 固化类
* author: luozhun
* desc 由groovy脚本自动生成
*/
@Mapper
public interface SecurityUserMapper extends BaseMapper<SecurityUser> {
/**
* 服务项目内的保安人员分页
*
* @param page 分页对象
* @param params 查询参数
* @return 人员
*/
Page<ServiceProjectSecurityUserPagerVo> securityUserPager(@Param("page") Page<ServiceProjectSecurityUserPagerVo> page,
@Param("params") ServiceProjectSecurityUserPagerQueryParams params);
}

View File

@ -0,0 +1,92 @@
package com.changhu.module.miniProgram.pojo.entity;
import java.io.Serial;
import java.io.Serializable;
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
import lombok.Data;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import lombok.EqualsAndHashCode;
import com.baomidou.mybatisplus.annotation.TableName;
/**
* 保安人员 实体类
* author: luozhun
* desc 由groovy脚本自动生成
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
@TableName(autoResultMap = true)
public class SecurityUser extends BaseEntity implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 所属保安单位id
*/
private Long securityUnitId;
/**
* 服务项目id
*/
private Long serviceProjectId;
/**
* 名称
*/
private String name;
/**
* 手机号
*/
private String telephone;
/**
* 工作岗位
*/
private String workPost;
/**
* 性别
*/
private Integer sex;
/**
* 籍贯
*/
private String nativePlace;
/**
* 身份证
*/
private String idCard;
/**
* 出生日期
*/
private java.time.LocalDate dateOfBirth;
/**
* 保安证号
*/
private String securityNumber;
/**
* 家庭住址
*/
private String homeAddress;
/**
* 备注
*/
private String remark;
}

View File

@ -0,0 +1,62 @@
package com.changhu.module.miniProgram.pojo.params;
import com.changhu.common.db.enums.Sex;
import com.changhu.common.validator.annotation.IdCard;
import com.changhu.common.validator.annotation.IsMobile;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
* @author 20252
* @createTime 2024/9/12 上午9:57
* @desc SaveOrUpdateSecurityUserParams...
*/
@Data
public class SaveOrUpdateSecurityUserParams {
@Schema(description = "id")
private Long snowFlakeId;
@NotNull(message = "服务项目不能为空")
@Schema(description = "服务项目id")
private Long serviceProjectId;
@NotBlank(message = "名字不能为空")
@Schema(description = "名称")
private String name;
@NotBlank(message = "手机号不能为空")
@IsMobile
@Schema(description = "手机号")
private String telephone;
@Schema(description = "工作岗位")
private String workPost;
@NotNull(message = "性别不能为空")
@Schema(description = "性别")
private Sex sex;
@Schema(description = "籍贯")
private String nativePlace;
@NotBlank(message = "身份证不能为空")
@IdCard
@Schema(description = "身份证")
private String idCard;
@Schema(description = "出生日期")
private java.time.LocalDate dateOfBirth;
@Schema(description = "保安证号")
private String securityNumber;
@Schema(description = "家庭住址")
private String homeAddress;
@Schema(description = "备注")
private String remark;
}

View File

@ -0,0 +1,15 @@
package com.changhu.module.miniProgram.pojo.queryParams;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @author 20252
* @createTime 2024/9/12 上午9:41
* @desc ServiceProjectSecurityUserPagerQueryParams...
*/
@Data
public class ServiceProjectSecurityUserPagerQueryParams {
@Schema(description = "服务项目id")
private Long serviceProjectId;
}

View File

@ -0,0 +1,60 @@
package com.changhu.module.miniProgram.pojo.vo;
import com.changhu.common.db.enums.Sex;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author 20252
* @createTime 2024/9/12 上午9:41
* @desc ServiceProjectSecurityUserPagerVo...
*/
@Data
public class ServiceProjectSecurityUserPagerVo {
@Schema(description = "id")
private Long snowFlakeId;
@Schema(description = "所属保安单位id")
private Long securityUnitId;
@Schema(description = "保安单位名字")
private String securityUnitName;
@Schema(description = "服务项目id")
private Long serviceProjectId;
@Schema(description = "名称")
private String name;
@Schema(description = "手机号")
private String telephone;
;
@Schema(description = "工作岗位")
private String workPost;
@Schema(description = "性别")
private Sex sex;
@Schema(description = "籍贯")
private String nativePlace;
@Schema(description = "身份证")
private String idCard;
@Schema(description = "出生日期")
private java.time.LocalDate dateOfBirth;
@Schema(description = "保安证号")
private String securityNumber;
@Schema(description = "家庭住址")
private String homeAddress;
@Schema(description = "备注")
private String remark;
@Schema(description = "创建时间")
private LocalDateTime createTime;
}

View File

@ -1,8 +1,12 @@
package com.changhu.module.miniProgram.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser;
import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams;
import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams;
import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
/**
* mini_program_user (小程序用户) 服务类
@ -17,4 +21,12 @@ public interface MiniProgramUserService extends IService<MiniProgramUser> {
* @param params 参数
*/
void register(MiniProgramUserRegisterParams params);
/**
* 服务项目内的保安人员分页
*
* @param queryParams 查询参数
* @return 保安人员
*/
Page<ServiceProjectSecurityUserPagerVo> securityUserPager(PageParams<ServiceProjectSecurityUserPagerQueryParams, ServiceProjectSecurityUserPagerVo> queryParams);
}

View File

@ -1,5 +1,6 @@
package com.changhu.module.miniProgram.service;
import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams;
import com.changhu.module.miniProgram.pojo.vo.IndexServiceProjectListVo;
import java.util.List;
@ -16,4 +17,18 @@ public interface ProjectManageIndexService {
* @return 服务项目列表
*/
List<IndexServiceProjectListVo> getMyServiceProjectList();
/**
* 根据id删除保安人员
*
* @param securityUserId 保安人员id
*/
void deleteSecurityUserByServiceProjectId(Long securityUserId);
/**
* 保存或更新保安人员
*
* @param params 保安人员参数
*/
void saveOrUpdateSecurityUser(SaveOrUpdateSecurityUserParams params);
}

View File

@ -0,0 +1,13 @@
package com.changhu.module.miniProgram.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.changhu.module.miniProgram.pojo.entity.SecurityUser;
/**
* security_user (保安人员) 服务类
* author: luozhun
* desc 由groovy脚本自动生成
*/
public interface SecurityUserService extends IService<SecurityUser> {
}

View File

@ -4,13 +4,19 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.changhu.common.exception.MessageException;
import com.changhu.common.utils.SnowFlakeIdUtil;
import com.changhu.module.miniProgram.mapper.MiniProgramUserMapper;
import com.changhu.module.miniProgram.mapper.SecurityUserMapper;
import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser;
import com.changhu.module.miniProgram.pojo.entity.SecurityUser;
import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams;
import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams;
import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo;
import com.changhu.module.miniProgram.service.MiniProgramUserService;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -26,6 +32,9 @@ public class MiniProgramUserServiceImpl extends ServiceImpl<MiniProgramUserMappe
@Autowired
private WxMaService wxMaService;
@Autowired
private SecurityUserMapper securityUserMapper;
@Override
public void register(MiniProgramUserRegisterParams params) {
MiniProgramUser miniProgramUser = BeanUtil.copyProperties(params, MiniProgramUser.class);
@ -47,4 +56,9 @@ public class MiniProgramUserServiceImpl extends ServiceImpl<MiniProgramUserMappe
throw new MessageException();
}
}
@Override
public Page<ServiceProjectSecurityUserPagerVo> securityUserPager(PageParams<ServiceProjectSecurityUserPagerQueryParams, ServiceProjectSecurityUserPagerVo> queryParams) {
return securityUserMapper.securityUserPager(queryParams.getPage(), queryParams.getParams());
}
}

View File

@ -1,13 +1,20 @@
package com.changhu.module.miniProgram.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.changhu.common.exception.MessageException;
import com.changhu.common.utils.UserUtil;
import com.changhu.module.management.mapper.ServiceProjectMapper;
import com.changhu.module.miniProgram.pojo.entity.SecurityUser;
import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams;
import com.changhu.module.miniProgram.pojo.vo.IndexServiceProjectListVo;
import com.changhu.module.miniProgram.service.ProjectManageIndexService;
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
/**
* @author 20252
@ -24,4 +31,47 @@ public class ProjectManageIndexServiceImpl implements ProjectManageIndexService
public List<IndexServiceProjectListVo> getMyServiceProjectList() {
return serviceProjectMapper.getServiceProjectList(null, UserUtil.getUserId());
}
@Override
public void deleteSecurityUserByServiceProjectId(Long securityUserId) {
boolean b = Db.removeById(securityUserId, SecurityUser.class);
if (!b) {
throw new MessageException();
}
}
@Override
public void saveOrUpdateSecurityUser(SaveOrUpdateSecurityUserParams params) {
SecurityUser securityUser = BeanUtil.copyProperties(params, SecurityUser.class);
//填充保安单位
securityUser.setSecurityUnitId(UserUtil.getUnitId());
//新增的情况
Long snowFlakeId = securityUser.getSnowFlakeId();
if (snowFlakeId == null) {
//判断是否已经存在
boolean exists = Db.lambdaQuery(SecurityUser.class)
.eq(SecurityUser::getServiceProjectId, securityUser.getServiceProjectId())
.eq(SecurityUser::getIdCard, securityUser.getIdCard())
.exists();
if (exists) {
throw new MessageException("服务项目下已经存在该人员");
}
} else {
//如果修改了身份证 需要查重
SecurityUser byId = Db.getById(snowFlakeId, SecurityUser.class);
if (!securityUser.getIdCard().equals(byId.getIdCard())) {
boolean exists = Db.lambdaQuery(SecurityUser.class)
.eq(SecurityUser::getServiceProjectId, securityUser.getServiceProjectId())
.eq(SecurityUser::getIdCard, securityUser.getIdCard())
.exists();
if (exists) {
throw new MessageException("服务项目下已经存在该人员");
}
}
}
boolean b = Db.saveOrUpdate(securityUser);
if (!b) {
throw new MessageException();
}
}
}

View File

@ -0,0 +1,17 @@
package com.changhu.module.miniProgram.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.changhu.module.miniProgram.mapper.SecurityUserMapper;
import com.changhu.module.miniProgram.pojo.entity.SecurityUser;
import com.changhu.module.miniProgram.service.SecurityUserService;
import org.springframework.stereotype.Service;
/**
* security_user (保安人员) 服务实现类
* author: luozhun
* desc 由groovy脚本自动生成
*/
@Service
public class SecurityUserServiceImpl extends ServiceImpl<SecurityUserMapper, SecurityUser> implements SecurityUserService {
}

View File

@ -0,0 +1,14 @@
<?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.changhu.module.miniProgram.mapper.SecurityUserMapper">
<select id="securityUserPager"
resultType="com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo">
select su.*,
sun.name as 'securityUnitName'
from security_unit sun
join security_user su on su.security_unit_id = sun.snow_flake_id and su.delete_flag = 0
where sun.delete_flag = 0
and su.service_project_id = #{params.serviceProjectId}
order by su.create_time desc
</select>
</mapper>