diff --git a/cloud-common-dingding/src/main/java/com/cm/common/dingding/dao/IDingDingDepartmentDao.java b/cloud-common-dingding/src/main/java/com/cm/common/dingding/dao/IDingDingDepartmentDao.java new file mode 100644 index 0000000..3faafaf --- /dev/null +++ b/cloud-common-dingding/src/main/java/com/cm/common/dingding/dao/IDingDingDepartmentDao.java @@ -0,0 +1,35 @@ +package com.cm.common.dingding.dao; + +import com.cm.common.dingding.pojo.pos.DingDingDepartmentPO; +import com.cm.common.exception.SaveException; +import com.cm.common.exception.SearchException; +import org.springframework.stereotype.Repository; + +import java.util.Map; + +/** + * @ClassName: IDingDingDepartmentDao + * @Description: 钉钉部门 + * @Author: wanggeng + * @Date: 2021/8/12 4:40 下午 + * @Version: 1.0 + */ +@Repository +public interface IDingDingDepartmentDao { + /** + * 新增 + * + * @param params + * @throws SaveException + */ + void save(Map params) throws SaveException; + + /** + * 详情 + * + * @param params + * @return + * @throws SearchException + */ + DingDingDepartmentPO getPO(Map params) throws SearchException; +} diff --git a/cloud-common-dingding/src/main/java/com/cm/common/dingding/dao/IDingDingUserDao.java b/cloud-common-dingding/src/main/java/com/cm/common/dingding/dao/IDingDingUserDao.java new file mode 100644 index 0000000..47fbb43 --- /dev/null +++ b/cloud-common-dingding/src/main/java/com/cm/common/dingding/dao/IDingDingUserDao.java @@ -0,0 +1,36 @@ +package com.cm.common.dingding.dao; + +import com.cm.common.dingding.pojo.pos.DingDingUserPO; +import com.cm.common.exception.SaveException; +import com.cm.common.exception.SearchException; +import org.springframework.stereotype.Repository; + +import java.util.Map; + +/** + * @ClassName: IDingDingUserDao + * @Description: 钉钉用户 + * @Author: wanggeng + * @Date: 2021/8/12 4:40 下午 + * @Version: 1.0 + */ +@Repository +public interface IDingDingUserDao { + + /** + * 保存 + * + * @param params + * @throws SaveException + */ + void save(Map params) throws SaveException; + + /** + * 详情 + * + * @param params + * @return + * @throws SearchException + */ + DingDingUserPO getPO(Map params) throws SearchException; +} diff --git a/cloud-common-dingding/src/main/java/com/cm/common/dingding/pojo/pos/DingDingDepartmentPO.java b/cloud-common-dingding/src/main/java/com/cm/common/dingding/pojo/pos/DingDingDepartmentPO.java new file mode 100644 index 0000000..1e96a70 --- /dev/null +++ b/cloud-common-dingding/src/main/java/com/cm/common/dingding/pojo/pos/DingDingDepartmentPO.java @@ -0,0 +1,75 @@ +package com.cm.common.dingding.pojo.pos; + +/** + * @ClassName: DingDingDepartmentPO + * @Description: 钉钉部门 + * @Author: wanggeng + * @Date: 2021/8/12 10:54 下午 + * @Version: 1.0 + */ +public class DingDingDepartmentPO { + + private String dingDingDepartmentId; + private String dingDingDepartmentParentId; + private String departmentId; + private String departmentParentId; + private String departmentName; + private String gmtCreate; + private String gmtModified; + + public String getDingDingDepartmentId() { + return dingDingDepartmentId == null ? "" : dingDingDepartmentId.trim(); + } + + public void setDingDingDepartmentId(String dingDingDepartmentId) { + this.dingDingDepartmentId = dingDingDepartmentId; + } + + public String getDingDingDepartmentParentId() { + return dingDingDepartmentParentId == null ? "" : dingDingDepartmentParentId.trim(); + } + + public void setDingDingDepartmentParentId(String dingDingDepartmentParentId) { + this.dingDingDepartmentParentId = dingDingDepartmentParentId; + } + + public String getDepartmentId() { + return departmentId == null ? "" : departmentId.trim(); + } + + public void setDepartmentId(String departmentId) { + this.departmentId = departmentId; + } + + public String getDepartmentParentId() { + return departmentParentId == null ? "" : departmentParentId.trim(); + } + + public void setDepartmentParentId(String departmentParentId) { + this.departmentParentId = departmentParentId; + } + + public String getDepartmentName() { + return departmentName == null ? "" : departmentName.trim(); + } + + public void setDepartmentName(String departmentName) { + this.departmentName = departmentName; + } + + public String getGmtCreate() { + return gmtCreate == null ? "" : gmtCreate.trim(); + } + + public void setGmtCreate(String gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public String getGmtModified() { + return gmtModified == null ? "" : gmtModified.trim(); + } + + public void setGmtModified(String gmtModified) { + this.gmtModified = gmtModified; + } +} diff --git a/cloud-common-dingding/src/main/java/com/cm/common/dingding/pojo/pos/DingDingUserPO.java b/cloud-common-dingding/src/main/java/com/cm/common/dingding/pojo/pos/DingDingUserPO.java new file mode 100644 index 0000000..32513d2 --- /dev/null +++ b/cloud-common-dingding/src/main/java/com/cm/common/dingding/pojo/pos/DingDingUserPO.java @@ -0,0 +1,84 @@ +package com.cm.common.dingding.pojo.pos; + +/** + * @ClassName: DingDingUserPO + * @Description: 钉钉用户 + * @Author: wanggeng + * @Date: 2021/8/12 11:14 下午 + * @Version: 1.0 + */ +public class DingDingUserPO { + + private String unionid; + private String dingdingUserId; + private String userId; + private String name; + private String mobile; + private String deptIdList; + private String gmtCreate; + private String gmtModified; + + public String getUnionid() { + return unionid == null ? "" : unionid.trim(); + } + + public void setUnionid(String unionid) { + this.unionid = unionid; + } + + public String getDingdingUserId() { + return dingdingUserId == null ? "" : dingdingUserId.trim(); + } + + public void setDingdingUserId(String dingdingUserId) { + this.dingdingUserId = dingdingUserId; + } + + public String getUserId() { + return userId == null ? "" : userId.trim(); + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getName() { + return name == null ? "" : name.trim(); + } + + public void setName(String name) { + this.name = name; + } + + public String getMobile() { + return mobile == null ? "" : mobile.trim(); + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } + + public String getDeptIdList() { + return deptIdList == null ? "" : deptIdList.trim(); + } + + public void setDeptIdList(String deptIdList) { + this.deptIdList = deptIdList; + } + + public String getGmtCreate() { + return gmtCreate == null ? "" : gmtCreate.trim(); + } + + public void setGmtCreate(String gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public String getGmtModified() { + return gmtModified == null ? "" : gmtModified.trim(); + } + + public void setGmtModified(String gmtModified) { + this.gmtModified = gmtModified; + } +} diff --git a/cloud-common-dingding/src/main/java/com/cm/common/dingding/pojo/vos/DingDingDepartmentVO.java b/cloud-common-dingding/src/main/java/com/cm/common/dingding/pojo/vos/DingDingDepartmentVO.java new file mode 100644 index 0000000..1fbe954 --- /dev/null +++ b/cloud-common-dingding/src/main/java/com/cm/common/dingding/pojo/vos/DingDingDepartmentVO.java @@ -0,0 +1,58 @@ +package com.cm.common.dingding.pojo.vos; + +/** + * @ClassName: DingDingDepartmentVO + * @Description: 钉钉部门 + * @Author: wanggeng + * @Date: 2021/8/12 3:30 下午 + * @Version: 1.0 + */ +public class DingDingDepartmentVO { + + private Long dingdingDepartmentId; + private Long dingdingDepartmentParentId; + private String departmentId; + private String departmentParentId; + private String departmentName; + + public Long getDingdingDepartmentId() { + return dingdingDepartmentId == null ? 0 : dingdingDepartmentId; + } + + public void setDingdingDepartmentId(Long dingdingDepartmentId) { + this.dingdingDepartmentId = dingdingDepartmentId; + } + + public Long getDingdingDepartmentParentId() { + return dingdingDepartmentParentId == null ? 0 : dingdingDepartmentParentId; + } + + public void setDingdingDepartmentParentId(Long dingdingDepartmentParentId) { + this.dingdingDepartmentParentId = dingdingDepartmentParentId; + } + + public String getDepartmentId() { + return departmentId == null ? "" : departmentId.trim(); + } + + public void setDepartmentId(String departmentId) { + this.departmentId = departmentId; + } + + public String getDepartmentParentId() { + return departmentParentId == null ? "" : departmentParentId.trim(); + } + + public void setDepartmentParentId(String departmentParentId) { + this.departmentParentId = departmentParentId; + } + + public String getDepartmentName() { + return departmentName == null ? "" : departmentName.trim(); + } + + public void setDepartmentName(String departmentName) { + this.departmentName = departmentName; + } + +} diff --git a/cloud-common-dingding/src/main/java/com/cm/common/dingding/pojo/vos/DingDingUserVO.java b/cloud-common-dingding/src/main/java/com/cm/common/dingding/pojo/vos/DingDingUserVO.java new file mode 100644 index 0000000..f0861da --- /dev/null +++ b/cloud-common-dingding/src/main/java/com/cm/common/dingding/pojo/vos/DingDingUserVO.java @@ -0,0 +1,66 @@ +package com.cm.common.dingding.pojo.vos; + +/** + * @ClassName: DingDingUserVO + * @Description: 钉钉用户 + * @Author: wanggeng + * @Date: 2021/8/12 3:28 下午 + * @Version: 1.0 + */ +public class DingDingUserVO { + + private String unionid; + private String dingdingUserId; + private String userId; + private String name; + private String mobile; + private String deptIdList; + + public String getUnionid() { + return unionid == null ? "" : unionid.trim(); + } + + public void setUnionid(String unionid) { + this.unionid = unionid; + } + + public String getDingdingUserId() { + return dingdingUserId == null ? "" : dingdingUserId.trim(); + } + + public void setDingdingUserId(String dingdingUserId) { + this.dingdingUserId = dingdingUserId; + } + + public String getUserId() { + return userId == null ? "" : userId.trim(); + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getName() { + return name == null ? "" : name.trim(); + } + + public void setName(String name) { + this.name = name; + } + + public String getMobile() { + return mobile == null ? "" : mobile.trim(); + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } + + public String getDeptIdList() { + return deptIdList == null ? "" : deptIdList.trim(); + } + + public void setDeptIdList(String deptIdList) { + this.deptIdList = deptIdList; + } +} diff --git a/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/IDingDingAppDepartmentService.java b/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/IDingDingAppDepartmentService.java index ab7dbfe..e7733d4 100644 --- a/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/IDingDingAppDepartmentService.java +++ b/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/IDingDingAppDepartmentService.java @@ -1,6 +1,7 @@ package com.cm.common.dingding.service; -import com.alibaba.fastjson.JSONObject; +import com.cm.common.dingding.pojo.pos.DingDingDepartmentPO; +import com.cm.common.dingding.pojo.vos.DingDingDepartmentVO; import com.dingtalk.api.response.OapiV2DepartmentListsubResponse; import com.taobao.api.ApiException; @@ -15,6 +16,13 @@ import java.util.List; */ public interface IDingDingAppDepartmentService { + /** + * 保存 + * + * @param dingDingDepartmentVO + */ + void save(DingDingDepartmentVO dingDingDepartmentVO) throws Exception; + /** * 部门全部列表,无层级 * @@ -22,4 +30,20 @@ public interface IDingDingAppDepartmentService { */ List listAll() throws ApiException; + /** + * 部门列表 + * + * @param parentId + * @return + * @throws ApiException + */ + List list(Long parentId) throws ApiException; + + /** + * 部门详情 + * + * @param deptId + * @return + */ + DingDingDepartmentPO getPO(Long deptId); } diff --git a/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/IDingDingAppUserService.java b/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/IDingDingAppUserService.java index 3ff9151..2389510 100644 --- a/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/IDingDingAppUserService.java +++ b/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/IDingDingAppUserService.java @@ -1,5 +1,7 @@ package com.cm.common.dingding.service; +import com.cm.common.dingding.pojo.pos.DingDingUserPO; +import com.cm.common.dingding.pojo.vos.DingDingUserVO; import com.cm.common.exception.SearchException; import com.dingtalk.api.response.OapiUserGetResponse; import com.dingtalk.api.response.OapiV2UserListResponse; @@ -19,6 +21,14 @@ import java.util.List; **/ public interface IDingDingAppUserService { + /** + * 保存 + * + * @param dingDingUserVO + * @throws Exception + */ + void save(DingDingUserVO dingDingUserVO) throws Exception; + /** * 通过UnionId获取userId * @@ -61,4 +71,11 @@ public interface IDingDingAppUserService { */ List listByDeptIds(List deptIds) throws ApiException; + /** + * 详情 + * + * @param dingDingUserId + * @return + */ + DingDingUserPO getPO(String dingDingUserId); } diff --git a/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/impl/DingDingAppDepartmentServiceImpl.java b/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/impl/DingDingAppDepartmentServiceImpl.java index 6b3589b..ecb57ce 100644 --- a/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/impl/DingDingAppDepartmentServiceImpl.java +++ b/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/impl/DingDingAppDepartmentServiceImpl.java @@ -1,21 +1,23 @@ package com.cm.common.dingding.service.impl; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.cm.common.base.AbstractService; +import com.cm.common.dingding.dao.IDingDingDepartmentDao; import com.cm.common.dingding.manager.app.DingDingAppManager; +import com.cm.common.dingding.pojo.pos.DingDingDepartmentPO; +import com.cm.common.dingding.pojo.vos.DingDingDepartmentVO; import com.cm.common.dingding.service.IDingDingAppDepartmentService; +import com.cm.common.utils.HashMapUtil; import com.dingtalk.api.DefaultDingTalkClient; import com.dingtalk.api.DingTalkClient; -import com.dingtalk.api.request.OapiUserSimplelistRequest; import com.dingtalk.api.request.OapiV2DepartmentListsubRequest; -import com.dingtalk.api.response.OapiUserSimplelistResponse; import com.dingtalk.api.response.OapiV2DepartmentListsubResponse; import com.taobao.api.ApiException; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * @ClassName: DingDingAppDepartmentServiceImpl @@ -27,6 +29,16 @@ import java.util.List; @Service public class DingDingAppDepartmentServiceImpl extends AbstractService implements IDingDingAppDepartmentService { + @Autowired + private IDingDingDepartmentDao dingDingDepartmentDao; + + @Override + public void save(DingDingDepartmentVO dingDingDepartmentVO) throws Exception { + Map params = HashMapUtil.beanToMap(dingDingDepartmentVO); + setSaveInfoByUserId(params, "1"); + dingDingDepartmentDao.save(params); + } + @Override public List listAll() throws ApiException { List deptBaseResponses = new ArrayList<>(); @@ -34,13 +46,25 @@ public class DingDingAppDepartmentServiceImpl extends AbstractService implements return deptBaseResponses; } - private void buildDeptList(Long parentDeptId, List deptBaseResponses) throws ApiException { + @Override + public List list(Long parentDeptId) throws ApiException { DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub"); OapiV2DepartmentListsubRequest oapiV2DepartmentListsubRequest = new OapiV2DepartmentListsubRequest(); oapiV2DepartmentListsubRequest.setDeptId(parentDeptId); oapiV2DepartmentListsubRequest.setLanguage("zh_CN"); OapiV2DepartmentListsubResponse rsp = client.execute(oapiV2DepartmentListsubRequest, DingDingAppManager.getInstance().getAccessToken()); - List subDepts = rsp.getResult(); + return rsp.getResult(); + } + + @Override + public DingDingDepartmentPO getPO(Long deptId) { + Map params = getHashMap(2); + params.put("dingDingDepartmentId", deptId); + return dingDingDepartmentDao.getPO(params); + } + + private void buildDeptList(Long parentDeptId, List deptBaseResponses) throws ApiException { + List subDepts = list(parentDeptId); if (!subDepts.isEmpty()) { for (OapiV2DepartmentListsubResponse.DeptBaseResponse subDept : subDepts) { deptBaseResponses.add(subDept); diff --git a/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/impl/DingDingAppUserServiceImpl.java b/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/impl/DingDingAppUserServiceImpl.java index b526d2c..92f9fa9 100644 --- a/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/impl/DingDingAppUserServiceImpl.java +++ b/cloud-common-dingding/src/main/java/com/cm/common/dingding/service/impl/DingDingAppUserServiceImpl.java @@ -2,9 +2,13 @@ package com.cm.common.dingding.service.impl; import com.cm.common.base.AbstractService; import com.cm.common.dingding.config.properties.DingDingAppProperties; +import com.cm.common.dingding.dao.IDingDingUserDao; import com.cm.common.dingding.manager.app.DingDingAppManager; +import com.cm.common.dingding.pojo.pos.DingDingUserPO; +import com.cm.common.dingding.pojo.vos.DingDingUserVO; import com.cm.common.dingding.service.IDingDingAppUserService; import com.cm.common.exception.SearchException; +import com.cm.common.utils.HashMapUtil; import com.dingtalk.api.DefaultDingTalkClient; import com.dingtalk.api.DingTalkClient; import com.dingtalk.api.request.OapiUserGetByMobileRequest; @@ -21,6 +25,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * When you feel like quitting. Think about why you started @@ -37,6 +42,15 @@ public class DingDingAppUserServiceImpl extends AbstractService implements IDing @Autowired private DingDingAppProperties dingDingAppProperties; + @Autowired + private IDingDingUserDao dingDingUserDao; + + @Override + public void save(DingDingUserVO dingDingUserVO) throws Exception { + Map params = HashMapUtil.beanToMap(dingDingUserVO); + setSaveInfoByUserId(params, "1"); + dingDingUserDao.save(params); + } @Override public String getUserIdByUnionId(String unionId) throws SearchException { @@ -103,7 +117,7 @@ public class DingDingAppUserServiceImpl extends AbstractService implements IDing OapiV2UserListRequest req = new OapiV2UserListRequest(); req.setDeptId(deptId); req.setCursor(cursor); - req.setSize(1000L); + req.setSize(100L); req.setContainAccessLimit(true); req.setLanguage("zh_CN"); OapiV2UserListResponse oapiV2UserListResponse = client.execute(req, DingDingAppManager.getInstance().getAccessToken()); @@ -127,4 +141,11 @@ public class DingDingAppUserServiceImpl extends AbstractService implements IDing return userResponses; } + @Override + public DingDingUserPO getPO(String dingDingUserId) { + Map params = getHashMap(2); + params.put("dingDingUserId", dingDingUserId); + return dingDingUserDao.getPO(params); + } + } diff --git a/cloud-common-dingding/src/main/resources/mybatis/mapper/dingding-department-mapper.xml b/cloud-common-dingding/src/main/resources/mybatis/mapper/dingding-department-mapper.xml new file mode 100644 index 0000000..9e9fed5 --- /dev/null +++ b/cloud-common-dingding/src/main/resources/mybatis/mapper/dingding-department-mapper.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + INSERT INTO sys_dingding_department( + dingding_department_id, + dingding_department_parent_id, + department_id, + department_parent_id, + department_name, + gmt_create, + gmt_modified + ) VALUES( + #{dingdingDepartmentId}, + #{dingdingDepartmentParentId}, + #{departmentId}, + #{departmentParentId}, + #{departmentName}, + #{gmtCreate}, + #{gmtModified} + ) + + + + + + \ No newline at end of file diff --git a/cloud-common-dingding/src/main/resources/mybatis/mapper/dingding-user-mapper.xml b/cloud-common-dingding/src/main/resources/mybatis/mapper/dingding-user-mapper.xml new file mode 100644 index 0000000..a61f28c --- /dev/null +++ b/cloud-common-dingding/src/main/resources/mybatis/mapper/dingding-user-mapper.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + INSERT INTO sys_dingding_user( + unionid, + dingding_user_id, + user_id, + name, + mobile, + dept_id_list, + gmt_create, + gmt_modified + ) VALUES( + #{unionid}, + #{dingdingUserId}, + #{userId}, + #{name}, + #{mobile}, + #{deptIdList}, + #{gmtCreate}, + #{gmtModified} + ) + + + + + + \ No newline at end of file diff --git a/cloud-common-plugin/src/main/resources/templates/file/file-upload-v2.html b/cloud-common-plugin/src/main/resources/templates/file/file-upload-v2.html index 94bd7bf..953181d 100644 --- a/cloud-common-plugin/src/main/resources/templates/file/file-upload-v2.html +++ b/cloud-common-plugin/src/main/resources/templates/file/file-upload-v2.html @@ -30,7 +30,9 @@