部门修改

master
LegnaYet 6 years ago
parent ecb062597f
commit c731778ea0

@ -36,4 +36,15 @@ public class DepartmentConreoller extends BaseController {
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;
import com.kiisoo.ic.department.entity.DepartmentDO;
import com.kiisoo.ic.department.mapper.PrivilageDepartmentDOMapper;
import com.kiisoo.ic.wx.service.QWMailListManageService;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @Description: service
* @Auther: yechenhao
@ -19,6 +25,9 @@ public class DepartmentService {
@Autowired
private QWMailListManageService qwMailListManageService;
@Autowired
private PrivilageDepartmentDOMapper departmentDOMapper;
@Transactional(rollbackFor = Exception.class)
public Boolean addDepartment(DepartmentDO departmentDO) throws WxErrorException {
//数据库创建部门需要返回部门id
@ -28,4 +37,19 @@ public class DepartmentService {
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;
public class PrivilageCpUserDO {
/**
*
* id
*/
private Long id;
/**
* userId
*/
public class PrivilageCpUserDO {
private long id;
/**'成员名'*/
private String name;
/**企业微信userId账号*/
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 long status;
/**
*
*/
private Integer status;
public long getId() {
public Long getId() {
return id;
}
public void setId(long id) {
public void setId(Long id) {
this.id = id;
}
public String getCpUserId() {
return cpUserId;
}
public void setCpUserId(String cpUserId) {
this.cpUserId = cpUserId;
}
public String getName() {
return name;
}
@ -35,39 +72,47 @@ public class PrivilageCpUserDO {
}
public String getCpUserId() {
return cpUserId;
public String getAlias() {
return alias;
}
public void setCpUserId(String cpUserId) {
this.cpUserId = cpUserId;
public void setAlias(String alias) {
this.alias = alias;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public long getUserId() {
return userId;
public String getAddress() {
return address;
}
public void setUserId(long userId) {
this.userId = userId;
public void setAddress(String address) {
this.address = address;
}
public String getMobile() {
return mobile;
public String getPosition() {
return position;
}
public void setMobile(String mobile) {
this.mobile = mobile;
public void setPosition(String position) {
this.position = position;
}
public long getStatus() {
return status;
public String getMobile() {
return mobile;
}
public void setStatus(long status) {
this.status = status;
public void setMobile(String mobile) {
this.mobile = mobile;
}
}

@ -27,9 +27,8 @@ public class EmployeeService {
@Transactional(rollbackFor = Exception.class)
public Boolean addUser(EmployeeDO employee) throws WxErrorException {
//数据库创建用户
PrivilageCpUserDO privilageCpUserDO = new PrivilageCpUserDO();
//数据库创建登录account
//成功则添加用户到企业微信
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.WxCpService;
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.WxCpUser;
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Description: service
* @Auther: yechenhao
@ -41,7 +41,7 @@ public class QWMailListManageService {
}
/**
*
*
*/
public void addDepartment(DepartmentDO departmentDO) throws WxErrorException {
wxCpService = WxCpConfiguration.getCpService(applicationid);
@ -50,4 +50,13 @@ public class QWMailListManageService {
BeanUtils.copyProperties(departmentDO,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