Commit 27580fc1 by HaoN

查询通讯录组织架构增加校验是否存在组织架构根节点,不存在则从企业微信服务器拉取根节点入库

1 parent 2c012173
...@@ -18,7 +18,6 @@ public class RuoYiApplication ...@@ -18,7 +18,6 @@ public class RuoYiApplication
{ {
public static void main(String[] args) public static void main(String[] args)
{ {
// System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(RuoYiApplication.class, args); SpringApplication.run(RuoYiApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ LinkWeChat启动成功 ლ(´ڡ`ლ)゙ \n" + System.out.println("(♥◠‿◠)ノ゙ LinkWeChat启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" + " .-------. ____ __ \n" +
......
package com.linkwechat.web.controller.wecom; package com.linkwechat.web.controller.wecom;
import java.util.List;
import com.linkwechat.common.annotation.Log; import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType; import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.utils.poi.ExcelUtil; import com.linkwechat.wecom.domain.WeDepartment;
import com.linkwechat.wecom.service.IWeDepartmentService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PutMapping; import java.util.List;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.linkwechat.wecom.domain.WeDepartment;
import com.linkwechat.wecom.service.IWeDepartmentService;
/** /**
* 企业微信组织架构相关Controller * 企业微信组织架构相关Controller
...@@ -37,29 +27,21 @@ public class WeDepartmentController extends BaseController ...@@ -37,29 +27,21 @@ public class WeDepartmentController extends BaseController
@Autowired @Autowired
private IWeDepartmentService weDepartmentService; private IWeDepartmentService weDepartmentService;
/** /**
* 查询企业微信组织架构相关列表 * 查询企业微信组织架构相关列表
*/ */
@PreAuthorize("@ss.hasPermi('wecom:department:list')") @PreAuthorize("@ss.hasPermi('wecom:department:list')")
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("获取部门列表") @ApiOperation("获取部门列表")
public TableDataInfo list() public AjaxResult list()
{ {
List<WeDepartment> list = weDepartmentService.selectWeDepartmentList(); List<WeDepartment> list = weDepartmentService.selectWeDepartmentList();
return getDataTable(list); return AjaxResult.success(list);
} }
//
//
//
// /**
// * 获取企业微信组织架构相关详细信息
// */
// @PreAuthorize("@ss.hasPermi('wecom:department:query')")
// @GetMapping(value = "/{id}")
// public AjaxResult getInfo(@PathVariable("id") Long id)
// {
// return AjaxResult.success(weDepartmentService.selectWeDepartmentById(id));
// }
/** /**
* 新增企业微信组织架构相关 * 新增企业微信组织架构相关
......
...@@ -35,17 +35,17 @@ public class WeUserController extends BaseController ...@@ -35,17 +35,17 @@ public class WeUserController extends BaseController
@Autowired @Autowired
private IWeUserService weUserService; private IWeUserService weUserService;
/** // /**
* 查询通讯录相关客户列表 // * 查询通讯录相关客户列表
*/ // */
@PreAuthorize("@ss.hasPermi('wecom:user:list')") // @PreAuthorize("@ss.hasPermi('wecom:user:list')")
@GetMapping("/list") // @GetMapping("/list")
public TableDataInfo list(WeUser weUser) // public TableDataInfo list(WeUser weUser)
{ // {
startPage(); // startPage();
List<WeUser> list = weUserService.selectWeUserList(weUser); // List<WeUser> list = weUserService.selectWeUserList(weUser);
return getDataTable(list); // return getDataTable(list);
} // }
/** /**
* 导出通讯录相关客户列表 * 导出通讯录相关客户列表
......
...@@ -121,6 +121,7 @@ xss: ...@@ -121,6 +121,7 @@ xss:
# forest配置 # forest配置
forest: forest:
interceptors: com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor interceptors: com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor
backend: httpclient
wecome: wecome:
......
...@@ -22,5 +22,5 @@ public class WeConstans { ...@@ -22,5 +22,5 @@ public class WeConstans {
/** /**
* 企业微信端根部门id * 企业微信端根部门id
*/ */
public static final Long WE_ROOT_DEPARMENT_ID = new Long(1); public static final Long WE_ROOT_DEPARMENT_ID = 1L;
} }
...@@ -48,10 +48,11 @@ public interface WeDepartMentClient { ...@@ -48,10 +48,11 @@ public interface WeDepartMentClient {
/** /**
* 获取部门列表 * 获取部门列表
* @return * @return @Query("id") Long id
*/ */
@Request(url = "/department/list") @Request(url = "/department/list",
String weDepartMents(@Query("id") Long id); dataType = "json")
WeDepartMentDto weDepartMents(@Query("id")Long id);
/** /**
...@@ -59,7 +60,7 @@ public interface WeDepartMentClient { ...@@ -59,7 +60,7 @@ public interface WeDepartMentClient {
* @param sizeType qrcode尺寸类型,1: 171 x 171; 2: 399 x 399; 3: 741 x 741; 4: 2052 x 2052 * @param sizeType qrcode尺寸类型,1: 171 x 171; 2: 399 x 399; 3: 741 x 741; 4: 2052 x 2052
* @return * @return
*/ */
@Request(url = " /corp/get_join_qrcode") @Request(url = "/corp/get_join_qrcode")
WeUserQrcodeDto getJoinQrcode(@Query("size_type") Integer sizeType); WeUserQrcodeDto getJoinQrcode(@Query("size_type") Integer sizeType);
......
...@@ -42,7 +42,7 @@ public class WeDepartment extends BaseEntity ...@@ -42,7 +42,7 @@ public class WeDepartment extends BaseEntity
} }
/** 企业微信通讯录部门的dto对象转化为系统通讯录部门对象 */ /** 企业微信通讯录部门的dto对象转化为系统通讯录部门对象 */
public WeDepartment transformWeDepartment(WeDepartMentDto.DeartMentDto deartMentDto){ public static WeDepartment transformWeDepartment(WeDepartMentDto.DeartMentDto deartMentDto){
WeDepartment weDepartment=new WeDepartment(); WeDepartment weDepartment=new WeDepartment();
BeanUtils.copyPropertiesignoreOther(deartMentDto,weDepartment); BeanUtils.copyPropertiesignoreOther(deartMentDto,weDepartment);
......
...@@ -22,81 +22,62 @@ public class WeUser extends BaseEntity ...@@ -22,81 +22,62 @@ public class WeUser extends BaseEntity
private Long id; private Long id;
/** 头像地址 */ /** 头像地址 */
@Excel(name = "头像地址")
private String headImageUrl; private String headImageUrl;
/** 用户名称 */ /** 用户名称 */
@Excel(name = "用户名称")
private String userName; private String userName;
/** 用户昵称 */ /** 用户昵称 */
@Excel(name = "用户昵称")
private String alias; private String alias;
/** 账号 */ /** 账号 */
@Excel(name = "账号")
private String userId; private String userId;
/** 性别。1表示男性,2表示女性 */ /** 性别。1表示男性,2表示女性 */
@Excel(name = "性别。1表示男性,2表示女性")
private Integer gender; private Integer gender;
/** 手机号 */ /** 手机号 */
@Excel(name = "手机号")
private String mobile; private String mobile;
/** 邮箱 */ /** 邮箱 */
@Excel(name = "邮箱")
private String email; private String email;
/** 个人微信号 */ /** 个人微信号 */
@Excel(name = "个人微信号")
private String wxAccount; private String wxAccount;
/** 用户所属部门,使用逗号隔开,字符串格式存储 */ /** 用户所属部门,使用逗号隔开,字符串格式存储 */
@Excel(name = "用户所属部门,使用逗号隔开,字符串格式存储")
private String department; private String department;
/** 职务 */ /** 职务 */
@Excel(name = "职务")
private String position; private String position;
/** 1表示为上级,0表示普通成员(非上级)。 */ /** 1表示为上级,0表示普通成员(非上级)。 */
@Excel(name = "1表示为上级,0表示普通成员(非上级)。")
private Long isLeaderInDept; private Long isLeaderInDept;
/** 入职时间 */ /** 入职时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "入职时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date joinTime; private Date joinTime;
/** 是否启用(1表示启用成员,0表示禁用成员) */ /** 是否启用(1表示启用成员,0表示禁用成员) */
@Excel(name = "是否启用(1表示启用成员,0表示禁用成员)")
private Long enable; private Long enable;
/** 身份证号 */ /** 身份证号 */
@Excel(name = "身份证号")
private String idCard; private String idCard;
/** QQ号 */ /** QQ号 */
@Excel(name = "QQ号")
private String qqAccount; private String qqAccount;
/** 座机 */ /** 座机 */
@Excel(name = "座机")
private String telephone; private String telephone;
/** 地址 */ /** 地址 */
@Excel(name = "地址")
private String address; private String address;
/** 生日 */ /** 生日 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
private Date birthday; private Date birthday;
/** 是否激活(1:是;2:否)该字段主要表示当前信息是否同步微信 */ /** 是否激活(1:是;2:否)该字段主要表示当前信息是否同步微信 */
@Excel(name = "是否激活", readConverterExp = "1=:是;2:否")
private Long isActivate; private Long isActivate;
} }
...@@ -17,7 +17,7 @@ public class WeDepartMentDto extends WeResultDto { ...@@ -17,7 +17,7 @@ public class WeDepartMentDto extends WeResultDto {
private List<DeartMentDto> deartMents=new ArrayList<>(); private List<DeartMentDto> department=new ArrayList<>();
public WeDepartMentDto(){ public WeDepartMentDto(){
...@@ -28,7 +28,7 @@ public class WeDepartMentDto extends WeResultDto { ...@@ -28,7 +28,7 @@ public class WeDepartMentDto extends WeResultDto {
WeDepartMentDto.DeartMentDto deartMentDto=new WeDepartMentDto().new DeartMentDto(); WeDepartMentDto.DeartMentDto deartMentDto=new WeDepartMentDto().new DeartMentDto();
BeanUtils.copyPropertiesignoreOther(weDepartment,deartMentDto); BeanUtils.copyPropertiesignoreOther(weDepartment,deartMentDto);
deartMents.add(deartMentDto); department.add(deartMentDto);
} }
......
package com.linkwechat.wecom.interceptor; package com.linkwechat.wecom.interceptor;
import com.dtflys.forest.exceptions.ForestRuntimeException; import com.dtflys.forest.exceptions.ForestRuntimeException;
import com.dtflys.forest.http.ForestHeader;
import com.dtflys.forest.http.ForestRequest; import com.dtflys.forest.http.ForestRequest;
import com.dtflys.forest.http.ForestResponse; import com.dtflys.forest.http.ForestResponse;
import com.dtflys.forest.interceptor.Interceptor; import com.dtflys.forest.interceptor.Interceptor;
import com.dtflys.forest.utils.ForestDataType;
import com.linkwechat.common.annotation.Log; import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.config.WeComeConfig; import com.linkwechat.common.config.WeComeConfig;
import com.linkwechat.wecom.service.IWeAccessTokenService; import com.linkwechat.wecom.service.IWeAccessTokenService;
...@@ -16,7 +18,7 @@ import org.springframework.stereotype.Component; ...@@ -16,7 +18,7 @@ import org.springframework.stereotype.Component;
* @create: 2020-08-27 22:36 * @create: 2020-08-27 22:36
**/ **/
@Component @Component
public class WeAccessTokenInterceptor implements Interceptor { public class WeAccessTokenInterceptor implements Interceptor{
@Autowired @Autowired
...@@ -33,10 +35,9 @@ public class WeAccessTokenInterceptor implements Interceptor { ...@@ -33,10 +35,9 @@ public class WeAccessTokenInterceptor implements Interceptor {
*/ */
@Override @Override
public boolean beforeExecute(ForestRequest request) { public boolean beforeExecute(ForestRequest request) {
request.setDataType(ForestDataType.JSON);
request.setContentType("application/json"); request.setContentType("application/json");
String uri=request.getUrl().replace("http://",""); String uri=request.getUrl().replace("http://","");
// 添加请求参数access_token // 添加请求参数access_token
if(!weComeConfig.getNoAccessTokenUrl().equals(uri)){ if(!weComeConfig.getNoAccessTokenUrl().equals(uri)){
request.addQuery("access_token", iWeAccessTokenService.findToken()); request.addQuery("access_token", iWeAccessTokenService.findToken());
...@@ -62,8 +63,9 @@ public class WeAccessTokenInterceptor implements Interceptor { ...@@ -62,8 +63,9 @@ public class WeAccessTokenInterceptor implements Interceptor {
} }
/** /**
* 该方法在请求成功响应时被调用 * 请求成功调用
* @param o * @param o
* @param forestRequest * @param forestRequest
* @param forestResponse * @param forestResponse
......
...@@ -59,19 +59,19 @@ public class WeDepartmentServiceImpl implements IWeDepartmentService ...@@ -59,19 +59,19 @@ public class WeDepartmentServiceImpl implements IWeDepartmentService
{ {
//校验数据中中是否存在根节点,如果不存在,从微信端获取,同时入库 //校验数据中中是否存在根节点,如果不存在,从微信端获取,同时入库
// WeDepartment weDepartment=weDepartmentMapper.selectWeDepartmentById(WeConstans.WE_ROOT_DEPARMENT_ID); WeDepartment weDepartment=weDepartmentMapper.selectWeDepartmentById(WeConstans.WE_ROOT_DEPARMENT_ID);
// if(null == weDepartment){ if(null == weDepartment){
// String weDepartMentDto=weDepartMentClient.weDepartMents(WeConstans.WE_ROOT_DEPARMENT_ID); WeDepartMentDto weDepartMentDto=weDepartMentClient.weDepartMents(WeConstans.WE_ROOT_DEPARMENT_ID);
// System.out.println(weDepartMentDto); if(WeConstans.WE_SUCCESS_CODE.equals(weDepartMentDto.getErrcode())
// if(WeConstans.WE_SUCCESS_CODE.equals(weDepartMentDto.getErrcode()) && CollectionUtils.isNotEmpty(weDepartMentDto.getDepartment())){
// && CollectionUtils.isNotEmpty(weDepartMentDto.getDeartMents())){ weDepartmentMapper.insertWeDepartment(
// WeDepartment.transformWeDepartment(
// weDepartmentMapper.insertWeDepartment( weDepartMentDto.getDepartment().stream().filter(item->item.getId().equals(WeConstans.WE_ROOT_DEPARMENT_ID)).findFirst().get()
// weDepartment.transformWeDepartment(weDepartMentDto.getDeartMents().get(0)) )
// ); );
//
// } }
// } }
return weDepartmentMapper.selectWeDepartmentList(); return weDepartmentMapper.selectWeDepartmentList();
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!