fix bug
This commit is contained in:
@ -7,5 +7,9 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode MERCHANT_DETAILS_NOT_EXISTS = new ErrorCode(1008009000, "支付服务商配置不存在");
|
||||
|
||||
ErrorCode PAY_TYPE_NOT_EXISTS = new ErrorCode(800000000, "支付类型不存在");
|
||||
|
||||
ErrorCode PAY_TYPE_IS_EXISTS = new ErrorCode(800000001, "支付类型重复");
|
||||
|
||||
ErrorCode PAY_ID_IS_EXISTS = new ErrorCode(800000002, "支付id重复");
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package co.yixiang.yshop.module.pay.service.merchantdetails;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -32,6 +34,12 @@ public class MerchantDetailsServiceImpl implements MerchantDetailsService {
|
||||
|
||||
@Override
|
||||
public String createMerchantDetails(MerchantDetailsCreateReqVO createReqVO) {
|
||||
if (ObjectUtil.isNotNull(getMerchantByType(createReqVO.getPayType()))) {
|
||||
throw exception(PAY_TYPE_IS_EXISTS);
|
||||
}
|
||||
if (ObjectUtil.isNotNull(getMerchantDetails(createReqVO.getDetailsId()))) {
|
||||
throw exception(PAY_ID_IS_EXISTS);
|
||||
}
|
||||
// 插入
|
||||
MerchantDetailsDO merchantDetails = MerchantDetailsConvert.INSTANCE.convert(createReqVO);
|
||||
merchantDetailsMapper.insert(merchantDetails);
|
||||
@ -41,6 +49,12 @@ public class MerchantDetailsServiceImpl implements MerchantDetailsService {
|
||||
|
||||
@Override
|
||||
public void updateMerchantDetails(MerchantDetailsUpdateReqVO updateReqVO) {
|
||||
LambdaQueryWrapper<MerchantDetailsDO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MerchantDetailsDO::getPayType, updateReqVO.getPayType())
|
||||
.ne(MerchantDetailsDO::getDetailsId, updateReqVO.getDetailsId());
|
||||
if (merchantDetailsMapper.exists(queryWrapper)) {
|
||||
throw exception(PAY_TYPE_IS_EXISTS);
|
||||
}
|
||||
// 校验存在
|
||||
validateMerchantDetailsExists(updateReqVO.getDetailsId());
|
||||
// 更新
|
||||
|
@ -33,6 +33,8 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode ROLE_IS_DISABLE = new ErrorCode(1002002004, "名字为【{}】的角色已被禁用");
|
||||
ErrorCode ROLE_ADMIN_CODE_ERROR = new ErrorCode(1002002005, "编码【{}】不能使用");
|
||||
|
||||
ErrorCode ADMIN_ROLE_CAN_NOT_UPDATE = new ErrorCode(1002002006, "不能操作管理员的角色");
|
||||
|
||||
// ========== 用户模块 1002003000 ==========
|
||||
ErrorCode USER_USERNAME_EXISTS = new ErrorCode(1002003000, "用户账号已经存在");
|
||||
ErrorCode USER_MOBILE_EXISTS = new ErrorCode(1002003001, "手机号已经存在");
|
||||
@ -42,6 +44,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode USER_PASSWORD_FAILED = new ErrorCode(1002003005, "用户密码校验失败");
|
||||
ErrorCode USER_IS_DISABLE = new ErrorCode(1002003006, "名字为【{}】的用户已被禁用");
|
||||
ErrorCode USER_COUNT_MAX = new ErrorCode(1002003008, "创建用户失败,原因:超过租户最大租户配额({})!");
|
||||
ErrorCode ADMIN_USER_NOT_DELETE = new ErrorCode(1002003009, "管理员账户不能删除!");
|
||||
|
||||
// ========== 部门模块 1002004000 ==========
|
||||
ErrorCode DEPT_NAME_DUPLICATE = new ErrorCode(1002004000, "已经存在该名字的部门");
|
||||
|
@ -0,0 +1,21 @@
|
||||
package co.yixiang.yshop.module.system.enums.permission;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum UserTypeEnum {
|
||||
|
||||
ADMIN("admin", "超级管理员");
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private final String username;
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
}
|
@ -251,9 +251,9 @@ public class RoleServiceImpl implements RoleService {
|
||||
if (roleDO == null) {
|
||||
throw exception(ROLE_NOT_EXISTS);
|
||||
}
|
||||
// 内置角色,不允许删除
|
||||
if (RoleTypeEnum.SYSTEM.getType().equals(roleDO.getType())) {
|
||||
throw exception(ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE);
|
||||
// 管理员角色,不允许操作
|
||||
if (roleDO.getId() == 1) {
|
||||
throw exception(ADMIN_ROLE_CAN_NOT_UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ import co.yixiang.yshop.module.system.dal.dataobject.dept.UserPostDO;
|
||||
import co.yixiang.yshop.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import co.yixiang.yshop.module.system.dal.mysql.dept.UserPostMapper;
|
||||
import co.yixiang.yshop.module.system.dal.mysql.user.AdminUserMapper;
|
||||
import co.yixiang.yshop.module.system.enums.permission.UserTypeEnum;
|
||||
import co.yixiang.yshop.module.system.service.dept.DeptService;
|
||||
import co.yixiang.yshop.module.system.service.dept.PostService;
|
||||
import co.yixiang.yshop.module.system.service.permission.PermissionService;
|
||||
@ -195,6 +196,12 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
public void deleteUser(Long id) {
|
||||
// 校验用户存在
|
||||
validateUserExists(id);
|
||||
|
||||
// 管理员不能删除
|
||||
AdminUserDO user = userMapper.selectById(id);
|
||||
if(UserTypeEnum.ADMIN.getUsername().equals(user.getUsername())){
|
||||
throw exception(ADMIN_USER_NOT_DELETE);
|
||||
}
|
||||
// 删除用户
|
||||
userMapper.deleteById(id);
|
||||
// 删除用户关联数据
|
||||
|
Reference in New Issue
Block a user