创建店铺密码强度校验
修改密码 可通过验证码 发送验证码类型限制
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.account.entity.SysUser;
|
||||
import com.czg.account.service.CommonService;
|
||||
@@ -10,6 +9,7 @@ import com.czg.exception.CzgException;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.system.service.SmsService;
|
||||
import com.czg.utils.CzgRandomUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -37,9 +37,9 @@ public class CommonServiceImpl implements CommonService {
|
||||
if (val != null) {
|
||||
throw new CzgException("请勿频繁获取");
|
||||
}
|
||||
int code = RandomUtil.randomInt(100000, 1000000);
|
||||
String code = CzgRandomUtils.randomNumber(6,true);
|
||||
redisService.set(key, code, 300);
|
||||
smsService.sendCode(sysUser.getPhone(), String.valueOf(code));
|
||||
smsService.sendCode(sysUser.getPhone(), code);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.czg.service.account.mapper.ShopUserMapper;
|
||||
import com.czg.system.dto.SysParamsDTO;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.CzgStrUtils;
|
||||
import com.czg.utils.GeoUtil;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
@@ -113,7 +114,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ShopInfo> get(PageDTO pageDTO, String profiles, String phone, String shopName, Integer status, Integer isHeadShop) {
|
||||
public Page<ShopDetailDTO> get(PageDTO pageDTO, String profiles, String phone, String shopName, Integer status, Integer isHeadShop) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
if (StrUtil.isNotBlank(profiles)) {
|
||||
queryWrapper.eq(ShopInfo::getProfiles, profiles);
|
||||
@@ -135,11 +136,13 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
.eq(ShopInfo::getIsHeadShop, 1).ne(ShopInfo::getShopType, ShopTypeEnum.ONLY.getValue()));
|
||||
Map<Long, String> shopKv = shopAllList.stream().collect(Collectors.toMap(ShopInfo::getId, ShopInfo::getShopName));
|
||||
queryWrapper.orderBy(ShopInfo::getCreateTime, false);
|
||||
Page<ShopInfo> page = page(new Page<>(pageDTO.page(), pageDTO.size()), queryWrapper);
|
||||
Page<ShopDetailDTO> page = pageAs(new Page<>(pageDTO.page(), pageDTO.size()), queryWrapper, ShopDetailDTO.class);
|
||||
page.getRecords().forEach(shopInfo -> {
|
||||
ShopConfig shopConfig = shopConfigService.getById(shopInfo.getId());
|
||||
BeanUtil.copyProperties(shopConfig, shopInfo);
|
||||
shopInfo.setHeadShopName(shopKv.get(shopInfo.getMainId()));
|
||||
SysUser sysUser = sysUserService.getById(shopInfo.getId());
|
||||
shopInfo.setAccount(sysUser.getAccount());
|
||||
});
|
||||
return page;
|
||||
}
|
||||
@@ -190,7 +193,8 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
if (count > 0) {
|
||||
throw new CzgException("账户已存在");
|
||||
}
|
||||
|
||||
//校验密码长度和强度
|
||||
CzgStrUtils.checkPwd(shopInfoAddDTO.getAccountPwd());
|
||||
// 添加系统账号
|
||||
shopInfoAddDTO.setRoleId(shopInfoAddDTO.getRoleId() == null ? 2L : shopInfoAddDTO.getRoleId());
|
||||
SysUser sysUser = sysUserService.addUser(shopInfoAddDTO.getShopName(), shopInfoAddDTO.getAccountName(), shopInfoAddDTO.getAccountPwd(), shopInfoAddDTO.getPhone(), shopInfoAddDTO.getRoleId());
|
||||
@@ -198,9 +202,10 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
// 保存店铺信息
|
||||
ShopInfo shopInfo = BeanUtil.copyProperties(shopInfoAddDTO, ShopInfo.class);
|
||||
shopInfo.setId(sysUser.getId());
|
||||
//设置激活码
|
||||
shopInfo.setStatus(1);
|
||||
shopInfo.setProfiles("release");
|
||||
if (StrUtil.isNotBlank(shopInfo.getProfiles())) {
|
||||
shopInfo.setProfiles("release");
|
||||
}
|
||||
save(shopInfo);
|
||||
if (StrUtil.isNotBlank(shopInfoAddDTO.getActivateCode())) {
|
||||
activateShop(shopInfo, shopInfoAddDTO.getActivateCode());
|
||||
@@ -391,7 +396,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ShopInfo> getShopByMainId(PageDTO pageDTO, String shopName, Integer status) {
|
||||
public Page<ShopDetailDTO> getShopByMainId(PageDTO pageDTO, String shopName, Integer status) {
|
||||
Long loginId = (Long) StpKit.USER.getLoginId();
|
||||
ShopInfo shopInfo = getById(loginId);
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
@@ -408,7 +413,12 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
} else {
|
||||
queryWrapper.eq(ShopInfo::getId, loginId);
|
||||
}
|
||||
return page(new Page<>(pageDTO.page(), pageDTO.size()), queryWrapper);
|
||||
Page<ShopDetailDTO> page = pageAs(new Page<>(pageDTO.page(), pageDTO.size()), queryWrapper, ShopDetailDTO.class);
|
||||
page.getRecords().forEach(dto -> {
|
||||
SysUser sysUser = sysUserService.getById(shopInfo.getId());
|
||||
dto.setAccount(sysUser.getAccount());
|
||||
});
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,12 +14,14 @@ import com.czg.account.entity.SysUser;
|
||||
import com.czg.account.entity.SysUsersRoles;
|
||||
import com.czg.account.service.SysUserService;
|
||||
import com.czg.account.vo.SysUserDetailVO;
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.service.account.mapper.SysRoleMapper;
|
||||
import com.czg.service.account.mapper.SysUserMapper;
|
||||
import com.czg.service.account.mapper.SysUsersRolesMapper;
|
||||
import com.czg.utils.CzgStrUtils;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -34,8 +36,6 @@ import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mybatisflex.core.query.QueryMethods.column;
|
||||
|
||||
/**
|
||||
* 系统用户 服务层实现。
|
||||
*
|
||||
@@ -210,16 +210,22 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
throw new CzgException("修改失败");
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(sysUserEditPwdDTO.getOriginalPassword()) &&
|
||||
if (StrUtil.isNotBlank(sysUserEditPwdDTO.getCode())) {
|
||||
Object value = redisService.get(RedisCst.SMS_CODE + sysUser.getPhone() + ":shopPwd");
|
||||
if (!sysUserEditPwdDTO.getCode().equals(value)) {
|
||||
throw new CzgException("验证码不正确");
|
||||
}
|
||||
} else if (StrUtil.isNotBlank(sysUserEditPwdDTO.getOriginalPassword()) &&
|
||||
!sysUser.getPassword().equals(SecureUtil.md5(sysUser.getId() + sysUserEditPwdDTO.getOriginalPassword()))) {
|
||||
throw new CzgException("原密码不正确");
|
||||
} else {
|
||||
throw new CzgException("修改失败");
|
||||
}
|
||||
|
||||
if (!sysUserEditPwdDTO.getPassword().equals(sysUserEditPwdDTO.getCheckPassword())) {
|
||||
throw new CzgException("两次密码不一致");
|
||||
throw new CzgException("新密码与确认密码不一致");
|
||||
}
|
||||
|
||||
CzgStrUtils.checkPwd(sysUserEditPwdDTO.getPassword());
|
||||
sysUser.setPassword(SecureUtil.md5(sysUser.getId() + sysUserEditPwdDTO.getPassword()));
|
||||
boolean isUp = updateById(sysUser);
|
||||
if (isUp) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.czg.account.dto.user.userinfo.UserInfoAssetsSummaryDTO;
|
||||
@@ -19,6 +18,7 @@ import com.czg.service.account.mapper.ShopUserMapper;
|
||||
import com.czg.service.account.mapper.UserInfoMapper;
|
||||
import com.czg.service.account.util.AcAccountUtil;
|
||||
import com.czg.system.service.SmsService;
|
||||
import com.czg.utils.CzgRandomUtils;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -81,9 +81,9 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
|
||||
if (StrUtil.isBlank(userInfo.getPhone())) {
|
||||
throw new CzgException("账号未绑定手机号");
|
||||
}
|
||||
int code = RandomUtil.randomInt(100000, 1000000);
|
||||
redisService.set("%s%s:%s".formatted(RedisCst.SMS_CODE, userInfo.getPhone(), type), String.valueOf(code), 300);
|
||||
smsService.sendCode(userInfo.getPhone(), String.valueOf(code));
|
||||
String code = CzgRandomUtils.randomNumber(6, false);
|
||||
redisService.set("%s%s:%s".formatted(RedisCst.SMS_CODE, userInfo.getPhone(), type), code, 300);
|
||||
smsService.sendCode(userInfo.getPhone(), code);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user