Commit 0b8225c2 by qwmqiuwenmin

部门相关

parent 79fc354a
......@@ -52,6 +52,11 @@
<artifactId>haoban-base-api</artifactId>
<version>${haoban-base-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>haoban-common</artifactId>
<version>${haoban-common}</version>
</dependency>
</dependencies>
<build>
......
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
import java.util.Date;
public class DepartmentDTO implements Serializable {
private String departmentId;
private String departmentName;
private String parentDepartmentId;
private String relatedId;
private String chainId;
private Integer isStore;
private Integer statusFlag;
private Integer recycleFlag;
private Date createTime;
private Date updateTime;
private String wxDepartmentId;
private static final long serialVersionUID = 1L;
public String getDepartmentId() {
return departmentId;
}
public void setDepartmentId(String departmentId) {
this.departmentId = departmentId == null ? null : departmentId.trim();
}
public String getDepartmentName() {
return departmentName;
}
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName == null ? null : departmentName.trim();
}
public String getParentDepartmentId() {
return parentDepartmentId;
}
public void setParentDepartmentId(String parentDepartmentId) {
this.parentDepartmentId = parentDepartmentId == null ? null : parentDepartmentId.trim();
}
public String getRelatedId() {
return relatedId;
}
public void setRelatedId(String relatedId) {
this.relatedId = relatedId == null ? null : relatedId.trim();
}
public String getChainId() {
return chainId;
}
public void setChainId(String chainId) {
this.chainId = chainId == null ? null : chainId.trim();
}
public Integer getIsStore() {
return isStore;
}
public void setIsStore(Integer isStore) {
this.isStore = isStore;
}
public Integer getStatusFlag() {
return statusFlag;
}
public void setStatusFlag(Integer statusFlag) {
this.statusFlag = statusFlag;
}
public Integer getRecycleFlag() {
return recycleFlag;
}
public void setRecycleFlag(Integer recycleFlag) {
this.recycleFlag = recycleFlag;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getWxDepartmentId() {
return wxDepartmentId;
}
public void setWxDepartmentId(String wxDepartmentId) {
this.wxDepartmentId = wxDepartmentId;
}
}
package com.gic.haoban.manage.api.service;
import java.util.List;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
public interface DepartmentApiService {
List<DepartmentDTO> listByParentId(String parentId);
/**
* 根据部门id查询部门
* @param departmentId
* @return
*/
DepartmentDTO selectById(String departmentId);
/**
* 新增部门
* @param department
* @return
*/
HaobanResponse add(DepartmentDTO department);
/**
* 修改部门
* @param department
* @return
*/
HaobanResponse edit(DepartmentDTO department);
/**
* 删除部门
* @param departmentId
* @return
*/
HaobanResponse del(String departmentId);
}
package com.gic.haoban.manage.service.dao.mapper;
import java.util.List;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
public interface DepartmentMapper {
......@@ -14,4 +16,6 @@ public interface DepartmentMapper {
int updateByPrimaryKeySelective(TabHaobanDepartment record);
int updateByPrimaryKey(TabHaobanDepartment record);
List<TabHaobanDepartment> listByParentId(String parentId);
}
\ No newline at end of file
......@@ -24,6 +24,8 @@ public class TabHaobanDepartment implements Serializable {
private Date updateTime;
private String wxDepartmentId;
private static final long serialVersionUID = 1L;
public String getDepartmentId() {
......@@ -105,4 +107,14 @@ public class TabHaobanDepartment implements Serializable {
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getWxDepartmentId() {
return wxDepartmentId;
}
public void setWxDepartmentId(String wxDepartmentId) {
this.wxDepartmentId = wxDepartmentId;
}
}
\ No newline at end of file
package com.gic.haoban.manage.service.service;
import java.util.List;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
public interface DepartmentService {
List<TabHaobanDepartment> listByParentId(String parentId);
TabHaobanDepartment selectById(String departmentId);
String add(DepartmentDTO department);
void edit(DepartmentDTO department);
void del(String departmentId);
}
package com.gic.haoban.manage.service.service.impl;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.service.DepartmentService;
@Service
public class DepartmentApiServiceImpl implements DepartmentApiService {
@Autowired
private DepartmentService departmentService;
@Override
public List<DepartmentDTO> listByParentId(String parentId) {
List<TabHaobanDepartment> list = departmentService.listByParentId(parentId);
return EntityUtil.changeEntityListByJSON(DepartmentDTO.class, list);
}
@Override
public DepartmentDTO selectById(String departmentId) {
TabHaobanDepartment tab = departmentService.selectById(departmentId);
return EntityUtil.changeEntityByJSON(DepartmentDTO.class, tab);
}
@Override
public HaobanResponse add(DepartmentDTO department) {
HaobanResponse hr = new HaobanResponse();
hr.setErrorCode(1);
//调微信的新增接口
String wxDepartmentId = "";
if(StringUtils.isBlank(wxDepartmentId)) {
hr.setErrorCode(0);
hr.setMessage("微信新增部门失败");
return hr;
}
department.setWxDepartmentId(wxDepartmentId);
departmentService.add(department);
return hr;
}
@Override
public HaobanResponse edit(DepartmentDTO department) {
HaobanResponse hr = new HaobanResponse();
hr.setErrorCode(1);
//调微信的修改接口
String wxDepartmentId = "";
if(StringUtils.isBlank(wxDepartmentId)) {
hr.setErrorCode(0);
hr.setMessage("微信修改部门失败");
return hr;
}
departmentService.edit(department);
return hr;
}
@Override
public HaobanResponse del(String departmentId) {
HaobanResponse hr = new HaobanResponse();
hr.setErrorCode(1);
//调微信的新增接口
String wxDepartmentId = "";
if(StringUtils.isBlank(wxDepartmentId)) {
hr.setErrorCode(0);
hr.setMessage("微信删除部门失败");
return hr;
}
departmentService.del(departmentId);
return hr;
}
}
package com.gic.haoban.manage.service.service.out.impl;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.service.dao.mapper.DepartmentMapper;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.service.DepartmentService;
@Service
public class DepartmentServiceImpl implements DepartmentService {
@Autowired
private DepartmentMapper mapper;
@Override
public List<TabHaobanDepartment> listByParentId(String parentId) {
return mapper.listByParentId(parentId);
}
@Override
public TabHaobanDepartment selectById(String departmentId) {
return mapper.selectByPrimaryKey(departmentId);
}
@Override
public String add(DepartmentDTO department) {
Date now = new Date();
TabHaobanDepartment tab = EntityUtil.changeEntityByJSON(TabHaobanDepartment.class, department);
tab.setCreateTime(now);
tab.setUpdateTime(now);
tab.setStatusFlag(1);
tab.setDepartmentId(StringUtil.randomUUID());
mapper.insert(tab);
return tab.getDepartmentId();
}
@Override
public void edit(DepartmentDTO department) {
Date now = new Date();
TabHaobanDepartment tab = EntityUtil.changeEntityByJSON(TabHaobanDepartment.class, department);
tab.setUpdateTime(now);
mapper.updateByPrimaryKeySelective(tab);
}
@Override
public void del(String departmentId) {
mapper.deleteByPrimaryKey(departmentId);
}
}
......@@ -12,10 +12,11 @@
<result column="recycle_flag" property="recycleFlag" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="wx_department_id" property="wxDepartmentId" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
department_id, department_name, parent_department_id, related_id, chain_id, is_store,
status_flag, recycle_flag, create_time, update_time
status_flag, recycle_flag, create_time, update_time,wx_department_id
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
......@@ -31,11 +32,11 @@
insert into tab_haoban_department (department_id, department_name, parent_department_id,
related_id, chain_id, is_store,
status_flag, recycle_flag, create_time,
update_time)
update_time,wx_department_id)
values (#{departmentId,jdbcType=VARCHAR}, #{departmentName,jdbcType=VARCHAR}, #{parentDepartmentId,jdbcType=VARCHAR},
#{relatedId,jdbcType=VARCHAR}, #{chainId,jdbcType=VARCHAR}, #{isStore,jdbcType=INTEGER},
#{statusFlag,jdbcType=INTEGER}, #{recycleFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
#{updateTime,jdbcType=TIMESTAMP},#{wxDepartmentId})
</insert>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanDepartment" >
insert into tab_haoban_department
......@@ -70,6 +71,9 @@
<if test="updateTime != null" >
update_time,
</if>
<if test="wxDepartmentId != null" >
wx_department_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="departmentId != null" >
......@@ -102,6 +106,9 @@
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="wxDepartmentId != null" >
#{wxDepartmentId},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanDepartment" >
......@@ -134,6 +141,9 @@
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="wxDepartmentId != null" >
wx_department_id = #{wxDepartmentId,jdbcType=VARCHAR},
</if>
</set>
where department_id = #{departmentId,jdbcType=VARCHAR}
</update>
......@@ -143,6 +153,7 @@
parent_department_id = #{parentDepartmentId,jdbcType=VARCHAR},
related_id = #{relatedId,jdbcType=VARCHAR},
chain_id = #{chainId,jdbcType=VARCHAR},
wx_department_id = #{wxDepartmentId,jdbcType=VARCHAR},
is_store = #{isStore,jdbcType=INTEGER},
status_flag = #{statusFlag,jdbcType=INTEGER},
recycle_flag = #{recycleFlag,jdbcType=INTEGER},
......@@ -150,4 +161,12 @@
update_time = #{updateTime,jdbcType=TIMESTAMP}
where department_id = #{departmentId,jdbcType=VARCHAR}
</update>
<select id="listByParentId" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_department
where parent_department_id = #{parentId,jdbcType=VARCHAR}
and status_flag = 1
</select>
</mapper>
\ No newline at end of file
package com.gic.haoban.manage.web.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gic.haoban.base.api.common.Constant;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
@RestController
public class DepartmentContoller extends WebBaseController{
@Autowired
private DepartmentApiService departmentApiService;
@RequestMapping("department-list")
public HaobanResponse departmentList(String parentId) {
List<DepartmentDTO> list = departmentApiService.listByParentId(parentId);
return resultResponse(HaoBanErrCode.ERR_1,list);
}
@RequestMapping("department-add")
public HaobanResponse departmentAdd(String parentId,String departmentName) {
DepartmentDTO dto = departmentApiService.selectById(parentId);
if(dto == null || dto.getStatusFlag() == 0) {
return resultResponse(HaoBanErrCode.ERR_10001);
}
if(dto.getIsStore() == 1) {
return resultResponse(HaoBanErrCode.ERR_10002);
}
DepartmentDTO department = new DepartmentDTO();
department.setParentDepartmentId(parentId);
department.setDepartmentName(departmentName);
department.setChainId(dto.getChainId() + Constant.ID_SEPARATOR + dto.getDepartmentId());
department.setIsStore(0);
departmentApiService.add(department);
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("department-edit")
public HaobanResponse departmentEdit(String departmentId,String departmentName) {
DepartmentDTO dto = departmentApiService.selectById(departmentId);
if(dto == null || dto.getStatusFlag() == 0) {
return resultResponse(HaoBanErrCode.ERR_10001);
}
dto.setDepartmentName(dto.getDepartmentName());
departmentApiService.edit(dto);
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("department-sel")
public HaobanResponse departmentSel(String departmentId) {
DepartmentDTO dto = departmentApiService.selectById(departmentId);
if(dto == null || dto.getStatusFlag() == 0) {
return resultResponse(HaoBanErrCode.ERR_10003);
}
return resultResponse(HaoBanErrCode.ERR_1,dto);
}
@RequestMapping("department-del")
public HaobanResponse departmentDel(String departmentId) {
DepartmentDTO dto = departmentApiService.selectById(departmentId);
if(dto == null || dto.getStatusFlag() == 0) {
return resultResponse(HaoBanErrCode.ERR_10003);
}
departmentApiService.del(departmentId);
return resultResponse(HaoBanErrCode.ERR_1);
}
}
......@@ -61,114 +61,10 @@ public enum HaoBanErrCode {
*/
ERR_12(12, "验证码校验失败"),
/**
* 员工档案模块
*/
ERR_400001(400001, "通讯录中不存在"),
ERR_400002(400002, "企业不存在"),
ERR_400003(400003, "品牌不存在"),
ERR_400004(400004, "excel文件格式有问题"),
ERR_400005(400005, "选择文件错误"),
ERR_400006(400006, "模板内容为空"),
ERR_400007(400007, "总列数与模板不一致"),
ERR_400008(400008, "导入的title跟模板title描述不匹配"),
ERR_400009(400009, "共享企业或取得共享企业已达最大数量"),
ERR_400010(400010, "不是该企业无权限添加"),
ERR_400011(400011, "添加共享企业重复"),
ERR_400012(400012, "员工档案不存在"),
ERR_400013(400013, "没有查看共享通讯录的权限"),
ERR_400014(400014, "仅支持认证企业建立企业通讯录共享"),
ERR_400015(400015, "数据为空"),
ERR_400016(400016, "提交人不存在"),
/**
* 文件不存在
*/
ERR_20001(201, "文件不存在"),
/**
* 文件格式错误
*/
ERR_20002(202, "文件格式错误"),
/**
* 文件读取失败
*/
ERR_20003(203, "文件读取失败"),
/**
* 文件列数错误
*/
ERR_20004(204, "文件列数错误"),
//登录权限
ERR_30001(30001, "请添加权限"),
ERR_30002(30002, "二维码超时,请刷新二维码"),
ERR_30003(30003, "您没有管理员权限"),
ERR_30004(30004, "登录超时,请重新登录"),
ERR_30005(30005, "用户不存在"),
ERR_30006(30006, "用户名或密码错误"),
ERR_30007(30007, "未设置密码,请先设置密码"),
ERR_30008(30008, "超级管理员不存在"),
//角色
ERR_40001(40001, "角色异常"),
ERR_500002(500002, "角色下存在管理员,请移除管理员!"),
/**
* 办理离职
*/
ERR_100001(100001, "办理离职成功"),
ERR_100002(100002, "正在等待审核"),
ERR_100003(100003, "办理转正成功"),
ERR_100004(100004, "已经离职"),
ERR_100005(100005, "已经转正"),
ERR_100006(100006, "店长不能办理离职"),
ERR_100007(100007, "管理员不能办理离职"),
ERR_100008(100008, "与gic关联不能办理离职"),
/**
* 通讯录模块
*/
ERR_111111(111111, "用户已存在"),
ERR_111112(111112, "层级不能超过6"),
ERR_111113(111113, "店铺已存在"),
ERR_111114(111114, "该员工已在行政架构下"),
ERR_111115(1111115, "该员工已在门店架构下"),
ERR_111116(111116, "code不能为空"),
ERR_111117(111117, "code已存在"),
ERR_111118(111118, "部门不能为空"),
ERR_111119(111119, "门店不能为空"),
ERR_111120(111120, "手机不能为空"),
ERR_111121(111121, "姓名不能为空"),
ERR_111122(111122, "门店名称不能为空"),
ERR_111123(111123, "店长名称不能为空"),
ERR_111124(111124, "店长电话不能为空"),
ERR_111125(111125, "门店编号不能为空"),
ERR_111126(111126, "门店编号已存在"),
ERR_111127(111127, "该部门下存在部门不让删除"),
ERR_111128(111128, "该部门下存在店铺不让删除"),
ERR_111129(111129, "该部门下存在人员不让删除"),
ERR_111130(111130, "品牌不能修改"),
ERR_111131(111131, "店长不能删除"),
ERR_111132(111132, "管理员不能删除"),
ERR_111133(111133, "品牌名称不能重复"),
ERR_111134(111134, "未认证企业只能导入30家门店"),
ERR_111135(111135, "未认证企业只能导入200个用户"),
ERR_111136(111136, "部门名称不能重复"),
ERR_111137(111137, "其他管理员正在导入"),
ERR_111138(111138, "企业每次最多只能导入800个用户"),
ERR_111139(111134, "未认证企业只能导入200家门店"),
ERR_111140(111140,"已经与gic关联,无法操作"),
ERR_111141(111141,"门店面积不能超过999999"),
ERR_111142(111142,"品牌不能为空"),
ERR_111143(111143,"code或者手机号码已存在"),
ERR_111144(111144,"该企业或品牌已关联"),
// 企业设置
ERR_200001(200001, "员工不存在"),
ERR_200002(200002, "非当前登录企业员工"),
ERR_10001(10001,"父部门不存在"),
ERR_10002(10002,"门店类型部门不能新增子节点"),
ERR_10003(10003,"部门不存在"),
ERR_500001(500001, "该企业没关联好办"),
ERR_DEFINE(-888, "自定义错误"),
ERR_OTHER(-999, "未知错误code");
private int code;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment