From b47d4a7accabce974e19d2a1ffb3c5c67507d74b Mon Sep 17 00:00:00 2001 From: wangwh <2397901735@qq.com> Date: Wed, 28 Aug 2024 15:11:59 +0800 Subject: [PATCH] 1、组织架构的接口 2、事项登记接口 --- dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/controller/web/CtDeptWebController.java | 82 ++++++++++++++++++++++++++++------------- 1 files changed, 56 insertions(+), 26 deletions(-) diff --git a/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/controller/web/CtDeptWebController.java b/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/controller/web/CtDeptWebController.java index 0eb6025..f845193 100644 --- a/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/controller/web/CtDeptWebController.java +++ b/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/controller/web/CtDeptWebController.java @@ -1,9 +1,13 @@ -package cn.huge.module.ctuser.controller; +package cn.huge.module.ctuser.controller.web; +import cn.huge.base.common.utils.IdUtils; import cn.huge.base.common.utils.ReturnFailUtils; import cn.huge.base.common.utils.ReturnSucUtils; +import cn.huge.base.config.CurrentUser; import cn.huge.module.ctuser.domain.po.CtDept; +import cn.huge.module.ctuser.domain.po.CtUser; import cn.huge.module.ctuser.service.CtDeptService; +import cn.huge.module.ctuser.service.CtUserService; import com.google.common.collect.Maps; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -14,16 +18,15 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; +import java.util.List; import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; /** - * @title: 客户部门表接口api - * @description: 客户部门表接口api + * @title: 客户部门表接口api-web端 + * @description: 客户部门表接口api-web端 * @company: hugeinfo * @author: liyj - * @time: 2024-08-17 15:30:57 + * @time: 2024-08-19 20:04:19 * @version: 1.0.0 */ @Slf4j @@ -36,6 +39,9 @@ @Autowired private CtDeptService service; + + @Autowired + private CtUserService ctUserService; /** * 获取请求URL参数 @@ -93,7 +99,7 @@ if (StringUtils.isNotBlank(canFieldName)){ terms.put("canFieldName", canFieldName); } - // 删除状态,0:已删除,1:未删除 + // 删除状态,0:未删除,1:已删除 String deleteStatus = request.getParameter("deleteStatus"); if (StringUtils.isNotBlank(deleteStatus)){ terms.put("deleteStatus", deleteStatus); @@ -171,19 +177,15 @@ } /** - * 根据主键单个/批量删除 - * @url {ctx}/api/web/ctDept/deleteByIds - * @param ids 主键编号 + * 根据主键单个 + * @url {ctx}/api/web/ctDept/deleteById + * @param id 主键编号 * @return Object */ - @GetMapping("/deleteByIds") - public Object deleteByIds(@RequestParam(value = "ids") String ids) { + @GetMapping("/deleteById") + public Object deleteById(@RequestParam(value = "id") String id) { try { - if (ids.indexOf(",") != -1) { - service.removeByIds(Stream.of(ids.split(",")).collect(Collectors.toList())); - }else{ - service.removeById(ids); - } + service.removeById(id); return ReturnSucUtils.getRepInfo(); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); @@ -191,19 +193,47 @@ } /** - * 新增或更新对象 - * @url {ctx}/api/web/ctDept/saveCtDept - * @param ctDept 实体对象 - * @return Object - */ + * 新增部门或更新部门 + * @url {ctx}/api/v1/ctDept/saveCtDept + * @param ctDept 实体对象 + * @return Object + */ @PostMapping("/saveCtDept") - public Object saveCtDept(@RequestBody CtDept ctDept) { + public Object saveCtDept(@RequestBody CtDept ctDept, @CurrentUser String userId) { try { - service.saveCtDept(ctDept); - return ReturnSucUtils.getRepInfo(); + //判断name是否存在 + if (IdUtils.checkNewId(ctDept.getId())) { + Map<String, Object> terms = getParameter(); + terms.put("name", ctDept.getName()); + terms.put("unitId", ctDept.getUnitId()); + long ctDeptCount = service.countTerms(terms); + if (ctDeptCount > 0) { + return ReturnFailUtils.getRepInfo("名称已存在,请重新设定"); + } + } + service.saveCtDept(ctDept, userId); + return ReturnSucUtils.getRepInfo("保存成功", null); } catch (Exception e) { - return ReturnFailUtils.getRepInfo(); + log.error("Controller接口[CtDeptController.saveCtDept]请求异常:"+e, e); + return ReturnFailUtils.getRepInfo("保存失败", null); } } + /** + * 根据主键编号删除部门 + * @url {ctx}/api/v1/ctDept/removeByIds + * @param ids 主键编号 + * @return Object + * @throws Exception + */ + @GetMapping("/removeByIds") + public Object removeByIds(@RequestParam(value = "ids") String ids) { + try { + service.removeById(ids); + return ReturnSucUtils.getRepInfo(); + } catch (Exception e) { + log.error("Controller接口[CtDeptController.removeByIds]请求异常:"+e, e); + return ReturnFailUtils.getRepInfo(); + } + } } -- Gitblit v1.8.0