|
@@ -0,0 +1,86 @@
|
|
|
|
+package com.management.platform.controller;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.management.platform.entity.SysForm;
|
|
|
|
+import com.management.platform.mapper.UserMapper;
|
|
|
|
+import com.management.platform.service.SysFormService;
|
|
|
|
+import com.management.platform.util.HttpRespMsg;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Priority;
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * <p>
|
|
|
|
+ * 前端控制器
|
|
|
|
+ * </p>
|
|
|
|
+ *
|
|
|
|
+ * @author Seyason
|
|
|
|
+ * @since 2024-03-04
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/sys-form")
|
|
|
|
+public class SysFormController {
|
|
|
|
+ @Resource
|
|
|
|
+ private SysFormService sysFormService;
|
|
|
|
+ @Resource
|
|
|
|
+ private HttpServletRequest request;
|
|
|
|
+ @Resource
|
|
|
|
+ private UserMapper userMapper;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @RequestMapping("/list")
|
|
|
|
+ public HttpRespMsg list(){
|
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
|
+ List<SysForm> list = sysFormService.list(new LambdaQueryWrapper<SysForm>().eq(SysForm::getCompanyId, companyId));
|
|
|
|
+ msg.setData(list);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @RequestMapping("/getListByCode")
|
|
|
|
+ public HttpRespMsg getListByCode(@RequestParam String code){
|
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
|
+ List<SysForm> sysFormList = sysFormService.list(new LambdaQueryWrapper<SysForm>().eq(SysForm::getCompanyId, companyId).eq(SysForm::getCode, code));
|
|
|
|
+ msg.setData(sysFormList);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @RequestMapping("addOrUpdate")
|
|
|
|
+ public HttpRespMsg addOrUpdate(SysForm sysForm){
|
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
|
+ sysForm.setCompanyId(companyId);
|
|
|
|
+ Integer count;
|
|
|
|
+ if(sysForm.getId()==null){
|
|
|
|
+ count = sysFormService.count(new LambdaQueryWrapper<SysForm>().eq(SysForm::getCode, sysForm.getCode()).eq(SysForm::getName,sysForm.getName()).eq(SysForm::getCompanyId, companyId));
|
|
|
|
+ }else {
|
|
|
|
+ count = sysFormService.count(new LambdaQueryWrapper<SysForm>().ne(sysForm.getId()!=null,SysForm::getId, sysForm.getId()).eq(SysForm::getName,sysForm.getName()).eq(SysForm::getCode, sysForm.getCode()).eq(SysForm::getCompanyId, companyId));
|
|
|
|
+ }
|
|
|
|
+ if(count>0){
|
|
|
|
+ msg.setError("名称为["+sysForm.getName()+"]的自定义模板配置已存在");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ if(!sysFormService.saveOrUpdate(sysForm)){
|
|
|
|
+ msg.setError("验证失败");
|
|
|
|
+ };
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @RequestMapping("/delete")
|
|
|
|
+ public HttpRespMsg delete(Integer id){
|
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
|
+ if(!sysFormService.removeById(id)){
|
|
|
|
+ msg.setError("验证失败");
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|