Commit c25c57d6 by 陶光胜

Merge branch 'developer' of http://115.159.76.241/haoban3.0/haoban-manage3.0 into developer

parents c6e7bc9b 1229a6c9
......@@ -43,6 +43,10 @@ public class DepartmentDTO implements Serializable {
private Integer bindFlag;
private String relatedCode;
private String gicEnterpriseName;
private static final long serialVersionUID = 1L;
public String getDepartmentId() {
......@@ -197,6 +201,22 @@ public class DepartmentDTO implements Serializable {
this.bindFlag = bindFlag;
}
public String getRelatedCode() {
return relatedCode;
}
public void setRelatedCode(String relatedCode) {
this.relatedCode = relatedCode;
}
public String getGicEnterpriseName() {
return gicEnterpriseName;
}
public void setGicEnterpriseName(String gicEnterpriseName) {
this.gicEnterpriseName = gicEnterpriseName;
}
}
......@@ -18,4 +18,12 @@ public interface WxApplicationApiService {
* @param suiteId
*/
void cancelSuite(String corpId, String suiteId);
/**
*
* @param wxEnterpriseId
* @param type
* @return
*/
WxApplicationDTO selectByWxEnterpriseIdAndApplicationType(String wxEnterpriseId, int type);
}
......@@ -34,6 +34,8 @@ public class TabHaobanDepartment implements Serializable {
private String wxEnterpriseId;
private String relatedCode;
private static final long serialVersionUID = 1L;
public String getDepartmentId() {
......@@ -156,5 +158,13 @@ public class TabHaobanDepartment implements Serializable {
this.chainName = chainName;
}
public String getRelatedCode() {
return relatedCode;
}
public void setRelatedCode(String relatedCode) {
this.relatedCode = relatedCode;
}
}
\ No newline at end of file
......@@ -37,7 +37,7 @@ public class StaffServiceImpl implements StaffService {
tab.setUpdateTime(now);
tab.setStaffId(StringUtil.randomUUID());
tab.setStatusFlag(1);
if(StringUtils.isBlank(tab.getStaffId())){
if(StringUtils.isBlank(tab.getWxUserId())){
tab.setWxUserId(tab.getStaffId());
}
mapper.insertSelective(tab);
......
......@@ -91,6 +91,12 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
logger.info("【部门新增】enterpriseDTO = {}",JSON.toJSONString(enterpriseDTO));
if(enterpriseDTO != null) {
if(application != null) {
Integer sort = department.getSort();
if(sort == null) {
int maxSort = departmentMapper.selectMaxSort(department.getParentDepartmentId());
department.setSort(maxSort + 1);
}
com.gic.wechat.api.dto.qywx.DepartmentDTO dto = new com.gic.wechat.api.dto.qywx.DepartmentDTO();
dto.setCorpid(enterpriseDTO.getCorpid());
dto.setName(department.getDepartmentName());
......@@ -157,6 +163,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
hr.setErrorCode(1);
List<TabHaobanDepartment> list = departmentService.listByParentId(departmentId);
logger.info("【部门删除】list.size={}",list.size());
if(!list.isEmpty()) {
hr.setErrorCode(0);
hr.setMessage("存在子部门,删除部门失败");
......@@ -164,6 +171,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
}
List<TabHaobanStaffDepartmentRelated> staffList = staffDepartmentService.listByDepartmentId(departmentId);
logger.info("【部门删除】staffList.size={}",staffList.size());
if(!staffList.isEmpty()) {
hr.setErrorCode(0);
hr.setMessage("存在成员,删除部门失败");
......@@ -198,6 +206,22 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
public HaobanResponse recycle(String departmentId) {
HaobanResponse hr = new HaobanResponse();
hr.setErrorCode(1);
List<TabHaobanDepartment> list = departmentService.listByParentId(departmentId);
logger.info("【部门删除】list.size={}",list.size());
if(!list.isEmpty()) {
hr.setErrorCode(0);
hr.setMessage("存在子部门,删除部门失败");
return hr;
}
List<TabHaobanStaffDepartmentRelated> staffList = staffDepartmentService.listByDepartmentId(departmentId);
logger.info("【部门删除】staffList.size={}",staffList.size());
if(!staffList.isEmpty()) {
hr.setErrorCode(0);
hr.setMessage("存在成员,删除部门失败");
return hr;
}
//调微信的新增接口
TabHaobanDepartment department = departmentService.selectById(departmentId);
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId());
......
......@@ -75,6 +75,7 @@ public class MessageApiServiceImpl implements MessageApiService {
departmentDTO.setDepartmentName(dto.getName());
departmentDTO.setIsStore(dto.getType() != GicDataType.STORE.getCode() ? 0 : 1);
departmentDTO.setRelatedId(dto.getId());
log.info("【部门同步】dto={}",JSON.toJSONString(dto));
DepartmentDTO parentDepartment = this.getParentDepartment(dto.getParentChain(), dto.getType(), enterprise.getWxEnterpriseId());
departmentDTO.setParentDepartmentId(parentDepartment.getDepartmentId());
departmentDTO.setChainId(parentDepartment.getChainId()+ Constant.ID_SEPARATOR + parentDepartment.getDepartmentId());
......@@ -110,6 +111,7 @@ public class MessageApiServiceImpl implements MessageApiService {
@Override
public void dealWxMessage(String param) {
QywxCallBackDTO dto = JSON.parseObject(param, QywxCallBackDTO.class);
log.info("【处理微信回调】dto={}",JSON.toJSONString(dto));
if(dto.getChangeType().endsWith("party")){
this.dealDepartment(dto);
}else {
......@@ -121,18 +123,22 @@ public class MessageApiServiceImpl implements MessageApiService {
DepartmentDTO departmentDTO = new DepartmentDTO();
departmentDTO.setDepartmentName(qywxCallBackDTO.getDepartmentName());
departmentDTO.setIsStore(0);
departmentDTO.setRelatedId(qywxCallBackDTO.getId()+"");
//departmentDTO.setRelatedId(qywxCallBackDTO.getId()+"");
TabHaobanWxEnterprise enterprise = this.enterpriseService.getEnterpriseBycorpId(qywxCallBackDTO.getAuthCorpId());
TabHaobanDepartment parentDepartment = this.departmentService.getByWxId(qywxCallBackDTO.getParentId() + "", enterprise.getWxEnterpriseId());
if(!qywxCallBackDTO.getChangeType().equals(WxEditType.DELETEDEPART.getCode())){
if(parentDepartment == null){
log.info("微信同步父部门不存在");
return;
}
departmentDTO.setParentDepartmentId(parentDepartment.getDepartmentId());
departmentDTO.setChainId(parentDepartment.getChainId()+ Constant.ID_SEPARATOR + parentDepartment.getDepartmentId());
departmentDTO.setChainName(parentDepartment.getChainName() + Constant.NAME_SEPARATOR + parentDepartment.getChainName());
departmentDTO.setLevel(parentDepartment.getLevel() + 1);
}
departmentDTO.setWxEnterpriseId(enterprise.getWxEnterpriseId());
departmentDTO.setWxDepartmentId(qywxCallBackDTO.getId()+"");
departmentDTO.setSort(qywxCallBackDTO.getOrder());
if(qywxCallBackDTO.getChangeType().equals(WxEditType.ADDDEPART.getCode())){
String response = this.departmentService.add(departmentDTO);
log.info("微信同步新增部门:{}", JSON.toJSONString(response));
......@@ -151,7 +157,11 @@ public class MessageApiServiceImpl implements MessageApiService {
if(department == null){
log.info("微信同步删除部门不存在");
}else {
this.departmentService.del(departmentDTO.getDepartmentId());
if(StringUtils.isBlank(department.getRelatedId())){
this.departmentService.del(department.getDepartmentId());
}else{
this.departmentApiService.recycle(department.getDepartmentId());
}
log.info("企业微信删除同步完成");
}
}
......
......@@ -92,6 +92,7 @@ public class StaffApiServiceImpl implements StaffApiService {
HaobanResponse hr = new HaobanResponse();
hr.setErrorCode(1);
Integer activeFlag = staff.getActiveFlag();
staff.setActiveFlag(0);
TabHaobanStaff tab = EntityUtil.changeEntityByJSON(TabHaobanStaff.class, staff);
String staffId = staffService.add(tab);
//调接口获取
......@@ -203,9 +204,11 @@ public class StaffApiServiceImpl implements StaffApiService {
if(enterpriseDTO != null) {
if(application != null) {
JSONResponse jp = qywxUserApiService.deleteWorkWxUser(enterpriseDTO.getCorpid(), application.getSiteId(), staff.getWxUserId());
logger.info("【删除成员】jp={}",JSON.toJSONString(jp));
}
}
staffDepartmentRelatedService.del(related);
staffService.delByuserid(relatedList.get(0).getStaffId());
//走修改流程
}else {
String departmentIds = "";
......@@ -246,6 +249,7 @@ public class StaffApiServiceImpl implements StaffApiService {
tab.setNickName(user.getName());
tab.setNationCode("86");
tab.setSex(Integer.parseInt(user.getGender()));
tab.setActiveFlag(1);
String staffId = staffService.add(tab);
Integer[] departmentId = user.getDepartment();
......
......@@ -39,4 +39,9 @@ public class WxApplicationApiServiceImpl implements WxApplicationApiService{
}
log.info("企业未绑定过,{}", corpId);
}
@Override
public WxApplicationDTO selectByWxEnterpriseIdAndApplicationType(String wxEnterpriseId, int type) {
return EntityUtil.changeEntityByJSON(WxApplicationDTO.class, wxApplicationService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, type));
}
}
......@@ -38,44 +38,38 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
List<TabHaobanWxEnterpriseRelated> relatedList = wxEnterpriseRelatedMapper.listByWxenterpriseId(wxEnterpriseId);
List<EnterpriseDetailDTO> result = EntityUtil.changeEntityListByJSON(EnterpriseDetailDTO.class, relatedList);
for (EnterpriseDetailDTO enterpriseDetailDTO : result) {
String enterpriseId = enterpriseDetailDTO.getEnterpriseId();
// String enterpriseId = enterpriseDetailDTO.getEnterpriseId();
int nodeCount = 0;
// List<GicTreeDTO> departmentList = storeGroupService.listGicTree(enterpriseId,1, null);
// List<GicTreeDTO> departmentList = storeGroupService.listGicTree(enterpriseId,null, null);
// for (GicTreeDTO gicTreeDTO : departmentList) {
// if(departmentService.getByRelatedId(gicTreeDTO.getId()) == null) {
// nodeCount ++;
// }
// nodeCount += getNodeCount(enterpriseId,gicTreeDTO.getId(),gicTreeDTO.getType());
// }
// List<GicTreeDTO> departmentList2 = storeGroupService.listGicTree(enterpriseId,2, null);
// for (GicTreeDTO gicTreeDTO : departmentList2) {
// if(departmentService.getByRelatedId(gicTreeDTO.getId()) == null) {
// nodeCount ++;
// }
// nodeCount += getNodeCount(enterpriseId,gicTreeDTO.getId(),gicTreeDTO.getType());
// }
enterpriseDetailDTO.setNodeCount(nodeCount);
}
return result;
}
public int getNodeCount(String enterpriseId,String parentId,int type) {
int nodeCount = 0;
List<GicTreeDTO> departmentList = storeGroupService.listGicTree(enterpriseId,type, parentId);
for (GicTreeDTO gicTreeDTO : departmentList) {
if(departmentService.getByRelatedId(gicTreeDTO.getId()) == null) {
nodeCount ++;
}
}
while(departmentList.isEmpty()) {
for (GicTreeDTO gicTreeDTO : departmentList) {
nodeCount += getNodeCount(enterpriseId,gicTreeDTO.getId(),gicTreeDTO.getType());
}
}
return nodeCount;
}
// public int getNodeCount(String enterpriseId,String parentId,int type) {
// int nodeCount = 0;
// List<GicTreeDTO> departmentList = storeGroupService.listGicTree(enterpriseId,type, parentId);
// for (GicTreeDTO gicTreeDTO : departmentList) {
// if(departmentService.getByRelatedId(gicTreeDTO.getId()) == null) {
// nodeCount ++;
// }
// List<GicTreeDTO> departmentList2 = storeGroupService.listGicTree(enterpriseId,gicTreeDTO.getType(), gicTreeDTO.getId());
// while(!departmentList2.isEmpty()) {
// for (GicTreeDTO gicTreeDTO2 : departmentList) {
// nodeCount += getNodeCount(enterpriseId,gicTreeDTO2.getId(),gicTreeDTO2.getType());
// }
// }
// }
//
// return nodeCount;
//
// }
@Override
public int wxEnterpriseBind(String enterpriseId, String wxEnterpriseId,
String version) {
......
......@@ -6,6 +6,7 @@
<result column="department_name" property="departmentName" jdbcType="VARCHAR" />
<result column="parent_department_id" property="parentDepartmentId" jdbcType="VARCHAR" />
<result column="related_id" property="relatedId" jdbcType="VARCHAR" />
<result column="related_code" property="relatedCode" jdbcType="VARCHAR" />
<result column="chain_id" property="chainId" jdbcType="VARCHAR" />
<result column="chain_name" property="chainName" jdbcType="VARCHAR" />
<result column="is_store" property="isStore" jdbcType="INTEGER" />
......@@ -19,7 +20,7 @@
<result column="level" property="level" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
department_id, department_name, parent_department_id, related_id, chain_id, is_store,
department_id, department_name, parent_department_id, related_id, related_code,chain_id, is_store,
status_flag, recycle_flag, create_time, update_time,wx_department_id,sort,level,wx_enterprise_id,chain_name
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
......@@ -34,11 +35,11 @@
</delete>
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanDepartment" >
insert into tab_haoban_department (department_id, department_name, parent_department_id,
related_id, chain_id, is_store,
related_id,related_code, chain_id, is_store,
status_flag, recycle_flag, create_time,
update_time,wx_department_id,sort,level,wx_enterprise_id,chain_name)
values (#{departmentId,jdbcType=VARCHAR}, #{departmentName,jdbcType=VARCHAR}, #{parentDepartmentId,jdbcType=VARCHAR},
#{relatedId,jdbcType=VARCHAR}, #{chainId,jdbcType=VARCHAR}, #{isStore,jdbcType=INTEGER},
#{relatedId,jdbcType=VARCHAR},#{relatedCode,jdbcType=VARCHAR}, #{chainId,jdbcType=VARCHAR}, #{isStore,jdbcType=INTEGER},
#{statusFlag,jdbcType=INTEGER}, #{recycleFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP},#{wxDepartmentId},#{sort},#{level},#{wxEnterpriseId},#{chainName})
</insert>
......@@ -57,6 +58,9 @@
<if test="relatedId != null" >
related_id,
</if>
<if test="relatedCode != null" >
related_code,
</if>
<if test="chainId != null" >
chain_id,
</if>
......@@ -101,6 +105,9 @@
<if test="relatedId != null" >
#{relatedId,jdbcType=VARCHAR},
</if>
<if test="relatedCode != null" >
#{relatedCode,jdbcType=VARCHAR},
</if>
<if test="chainId != null" >
#{chainId,jdbcType=VARCHAR},
</if>
......@@ -145,6 +152,9 @@
<if test="relatedId != null" >
related_id = #{relatedId,jdbcType=VARCHAR},
</if>
<if test="relatedCode != null" >
related_code = #{relatedCode,jdbcType=VARCHAR},
</if>
<if test="chainId != null" >
chain_id = #{chainId,jdbcType=VARCHAR},
</if>
......@@ -186,6 +196,7 @@
set department_name = #{departmentName,jdbcType=VARCHAR},
parent_department_id = #{parentDepartmentId,jdbcType=VARCHAR},
related_id = #{relatedId,jdbcType=VARCHAR},
related_code = #{relatedCode,jdbcType=VARCHAR},
chain_id = #{chainId,jdbcType=VARCHAR},
chain_name = #{chainName,jdbcType=VARCHAR},
wx_department_id = #{wxDepartmentId,jdbcType=VARCHAR},
......@@ -245,7 +256,7 @@
and wx_enterprise_id = #{wxEnterpriseId}
</if>
<if test="keyword != null and keyword != ''">
and department_name like CONCAT('%',#{keyword},'%')
and (department_name like CONCAT('%',#{keyword},'%') or wx_department_id like CONCAT('%',#{keyword},'%') or related_code like CONCAT('%',#{keyword},'%'))
</if>
<if test="recycleFlag != null">
and recycle_flag = #{recycleFlag}
......@@ -253,6 +264,7 @@
<if test="storeFlag != null">
and is_store = #{storeFlag}
</if>
order by sort asc
</select>
<select id="listByDepartmentIds" resultMap="BaseResultMap" >
......@@ -351,13 +363,14 @@
<include refid="Base_Column_List" />
from tab_haoban_department
where status_flag = 1
and recycle_flag != 1
<if test="parentId != null and parentId != ''">
and parent_department_id = #{parentId}
</if>
<if test="keyword != null and keyword != ''">
and (department_name like CONCAT('%',#{keyword},'%') or department_id like CONCAT('%',#{keyword},'%'))
and (department_name like CONCAT('%',#{keyword},'%') or wx_department_id like CONCAT('%',#{keyword},'%'))
</if>
order by sort asc
</select>
......
......@@ -257,7 +257,7 @@
from tab_haoban_staff
where status_flag = 1
<if test="keyword != null and keyword != ''">
and (staff_name like CONCAT('%',#{keyWord},'%') or phone_number like CONCAT('%',#{keyWord},'%'))
and (staff_name like CONCAT('%',#{keyword},'%') or phone_number like CONCAT('%',#{keyword},'%'))
</if>
<if test="activeFlag != null">
and active_flag = #{activeFlag}
......
......@@ -16,8 +16,11 @@ import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.gic.api.base.commons.Page;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.dto.GicTreeDTO;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.dto.StoreGroupDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.StoreGroupService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.BasePageInfo;
......@@ -37,6 +40,8 @@ import com.gic.haoban.manage.web.vo.LoginVO;
import com.gic.haoban.manage.web.vo.StoreVo;
import com.gic.redis.data.util.RedisUtil;
import okhttp3.internal.http2.ErrorCode;
@RestController
public class DepartmentContoller extends WebBaseController{
......@@ -50,6 +55,9 @@ public class DepartmentContoller extends WebBaseController{
private StoreService storeService;
@Autowired
private StaffApiService staffApiService;
@Autowired
private EnterpriseService enterpriseService;
@RequestMapping("department-list")
public HaobanResponse departmentList(String parentId,BasePageInfo pageInfo,String keyWord) {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
......@@ -100,9 +108,28 @@ public class DepartmentContoller extends WebBaseController{
list.add(dto);
}
for (DepartmentDTO departmentDTO : list) {
if(StringUtils.isBlank(departmentDTO.getRelatedId())){
String relatedId = departmentDTO.getRelatedId();
if(StringUtils.isBlank(relatedId)){
departmentDTO.setBindFlag(0);
}else{
String gicEnterpriseName = "";
String gicEnterpriseId = "";
if(departmentDTO.getIsStore() == 1){
StoreDTO store = storeService.getStore(relatedId);
if(store != null){
gicEnterpriseId = store.getEnterpriseId();
}
}else{
StoreGroupDTO department = storeGroupService.getStoreGroupById(relatedId);
if(department != null){
gicEnterpriseId = department.getEnterpriseId();
}
}
EnterpriseDTO enterprise = enterpriseService.getEnterpriseById(gicEnterpriseId);
if(enterprise != null){
gicEnterpriseName = enterprise.getEnterpriseName();
}
departmentDTO.setGicEnterpriseName(gicEnterpriseName);
departmentDTO.setBindFlag(1);
}
}
......@@ -127,9 +154,12 @@ public class DepartmentContoller extends WebBaseController{
department.setChainId(dto.getChainId() + Constant.ID_SEPARATOR + dto.getDepartmentId());
department.setIsStore(0);
department.setLevel(dto.getLevel() + 1);
departmentApiService.add(department);
HaobanResponse hr = departmentApiService.add(department);
if(hr.getErrorCode() != 1){
return resultResponse(HaoBanErrCode.ERR_DEFINE, hr.getMessage(), null, hr.getMessage());
}
return resultResponse(HaoBanErrCode.ERR_1,department);
return resultResponse(HaoBanErrCode.ERR_1,hr.getResult());
}
......@@ -139,7 +169,7 @@ public class DepartmentContoller extends WebBaseController{
if(dto == null || dto.getStatusFlag() == 0) {
return resultResponse(HaoBanErrCode.ERR_10001);
}
dto.setDepartmentName(dto.getDepartmentName());
dto.setDepartmentName(departmentName);
departmentApiService.edit(dto);
return resultResponse(HaoBanErrCode.ERR_1);
......@@ -183,7 +213,7 @@ public class DepartmentContoller extends WebBaseController{
}
if(hr.getErrorCode() == 0) {
return resultResponse(HaoBanErrCode.ERR_0, hr.getMessage());
return resultResponse(HaoBanErrCode.ERR_0, hr.getMessage(),null,hr.getMessage());
}
return resultResponse(HaoBanErrCode.ERR_1);
......@@ -207,8 +237,13 @@ public class DepartmentContoller extends WebBaseController{
}
Integer type = departmentAddQO.getType();
Integer isStore = 0;
String storeCode = "";
if(type != null && type == 3){
isStore = 1;
StoreDTO store = storeService.getStore(departmentAddQO.getRelatedId());
if(store != null){
storeCode = store.getStoreCode();
}
}
DepartmentDTO department = new DepartmentDTO();
department.setParentDepartmentId(parentId);
......@@ -225,6 +260,7 @@ public class DepartmentContoller extends WebBaseController{
department.setSort(departmentAddQO.getSort());
department.setLevel(dto.getLevel() + 1);
department.setRelatedId(departmentAddQO.getRelatedId());
department.setStoreCode(storeCode);
HaobanResponse hr = departmentApiService.add(department);
if(hr.getErrorCode() != 1) {
continue;
......@@ -381,8 +417,13 @@ public class DepartmentContoller extends WebBaseController{
for (DepartmentAddQO departmentAddQO : list) {
Integer type = departmentAddQO.getType();
Integer isStore = 0;
String storeCode = "";
if(type != null && type == 3){
isStore = 1;
StoreDTO store = storeService.getStore(departmentAddQO.getRelatedId());
if(store != null){
storeCode = store.getStoreCode();
}
}
String sonParentId = "";
DepartmentDTO dto = departmentApiService.selectById(parentId);
......@@ -411,6 +452,7 @@ public class DepartmentContoller extends WebBaseController{
department.setIsStore(isStore);
}
department.setRelatedId(departmentAddQO.getRelatedId());
department.setStoreCode(storeCode);
HaobanResponse hr = departmentApiService.add(department);
if(hr.getErrorCode() != 1) {
continue;
......
......@@ -86,6 +86,18 @@ public class LoginController extends WebBaseController{
}
@RequestMapping("login_local")
public HaobanResponse login() {
LoginVO loginVO = new LoginVO();
StaffDTO staff = staffApiService.selectById("1");
logger.info("【好办登录】staff={}",JSON.toJSONString(staff));
loginVO.setWxEnterpriseId(staff.getWxEnterpriseId());
loginVO.setStaffDTO(staff);
AuthRequestUtil.setSessionUser(loginVO);
return resultResponse(HaoBanErrCode.ERR_1,loginVO);
}
@RequestMapping("get-login-info")
public HaobanResponse getLoginInfo(){
LoginVO loginVO = (LoginVO) AuthRequestUtil.getSessionUser();
......
......@@ -18,15 +18,18 @@ import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.dto.WxApplicationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.api.service.WxApplicationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.web.auth.AuthRequestUtil;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.StaffEditJsonQO;
import com.gic.haoban.manage.web.vo.LoginVO;
import com.google.gson.JsonArray;
import com.squareup.moshi.Json;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
@RestController
......@@ -39,6 +42,12 @@ public class StaffController extends WebBaseController{
private DepartmentApiService departmentApiService;
@Autowired
private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService;
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private WxApplicationApiService wxApplicationApiService;
@RequestMapping("staff-add")
public HaobanResponse staffAdd(StaffDTO staffDTO,String departmentIds){
......@@ -131,6 +140,32 @@ public class StaffController extends WebBaseController{
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-invite")
public HaobanResponse staffInvite(String staffIds){
if(StringUtils.isBlank(staffIds)){
return resultResponse(HaoBanErrCode.ERR_2);
}
String[] staffArr = staffIds.split(",");
List<String> userArr = new ArrayList<>();
String wxEnterpriseId = "";
for (String staffId : staffArr) {
StaffDTO staff = staffApiService.selectById(staffId);
if(staff != null){
String userId = staff.getWxUserId();
wxEnterpriseId = staff.getWxEnterpriseId();
userArr.add(userId);
}
}
WxEnterpriseDTO enterpriseDTO = wxEnterpriseApiService.getOne(wxEnterpriseId);
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId,1);
if(enterpriseDTO != null) {
if(application != null) {
qywxUserApiService.inviteUser(enterpriseDTO.getCorpid(), application.getSiteId(), userArr);
}
}
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-batch-edit-department")
public HaobanResponse staffBatchEditDepartment(String params){
......
......@@ -38,6 +38,7 @@ public class WebBaseController {
public HaobanResponse resultResponse(HaoBanErrCode errCode, String message,Object data,String detailError) {
HaobanResponse response = new HaobanResponse();
response.setMessage(message);
response.setDetailError(detailError);
response.setErrorCode(errCode.getCode());
return response;
}
......
......@@ -14,6 +14,8 @@ public class DepartmentEditQO implements Serializable{
private Integer sort;
private String parentDepartmentId;
public String getDepartmentId() {
return departmentId;
}
......@@ -23,7 +25,7 @@ public class DepartmentEditQO implements Serializable{
}
public String getParentId() {
return parentId;
return parentDepartmentId;
}
public void setParentId(String parentId) {
......@@ -54,6 +56,14 @@ public class DepartmentEditQO implements Serializable{
this.sort = sort;
}
public String getParentDepartmentId() {
return parentDepartmentId;
}
public void setParentDepartmentId(String parentDepartmentId) {
this.parentDepartmentId = parentDepartmentId;
}
}
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