| | |
| | | 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; |
| | |
| | | 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-web端 |
| | |
| | | |
| | | @Autowired |
| | | private CtDeptService service; |
| | | |
| | | @Autowired |
| | | private CtUserService ctUserService; |
| | | |
| | | /** |
| | | * 获取请求URL参数 |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 新增或更新对象 |
| | | * @url {ctx}/api/web/ctDept/saveCtDept |
| | | * @param ctDept 实体对象 |
| | | * @return Object |
| | | */ |
| | | * 新增部门或更新部门 |
| | | * @url {ctx}/api/web/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/web/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(); |
| | | } |
| | | } |
| | | } |