新增角色标签

This commit is contained in:
戚辰先生 2024-12-01 11:43:18 +08:00
parent 82997245a4
commit fa31848e9f

View File

@ -2,12 +2,14 @@ package com.qqchen.deploy.backend.service.impl;
import com.qqchen.deploy.backend.entity.RoleTag; import com.qqchen.deploy.backend.entity.RoleTag;
import com.qqchen.deploy.backend.framework.enums.ResponseCode; import com.qqchen.deploy.backend.framework.enums.ResponseCode;
import com.qqchen.deploy.backend.framework.exception.BusinessException;
import com.qqchen.deploy.backend.framework.exception.UniqueConstraintException; import com.qqchen.deploy.backend.framework.exception.UniqueConstraintException;
import com.qqchen.deploy.backend.framework.service.impl.BaseServiceImpl; import com.qqchen.deploy.backend.framework.service.impl.BaseServiceImpl;
import com.qqchen.deploy.backend.model.RoleTagDTO; import com.qqchen.deploy.backend.model.RoleTagDTO;
import com.qqchen.deploy.backend.repository.IRoleTagRepository; import com.qqchen.deploy.backend.repository.IRoleTagRepository;
import com.qqchen.deploy.backend.service.IRoleTagService; import com.qqchen.deploy.backend.service.IRoleTagService;
import com.qqchen.deploy.backend.framework.annotation.ServiceType; import com.qqchen.deploy.backend.framework.annotation.ServiceType;
import jakarta.transaction.Transactional;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@ -33,4 +35,15 @@ public class RoleTagServiceImpl extends BaseServiceImpl<RoleTag, RoleTagDTO, Lon
throw new UniqueConstraintException(ResponseCode.ROLE_TAG_NAME_EXISTS, "name", dto.getName()); throw new UniqueConstraintException(ResponseCode.ROLE_TAG_NAME_EXISTS, "name", dto.getName());
} }
} }
@Override
@Transactional
public void delete(Long id) {
RoleTag tag = findEntityById(id);
// 检查标签是否正在使用
if (!tag.getRoles().isEmpty()) {
throw new BusinessException(ResponseCode.ROLE_TAG_IN_USE);
}
super.delete(id);
}
} }