| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.exam.common.exception.ApiException; |
| | | import com.gkhy.exam.common.utils.SecurityUtils; |
| | | import com.gkhy.exam.system.domain.SysClauseManagement; |
| | | import com.gkhy.exam.system.mapper.SysClauseManagementMapper; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | |
| | | |
| | | @Override |
| | | public int saveSysClauseManagement(SysClauseManagement sysClauseManagement) { |
| | | if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ |
| | | throw new RuntimeException("没有权限访问!"); |
| | | if (!SecurityUtils.adminUser()){ |
| | | throw new ApiException("没有权限访问!"); |
| | | } |
| | | LambdaQueryWrapper<SysClauseManagement> lambdaQueryWrapper = Wrappers.<SysClauseManagement>lambdaQuery() |
| | | .eq(SysClauseManagement::getDelFlag, "0").eq(SysClauseManagement::getClauseNum, sysClauseManagement.getClauseNum()); |
| | | if (sysClauseManagement.getId() == null){ |
| | | if (baseMapper.selectCount(lambdaQueryWrapper) > 0){ |
| | | throw new RuntimeException("条款编号已存在!"); |
| | | throw new ApiException("条款编号已存在!"); |
| | | } |
| | | sysClauseManagement.setCreateBy(SecurityUtils.getUsername()); |
| | | sysClauseManagement.setCreateTime(LocalDateTime.now()); |
| | |
| | | }else { |
| | | lambdaQueryWrapper.ne(SysClauseManagement::getId, sysClauseManagement.getId()); |
| | | if (baseMapper.selectCount(lambdaQueryWrapper) > 0){ |
| | | throw new RuntimeException("条款编号已存在!"); |
| | | throw new ApiException("条款编号已存在!"); |
| | | } |
| | | sysClauseManagement.setUpdateBy(SecurityUtils.getUsername()); |
| | | sysClauseManagement.setUpdateTime(LocalDateTime.now()); |
| | |
| | | |
| | | @Override |
| | | public int delSysClauseManagement(Long id) { |
| | | if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ |
| | | throw new RuntimeException("没有权限访问!"); |
| | | if (!SecurityUtils.adminUser()){ |
| | | throw new ApiException("没有权限访问!"); |
| | | } |
| | | //todo 校验已使用的? |
| | | SysClauseManagement sysClauseManagement = new SysClauseManagement(); |