增加正则

This commit is contained in:
liuyingfang
2024-03-02 15:19:05 +08:00
parent 9f13d37960
commit 8f7acca8e6
2 changed files with 25 additions and 0 deletions

View File

@@ -15,6 +15,7 @@
*/
package me.zhengjie.modules.shopInfo.shopStaff.service.impl;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.shopInfo.shopStaff.domain.TbPlussShopStaff;
import me.zhengjie.utils.*;
import lombok.RequiredArgsConstructor;
@@ -71,6 +72,9 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
@Override
@Transactional(rollbackFor = Exception.class)
public TbPlussShopStaffDto create(TbPlussShopStaff resources) {
if (!PhoneUtil.validator(resources.getAccount())){
throw new BadRequestException("手机号格式有误");
}
resources.setPassword(MD5Utils.md5("123456"));
resources.setCreatedAt(Instant.now().toEpochMilli());
resources.setUpdatedAt(Instant.now().toEpochMilli());
@@ -81,6 +85,7 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
@Transactional(rollbackFor = Exception.class)
public void update(TbPlussShopStaff resources) {
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(resources.getId()).orElseGet(TbPlussShopStaff::new);
resources.setUpdatedAt(tbPlussShopStaff.getUpdatedAt());
ValidationUtil.isNull( tbPlussShopStaff.getId(),"TbPlussShopStaff","id",resources.getId());
tbPlussShopStaff.copy(resources);
tbPlussShopStaffRepository.save(tbPlussShopStaff);