商家管理员账号 默认为店铺名称

修改时 该店铺的 Master员工 名称一律为店铺名称
This commit is contained in:
2024-07-26 16:47:01 +08:00
parent 80e666126c
commit 92e743cb8f
2 changed files with 10 additions and 0 deletions

View File

@@ -21,6 +21,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
/**
* @website https://eladmin.vip
* @author lyf
@@ -42,4 +44,8 @@ public interface TbPlussShopStaffRepository extends JpaRepository<TbPlussShopSta
@Query("select staff from TbPlussShopStaff as staff where staff.account = :account")
TbPlussShopStaff queryByAccount(String account);
@Modifying
@Query("update TbPlussShopStaff set name=:name where shopId = :shopId and type='master'")
void updateNameById(String name, String shopId);
}

View File

@@ -203,6 +203,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
TbPlussShopStaff tbPlussShopStaff = new TbPlussShopStaff();
tbPlussShopStaff.setShopId(String.valueOf(save.getId()));
tbPlussShopStaff.setType("master");
tbPlussShopStaff.setName(resources.getShopName());
tbPlussShopStaff.setAccount(resources.getAccount());
tbPlussShopStaff.setPassword(MD5Utils.encrypt(resources.getPassword()));
tbPlussShopStaff.setStatus(1);
@@ -237,6 +238,9 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
@Transactional(rollbackFor = Exception.class)
public void update(TbShopInfo resources) {
TbShopInfo tbShopInfo = tbShopInfoRepository.findById(resources.getId()).orElseGet(TbShopInfo::new);
if (!resources.getShopName().equals(tbShopInfo.getShopName())) {
shopStaffRepository.updateNameById(resources.getShopName(),resources.getId().toString());
}
ValidationUtil.isNull( tbShopInfo.getId(),"TbShopInfo","id",resources.getId());
tbShopInfo.copy(resources);
tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli());