diff --git a/kiisoo-ic-ui/src/iview.js b/kiisoo-ic-ui/src/iview.js
index 6a75ee8..4741d2d 100644
--- a/kiisoo-ic-ui/src/iview.js
+++ b/kiisoo-ic-ui/src/iview.js
@@ -21,7 +21,8 @@ import {
DatePicker,
CheckboxGroup,
Checkbox,
- RadioGroup
+ RadioGroup,
+ Switch
} from "view-design";
import 'view-design/dist/styles/iview.css';
@@ -49,3 +50,4 @@ Vue.component('DatePicker', DatePicker);
Vue.component('CheckboxGroup', CheckboxGroup);
Vue.component('Checkbox', Checkbox);
Vue.component('RadioGroup', RadioGroup);
+Vue.component('i-switch', Switch);
diff --git a/kiisoo-ic-ui/src/pages/shop/IncreaseDataRegion.vue b/kiisoo-ic-ui/src/pages/shop/IncreaseDataRegion.vue
index 6fbc3b0..1da9ee6 100644
--- a/kiisoo-ic-ui/src/pages/shop/IncreaseDataRegion.vue
+++ b/kiisoo-ic-ui/src/pages/shop/IncreaseDataRegion.vue
@@ -15,7 +15,7 @@
时间
-
diff --git a/kiisoo-ic-ui/src/pages/shop/IncreaseDataStaff.vue b/kiisoo-ic-ui/src/pages/shop/IncreaseDataStaff.vue
index 2e5b9a4..7d16b6b 100644
--- a/kiisoo-ic-ui/src/pages/shop/IncreaseDataStaff.vue
+++ b/kiisoo-ic-ui/src/pages/shop/IncreaseDataStaff.vue
@@ -33,7 +33,7 @@
时间
-
diff --git a/kiisoo-ic-ui/src/pages/shop/IncreaseDataStore.vue b/kiisoo-ic-ui/src/pages/shop/IncreaseDataStore.vue
index 1873a98..7acbc45 100644
--- a/kiisoo-ic-ui/src/pages/shop/IncreaseDataStore.vue
+++ b/kiisoo-ic-ui/src/pages/shop/IncreaseDataStore.vue
@@ -23,7 +23,7 @@
时间
-
diff --git a/kiisoo-ic-ui/src/pages/shop/IncreaseStaffManager.vue b/kiisoo-ic-ui/src/pages/shop/IncreaseStaffManager.vue
index eabb2ae..bb65369 100644
--- a/kiisoo-ic-ui/src/pages/shop/IncreaseStaffManager.vue
+++ b/kiisoo-ic-ui/src/pages/shop/IncreaseStaffManager.vue
@@ -1,15 +1,198 @@
-
IncreaseStaffManager
+
+
+
+
+ 区域选择
+
+
+
+
+
+ 店铺选择
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 开启
+ 关闭
+
+
+
+
+
+
+
+
diff --git a/kiisoo-ic-ui/src/pages/shop/IncreaseStoreManager.vue b/kiisoo-ic-ui/src/pages/shop/IncreaseStoreManager.vue
index ded5f37..d05233e 100644
--- a/kiisoo-ic-ui/src/pages/shop/IncreaseStoreManager.vue
+++ b/kiisoo-ic-ui/src/pages/shop/IncreaseStoreManager.vue
@@ -1,15 +1,150 @@
-
IncreaseStoreManager
+
+
+
+
+ 区域选择
+
+
+
+
+
+ 店铺选择
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/kiisoo-ic-ui/src/router/index.js b/kiisoo-ic-ui/src/router/index.js
index 60b72ae..3398433 100755
--- a/kiisoo-ic-ui/src/router/index.js
+++ b/kiisoo-ic-ui/src/router/index.js
@@ -11,6 +11,9 @@ import IncreaseData from '@/pages/shop/IncreaseData';
import IncreaseDataRegion from '@/pages/shop/IncreaseDataRegion';
import IncreaseDataStaff from '@/pages/shop/IncreaseDataStaff';
import IncreaseDataStore from '@/pages/shop/IncreaseDataStore';
+import IncreaseStaffManager from '@/pages/shop/IncreaseStaffManager';
+import IncreaseStoreManager from '@/pages/shop/IncreaseStoreManager';
+
Vue.use(Router);
const router = new Router({
@@ -58,13 +61,13 @@ const router = new Router({
},
{
path: '/shop/increase/manager/store',
- name: 'IncreaseDataRegion',
- component: IncreaseDataRegion
+ name: 'IncreaseStoreManager',
+ component: IncreaseStoreManager
},
{
path: '/shop/increase/manager/staff',
- name: 'IncreaseDataStore',
- component: IncreaseDataStore
+ name: 'IncreaseStaffManager',
+ component: IncreaseStaffManager
}
]
},
diff --git a/src/main/java/com/kiisoo/ic/department/constant/Constants.java b/src/main/java/com/kiisoo/ic/department/constant/Constants.java
new file mode 100644
index 0000000..f7dd6b0
--- /dev/null
+++ b/src/main/java/com/kiisoo/ic/department/constant/Constants.java
@@ -0,0 +1,22 @@
+package com.kiisoo.ic.department.constant;
+
+/**
+ * @Description: 部门静态类
+ * @Auther: yechenhao
+ * @Date: 2020/4/8 0002 21:14
+ * @Version: v1
+ */
+public class Constants {
+ /**
+ * 企业微信主部门id
+ */
+ public static Long MAIN_DEPARTMENT_ID = 1L;
+ /**
+ * 根层级
+ */
+ public static int LEVEL_ONE = 1;
+ /**
+ * 根层级
+ */
+ public static int LEVEL_TWO = 2;
+}
diff --git a/src/main/java/com/kiisoo/ic/department/entity/DepartmentDO.java b/src/main/java/com/kiisoo/ic/department/entity/DepartmentDO.java
index 33f95e2..43f6ff3 100644
--- a/src/main/java/com/kiisoo/ic/department/entity/DepartmentDO.java
+++ b/src/main/java/com/kiisoo/ic/department/entity/DepartmentDO.java
@@ -1,7 +1,14 @@
package com.kiisoo.ic.department.entity;
+import com.alibaba.fastjson.annotation.JSONField;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
+import java.util.List;
+
/**
* @Description: 部门对象
* @Auther: yechenhao
@@ -9,6 +16,7 @@ import lombok.Data;
* @Version: v1
*/
@Data
+@TableName("privilage_department")
public class DepartmentDO {
/**
* 数据库实体id和企业微信部门id相同
@@ -22,8 +30,19 @@ public class DepartmentDO {
* 父部门id,32位整型
*/
private Long parentId;
+ /**
+ * 部门层级
+ */
+ private Integer level;
/**
* 在父部门中的次序值。order值大的排序靠前。有效的值范围是[0, 2^32)
*/
- private Long order;
+ @JSONField(name = "order_num")
+ private Long orderNum;
+
+ /**
+ * 子部门
+ */
+ @TableField(exist = false)
+ private List departments;
}
diff --git a/src/main/java/com/kiisoo/ic/department/service/DepartmentService.java b/src/main/java/com/kiisoo/ic/department/service/DepartmentService.java
index f8df41a..1d8050e 100644
--- a/src/main/java/com/kiisoo/ic/department/service/DepartmentService.java
+++ b/src/main/java/com/kiisoo/ic/department/service/DepartmentService.java
@@ -11,8 +11,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import java.util.ArrayList;
import java.util.List;
+import static com.kiisoo.ic.department.constant.Constants.*;
+
/**
* @Description: 部门管理service
* @Auther: yechenhao
@@ -42,14 +45,126 @@ public class DepartmentService {
public Boolean syncDepartment() throws WxErrorException {
//获取企业微信部门架构
List wxCpDeparts = qwMailListManageService.syncDepartment();
+ //分组
+ List departmentDOS = new ArrayList<>();
+ groupByDepartments(wxCpDeparts,departmentDOS);
+
+ recursionInsertDepartment(departmentDOS);
+ return true;
+ }
+
+ /**
+ * 递归分组
+ * @param wxCpDeparts 企业微信部门架构
+ * @param departmentDOS 分组部门架构
+ * @return
+ */
+ private void groupByDepartments(List wxCpDeparts,List departmentDOS){
+ List recursionList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(wxCpDeparts)){
wxCpDeparts.forEach(wxDept -> {
- DepartmentDO departmentDO = new DepartmentDO();
- BeanUtils.copyProperties(wxDept,departmentDO);
+ Long departmentId = wxDept.getId();
+ Long parentId = wxDept.getParentId();
+ //如果部门id为1为首(根)部门直接加入数组
+ if (MAIN_DEPARTMENT_ID.equals(departmentId)){
+ DepartmentDO departmentDO = new DepartmentDO();
+ BeanUtils.copyProperties(wxDept,departmentDO);
+ departmentDO.setOrderNum(wxDept.getOrder());
+ departmentDO.setLevel(LEVEL_ONE);
+ departmentDOS.add(departmentDO);
+ }else{
+ //部门id不为1,则寻找部门数组中是否有其夫部门
+ Boolean hasParents = false;
+ if (CollectionUtils.isNotEmpty(departmentDOS)){
+ for(DepartmentDO departmentDO:departmentDOS) {
+ Long oneId = departmentDO.getId();
+ //判断该部门是否为夫部门
+ if (parentId.equals(oneId)){
+ List departments = departmentDO.getDepartments();
+ if (CollectionUtils.isEmpty(departments)){
+ departments = new ArrayList<>();
+ }
+ DepartmentDO de = new DepartmentDO();
+ BeanUtils.copyProperties(wxDept,de);
+ de.setOrderNum(wxDept.getOrder());
+ de.setLevel(LEVEL_TWO);
+ departments.add(de);
+ departmentDO.setDepartments(departments);
+ hasParents = true;
+ break;
+ }else{
+ //不是副部门则递归判断该部门的子部门时候为父部门
+ hasParents = recursionLevel(LEVEL_TWO,hasParents,departmentDO,wxDept);
+ }
+ }
+ if(!hasParents){
+ recursionList.add(wxDept);
+ }
+ }else {
+ recursionList.add(wxDept);
+ }
+ }
});
+ groupByDepartments(recursionList,departmentDOS);
+ }
+ }
+
+ /**
+ * 递归寻找父部门
+ * @param level
+ * @param hasParents
+ * @param departmentDO
+ * @param wxDept
+ */
+ private Boolean recursionLevel(int level,Boolean hasParents,DepartmentDO departmentDO,WxCpDepart wxDept){
+ int nowLevel = ++level;
+ Long parentId = wxDept.getParentId();
+ List departments = departmentDO.getDepartments();
+ //寻找部门数组中是否有其夫部门
+ if (CollectionUtils.isNotEmpty(departments)){
+ for(DepartmentDO dep:departments) {
+ Long oneId = dep.getId();
+ //判断该部门是否为夫部门
+ if (parentId.equals(oneId)){
+ List deps = dep.getDepartments();
+ if (CollectionUtils.isEmpty(deps)){
+ deps = new ArrayList<>();
+ }
+ DepartmentDO de = new DepartmentDO();
+ BeanUtils.copyProperties(wxDept,de);
+ de.setOrderNum(wxDept.getOrder());
+ de.setLevel(nowLevel);
+ deps.add(de);
+ dep.setDepartments(deps);
+ hasParents = true;
+ }else{
+ //不是副部门则递归判断该部门的子部门时候为父部门
+ hasParents = recursionLevel(nowLevel,hasParents,dep,wxDept);
+ }
+ }
+ }
+ return hasParents;
+ }
+
+ /**
+ * 递归插入
+ * @param departmentDO
+ */
+ private void recursionInsertDepartment(List departmentDO){
+ if (CollectionUtils.isNotEmpty(departmentDO)){
+ departmentDO.forEach(department -> {
+ DepartmentDO dep = departmentDOMapper.selectById(department.getId());
+ if (dep == null){
+ departmentDOMapper.insert(department);
+ }else{
+ departmentDOMapper.updateById(department);
+ }
+ List departments = department.getDepartments();
+ if (CollectionUtils.isNotEmpty(departments)){
+ recursionInsertDepartment(departments);
+ }
+ });
}
-// departmentDOMapper.insert(departmentDO);
- return true;
}
}
diff --git a/src/main/java/com/kiisoo/ic/employee/mapper/PoiStoreStaffDOMapper.java b/src/main/java/com/kiisoo/ic/employee/mapper/PoiStoreStaffDOMapper.java
index 66ee891..9c6270f 100644
--- a/src/main/java/com/kiisoo/ic/employee/mapper/PoiStoreStaffDOMapper.java
+++ b/src/main/java/com/kiisoo/ic/employee/mapper/PoiStoreStaffDOMapper.java
@@ -1,16 +1,16 @@
-package com.kiisoo.ic.employee.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.kiisoo.ic.employee.entity.PoiStoreStaffDO;
-import org.springframework.stereotype.Repository;
-
-/**
- * @Description 店铺人员表mapper
- * @Author yinliujing
- * @Version V1.0.0
- * @Date 2020/4/7
- */
-@Repository
-public interface PoiStoreStaffDOMapper extends BaseMapper {
-
-}
+//package com.kiisoo.ic.employee.mapper;
+//
+//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+//import com.kiisoo.ic.employee.entity.PoiStoreStaffDO;
+//import org.springframework.stereotype.Repository;
+//
+///**
+// * @Description 店铺人员表mapper
+// * @Author yinliujing
+// * @Version V1.0.0
+// * @Date 2020/4/7
+// */
+//@Repository
+//public interface PoiStoreStaffDOMapper extends BaseMapper {
+//
+//}
diff --git a/src/main/java/com/kiisoo/ic/employee/service/QrCodeService.java b/src/main/java/com/kiisoo/ic/employee/service/QrCodeService.java
index 02ed97d..e822244 100644
--- a/src/main/java/com/kiisoo/ic/employee/service/QrCodeService.java
+++ b/src/main/java/com/kiisoo/ic/employee/service/QrCodeService.java
@@ -1,86 +1,87 @@
-package com.kiisoo.ic.employee.service;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.kiisoo.ic.config.WxCpConfiguration;
-import com.kiisoo.ic.employee.entity.PoiStoreStaffDO;
-import com.kiisoo.ic.employee.entity.QrCodeDO;
-import com.kiisoo.ic.employee.entity.QrCodeVO;
-import com.kiisoo.ic.employee.mapper.PoiStoreStaffDOMapper;
-import me.chanjar.weixin.common.error.WxErrorException;
-import me.chanjar.weixin.cp.api.WxCpService;
-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.HashMap;
-import java.util.Map;
-
-/**
- * @Description: 推广码业务
- * @Auther: yinliujing
- * @Date: 2020/4/7 0002 14:06
- * @Version: v1
- */
-@Service
-public class QrCodeService {
- WxCpService mainService = WxCpConfiguration.getCpService(1000037);
- @Autowired
- private PoiStoreStaffDOMapper poiStoreStaffDOMapper;
-
- public QrCodeVO getQrCode(QrCodeDO qrCodeDO) throws Exception {
- //获取token
- String token = mainService.getAccessToken();
- qrCodeDO.setAccess_token(token);
- //获取configId
- String configId = getConfigId(qrCodeDO);
- //获取配置实体
- QrCodeVO qrCodeVO = getContactWay(token, configId);
- return qrCodeVO;
- }
-
- /**
- * 配置客户联系「联系我」方式
- *
- * @param qrCodeDO
- * @return
- * @throws WxErrorException
- */
- public String getConfigId(QrCodeDO qrCodeDO) throws WxErrorException {
- String url = mainService.getWxCpConfigStorage().getApiUrl("/cgi-bin/externalcontact/add_contact_way");
- String result = mainService.post(url, qrCodeDO.toJson());
- JSONObject parseObject = JSON.parseObject(result);
- String configId = parseObject.getString("config_id");
- return configId;
- }
-
- /**
- * 获取企业已配置的「联系我」方式
- *
- * @param token
- * @param configId
- * @return
- * @throws WxErrorException
- */
- public QrCodeVO getContactWay(String token, String configId) throws WxErrorException {
- String url = mainService.getWxCpConfigStorage().getApiUrl("/cgi-bin/externalcontact/get_contact_way");
- Map map = new HashMap<>();
- map.put("config_id", configId);
- map.put("access_token", token);
- String result = mainService.post(url, JSON.toJSONString(map));
- JSONObject parseObject = JSON.parseObject(result);
- QrCodeVO qrCodeVO = JSONObject.parseObject(parseObject.getString("contact_way"), QrCodeVO.class);
- return qrCodeVO;
- }
-
- /**
- * 添加店铺人员表
- * @return
- * @throws WxErrorException
- */
- @Transactional(rollbackFor = Exception.class)
- public int saveStoreStaff(PoiStoreStaffDO poiStoreStaffDO) throws Exception {
- return poiStoreStaffDOMapper.insert(poiStoreStaffDO);
- }
-}
+//package com.kiisoo.ic.employee.service;
+//
+//import com.alibaba.fastjson.JSON;
+//import com.alibaba.fastjson.JSONObject;
+//import com.kiisoo.ic.config.WxCpConfiguration;
+//import com.kiisoo.ic.employee.entity.PoiStoreStaffDO;
+//import com.kiisoo.ic.employee.entity.QrCodeDO;
+//import com.kiisoo.ic.employee.entity.QrCodeVO;
+////import com.kiisoo.ic.employee.mapper.PoiStoreStaffDOMapper;
+//import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
+//import me.chanjar.weixin.common.error.WxErrorException;
+//import me.chanjar.weixin.cp.api.WxCpService;
+//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.HashMap;
+//import java.util.Map;
+//
+///**
+// * @Description: 推广码业务
+// * @Auther: yinliujing
+// * @Date: 2020/4/7 0002 14:06
+// * @Version: v1
+// */
+//@Service
+//public class QrCodeService {
+// WxCpService mainService = WxCpConfiguration.getCpService(1000037);
+// @Autowired
+// private PoiStoreStaffDOMapper poiStoreStaffDOMapper;
+//
+// public QrCodeVO getQrCode(QrCodeDO qrCodeDO) throws Exception {
+// //获取token
+// String token = mainService.getAccessToken();
+// qrCodeDO.setAccess_token(token);
+// //获取configId
+// String configId = getConfigId(qrCodeDO);
+// //获取配置实体
+// QrCodeVO qrCodeVO = getContactWay(token, configId);
+// return qrCodeVO;
+// }
+//
+// /**
+// * 配置客户联系「联系我」方式
+// *
+// * @param qrCodeDO
+// * @return
+// * @throws WxErrorException
+// */
+// public String getConfigId(QrCodeDO qrCodeDO) throws WxErrorException {
+// String url = mainService.getWxCpConfigStorage().getApiUrl("/cgi-bin/externalcontact/add_contact_way");
+// String result = mainService.post(url, qrCodeDO.toJson());
+// JSONObject parseObject = JSON.parseObject(result);
+// String configId = parseObject.getString("config_id");
+// return configId;
+// }
+//
+// /**
+// * 获取企业已配置的「联系我」方式
+// *
+// * @param token
+// * @param configId
+// * @return
+// * @throws WxErrorException
+// */
+// public QrCodeVO getContactWay(String token, String configId) throws WxErrorException {
+// String url = mainService.getWxCpConfigStorage().getApiUrl("/cgi-bin/externalcontact/get_contact_way");
+// Map map = new HashMap<>();
+// map.put("config_id", configId);
+// map.put("access_token", token);
+// String result = mainService.post(url, JSON.toJSONString(map));
+// JSONObject parseObject = JSON.parseObject(result);
+// QrCodeVO qrCodeVO = JSONObject.parseObject(parseObject.getString("contact_way"), QrCodeVO.class);
+// return qrCodeVO;
+// }
+//
+// /**
+// * 添加店铺人员表
+// * @return
+// * @throws WxErrorException
+// */
+// @Transactional(rollbackFor = Exception.class)
+// public int saveStoreStaff(PoiStoreStaffDO poiStoreStaffDO) throws Exception {
+// return poiStoreStaffDOMapper.insert(poiStoreStaffDO);
+// }
+//}
diff --git a/src/main/java/com/kiisoo/ic/wx/controller/WxAccessController.java b/src/main/java/com/kiisoo/ic/wx/controller/WxAccessController.java
index 43edbc4..e21d20c 100644
--- a/src/main/java/com/kiisoo/ic/wx/controller/WxAccessController.java
+++ b/src/main/java/com/kiisoo/ic/wx/controller/WxAccessController.java
@@ -6,7 +6,7 @@ import com.kiisoo.ic.common.utils.SignUtils;
import com.kiisoo.ic.common.utils.WeixinApi;
import com.kiisoo.ic.employee.entity.QrCodeDO;
import com.kiisoo.ic.employee.entity.QrCodeVO;
-import com.kiisoo.ic.employee.service.QrCodeService;
+//import com.kiisoo.ic.employee.service.QrCodeService;
import com.kiisoo.ic.wx.entity.ContactWayDTO;
import com.kiisoo.ic.wx.service.WxAccessService;
import com.kiisoo.ic.wx.service.WxLoginService;
@@ -55,8 +55,8 @@ public class WxAccessController extends BaseController {
@Autowired
private WxResponseService wxResponseService;
- @Autowired
- private QrCodeService qrCodeService;
+// @Autowired
+// private QrCodeService qrCodeService;
private String loginPageUrl = "http://localhost:8311/kiisoo-ic-ui";
private String baseUrl = "http://jdxdev.vipgz4.idcfengye.com/kiisoo-ic";
@@ -318,9 +318,9 @@ public class WxAccessController extends BaseController {
// contactWayDTO.setState("D1");
contactWayDTO.setState("D2");
- QrCodeVO res = qrCodeService.getQrCode(contactWayDTO);
- System.out.println(res);
- return res;
+// QrCodeVO res = qrCodeService.getQrCode(contactWayDTO);
+// System.out.println(res);
+ return null;
} catch (Exception e) {
//验证URL失败,错误原因请查看异常
e.printStackTrace();
diff --git a/src/main/java/com/kiisoo/ic/wx/service/QWMailListManageService.java b/src/main/java/com/kiisoo/ic/wx/service/QWMailListManageService.java
index 325af2e..9ec3d86 100644
--- a/src/main/java/com/kiisoo/ic/wx/service/QWMailListManageService.java
+++ b/src/main/java/com/kiisoo/ic/wx/service/QWMailListManageService.java
@@ -55,7 +55,7 @@ public class QWMailListManageService {
* 获取企业微信所有部门架构
*/
public List syncDepartment() throws WxErrorException {
- wxCpService = WxCpConfiguration.getCpService(applicationid);
+ wxCpService = WxCpConfiguration.getCpService(1);
WxCpDepartmentService departmentService = wxCpService.getDepartmentService();
return departmentService.list(null);
}
diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml
index d982cd0..3fce2a4 100644
--- a/src/main/resources/application-dev.yml
+++ b/src/main/resources/application-dev.yml
@@ -8,7 +8,7 @@ mybatis:
spring:
datasource:
- url: jdbc:mysql://192.168.0.215:3306/p2p?characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true
+ url: jdbc:mysql://192.168.0.215:3306/ic?characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true
username: p2p
password: p2p
driver-class-name: com.mysql.jdbc.Driver