店铺对接企业微信
parent
5bf4716cb1
commit
f3697f5bda
@ -0,0 +1,9 @@
|
||||
package com.kiisoo.ic.employee.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.kiisoo.ic.employee.entity.PrivilageCpUserDO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PrivilageCpUserDOMapper extends BaseMapper<PrivilageCpUserDO> {
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.kiisoo.ic.test;
|
||||
|
||||
import com.kiisoo.ic.app.IcApplication;
|
||||
import com.kiisoo.ic.wx.service.AddWXService;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = IcApplication.class)
|
||||
public class Test {
|
||||
|
||||
@Autowired
|
||||
AddWXService addWXService;
|
||||
|
||||
@org.junit.Test
|
||||
public void te(){
|
||||
addWXService.addWX("a","b");
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.kiisoo.ic.wechat.web;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/wechat")
|
||||
public class CreateWechatController {
|
||||
|
||||
@RequestMapping("/create")
|
||||
public void createWechat(@RequestParam("code") String code){
|
||||
System.out.println(code) ;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.kiisoo.ic.wx.constants;
|
||||
|
||||
/***
|
||||
* 微信相关常量
|
||||
*/
|
||||
public class Constant {
|
||||
|
||||
/**增加企业微信返回状态码*/
|
||||
public static String ADD_URL_RETURN_PARAM = "errcode";
|
||||
|
||||
/**增企业微信成功返回码*/
|
||||
public static int ADD_URL_SUCC_CODE = 0;
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.kiisoo.ic.wx.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.kiisoo.ic.common.BaseController;
|
||||
import com.kiisoo.ic.wx.entity.CreateWXDO;
|
||||
import com.kiisoo.ic.wx.service.AddWXService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/wechat")
|
||||
public class CreateWechatController extends BaseController {
|
||||
|
||||
@RequestMapping("/create")
|
||||
public void createWechat(@RequestParam("code") String code){
|
||||
System.out.println(code) ;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private AddWXService addWXService;
|
||||
/**
|
||||
* 登录账号
|
||||
* @return 成功/失败
|
||||
*/
|
||||
@RequestMapping(value = "/test",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public String loginAccount(@RequestBody CreateWXDO createWXDO){
|
||||
Map<String, Object> m = new HashMap<>();
|
||||
m.put("errcode",0);
|
||||
return JSON.toJSONString(m);
|
||||
}
|
||||
|
||||
// @Scheduled(cron = "59 05 17 * * ?")
|
||||
public void a(){
|
||||
addWXService.addWX("a","b");
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.kiisoo.ic.wx.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.kiisoo.ic.common.utils.httpClientUtil.HttpClientUtil;
|
||||
import com.kiisoo.ic.common.utils.httpClientUtil.HttpResult;
|
||||
import com.kiisoo.ic.employee.entity.PrivilageCpUserDO;
|
||||
import com.kiisoo.ic.employee.service.EmployeeService;
|
||||
import com.kiisoo.ic.wx.constants.Constant;
|
||||
import com.kiisoo.ic.wx.utils.UrlUtil;
|
||||
import com.kiisoo.ic.wx.entity.CreateWXDO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 增加企业微信
|
||||
*/
|
||||
@Service
|
||||
public class AddWXService {
|
||||
|
||||
@Autowired
|
||||
private EmployeeService employeeServicel;
|
||||
String token = "a";
|
||||
boolean ifHad = false;
|
||||
String tock = "";
|
||||
/**
|
||||
* 增加企业微信
|
||||
*/
|
||||
public void addWX(String phone, String name){
|
||||
//查看此人是否已经创建过企业微信
|
||||
PrivilageCpUserDO privilageCpUserDO = employeeServicel.getUserWX(phone);
|
||||
//如果已经创建过
|
||||
if(privilageCpUserDO == null){
|
||||
return;
|
||||
}
|
||||
//创建企业微信基础数据
|
||||
CreateWXDO createWXDO = new CreateWXDO();
|
||||
createWXDO.setUserid(phone);
|
||||
createWXDO.setName(name);
|
||||
//未创建,则创建
|
||||
HttpResult result = HttpClientUtil.httpPost(UrlUtil.getAddWXUrl(token), JSON.toJSONString(createWXDO), tock);
|
||||
//是否添加微信成功
|
||||
boolean ifAdd = UrlUtil.compHttpResult(result, Constant.ADD_URL_RETURN_PARAM, Constant.ADD_URL_SUCC_CODE);
|
||||
//如果成功,则添加对应的表信息
|
||||
// if(ifAdd){
|
||||
//
|
||||
// }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue