领导人员功能开发

This commit is contained in:
lizhenhua 2025-12-17 17:24:34 +08:00
parent 3dce4e1868
commit 420fc1907c
6 changed files with 275 additions and 0 deletions

View File

@ -0,0 +1,38 @@
package com.bonus.canteen.core.userinfo.beans;
import lombok.Data;
@Data
public class CustInfoQuery {
// 查询条件
private String custName;
private String phone;
private String custNum;
private String functionStatus;
private String configCode;
private Long orgId;
private Integer custState;
// 分页参数
private Integer pageNum;
private Integer pageSize;
// 查询结果字段
private Long custId;
private String custNumResult;
private String custNameResult;
private String phoneResult;
private String operator;
private Long orgIdResult;
private String orgName;
private String orgFullName;
private String idCard;
private Integer sex;
private String birthday;
private String crtime;
// 功能状态true=有配置=开启false=无配置=关闭
private Boolean hasFunction;
private String[] selectedOrg;
}

View File

@ -0,0 +1,59 @@
package com.bonus.canteen.core.userinfo.controller;
import com.bonus.canteen.core.userinfo.beans.CustInfoQuery;
import com.bonus.canteen.core.userinfo.service.ICustInfoService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/custInfo")
public class platCustInfoController extends BaseController {
@Autowired
private ICustInfoService custInfoService;
@GetMapping("/list")
public TableDataInfo list(CustInfoQuery query) {
startPage();
List<CustInfoQuery> peoplelist = custInfoService.selectCustInfoList(query);
return getDataTable(peoplelist);
}
@PostMapping("/toggleFunction")
public AjaxResult toggleFunction(@RequestBody CustInfoQuery query) {
try {
// 获取当前登录用户
String operator = SecurityUtils.getUsername();;
query.setOperator(operator);
int result = custInfoService.toggleFunction(query);
if (result > 0) {
return success("操作成功");
} else {
return success("状态未变化");
}
} catch (Exception e) {
return error("操作失败:" + e.getMessage());
}
}
/**
* 给app提供的接口 是否存在领导配置
* @param query
* @return
*/
@PostMapping("/ifLeader")
public Boolean ifLeader(@RequestBody CustInfoQuery query) {
boolean result = custInfoService.ifLeader(query);
return result;
}
}

View File

@ -0,0 +1,16 @@
package com.bonus.canteen.core.userinfo.mapper;
import com.bonus.canteen.core.userinfo.beans.CustInfoQuery;
import java.util.List;
public interface platCustInfoMapper {
List<CustInfoQuery> selectCustInfoList(CustInfoQuery query);
int checkConfigExists(Long custId);
int insertConfig(CustInfoQuery query);
int deleteConfig(CustInfoQuery query);
}

View File

@ -0,0 +1,15 @@
package com.bonus.canteen.core.userinfo.service;
import com.bonus.canteen.core.userinfo.beans.CustInfoQuery;
import com.bonus.common.core.web.page.TableDataInfo;
import java.util.List;
public interface ICustInfoService {
List<CustInfoQuery> selectCustInfoList(CustInfoQuery query);
int toggleFunction(CustInfoQuery quer);
boolean ifLeader(CustInfoQuery query);
}

View File

@ -0,0 +1,84 @@
package com.bonus.canteen.core.userinfo.service.impl;
import com.bonus.canteen.core.reportforms.beans.ReportOrderInfoVo;
import com.bonus.canteen.core.userinfo.beans.CustInfoQuery;
import com.bonus.canteen.core.userinfo.mapper.platCustInfoMapper;
import com.bonus.canteen.core.userinfo.service.ICustInfoService;
import com.bonus.common.core.utils.PageUtils;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.houqin.utils.SM4EncryptUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
@Service
public class ICustinfoServiceimpl implements ICustInfoService {
@Autowired
private platCustInfoMapper custInfoMapper;
@Override
public List<CustInfoQuery> selectCustInfoList(CustInfoQuery query) {
if(query.getCustName() != null){
// 解密
try {
query.setCustName(SM4EncryptUtils.sm4Encrypt(query.getCustName()));
}catch (Exception e){
e.printStackTrace();
}
}
List<CustInfoQuery> list = custInfoMapper.selectCustInfoList(query);
for (CustInfoQuery c : list) {
try {
// 姓名解密
if (c.getCustNameResult() != null && !c.getCustNameResult().isEmpty()) {
c.setCustNameResult(SM4EncryptUtils.sm4Decrypt(c.getCustNameResult()));
}
// 手机解密 + 脱敏
if (c.getPhoneResult() != null && !c.getPhoneResult().isEmpty()) {
String phone = SM4EncryptUtils.sm4Decrypt(c.getPhoneResult());
if (phone.length() == 11) {
c.setPhoneResult(phone.substring(0, 3) + "****" + phone.substring(7));
} else {
c.setPhoneResult(phone);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
return list;
}
@Override
public int toggleFunction(CustInfoQuery query) {
int exists = custInfoMapper.checkConfigExists(query.getCustId());
if (query.getHasFunction()) {
// 开启功能插入配置记录
if (exists == 0) {
return custInfoMapper.insertConfig(query);
}
// 已存在不做操作
return 0;
} else {
// 关闭功能删除配置记录
if (exists > 0) {
return custInfoMapper.deleteConfig(query);
}
// 已删除不做操作
return 0;
}
}
@Override
public boolean ifLeader(CustInfoQuery query) {
int exists = custInfoMapper.checkConfigExists(query.getCustId());
return exists > 0;
}
}

View File

@ -0,0 +1,63 @@
<?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.bonus.canteen.core.userinfo.mapper.platCustInfoMapper">
<insert id="insertConfig">
INSERT INTO sys_cust_config(cust_id, config_code, operator)
VALUES(#{custId}, #{configCode}, #{operator})
</insert>
<delete id="deleteConfig">
DELETE FROM sys_cust_config
WHERE cust_id = #{custId}
</delete>
<select id="selectCustInfoList" parameterType="com.bonus.canteen.core.userinfo.beans.CustInfoQuery" resultType="com.bonus.canteen.core.userinfo.beans.CustInfoQuery">
SELECT
ci.cust_id AS custId,
ci.cust_name AS custNameResult,
ci.mobile AS phoneResult,
ci.cust_num AS custNumResult,
ci.org_full_name AS orgFullName,
ci.cust_state AS custState,
DATE_FORMAT(ci.crtime, '%Y-%m-%d %H:%i:%s') AS crtime,
<!-- 判断配置是否存在 -->
CASE WHEN scc.cust_id IS NOT NULL THEN true ELSE false END AS hasFunction
FROM cust_info ci
LEFT JOIN sys_cust_config scc ON ci.cust_id = scc.cust_id
<where>
<if test="custName != null and custName != ''">
AND ci.cust_name LIKE CONCAT('%', #{custName}, '%')
</if>
<if test="phone != null and phone != ''">
AND ci.mobile LIKE CONCAT('%', #{phone}, '%')
</if>
<if test="custNum != null and custNum != ''">
AND ci.cust_num = #{custNum}
</if>
AND ci.cust_state = 1
<if test="functionStatus != null and functionStatus != ''">
<choose>
<when test="functionStatus == '1'.toString()">
<!-- 已开启:配置表中有记录 -->
AND scc.cust_id IS NOT NULL
</when>
<when test="functionStatus == '0'.toString()">
<!-- 未开启:配置表中无记录 -->
AND scc.cust_id IS NULL
</when>
</choose>
</if>
<if test="selectedOrg != null and selectedOrg.length > 0">
AND ci.org_id IN
<foreach collection="selectedOrg" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
</where>
ORDER BY ci.cust_id DESC
</select>
<select id="checkConfigExists" resultType="java.lang.Integer">
SELECT COUNT(1) FROM sys_cust_config
WHERE cust_id = #{custId}
</select>
</mapper>