rk
昨天 996b2f16afaa271ce8aad6abf6858aa5db503eb3
server/services/src/main/java/com/doumee/service/business/impl/ShopInfoServiceImpl.java
@@ -757,6 +757,13 @@
            }
        }
        // 门店头像:优先使用 coverImg,为空则取门头照第一张
        if (StringUtils.isNotBlank(shopInfo.getCoverImg())) {
            vo.setShopAvatar(imgPrefix + shopInfo.getCoverImg());
        } else if (!CollectionUtils.isEmpty(vo.getStoreFrontImgUrls())) {
            vo.setShopAvatar(vo.getStoreFrontImgUrls().get(0));
        }
        return vo;
    }
@@ -906,8 +913,8 @@
    }
    @Override
    public ShopInfoMaintainDTO getShopMaintainInfo(Integer memberId) {
        ShopInfo shop = shopInfoMapper.selectById(memberId);
    public ShopInfoMaintainDTO getShopMaintainInfo(Integer shopId) {
        ShopInfo shop = shopInfoMapper.selectById(shopId);
        if (Objects.isNull(shop) || Constants.equalsInteger(shop.getDeleted(), Constants.ONE)) {
            return null;
        }
@@ -919,6 +926,10 @@
        dto.setDeliveryArea(shop.getDeliveryArea());
        dto.setShopHours(shop.getShopHours());
        dto.setBusinessType(shop.getBusinessType());
        // 头像全路径
        if (StringUtils.isNotBlank(shop.getCoverImg())) {
            dto.setCoverImgUrl(getShopPrefix() + shop.getCoverImg());
        }
        return dto;
    }
@@ -1351,4 +1362,31 @@
        }
    }
    @Override
    public void changePassword(Integer shopId, String newPassword, String token) {
        if (StringUtils.isBlank(newPassword)) {
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "密码不能为空");
        }
        // 校验密码必须同时包含字母和数字
        boolean hasLetter = newPassword.chars().anyMatch(Character::isLetter);
        boolean hasDigit = newPassword.chars().anyMatch(Character::isDigit);
        if (!hasLetter || !hasDigit) {
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "密码必须同时包含字母和数字");
        }
        // 查询门店
        ShopInfo shopInfo = shopInfoMapper.selectById(shopId);
        if (shopInfo == null || Constants.equalsInteger(shopInfo.getDeleted(), Constants.ONE)) {
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        // 重新生成salt,加密新密码并更新
        String salt = RandomStringUtils.randomAlphabetic(6);
        shopInfo.setPassword(Utils.Secure.encryptPassword(newPassword, salt));
        shopInfo.setSalt(salt);
        shopInfoMapper.updateById(shopInfo);
        // 清除token,强制重新登录
        if (StringUtils.isNotBlank(token)) {
            redisTemplate.delete(token);
        }
    }
}