刘帅
2026-09-22 9bcbf4398202139b31de1df6599e362915f15682
bug:数据返回问题
7个文件已修改
69 ■■■■■ 已修改文件
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/UserMgrController.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-management/src/main/resources/mapper/TStoreMapper.xml 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-management/src/main/webapp/WEB-INF/view/system/user/user_add.html 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-management/src/main/webapp/WEB-INF/view/system/user/user_edit.html 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-management/src/main/webapp/WEB-INF/view/system/user/user_edit1.html 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-management/src/main/webapp/WEB-INF/view/system/user/user_view.html 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-management/src/main/webapp/static/modular/system/user/user_info.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/UserMgrController.java
@@ -153,6 +153,11 @@
        User user = this.userService.getById(userId);
        Role role = roleService.getById(user.getRoleid());
        Dept dept = deptService.getById(user.getDeptid());
        // 兼容历史账号:部分账号的登录手机号仅保存在 account 字段。
        // 个人资料页必须能回显该绑定手机号,避免前端提交空值。
        if (StringUtils.isEmpty(user.getPhone()) && !StringUtils.isEmpty(user.getAccount())) {
            user.setPhone(user.getAccount());
        }
        user.setPhone(maskPhone(user.getPhone()));
        user.setIdCard(maskIdCard(user.getIdCard()));
        model.addAttribute(user);
@@ -214,6 +219,11 @@
        User user = this.userService.getById(userId);
        Role role = roleService.getById(user.getRoleid());
        Dept dept = deptService.getById(user.getDeptid());
        // 兼容历史账号:部分账号的登录手机号仅保存在 account 字段。
        // 个人资料页必须能回显该绑定手机号,避免前端提交空值。
        if (StringUtils.isEmpty(user.getPhone()) && !StringUtils.isEmpty(user.getAccount())) {
            user.setPhone(user.getAccount());
        }
        user.setPhone(maskPhone(user.getPhone()));
        user.setIdCard(maskIdCard(user.getIdCard()));
        model.addAttribute(user);
@@ -434,9 +444,12 @@
        }
        User oldUser = userService.getById(user.getId());
        // 判断是否更改电话
        if (user.getPhone() != null && user.getPhone().contains("*")) {
        if (StringUtils.isEmpty(user.getPhone()) || user.getPhone().contains("*")) {
            // The edit view displays a masked phone. Treat an unchanged masked
            // value as "keep original", never as a value to persist.
            // value, or an omitted field, as "keep original", never as a
            // value to persist. Some edit forms do not submit disabled or
            // hidden fields; allowing an empty value through would erase the
            // stored phone after deployment.
        } else if (!Objects.equals(oldUser.getPhone(), user.getPhone())) {
            User phone = userService.getOne(new QueryWrapper<User>().eq("phone", user.getPhone()));
            if (phone == null){
@@ -448,7 +461,11 @@
        oldUser.setName(user.getName());
        oldUser.setBirthday(user.getBirthday());
        oldUser.setDeptid(user.getDeptid());
        if (user.getIdCard() == null || !user.getIdCard().contains("*")) oldUser.setIdCard(user.getIdCard());
        // 身份证号为空说明本次表单没有提交该字段,不能覆盖数据库中的历史值;
        // 脱敏值同样只用于回显,不能写回数据库。
        if (!StringUtils.isEmpty(user.getIdCard()) && !user.getIdCard().contains("*")) {
            oldUser.setIdCard(user.getIdCard());
        }
        oldUser.setSex(user.getSex());
        oldUser.setEmail(user.getEmail());
        if (user.getAvatar()!=null && (!user.getAvatar().equals("")))
@@ -468,13 +485,21 @@
        }
        // 门店关联会维护员工归属信息,但不能覆盖编辑页明确选择的角色。
        // 必须在关联处理后写入,否则有门店的员工会被上面的兼容逻辑强制改回角色 3。
        if (!StringUtils.isEmpty(user.getRoleid())) {
        // 个人资料页不提供 roleid_ 回显控件时,旧版前端可能提交字符串
        // "undefined";该值绝不能覆盖 sys_user.roleid。
        if (isValidRoleId(user.getRoleid())) {
            oldUser.setRoleid(user.getRoleid());
        }
        this.userService.updateById(oldUser);
        return SUCCESS_TIP;
    }
    private boolean isValidRoleId(String roleId) {
        return !StringUtils.isEmpty(roleId)
                && !"undefined".equalsIgnoreCase(roleId)
                && !"null".equalsIgnoreCase(roleId);
    }
    private String maskPhone(String value) {
        if (value == null) return null;
        return value.length() <= 7 ? stars(value.length()) : value.substring(0, 3) + "****" + value.substring(7);
cloud-server-management/src/main/resources/mapper/TStoreMapper.xml
@@ -35,7 +35,11 @@
    </delete>
    <select id="listAll" resultType="com.dsh.guns.modular.system.model.TStoreListVo">
        select t1.*,t2.name userName,t2.phone userPhone,t3.name yysName
        select t1.*,
               t2.name as userName,
               coalesce(nullif(t1.phone, ''), nullif(t2.phone, '')) as phone,
               coalesce(nullif(t2.phone, ''), nullif(t1.phone, '')) as userPhone,
               t3.name as yysName
        from t_store t1
        left join sys_user t2 on t1.storeStaffId = t2.id
        left  join t_operator t3 on t1.operatorId = t3.id
@@ -50,7 +54,7 @@
            and t2.name like concat("%",#{name},"%")
        </if>
        <if test="phone !=null and phone !=''">
            and t2.phone like concat("%",#{phone},"%")
            and coalesce(nullif(t2.phone, ''), nullif(t1.phone, '')) like concat("%",#{phone},"%")
        </if>
        <if test="shopName !=null and shopName !=''">
            and t1.name like concat("%",#{shopName},"%")
@@ -177,7 +181,14 @@
    </select>
    <select id="listAllStore" resultType="com.dsh.guns.modular.system.model.TStoreListVo">
        select t1.*,t2.name userName,t2.phone userPhone,t3.name yysName from t_store t1 left join sys_user t2 on t1.storeStaffId = t2.id left  join t_operator t3 on t1.operatorId = t3.id
        select t1.*,
               t2.name as userName,
               coalesce(nullif(t1.phone, ''), nullif(t2.phone, '')) as phone,
               coalesce(nullif(t2.phone, ''), nullif(t1.phone, '')) as userPhone,
               t3.name as yysName
        from t_store t1
        left join sys_user t2 on t1.storeStaffId = t2.id
        left join t_operator t3 on t1.operatorId = t3.id
        where t1.id =#{id}
        <if test="provinceCode !=null and provinceCode !=''">
            and t1.provinceCode = #{provinceCode}
@@ -189,7 +200,7 @@
            and t2.name like concat("%",#{name},"%")
        </if>
        <if test="phone !=null and phone !=''">
            and t2.phone like concat("%",#{phone},"%")
            and coalesce(nullif(t2.phone, ''), nullif(t1.phone, '')) like concat("%",#{phone},"%")
        </if>
        <if test="shopName !=null and shopName !=''">
            and t1.name like concat("%",#{shopName},"%")
cloud-server-management/src/main/webapp/WEB-INF/view/system/user/user_add.html
@@ -60,7 +60,7 @@
</div>
<script src="${ctxPath}/modular/system/user/user_info.js?v=20260916-2"></script>
<script src="${ctxPath}/modular/system/user/user_info.js?v=20260922-1"></script>
<script>
    laydate.render({
        elem: '#birthday'
cloud-server-management/src/main/webapp/WEB-INF/view/system/user/user_edit.html
@@ -67,7 +67,7 @@
<script src="${ctxPath}/modular/system/user/user_info.js?v=20260916-2"></script>
<script src="${ctxPath}/modular/system/user/user_info.js?v=20260922-1"></script>
<script>
    laydate.render({
        elem: '#birthday'
cloud-server-management/src/main/webapp/WEB-INF/view/system/user/user_edit1.html
@@ -51,7 +51,7 @@
<script src="${ctxPath}/modular/system/user/user_info.js?v=20260916-2"></script>
<script src="${ctxPath}/modular/system/user/user_info.js?v=20260922-1"></script>
<script>
    laydate.render({
        elem: '#birthday'
cloud-server-management/src/main/webapp/WEB-INF/view/system/user/user_view.html
@@ -67,7 +67,7 @@
    </div>
</div>
</div>
<script src="${ctxPath}/modular/system/user/user_info.js?v=20260916-2"></script>
<script src="${ctxPath}/modular/system/user/user_info.js?v=20260922-1"></script>
<script>
    laydate.render({
        elem: '#birthday'
cloud-server-management/src/main/webapp/static/modular/system/user/user_info.js
@@ -409,5 +409,12 @@
    avatarUp.setUploadBarId("progressBar");
    avatarUp.init();
    document.getElementById('roleid').value = $("#roleid_").val();
    // 员工编辑页有 roleid_ 用于回显;个人资料页只有隐藏的 roleid。
    // 不能把不存在控件的 undefined 写回 roleid,否则提交 /mgr/edit
    // 会将 sys_user.roleid 更新为字符串 "undefined"。
    var roleIdSource = $("#roleid_");
    var roleIdTarget = $("#roleid");
    if (roleIdSource.length && roleIdTarget.length && roleIdSource.val()) {
        roleIdTarget.val(roleIdSource.val());
    }
});