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

View File

@ -114,7 +114,7 @@ public class StockController {
} }
@Log("商品库存:上下架商品") @Log("商品库存 上下架商品")
@PutMapping("/grounding") @PutMapping("/grounding")
@ApiOperation("上下架商品") @ApiOperation("上下架商品")
public ResponseEntity<Object> grounding( public ResponseEntity<Object> grounding(
@ -141,7 +141,7 @@ public class StockController {
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@Log("商品库存:修改商品状态") @Log("商品库存 修改商品状态")
@PutMapping("productStatus") @PutMapping("productStatus")
public ResponseEntity<Object> updateProductStatus(@RequestBody StockUpdateValueVO updateValueVO) { public ResponseEntity<Object> updateProductStatus(@RequestBody StockUpdateValueVO updateValueVO) {
stockService.updateProductStatus(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") @Query("select staff from TbPlussShopStaff as staff where staff.account = :account")
TbPlussShopStaff queryByAccount(String 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 @Modifying
@Query("update TbPlussShopStaff set name=:name where shopId = :shopId and type='master'") @Query("update TbPlussShopStaff set name=:name where shopId = :shopId and type='master'")
void updateNameById(String name, String shopId); void updateNameById(String name, String shopId);

View File

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

View File

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

View File

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