|
|
@@ -14,6 +14,7 @@ import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
/**
|
|
|
+ * admin/企业微信/微信客服
|
|
|
* 项目名: yhlxj2
|
|
|
* 文件名: CorpKfUserController
|
|
|
* 创建者: JavaZou
|
|
|
@@ -32,52 +33,52 @@ public class CorpKfUserController {
|
|
|
*/
|
|
|
@GetMapping("/get/detail")
|
|
|
public Result<CorpKfUser> getCorpKfUserInfo(String externalUserid) throws Exception {
|
|
|
- CorpKfUser corpKfUser = corpKfUserMapper.selectOne(Wrappers.lambdaQuery(CorpKfUser.class)
|
|
|
- .eq(CorpKfUser::getExternalUserid, externalUserid)
|
|
|
- .last("limit 1"));
|
|
|
- if (corpKfUser == null) {
|
|
|
- CorpKfUserInfo corpKfUserInfo = wxCorpOps.getCorpKfUserInfo(externalUserid);
|
|
|
- try {
|
|
|
- corpKfUser = new CorpKfUser();
|
|
|
- BeanUtil.copyProperties(corpKfUserInfo, corpKfUser);
|
|
|
- corpKfUserMapper.insert(corpKfUser);
|
|
|
- } catch (DuplicateKeyException e) {
|
|
|
- }
|
|
|
- }
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(corpKfUser);
|
|
|
+ CorpKfUser user = getCorpUser(externalUserid);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(user);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置备注
|
|
|
*/
|
|
|
@PostMapping("/set/remark")
|
|
|
- public Result<String> setUserRemark(@RequestBody CorpKfUser corpKfUser) {
|
|
|
- Long id = corpKfUser.getId();
|
|
|
- CorpKfUser dbCorpKfUser = corpKfUserMapper.selectById(id);
|
|
|
- if (dbCorpKfUser != null) {
|
|
|
- dbCorpKfUser.setRemark(corpKfUser.getRemark());
|
|
|
- corpKfUserMapper.updateById(corpKfUser);
|
|
|
- }
|
|
|
+ public Result<String> setUserRemark(@RequestBody CorpKfUser corpKfUser) throws Exception {
|
|
|
+ CorpKfUser user = getCorpUser(corpKfUser.getExternalUserid());
|
|
|
+ user.setRemark(corpKfUser.getRemark());
|
|
|
+ corpKfUserMapper.updateById(user);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 标记为设备用户
|
|
|
*/
|
|
|
- @PostMapping("/mark/device/{id}")
|
|
|
- public Result<String> markUserDevice(@RequestBody CorpKfUserMarkReq corpKfUserMarkReq) {
|
|
|
- Long id = corpKfUserMarkReq.getId();
|
|
|
+ @PostMapping("/mark/device")
|
|
|
+ public Result<String> markUserDevice(@RequestBody CorpKfUserMarkReq corpKfUserMarkReq) throws Exception {
|
|
|
+ String externalUserid = corpKfUserMarkReq.getExternalUserid();
|
|
|
String followId = corpKfUserMarkReq.getFollowId();
|
|
|
- CorpKfUser corpKfUser = corpKfUserMapper.selectById(id);
|
|
|
- if (corpKfUser != null) {
|
|
|
- if (corpKfUser.getIsDevice()) {
|
|
|
- corpKfUser.setFollowId(null);
|
|
|
- } else {
|
|
|
- corpKfUser.setFollowId(followId);
|
|
|
- }
|
|
|
- corpKfUser.setIsDevice(!corpKfUser.getIsDevice());
|
|
|
- corpKfUserMapper.updateById(corpKfUser);
|
|
|
+ CorpKfUser user = getCorpUser(externalUserid);
|
|
|
+ if (user.getIsDevice()) {
|
|
|
+ user.setFollowId(null);
|
|
|
+ } else {
|
|
|
+ user.setFollowId(followId);
|
|
|
}
|
|
|
+ user.setIsDevice(!user.getIsDevice());
|
|
|
+ corpKfUserMapper.updateById(user);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
+
|
|
|
+ public CorpKfUser getCorpUser(String externalUserid) throws Exception {
|
|
|
+ CorpKfUser corpKfUser = corpKfUserMapper.selectOne(Wrappers.lambdaQuery(CorpKfUser.class)
|
|
|
+ .eq(CorpKfUser::getExternalUserid, externalUserid)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (corpKfUser == null) {
|
|
|
+ CorpKfUserInfo corpKfUserInfo = wxCorpOps.getCorpKfUserInfo(externalUserid);
|
|
|
+ try {
|
|
|
+ corpKfUser = new CorpKfUser();
|
|
|
+ BeanUtil.copyProperties(corpKfUserInfo, corpKfUser);
|
|
|
+ corpKfUserMapper.insert(corpKfUser);
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return corpKfUser;
|
|
|
+ }
|
|
|
}
|