import com.example.entity.Department;
import com.example.mapper.DepartmentMapper;
import com.example.request.DelDepartmentPermissionRequest;
import com.example.response.DelDepartmentPermissionResponse;
import com.example.service.DepartmentPermissionService;
import com.example.utils.RespUtils;
import com.example.exception.TitanException;
import com.example.enums.ErrorCodeEnum;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class DepartmentServiceImpl {
@Autowired
private DepartmentMapper departmentMapper;
@Autowired
private DepartmentPermissionService permissionService;
@Transactional(rollbackFor = Exception.class)
public DelDepartmentPermissionResponse deleteDepartmentPermission(DelDepartmentPermissionRequest request) {
DelDepartmentPermissionResponse response = new DelDepartmentPermissionResponse();
// 参数校验
if (StringUtils.isEmpty(request.getDepartmentId()) || request.getIndexPatternNameList() == null || request.getIndexPatternNameList().isEmpty()) {
log.error("删除部门权限请求参数为空");
throw new TitanException("所传参数为空!");
}
// 获取部门信息
Department department = getDepartmentById(request.getDepartmentId());
if (department == null) {
RespUtils.setError(ErrorCodeEnum.DEPARTMENT_NOT_FOUND, response);
return response;
}
// 删除权限
permissionService.deletePermissionForDepartment(request.getDepartmentId(), request.getIndexPatternNameList());
// 设置成功响应
RespUtils.setSuccess(response);
return response;
}
private Department getDepartmentById(String departmentId) {
return departmentMapper.selectOneByExample(departmentId);
}
}
标签:request,example,DelDepartmentPermissionResponse,import,源代码,com,response From: https://www.cnblogs.com/lmzzr24/p/18546297