|
|
@@ -0,0 +1,100 @@
|
|
|
+package com.management.platform.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.management.platform.entity.AbnormalItem;
|
|
|
+import com.management.platform.entity.ContractType;
|
|
|
+import com.management.platform.entity.Report;
|
|
|
+import com.management.platform.entity.User;
|
|
|
+import com.management.platform.mapper.ReportMapper;
|
|
|
+import com.management.platform.mapper.UserMapper;
|
|
|
+import com.management.platform.service.AbnormalItemService;
|
|
|
+import com.management.platform.service.ContractTypeService;
|
|
|
+import com.management.platform.util.HttpRespMsg;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 前端控制器
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author Seyason
|
|
|
+ * @since 2026-05-11
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/abnormal-item")
|
|
|
+public class AbnormalItemController {
|
|
|
+ @Resource
|
|
|
+ private AbnormalItemService abnormalItemService;
|
|
|
+ @Autowired
|
|
|
+ private UserMapper userMapper;
|
|
|
+ @Autowired
|
|
|
+ private ReportMapper reportMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 返回公司自定义合同类型
|
|
|
+ */
|
|
|
+ @RequestMapping("/save")
|
|
|
+ public HttpRespMsg save (HttpServletRequest request, AbnormalItem abnormalItem){
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
+ abnormalItem.setCompanyId(user.getCompanyId());
|
|
|
+ //校验名称不能重复
|
|
|
+ if (abnormalItem.getId() == null) {
|
|
|
+ int count = abnormalItemService.count(new QueryWrapper<AbnormalItem>().eq("name", abnormalItem.getName()).eq("company_id", abnormalItem.getCompanyId()));
|
|
|
+ if (count > 0) {
|
|
|
+ msg.setError("名称重复");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ int count = abnormalItemService.count(new QueryWrapper<AbnormalItem>().eq("name", abnormalItem.getName()).eq("company_id", abnormalItem.getCompanyId()).ne("id", abnormalItem.getId()));
|
|
|
+ if (count > 0) {
|
|
|
+ msg.setError("名称重复");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ abnormalItemService.save(abnormalItem);
|
|
|
+ return new HttpRespMsg();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增、修改合同类型
|
|
|
+ */
|
|
|
+ @RequestMapping("/list")
|
|
|
+ public HttpRespMsg list(HttpServletRequest request){
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ msg.data = abnormalItemService.list(new QueryWrapper<AbnormalItem>().eq("company_id", user.getCompanyId()));
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除合同类型
|
|
|
+ */
|
|
|
+ @RequestMapping("/delete")
|
|
|
+ public HttpRespMsg delete (HttpServletRequest request, Integer deleteId){
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ //校验是否已经被日报使用
|
|
|
+ int count = reportMapper.selectCount(new QueryWrapper<Report>().eq("company_id", userMapper.selectById(request.getHeader("token")).getCompanyId()).eq("extra_field2", deleteId));
|
|
|
+ if (count > 0) {
|
|
|
+ msg.setError("存在使用当前数据的日报,无法删除");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ boolean success = abnormalItemService.removeById(deleteId);
|
|
|
+ if (success) {
|
|
|
+ msg.data = "删除成功";
|
|
|
+ } else {
|
|
|
+ msg.setError("删除失败");
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|