部门修改

master
LegnaYet 6 years ago
parent ecb062597f
commit c731778ea0

@ -36,4 +36,15 @@ public class DepartmentConreoller extends BaseController {
return fail(); return fail();
} }
} }
@RequestMapping(value = "sync",method = RequestMethod.GET)
public Map<String,Object> syncDepartment(){
try {
Boolean hasAdd = departmentService.syncDepartment();
return data(hasAdd);
}catch (Exception e){
log.error("添加部门失败",e);
return fail();
}
}
} }

@ -0,0 +1,9 @@
package com.kiisoo.ic.department.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kiisoo.ic.department.entity.DepartmentDO;
import org.springframework.stereotype.Repository;
@Repository
public interface PrivilageDepartmentDOMapper extends BaseMapper<DepartmentDO> {
}

@ -1,12 +1,18 @@
package com.kiisoo.ic.department.service; package com.kiisoo.ic.department.service;
import com.kiisoo.ic.department.entity.DepartmentDO; import com.kiisoo.ic.department.entity.DepartmentDO;
import com.kiisoo.ic.department.mapper.PrivilageDepartmentDOMapper;
import com.kiisoo.ic.wx.service.QWMailListManageService; import com.kiisoo.ic.wx.service.QWMailListManageService;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.WxCpDepart;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* @Description: service * @Description: service
* @Auther: yechenhao * @Auther: yechenhao
@ -19,6 +25,9 @@ public class DepartmentService {
@Autowired @Autowired
private QWMailListManageService qwMailListManageService; private QWMailListManageService qwMailListManageService;
@Autowired
private PrivilageDepartmentDOMapper departmentDOMapper;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean addDepartment(DepartmentDO departmentDO) throws WxErrorException { public Boolean addDepartment(DepartmentDO departmentDO) throws WxErrorException {
//数据库创建部门需要返回部门id //数据库创建部门需要返回部门id
@ -28,4 +37,19 @@ public class DepartmentService {
return true; return true;
} }
@Transactional(rollbackFor = Exception.class)
public Boolean syncDepartment() throws WxErrorException {
//获取企业微信部门架构
List<WxCpDepart> wxCpDeparts = qwMailListManageService.syncDepartment();
if (CollectionUtils.isNotEmpty(wxCpDeparts)){
wxCpDeparts.forEach(wxDept -> {
DepartmentDO departmentDO = new DepartmentDO();
BeanUtils.copyProperties(wxDept,departmentDO);
});
}
// departmentDOMapper.insert(departmentDO);
return true;
}
} }

@ -1,31 +1,68 @@
package com.kiisoo.ic.employee.entity; package com.kiisoo.ic.employee.entity;
/**
*
*/
public class PrivilageCpUserDO { public class PrivilageCpUserDO {
private long id;
/**'成员名'*/ /**
private String name; * id
/**企业微信userId账号*/ */
private Long id;
/**
* userId
*/
private String cpUserId; private String cpUserId;
/**privilage_user中id*/ /**
private long userId; *
/**'手机号(唯一)'*/ */
private String name;
/**
*
*/
private String alias;
/**
* '12
*/
private Integer gender;
/**
* 6~64emailmobile/email
*/
private String email;
/**
*
*/
private String address;
/**
* 0~128
*/
private String position;
/**
* ()
*/
private String mobile; private String mobile;
/**'成员状态'*/ /**
private long status; *
*/
private Integer status;
public long getId() { public Long getId() {
return id; return id;
} }
public void setId(long id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
public String getCpUserId() {
return cpUserId;
}
public void setCpUserId(String cpUserId) {
this.cpUserId = cpUserId;
}
public String getName() { public String getName() {
return name; return name;
} }
@ -35,39 +72,47 @@ public class PrivilageCpUserDO {
} }
public String getCpUserId() { public String getAlias() {
return cpUserId; return alias;
} }
public void setCpUserId(String cpUserId) { public void setAlias(String alias) {
this.cpUserId = cpUserId; this.alias = alias;
} }
public String getEmail() {
return email;
}
public long getUserId() { public void setEmail(String email) {
return userId; this.email = email;
} }
public void setUserId(long userId) {
this.userId = userId; public String getAddress() {
return address;
} }
public void setAddress(String address) {
this.address = address;
}
public String getMobile() {
return mobile; public String getPosition() {
return position;
} }
public void setMobile(String mobile) { public void setPosition(String position) {
this.mobile = mobile; this.position = position;
} }
public long getStatus() { public String getMobile() {
return status; return mobile;
} }
public void setStatus(long status) { public void setMobile(String mobile) {
this.status = status; this.mobile = mobile;
} }
} }

@ -27,9 +27,8 @@ public class EmployeeService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean addUser(EmployeeDO employee) throws WxErrorException { public Boolean addUser(EmployeeDO employee) throws WxErrorException {
//数据库创建用户 PrivilageCpUserDO privilageCpUserDO = new PrivilageCpUserDO();
//数据库创建登录account
//成功则添加用户到企业微信 //成功则添加用户到企业微信
qwMailListManageService.addUser(employee); qwMailListManageService.addUser(employee);

@ -7,14 +7,14 @@ import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpDepartmentService; import me.chanjar.weixin.cp.api.WxCpDepartmentService;
import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.api.WxCpUserService; import me.chanjar.weixin.cp.api.WxCpUserService;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
import me.chanjar.weixin.cp.bean.WxCpDepart; import me.chanjar.weixin.cp.bean.WxCpDepart;
import me.chanjar.weixin.cp.bean.WxCpUser; import me.chanjar.weixin.cp.bean.WxCpUser;
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* @Description: service * @Description: service
* @Auther: yechenhao * @Auther: yechenhao
@ -41,7 +41,7 @@ public class QWMailListManageService {
} }
/** /**
* *
*/ */
public void addDepartment(DepartmentDO departmentDO) throws WxErrorException { public void addDepartment(DepartmentDO departmentDO) throws WxErrorException {
wxCpService = WxCpConfiguration.getCpService(applicationid); wxCpService = WxCpConfiguration.getCpService(applicationid);
@ -50,4 +50,13 @@ public class QWMailListManageService {
BeanUtils.copyProperties(departmentDO,wxCpDepart); BeanUtils.copyProperties(departmentDO,wxCpDepart);
departmentService.create(wxCpDepart); departmentService.create(wxCpDepart);
} }
/**
*
*/
public List<WxCpDepart> syncDepartment() throws WxErrorException {
wxCpService = WxCpConfiguration.getCpService(applicationid);
WxCpDepartmentService departmentService = wxCpService.getDepartmentService();
return departmentService.list(null);
}
} }

Loading…
Cancel
Save