员工部门修改

master
LegnaYet 6 years ago
parent 3f672eefa6
commit 5bf4716cb1

@ -2,11 +2,9 @@ package com.kiisoo.ic.config;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import lombok.val; import lombok.val;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
import me.chanjar.weixin.cp.constant.WxCpConsts;
import me.chanjar.weixin.cp.message.WxCpMessageRouter; import me.chanjar.weixin.cp.message.WxCpMessageRouter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -24,7 +22,6 @@ import java.util.stream.Collectors;
public class WxCpConfiguration { public class WxCpConfiguration {
private WxCpProperties properties; private WxCpProperties properties;
private static Map<Integer, WxCpMessageRouter> routers = Maps.newHashMap();
private static Map<Integer, WxCpService> cpServices = Maps.newHashMap(); private static Map<Integer, WxCpService> cpServices = Maps.newHashMap();
@Autowired @Autowired
@ -43,6 +40,8 @@ public class WxCpConfiguration {
configStorage.setCorpId(this.properties.getCorpId()); configStorage.setCorpId(this.properties.getCorpId());
configStorage.setAgentId(a.getAgentId()); configStorage.setAgentId(a.getAgentId());
configStorage.setCorpSecret(a.getSecret()); configStorage.setCorpSecret(a.getSecret());
configStorage.setToken(a.getToken());
configStorage.setAesKey(a.getAesKey());
val service = new WxCpServiceImpl(); val service = new WxCpServiceImpl();
service.setWxCpConfigStorage(configStorage); service.setWxCpConfigStorage(configStorage);
return service; return service;

@ -1,13 +1,13 @@
package com.kiisoo.ic.customer.mapper; //package com.kiisoo.ic.customer.mapper;
//
import com.baomidou.mybatisplus.core.mapper.BaseMapper; //import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kiisoo.ic.customer.entity.OpVipAttr; //import com.kiisoo.ic.customer.entity.OpVipAttr;
import org.springframework.stereotype.Repository; //import org.springframework.stereotype.Repository;
//
/** ///**
* vip // * 客户vip
*/ // */
@Repository //@Repository
public interface OpVipAttrDOMapper extends BaseMapper<OpVipAttr> { //public interface OpVipAttrDOMapper extends BaseMapper<OpVipAttr> {
//
} //}

@ -1,8 +1,8 @@
package com.kiisoo.ic.department.controller; package com.kiisoo.ic.department.controller;
import com.kiisoo.ic.common.BaseController; import com.kiisoo.ic.common.BaseController;
import com.kiisoo.ic.employee.entity.EmployeeDO; import com.kiisoo.ic.department.entity.DepartmentDO;
import com.kiisoo.ic.employee.service.EmployeeService; import com.kiisoo.ic.department.service.DepartmentService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -13,26 +13,26 @@ import org.springframework.web.bind.annotation.RequestMethod;
import java.util.Map; import java.util.Map;
/** /**
* @Description: controller * @Description: controller
* @Auther: yechenhao * @Auther: yechenhao
* @Date: 2020/4/7 0002 10:06 * @Date: 2020/4/7 0002 10:06
* @Version: v1 * @Version: v1
*/ */
@Controller @Controller
@RequestMapping("/user") @RequestMapping("/department")
@Slf4j @Slf4j
public class DepartmentConreoller extends BaseController { public class DepartmentConreoller extends BaseController {
@Autowired @Autowired
private EmployeeService employeeService; private DepartmentService departmentService;
@RequestMapping(value = "add",method = RequestMethod.POST) @RequestMapping(value = "add",method = RequestMethod.POST)
public Map<String,Object> addUser(@RequestBody EmployeeDO employee){ public Map<String,Object> addDepartment(@RequestBody DepartmentDO departmentDO){
try { try {
Boolean hasAdd = employeeService.addUser(employee); Boolean hasAdd = departmentService.addDepartment(departmentDO);
return data(hasAdd); return data(hasAdd);
}catch (Exception e){ }catch (Exception e){
log.error("添加用户失败",e); log.error("添加部门失败",e);
return fail(); return fail();
} }
} }

@ -1,10 +1,9 @@
package com.kiisoo.ic.department.entity; package com.kiisoo.ic.department.entity;
import lombok.Data; import lombok.Data;
import me.chanjar.weixin.cp.bean.Gender;
/** /**
* @Description: * @Description:
* @Auther: yechenhao * @Auther: yechenhao
* @Date: 2020/4/7 0002 10:06 * @Date: 2020/4/7 0002 10:06
* @Version: v1 * @Version: v1
@ -12,10 +11,19 @@ import me.chanjar.weixin.cp.bean.Gender;
@Data @Data
public class DepartmentDO { public class DepartmentDO {
/** /**
* idid * idid
*/ */
private Long id; private Long id;
/**
*
*/
private String name; private String name;
/**
* id32
*/
private Long parentId; private Long parentId;
/**
* order[0, 2^32)
*/
private Long order; private Long order;
} }

@ -1,6 +1,6 @@
package com.kiisoo.ic.department.service; package com.kiisoo.ic.department.service;
import com.kiisoo.ic.employee.entity.EmployeeDO; import com.kiisoo.ic.department.entity.DepartmentDO;
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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -8,25 +8,23 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
/** /**
* @Description: service * @Description: service
* @Auther: yechenhao * @Auther: yechenhao
* @Date: 2020/4/7 0002 10:06 * @Date: 2020/4/7 0002 10:06
* @Version: v1 * @Version: v1
*/ */
@Service @Service
public class EmployeeService { public class DepartmentService {
@Autowired @Autowired
private QWMailListManageService qwMailListManageService; private QWMailListManageService qwMailListManageService;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean addUser(EmployeeDO employee) throws WxErrorException { public Boolean addDepartment(DepartmentDO departmentDO) throws WxErrorException {
//数据库创建用户 //数据库创建部门需要返回部门id
//数据库创建登录account
//成功则添加用户到企业微信 //成功则添加用户到企业微信
qwMailListManageService.addUser(employee); qwMailListManageService.addDepartment(departmentDO);
return true; return true;
} }

@ -33,7 +33,7 @@ public class QWMailListManageService {
* *
*/ */
public void addUser(EmployeeDO employeeDO) throws WxErrorException { public void addUser(EmployeeDO employeeDO) throws WxErrorException {
wxCpService = WxCpConfiguration.getCpService(applicationid); wxCpService = WxCpConfiguration.getCpService(1);
WxCpUserService userService = wxCpService.getUserService(); WxCpUserService userService = wxCpService.getUserService();
WxCpUser wxCpUser = new WxCpUser(); WxCpUser wxCpUser = new WxCpUser();
BeanUtils.copyProperties(employeeDO,wxCpUser); BeanUtils.copyProperties(employeeDO,wxCpUser);

@ -15,17 +15,25 @@ spring:
qywx: qywx:
corpid: wwc8b3e81998fe5394 corpid: wwc8b3e81998fe5394
corpsecret: fNF_2L3qe9xw4cv4k1Xo4kqhFdzGa61Y6xb1RojNbmc corpsecret: scb9m8DEtSwJpB_ZFXg4J9WE91yH-WNBBQ4Vxv1NYy4
applicationid: 1000042 applicationid: 1000037
wechat: wechat:
cp: cp:
corpId: wwc8b3e81998fe5394 corpId: wwc8b3e81998fe5394
appConfigs: appConfigs:
- agentId: 1000037
secret: scb9m8DEtSwJpB_ZFXg4J9WE91yH-WNBBQ4Vxv1NYy4
token: mx3hi3yH1LkkHDgvs70u
aesKey: 9Dsf9pubOb2tMWtrueZsxC9jsYKX1Id7tTgeg2hou1w
- agentId: 1000042 - agentId: 1000042
secret: fNF_2L3qe9xw4cv4k1Xo4kqhFdzGa61Y6xb1RojNbmc secret: fNF_2L3qe9xw4cv4k1Xo4kqhFdzGa61Y6xb1RojNbmc
token: 111 token: 111
aesKey: 111 aesKey: 111
- agentId: 1
secret: 9FCD26JgFztDCc7ToTh-c9ETFBgKlgTRDCsrcv-GxBA
token: 111
aesKey: 111
##开发环境 ##开发环境
server: server:

Loading…
Cancel
Save