Merge branch 'dev'

This commit is contained in:
wangw 2024-08-01 18:24:27 +08:00
commit 8a07cde563
6 changed files with 23 additions and 13 deletions

View File

@ -99,6 +99,7 @@ public class AuthorizationController {
throw new BadRequestException("验证码错误");
}
String loginpre="";
String shopId="";
// 判断是否是员工登录
if (authUser.getLoginType() != null && "staff".equals(authUser.getLoginType())) {
if (StrUtil.isBlank(authUser.getMerchantName())) {
@ -110,6 +111,7 @@ public class AuthorizationController {
throw new BadRequestException("商户不存在");
}
loginpre = merchant.getShopId() + "@";
shopId = merchant.getShopId();
}
//生成token
@ -123,7 +125,12 @@ public class AuthorizationController {
// SecurityContextHolder.getContext().setAuthentication(authentication);
final JwtUserDto jwtUserDto = (JwtUserDto) authentication.getPrincipal();
// TbShopInfo byAccount = tbShopInfoRepository.findByAccount(jwtUserDto.getUsername());
TbPlussShopStaff tbPlussShopStaff = staffRepository.queryByAccount(authUser.getUsername());
TbPlussShopStaff tbPlussShopStaff;
if (authUser.getLoginType() != null && "staff".equals(authUser.getLoginType())) {
tbPlussShopStaff = staffRepository.queryByAccount(authUser.getUsername(),shopId);
} else {
tbPlussShopStaff = staffRepository.queryByAccount(authUser.getUsername());
}
if (tbPlussShopStaff != null && tbPlussShopStaff.getType().equals("staff")) {
Integer isManage = tbPlussShopStaff.getIsManage();
if (isManage != null && isManage != 1) {

View File

@ -114,7 +114,7 @@ public class StockController {
}
@Log("商品库存:上下架商品")
@Log("商品库存 上下架商品")
@PutMapping("/grounding")
@ApiOperation("上下架商品")
public ResponseEntity<Object> grounding(
@ -141,7 +141,7 @@ public class StockController {
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("商品库存:修改商品状态")
@Log("商品库存 修改商品状态")
@PutMapping("productStatus")
public ResponseEntity<Object> updateProductStatus(@RequestBody StockUpdateValueVO updateValueVO) {
stockService.updateProductStatus(updateValueVO);

View File

@ -45,6 +45,9 @@ public interface TbPlussShopStaffRepository extends JpaRepository<TbPlussShopSta
@Query("select staff from TbPlussShopStaff as staff where staff.account = :account")
TbPlussShopStaff queryByAccount(String account);
@Query("select staff from TbPlussShopStaff as staff where staff.account = :account and staff.shopId=:shopId")
TbPlussShopStaff queryByAccount(String account,String shopId);
@Modifying
@Query("update TbPlussShopStaff set name=:name where shopId = :shopId and type='master'")
void updateNameById(String name, String shopId);

View File

@ -100,7 +100,7 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
if (!PhoneUtil.validator(resources.getPhone())){
throw new BadRequestException("手机号格式有误");
}
if (userRepository.findByUsername(resources.getAccount()) != null) {
if (userRepository.findByUsername(resources.getShopId()+"@"+resources.getAccount()) != null) {
throw new BadRequestException("员工账号已存在");
}

View File

@ -36,6 +36,7 @@ public interface RoleRepository extends JpaRepository<Role, Long>, JpaSpecificat
* @return /
*/
Role findByName(String name);
Role findByNameAndShopId(String name,Integer shopId);
/**
* 删除多个角色

View File

@ -91,8 +91,8 @@ public class RoleServiceImpl implements RoleService {
@Override
@Transactional(rollbackFor = Exception.class)
public void create(Role resources) {
if (roleRepository.findByName(resources.getName()) != null) {
throw new EntityExistException(Role.class, "username", resources.getName());
if (roleRepository.findByNameAndShopId(resources.getName(),resources.getShopId()) != null) {
throw new BadRequestException("角色已存在");
}
roleRepository.save(resources);
}
@ -101,13 +101,12 @@ public class RoleServiceImpl implements RoleService {
@Transactional(rollbackFor = Exception.class)
public void update(Role resources) {
Role role = roleRepository.findById(resources.getId()).orElseGet(Role::new);
ValidationUtil.isNull(role.getId(), "Role", "id", resources.getId());
Role role1 = roleRepository.findByName(resources.getName());
if (role1 != null && !role1.getId().equals(role.getId())) {
throw new EntityExistException(Role.class, "username", resources.getName());
if (!resources.getName().equals(role.getName())) {
if (roleRepository.findByNameAndShopId(resources.getName(),resources.getShopId()) != null) {
throw new BadRequestException("修改失败,角色名称不可重复");
}
}
ValidationUtil.isNull(role.getId(), "Role", "id", resources.getId());
role.setName(resources.getName());
role.setDescription(resources.getDescription());
role.setDataScope(resources.getDataScope());