| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.common.utils.FileSaveUtil; |
| | | import com.ruoyi.personnel.dto.PersonPostAuthorizationRecordDto; |
| | | import com.ruoyi.personnel.pojo.PersonPostAuthorizationRecord; |
| | |
| | | @Operation(summary = "新增/更新 任职授权记录") |
| | | @PostMapping("/addOrUpdatePersonPostAuthorizationRecord") |
| | | public Result<?> addOrUpdatePersonPostAuthorizationRecord(@RequestBody PersonPostAuthorizationRecord personRewardPunishmentRecord) { |
| | | if (personRewardPunishmentRecord == null || personRewardPunishmentRecord.getUserId() == null) { |
| | | throw new ErrorException("请选择被任职人员"); |
| | | } |
| | | if (personRewardPunishmentRecord.getPost() == null || personRewardPunishmentRecord.getPost().trim().isEmpty()) { |
| | | throw new ErrorException("请输入任职岗位"); |
| | | } |
| | | if (personRewardPunishmentRecord.getId() != null |
| | | && personPostAuthorizationRecordService.getById(personRewardPunishmentRecord.getId()) == null) { |
| | | throw new ErrorException("任职授权记录不存在或已被删除"); |
| | | } |
| | | personPostAuthorizationRecordService.saveOrUpdate(personRewardPunishmentRecord); |
| | | return Result.success(); |
| | | } |
| | |
| | | @Operation(summary = "删除 任职授权记录") |
| | | @DeleteMapping("/deletePersonPostAuthorizationRecord") |
| | | public Result<?> deletePersonPostAuthorizationRecord(@RequestParam("id") Integer id) { |
| | | // 删除文件 |
| | | PersonPostAuthorizationRecord postAuthorizationRecord = personPostAuthorizationRecordService.getById(id); |
| | | if (postAuthorizationRecord == null) { |
| | | throw new ErrorException("任职授权记录不存在或已被删除"); |
| | | } |
| | | // 删除文件 |
| | | FileSaveUtil.DeleteFile(postAuthorizationRecord.getSystemFileName()); |
| | | // 删除数据 |
| | | personPostAuthorizationRecordService.removeById(id); |