Commit d6d163a1 by 水库浪子

提交企业微信微信企业ID管理,组织机构管理相关接口

1 parent 84bf1e06
Showing 26 changed files with 404 additions and 91 deletions
@echo off
echo.
echo [Ϣ] ·
echo.
%~d0
cd %~dp0
cd ..
call mvn clean
pause
\ No newline at end of file
@echo off
echo.
echo [信息] 打包Web工程,生成war/jar包文件。
echo.
%~d0
cd %~dp0
cd ..
call mvn clean package -Dmaven.test.skip=true
pause
\ No newline at end of file
@echo off
echo.
echo [Ϣ] Web̡
echo.
cd %~dp0
cd ../ruoyi-admin/target
set JAVA_OPTS=-Xms256m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
java -jar %JAVA_OPTS% ruoyi-admin.jar
cd bin
pause
\ No newline at end of file
No preview for this file type
package com.linkwechat;
import com.thebeastshop.forest.springboot.annotation.ForestScan;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......@@ -12,6 +13,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
*/
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@MapperScan("com.linkwechat.*.mapper")
@ForestScan(basePackages = "com.linkwechat.wecom.client")
public class RuoYiApplication
{
public static void main(String[] args)
......
......@@ -5,8 +5,7 @@ import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.utils.poi.ExcelUtil;
import com.linkwechat.wecom.domain.WxCorpAccount;
import com.linkwechat.wecom.domain.WeCorpAccount;
import com.linkwechat.wecom.service.IWxCorpAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -21,7 +20,7 @@ import java.util.List;
* @date 2020-08-24
*/
@RestController
@RequestMapping("/wechat/corp")
@RequestMapping("/wecom/corp")
public class WxCorpAccountController extends BaseController
{
@Autowired
......@@ -32,25 +31,25 @@ public class WxCorpAccountController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('wechat:corp:list')")
@GetMapping("/list")
public TableDataInfo list(WxCorpAccount wxCorpAccount)
public TableDataInfo list(WeCorpAccount wxCorpAccount)
{
startPage();
List<WxCorpAccount> list = wxCorpAccountService.selectWxCorpAccountList(wxCorpAccount);
List<WeCorpAccount> list = wxCorpAccountService.selectWxCorpAccountList(wxCorpAccount);
return getDataTable(list);
}
/**
* 导出企业id相关配置列表
*/
@PreAuthorize("@ss.hasPermi('wechat:corp:export')")
@Log(title = "企业id相关配置", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(WxCorpAccount wxCorpAccount)
{
List<WxCorpAccount> list = wxCorpAccountService.selectWxCorpAccountList(wxCorpAccount);
ExcelUtil<WxCorpAccount> util = new ExcelUtil<WxCorpAccount>(WxCorpAccount.class);
return util.exportExcel(list, "corp");
}
// /**
// * 导出企业id相关配置列表
// */
// @PreAuthorize("@ss.hasPermi('wechat:corp:export')")
// @Log(title = "企业id相关配置", businessType = BusinessType.EXPORT)
// @GetMapping("/export")
// public AjaxResult export(WxCorpAccount wxCorpAccount)
// {
// List<WxCorpAccount> list = wxCorpAccountService.selectWxCorpAccountList(wxCorpAccount);
// ExcelUtil<WxCorpAccount> util = new ExcelUtil<WxCorpAccount>(WxCorpAccount.class);
// return util.exportExcel(list, "corp");
// }
/**
* 获取企业id相关配置详细信息
......@@ -68,7 +67,7 @@ public class WxCorpAccountController extends BaseController
@PreAuthorize("@ss.hasPermi('wechat:corp:add')")
@Log(title = "企业id相关配置", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody WxCorpAccount wxCorpAccount)
public AjaxResult add(@RequestBody WeCorpAccount wxCorpAccount)
{
return toAjax(wxCorpAccountService.insertWxCorpAccount(wxCorpAccount));
}
......@@ -79,7 +78,7 @@ public class WxCorpAccountController extends BaseController
@PreAuthorize("@ss.hasPermi('wechat:corp:edit')")
@Log(title = "企业id相关配置", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody WxCorpAccount wxCorpAccount)
public AjaxResult edit(@RequestBody WeCorpAccount wxCorpAccount)
{
return toAjax(wxCorpAccountService.updateWxCorpAccount(wxCorpAccount));
}
......@@ -94,4 +93,5 @@ public class WxCorpAccountController extends BaseController
{
return toAjax(wxCorpAccountService.deleteWxCorpAccountByIds(ids));
}
}
......@@ -117,3 +117,7 @@ xss:
excludes: /system/notice/*
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
# forest配置
forest:
interceptors: com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor
\ No newline at end of file
......@@ -119,6 +119,11 @@
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>com.dtflys.forest</groupId>
<artifactId>spring-boot-starter-forest</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.linkwechat.common.constant;
/**
* @description: 企业微信相关常量
* @author: HaoN
* @create: 2020-08-26 17:01
**/
public class WxConstans {
/**
* 企业微信相关token
*/
public static final String WX_ACCESS_TOKEN = "WxAccessToken";
}
package com.linkwechat.common.exception.wecom;
/**
* @description: 企业微信相关异常类
* @author: My
* @create: 2020-08-26 16:52
**/
public class WeComException {
}
package com.linkwechat.wecom.client;
public interface CommonClient {
}
package com.linkwechat.wecom.client;
import com.dtflys.forest.annotation.Query;
import com.dtflys.forest.annotation.Request;
import com.linkwechat.wecom.domain.WeAccessToken;
/**
* @description: 获取企业微信Token相关
* @author: HaoN
* @create: 2020-08-26 14:33
**/
public interface WeAccessTokenClient {
/**
* 获取token
* @param corpId 企业id
* @param corpSecret 应用的凭证密钥
* @return
*/
@Request(url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken")
WeAccessToken getToken(@Query("corpid")String corpId, @Query("corpsecret") String corpSecret);
}
\ No newline at end of file
package com.linkwechat.wecom.client;
import com.dtflys.forest.annotation.DataObject;
import com.dtflys.forest.annotation.Query;
import com.dtflys.forest.annotation.Request;
import com.linkwechat.wecom.domain.WeDepartMent;
import com.linkwechat.wecom.domain.WeResult;
/**
* @description: 企业微信部门相关客户端
* @author: HaoN
* @create: 2020-08-27 16:40
**/
public interface WeDepartMentClient {
/**
* 创建部门
* @param weDepartMent
* @return
*/
@Request(url="https://qyapi.weixin.qq.com/cgi-bin/department/create",
type = "POST"
)
WeResult createWeDepartMent(@DataObject WeDepartMent weDepartMent);
/**
* 更新部门
* @param weDepartMent
* @return
*/
@Request(url="https://qyapi.weixin.qq.com/cgi-bin/department/update",
type = "POST"
)
WeResult updateWeDepartMent(@DataObject WeDepartMent weDepartMent);
/**
* 通过部门id删除部门 (注:不能删除根部门;不能删除含有子部门、成员的部门)
* @param departMnentId
* @return
*/
@Request(url = "https://qyapi.weixin.qq.com/cgi-bin/department/delete")
WeResult deleteWeDepartMent(@Query("id") String departMnentId);
/**
* 获取部门列表
* @return
*/
@Request(url = "https://qyapi.weixin.qq.com/cgi-bin/department/list")
WeDepartMent weDepartMents();
}
\ No newline at end of file
package com.linkwechat.wecom.domain;
public class AccessToken {
private Integer errcode;
private String errmsg;
private String access_token;
private Long expires_in;
}
package com.linkwechat.wecom.domain;
/**
* @description: accessToken相关
* @author: HaoN
* @create: 2020-08-27 15:54
**/
public class WeAccessToken extends WeResult{
private String access_token;
private Long expires_in;
}
......@@ -11,7 +11,7 @@ import com.linkwechat.common.core.domain.BaseEntity;
* @author ruoyi
* @date 2020-08-24
*/
public class WxCorpAccount extends BaseEntity
public class WeCorpAccount extends BaseEntity
{
private static final long serialVersionUID = 1L;
......
package com.linkwechat.wecom.domain;
import java.util.List;
/**
* @description: 企业部门
* @author: HaoN
* @create: 2020-08-27 15:54
**/
public class WeDepartMent extends WeResult {
private List<DeartMent> deartMents;
class DeartMent{
private String name;
private String name_en;
private Long parentid;
private Long order;
}
}
package com.linkwechat.wecom.domain;
/**
* @description: 统一返回体
* @author: HaoN
* @create: 2020-08-27 15:59
**/
public class WeResult {
private Long id;
private Integer errcode;
private String errmsg;
}
package com.linkwechat.wecom.domain;
/**
* @description: 通讯录用户
* @author: HaoN
* @create: 2020-08-28 10:45
**/
public class WeUser {
//成员头像的mediaid,通过素材管理接口上传图片获得的mediaid
private String avatar_mediaid;
//姓名
private String name;
//昵称
private String alias;
//账号
private String userid;
//性别。1表示男性,2表示女性
private String gender;
//手机号码。企业内必须唯一,mobile/email二者不能同时为空
private String mobile;
//邮箱
private String email;
//成员所属部门id列表,不超过100个
private Long[] department;
//职位
private String position;
//身份:表示在所在的部门内是否为上级。1表示为上级,0表示非上级。
private Long[] is_leader_in_dept;
//启用/禁用成员。1表示启用成员,0表示禁用成员
private Integer enable;
//座机。32字节以内,由纯数字或’-‘号组成。
private String telephone;
//地址
private String address;
//
// private Long main_department;
// private boolean to_invite;
// private String external_position;
}
package com.linkwechat.wecom.interceptor;
import com.dtflys.forest.exceptions.ForestRuntimeException;
import com.dtflys.forest.http.ForestRequest;
import com.dtflys.forest.http.ForestResponse;
import com.dtflys.forest.interceptor.Interceptor;
/**
* @description: 微信token拦截器
* @author: HaoN
* @create: 2020-08-27 22:36
**/
public class WeAccessTokenInterceptor implements Interceptor {
/**
* 该方法在请求发送之前被调用, 若返回false则不会继续发送请求
*/
@Override
public boolean beforeExecute(ForestRequest request) {
// 1.从缓存中获取token,如果缓存中不存在,则调用接口,重新获取。
// 获取到的的token,校验是否失效,如果失效了,则重新获取
request.addQuery("access_token", "11111111"); // 添加URL的Query参数
return true; // 继续执行请求返回true
}
/**
* 请求发送失败时被调用
* @param e
* @param forestRequest
* @param forestResponse
*/
@Override
public void onError(ForestRuntimeException e, ForestRequest forestRequest, ForestResponse forestResponse) {
}
/**
* 该方法在请求成功响应时被调用
* @param o
* @param forestRequest
* @param forestResponse
*/
@Override
public void onSuccess(Object o, ForestRequest forestRequest, ForestResponse forestResponse) {
}
}
package com.linkwechat.wecom.mapper;
import java.util.List;
import com.linkwechat.wecom.domain.WxCorpAccount;
import com.linkwechat.wecom.domain.WeCorpAccount;
/**
* 企业id相关配置Mapper接口
......@@ -17,7 +17,7 @@ public interface WxCorpAccountMapper
* @param id 企业id相关配置ID
* @return 企业id相关配置
*/
public WxCorpAccount selectWxCorpAccountById(Long id);
public WeCorpAccount selectWxCorpAccountById(Long id);
/**
* 查询企业id相关配置列表
......@@ -25,7 +25,7 @@ public interface WxCorpAccountMapper
* @param wxCorpAccount 企业id相关配置
* @return 企业id相关配置集合
*/
public List<WxCorpAccount> selectWxCorpAccountList(WxCorpAccount wxCorpAccount);
public List<WeCorpAccount> selectWxCorpAccountList(WeCorpAccount wxCorpAccount);
/**
* 新增企业id相关配置
......@@ -33,7 +33,7 @@ public interface WxCorpAccountMapper
* @param wxCorpAccount 企业id相关配置
* @return 结果
*/
public int insertWxCorpAccount(WxCorpAccount wxCorpAccount);
public int insertWxCorpAccount(WeCorpAccount wxCorpAccount);
/**
* 修改企业id相关配置
......@@ -41,7 +41,7 @@ public interface WxCorpAccountMapper
* @param wxCorpAccount 企业id相关配置
* @return 结果
*/
public int updateWxCorpAccount(WxCorpAccount wxCorpAccount);
public int updateWxCorpAccount(WeCorpAccount wxCorpAccount);
/**
* 删除企业id相关配置
......
package com.linkwechat.wecom.service;
/**
* @description: 微信token相关接口
* @author: My
* @create: 2020-08-26 14:43
**/
public interface IWeAccessTokenService {
void findToken();
}
\ No newline at end of file
package com.linkwechat.wecom.service;
import java.util.List;
import com.linkwechat.wecom.domain.WxCorpAccount;
import com.linkwechat.wecom.domain.WeCorpAccount;
/**
* 企业id相关配置Service接口
......@@ -17,7 +17,7 @@ public interface IWxCorpAccountService
* @param id 企业id相关配置ID
* @return 企业id相关配置
*/
public WxCorpAccount selectWxCorpAccountById(Long id);
public WeCorpAccount selectWxCorpAccountById(Long id);
/**
* 查询企业id相关配置列表
......@@ -25,7 +25,7 @@ public interface IWxCorpAccountService
* @param wxCorpAccount 企业id相关配置
* @return 企业id相关配置集合
*/
public List<WxCorpAccount> selectWxCorpAccountList(WxCorpAccount wxCorpAccount);
public List<WeCorpAccount> selectWxCorpAccountList(WeCorpAccount wxCorpAccount);
/**
* 新增企业id相关配置
......@@ -33,7 +33,7 @@ public interface IWxCorpAccountService
* @param wxCorpAccount 企业id相关配置
* @return 结果
*/
public int insertWxCorpAccount(WxCorpAccount wxCorpAccount);
public int insertWxCorpAccount(WeCorpAccount wxCorpAccount);
/**
* 修改企业id相关配置
......@@ -41,7 +41,7 @@ public interface IWxCorpAccountService
* @param wxCorpAccount 企业id相关配置
* @return 结果
*/
public int updateWxCorpAccount(WxCorpAccount wxCorpAccount);
public int updateWxCorpAccount(WeCorpAccount wxCorpAccount);
/**
* 批量删除企业id相关配置
......@@ -58,4 +58,13 @@ public interface IWxCorpAccountService
* @return 结果
*/
public int deleteWxCorpAccountById(Long id);
/**
* 获取有效的企业id
*
* @return 结果
*/
public WeCorpAccount findValidWxCorpAccount();
}
package com.linkwechat.wecom.service.impl;
import com.linkwechat.wecom.client.WeAccessTokenClient;
import com.linkwechat.wecom.domain.WeAccessToken;
import com.linkwechat.wecom.domain.WeCorpAccount;
import com.linkwechat.wecom.service.IWeAccessTokenService;
import com.linkwechat.wecom.service.IWxCorpAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
/**
* @description: 微信token相关接口
* @author: My
* @create: 2020-08-26 14:43
**/
@Service
public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
@Autowired
private WeAccessTokenClient accessTokenClient;
@Autowired
private IWxCorpAccountService iWxCorpAccountService;
@Autowired
private RedisTemplate redisTemplate;
/**
* 获取accessToken
*/
@Override
public void findToken() {
WeCorpAccount wxCorpAccount
= iWxCorpAccountService.findValidWxCorpAccount();
if(null == wxCorpAccount){
//返回错误异常,让用户绑定企业id相关信息
}
WeAccessToken accessToken
= accessTokenClient.getToken(wxCorpAccount.getCorpId(), wxCorpAccount.getCorpSecret());
if(null != accessToken){
//token存入redis中(清空原有的token)
// redisTemplate.opsForValue().set();
}
}
}
......@@ -6,7 +6,7 @@ import com.linkwechat.wecom.service.IWxCorpAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.mapper.WxCorpAccountMapper;
import com.linkwechat.wecom.domain.WxCorpAccount;
import com.linkwechat.wecom.domain.WeCorpAccount;
/**
* 企业id相关配置Service业务层处理
......@@ -27,7 +27,7 @@ public class WxCorpAccountServiceImpl implements IWxCorpAccountService
* @return 企业id相关配置
*/
@Override
public WxCorpAccount selectWxCorpAccountById(Long id)
public WeCorpAccount selectWxCorpAccountById(Long id)
{
return wxCorpAccountMapper.selectWxCorpAccountById(id);
}
......@@ -39,7 +39,7 @@ public class WxCorpAccountServiceImpl implements IWxCorpAccountService
* @return 企业id相关配置
*/
@Override
public List<WxCorpAccount> selectWxCorpAccountList(WxCorpAccount wxCorpAccount)
public List<WeCorpAccount> selectWxCorpAccountList(WeCorpAccount wxCorpAccount)
{
return wxCorpAccountMapper.selectWxCorpAccountList(wxCorpAccount);
}
......@@ -51,7 +51,7 @@ public class WxCorpAccountServiceImpl implements IWxCorpAccountService
* @return 结果
*/
@Override
public int insertWxCorpAccount(WxCorpAccount wxCorpAccount)
public int insertWxCorpAccount(WeCorpAccount wxCorpAccount)
{
wxCorpAccount.setCreateTime(DateUtils.getNowDate());
return wxCorpAccountMapper.insertWxCorpAccount(wxCorpAccount);
......@@ -64,7 +64,7 @@ public class WxCorpAccountServiceImpl implements IWxCorpAccountService
* @return 结果
*/
@Override
public int updateWxCorpAccount(WxCorpAccount wxCorpAccount)
public int updateWxCorpAccount(WeCorpAccount wxCorpAccount)
{
wxCorpAccount.setUpdateTime(DateUtils.getNowDate());
return wxCorpAccountMapper.updateWxCorpAccount(wxCorpAccount);
......@@ -93,4 +93,15 @@ public class WxCorpAccountServiceImpl implements IWxCorpAccountService
{
return wxCorpAccountMapper.deleteWxCorpAccountById(id);
}
/**
* 获取有效的企业id
*
* @return 结果
*/
@Override
public WeCorpAccount findValidWxCorpAccount() {
return null;
}
}
......@@ -30,6 +30,7 @@
<poi.version>3.17</poi.version>
<velocity.version>1.7</velocity.version>
<jwt.version>0.9.0</jwt.version>
<forest.version>1.4.0</forest.version>
</properties>
<!-- 依赖声明 -->
......@@ -189,6 +190,13 @@
<version>${linkwe.version}</version>
</dependency>
<!--forset-->
<dependency>
<groupId>com.dtflys.forest</groupId>
<artifactId>spring-boot-starter-forest</artifactId>
<version>${forest.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!