Commit c7181954 by ws

Merge remote-tracking branch 'origin/master'

2 parents 824cadae ba15ce14
Showing 41 changed files with 1610 additions and 61 deletions
......@@ -6,6 +6,7 @@ import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.scheduling.annotation.EnableAsync;
/**
* 启动程序
......@@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, PageHelperAutoConfiguration.class })
@MapperScan("com.linkwechat.*.mapper")
@ForestScan(basePackages = "com.linkwechat.wecom.client")
@EnableAsync
public class LinkWeChatApplication
{
public static void main(String[] args)
......
package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.wecom.service.IWeChatCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
/**
* 聊天工具 侧边栏栏 素材收藏
*
* @author kwen
*/
@RequestMapping(value = "/wecom/chat/collection")
@RestController
public class WeChatCollectionController extends BaseController {
@Autowired
private IWeChatCollectionService weChatCollectionService;
/**
* 添加收藏
*/
@PreAuthorize("@ss.hasPermi('chat:collection:add')")
@Log(title = "添加收藏", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult addCollection(@RequestParam(value = "materialId") Long materialId, @RequestParam(value = "userId") Long userId) {
return toAjax(weChatCollectionService.addCollection(materialId, userId));
}
/**
* 取消收藏
*/
@PreAuthorize("@ss.hasPermi('chat:collection:delete')")
@Log(title = "取消收藏", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult cancleCollection(@RequestParam(value = "materialId") Long materialId, @RequestParam(value = "userId") Long userId) {
return toAjax(weChatCollectionService.cancleCollection(materialId, userId));
}
}
package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.wecom.domain.dto.WeChatItemDto;
import com.linkwechat.wecom.service.IWeChatItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 聊天工具侧边栏
* @author kewen
*/
@RequestMapping(value = "/wecom/chat/item")
@RestController
public class WeChatItemController extends BaseController {
@Autowired
private IWeChatItemService weChatItemService;
/**
* 侧边栏抓取素材
*/
@PreAuthorize("@ss.hasPermi('chat:item:add')")
@Log(title = "侧边栏抓取素材", businessType = BusinessType.INSERT)
@PutMapping
public AjaxResult add(@RequestBody WeChatItemDto chatItemDto) {
return toAjax(weChatItemService.checkItems(chatItemDto));
}
}
package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.annotation.Log;
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.wecom.domain.WeChatSide;
import com.linkwechat.wecom.service.IWeChatSideService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 聊天工具侧边栏
* @author kewen
*/
@RequestMapping(value = "/wecom/chat/side")
@RestController
public class WeChatSideController extends BaseController {
@Autowired
public IWeChatSideService weChatSideService;
/**
* 群发侧边栏列表
*/
@PreAuthorize("@ss.hasPermi('chat:side:list')")
@GetMapping("/list")
public TableDataInfo list() {
startPage();
List<WeChatSide> weChatSides = weChatSideService.chatSides();
return getDataTable(weChatSides);
}
/**
* 更新侧边栏信息
*/
@PreAuthorize("@ss.hasPermi('chat:side:edit')")
@Log(title = "更新侧边栏信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody WeChatSide weChatSide) {
return toAjax(weChatSideService.updateWeChatSide(weChatSide));
}
}
......@@ -22,7 +22,7 @@ import java.util.List;
/**
* 企业微信客户Controller
*
*
* @author ruoyi
* @date 2020-09-13
*/
......@@ -106,16 +106,12 @@ public class WeCustomerController extends BaseController
@PreAuthorize("@ss.hasPermi('customerManage:customer:sync')")
@Log(title = "企业微信客户同步接口", businessType = BusinessType.DELETE)
@GetMapping("/synchWeCustomer")
public AjaxResult synchWeCustomer(){
SecurityContext securityContext = SecurityContextHolder.getContext();
public AjaxResult synchWeCustomer() {
try {
Threads.SINGLE_THREAD_POOL.execute(new Runnable() {
@Override
public void run() {
SecurityContextHolder.setContext(securityContext);
weCustomerService.synchWeCustomer();
}
});
SecurityContext context = SecurityContextHolder.getContext();
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
SecurityContextHolder.setContext(context);
weCustomerService.synchWeCustomer();
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -11,6 +11,8 @@ import com.linkwechat.wecom.service.IWeGroupMemberService;
import com.linkwechat.wecom.service.IWeGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -59,10 +61,14 @@ public class WeGroupController extends BaseController {
@PreAuthorize("@ss.hasPermi('customerManage:group:sync')")
@GetMapping({"/synchWeGroup"})
public AjaxResult synchWeGroup(){
weGroupService.synchWeGroup();
try {
SecurityContext context = SecurityContextHolder.getContext();
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
SecurityContextHolder.setContext(context);
weGroupService.synchWeGroup();
} catch (Exception e) {
e.printStackTrace();
}
return AjaxResult.success(WeConstans.SYNCH_TIP);
}
......
package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.redis.RedisCache;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.wecom.TicketUtils;
import com.linkwechat.wecom.client.WeTicketClient;
import com.linkwechat.wecom.domain.WeH5TicketDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.TimeUnit;
/**
* @author danmo
* @description h5 ticket校验接口
* @date 2021/1/6 11:23
**/
@Slf4j
@RequestMapping(value = "/wecom/ticket/")
@RestController
public class WeTicketController extends BaseController {
@Autowired
private RedisCache redisCache;
@Autowired
private WeTicketClient weTicketClient;
/**
* 获取企业的jsapi_ticket
*
* @param url JS接口页面的完整URL
* @return
*/
@Log(title = "获取企业的jsapi_ticket", businessType = BusinessType.OTHER)
@GetMapping("/getAppTicket")
public AjaxResult getAppTicket(String url) {
String ticketVaule = redisCache.getCacheObject(WeConstans.AppTicketKey);
if (StringUtils.isEmpty(ticketVaule)) {
WeH5TicketDto ticketRes = weTicketClient.getJsapiTicket();
if (ticketRes != null && StringUtils.isNotEmpty(ticketRes.getTicket())) {
redisCache.setCacheObject(WeConstans.AppTicketKey, ticketRes.getTicket(), ticketRes.getExpiresIn(), TimeUnit.SECONDS);
}
ticketVaule = ticketRes.getTicket();
}
return AjaxResult.success(TicketUtils.getSignatureMap(ticketVaule, url));
}
/**
* 获取应用的jsapi_ticket
*
* @param url JS接口页面的完整URL
* @return
*/
@Log(title = "获取应用的jsapi_ticket", businessType = BusinessType.OTHER)
@GetMapping("/getAgentTicket")
public AjaxResult getAgentTicket(String url) {
String ticketVaule = redisCache.getCacheObject(WeConstans.AgentTicketKey);
if (StringUtils.isEmpty(ticketVaule)) {
WeH5TicketDto ticketRes = weTicketClient.getTicket();
if (ticketRes != null && StringUtils.isNotEmpty(ticketRes.getTicket())) {
redisCache.setCacheObject(WeConstans.AgentTicketKey, ticketRes.getTicket(), ticketRes.getExpiresIn(), TimeUnit.SECONDS);
}
ticketVaule = ticketRes.getTicket();
}
return AjaxResult.success(TicketUtils.getSignatureMap(ticketVaule, url));
}
}
......@@ -56,6 +56,11 @@ spring:
max-file-size: 10MB
# 设置总上传的文件大小
max-request-size: 20MB
task:
execution:
pool:
keep-alive: 10s
thread-name-prefix: common-pool-
# 服务模块
devtools:
restart:
......@@ -173,6 +178,8 @@ wecome:
- /externalcontact/get_unassigned_list
- /externalcontact/send_welcome_msg
- /externalcontact/unionid_to_external_userid
- /get_jsapi_ticket
- /ticket/get
fileUplodUrl: /media/upload,/media/uploadimg
needProviderTokenUrl:
- /service/get_login_info
......
......@@ -225,6 +225,10 @@ public class WeConstans {
*/
public static final long LIMIT = 1_000L;
public static final String AppTicketKey = "ticket:AppGet";
public static final String AgentTicketKey = "ticket:AgentGet";
/**
* 企微回调事件类型路由
*/
......
package com.linkwechat.common.utils.wecom;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.RandomStringUtils;
import java.util.HashMap;
import java.util.Map;
/**
* @author danmo
* @description
* @date 2021/1/6 12:00
**/
@Slf4j
public class TicketUtils {
public static Map<String, Object> getSignatureMap(String ticketVaule, String url) {
String nonceStr = RandomStringUtils.randomAlphanumeric(10);
Long timestamp = System.currentTimeMillis() / 1000;
StringBuilder strBuild = new StringBuilder();
strBuild.append("jsapi_ticket=").append(ticketVaule)
.append("&noncestr=").append(nonceStr)
.append("&timestamp=").append(timestamp)
.append("&url=").append(url);
log.info("H5加密串:{}",strBuild.toString());
String signature = DigestUtils.sha1Hex(strBuild.toString());
return new HashMap(16) {{
put("nonceStr", nonceStr);
put("timestamp", timestamp);
put("signature", signature);
}};
}
}
{
"name": "link-wechat-mobile",
"version": "0.1.0",
"private": true,
"description": "LinkWeChat mobile",
"license": "GPL-3.0",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.21.1",
"core-js": "^3.6.5",
"vant": "^2.12.2",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
......@@ -24,9 +27,13 @@
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-vue": "^6.2.2",
"html-webpack-plugin": "^4.5.1",
"less": "^3.0.4",
"less-loader": "^5.0.0",
"prettier": "^1.19.1",
"script-ext-html-webpack-plugin": "^2.1.5",
"style-resources-loader": "^1.3.2",
"vue-cli-plugin-style-resources-loader": "~0.1.4",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
......
<script>
export default {
name: 'App',
data() {
return {
timestamp: '',
nonceStr: '',
signature: '',
}
},
created() {
// 调取服务端signature
},
watch: {
// 通过config接口注入权限验证配置
// 所有需要使用JS-SDK的页面必须先注入配置信息,否则将无法调用(同一个url仅需调用一次,对于变化url的SPA(single-page application)的web app可在每次url变化时进行调用)
$router() {
wx.config({
beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: '123456', // 必填,企业微信的corpID
timestamp: this.timestamp, // 必填,生成签名的时间戳
nonceStr: this.nonceStr, // 必填,生成签名的随机串
signature: this.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
jsApiList: [], // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
})
},
},
}
</script>
<template>
<div id="app">
<div id="nav">
......
const config = {
/**
* @description token在Cookie中存储的天数,默认1天
*/
cookieExpires: 1,
/**
* @description 是否使用国际化,默认为false
* 如果不使用,则需要在路由中给需要在菜单中展示的路由设置meta: {title: 'xxx'}
* 用来在菜单中显示文字
*/
useI18n: false,
/**
* @description api请求基础路径
*/
// 测试服
domain: process.env.NODE_ENV === 'development' ? 'http://192.168.1.32:8888' : 'http://192.168.1.26:8888', //
// 正式服
// domain: process.env.NODE_ENV === 'development' ? 'http://192.168.1.35:8118' : 'https://gateway.visualinsur.cn:8888', //
/**
* @description 默认打开的首页的路由name值,默认为home
*/
homeName: 'home',
/**
* @description 需要加载的插件
*/
plugin: {
// 'error-store': {
// showInHeader: true, // 设为false后不会在顶部显示错误日志徽标
// developmentOff: false // 设为true后在开发环境不会收集错误信息,方便开发中排查错误
// }
},
// get domain() {
// return process.env.NODE_ENV === 'development' ? this.baseUrl.dev : this.baseUrl.pro
// }
}
config.services = {
}
export default config
\ No newline at end of file
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import wx from '@/utils/jweixin-1.2.0.js'
import Vue from 'vue'
Vue.config.productionTip = false;
import Vant from 'vant'
import 'vant/lib/index.css'
Vue.use(Vant)
import App from './App.vue'
import router from './router'
import store from './store'
window.wx = wx
Vue.config.productionTip = false
new Vue({
router,
store,
render: h => h(App)
}).$mount("#app");
render: (h) => h(App),
}).$mount('#app')
// 全屏转场动画
.slide-left-enter-active,
.slide-right-enter-active {
transition: all 0.2s ease;
}
.slide-left-leave-active,
.slide-right-leave-active {
transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-left-enter,
.slide-right-leave-to {
transform: translateX(10px);
opacity: 0;
}
.slide-left-leave-to,
.slide-right-enter {
transform: translateX(-10px);
opacity: 0;
}
// 内页转场动画
.slide-inside-enter-active {
transition: all 0.3s ease;
}
.slide-inside-leave-active {
transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-inside-enter,
.slide-inside-leave-to
/* .slide-down-leave-active for below version 2.1.8 */
{
// position: absolute;
transform: translateY(-10px);
opacity: 0;
}
\ No newline at end of file
@charset "utf-8";
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
/**,*:before,*:after{-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;-webkit-tap-highlight-color: rgba(0,0,0,0);-webkit-tap-highlight-color: transparent;max-height: 100000px;}*/
body,
h1,
h2,
h3,
h4,
h5,
h6,
hr,
p,
blockquote,
dl,
dt,
dd,
ul,
ol,
li,
pre,
form,
fieldset,
legend,
button,
input,
textarea,
th,
td {
margin: 0;
padding: 0;
}
body,input, select, textarea /* for ie */ {
font: 14px Microsoft YaHei, "宋体", arial, -apple-system, "PingFang SC",
"Helvetica Neue", Helvetica, "DejaVu Sans", "Lucida Grande", Tahoma,
"Hiragino Sans GB", STHeiti, SimSun, sans-serif;
line-height: 1.15;
color: #333; /*touch-action: none*/
} /** 设置默认字体 **/
header,
section,
footer,
aside,
nav,
article,
figure {
display: block;
}
input,
button,
select,
textarea {
outline: none;
vertical-align: middle; /*解决父级底部多余空白*/
-webkit-appearance: none; /*去掉webkit默认的表单样式*/
font-size: 100%; /* 使得表单元素在 ie 下能继承字体大小 */
border: none;
background: none;
color: inherit;
}
address,
cite,
dfn,
em,
var {
font-style: normal;
} /* 将斜体扶正 , 注:optgroup 无法扶正 */
h1,
h2,
h3,
h4,
h5,
h6 {
font-size: 100%;
background: none;
}
code,
kbd,
pre,
samp {
font-family: courier new, courier, monospace;
} /* 统一等宽字体 */
object,
embed,
video {
max-width: 100%;
}
a:link,
a:active,
a:visited,
a:hover {
text-decoration: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
img {
border: 0;
max-width: 100%;
vertical-align: middle;
} /*解决父级底部多余空白*/
small {
font-size: 12px;
} /* 小于 12px 的中文很难阅读,让 small 正常化 */
legend {
color: #000;
} /*for ie6*/
fieldset {
border: 0;
}
li {
list-style: none;
}
a {
color: inherit;
}
/*click outline for firefox*/
button::-moz-focus-inner,
input[type="reset"]::-moz-focus-inner,
input[type="button"]::-moz-focus-inner,
input[type="submit"]::-moz-focus-inner,
input[type="file"] > input[type="button"]::-moz-focus-inner {
border: none;
}
/*click outline for IE and other browser*/
button:focus,
input[type="reset"]:focus,
input[type="button"]:focus,
input[type="submit"]:focus,
input[type="file"] > input[type="button"]:focus {
outline: none;
}
/* 注意此处合并写法无效 */
input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
color: #fff;
font-size: 16px;
}
input::-moz-placeholder,
textarea::-moz-placeholder {
color: #fff;
font-size: 16px;
}
input:-ms-input-placeholder,
textarea:-ms-input-placeholder {
color: #fff;
font-size: 16px;
}
*:not(input, select, textarea) {
-webkit-user-select: none;
} /*禁止选中文本内容*/
::-webkit-scrollbar {
/*滚动条整体样式*/
width: 10px; /*高宽分别对应横竖滚动条的尺寸*/
height: 10px;
}
::-webkit-scrollbar-thumb {
/*滚动条里面小方块*/
border-radius: 10px;
/*深色模式*/
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
background: #bbb;
/*浅色模式*/
/*-webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
background: rgb(245, 245, 245);
border: 1px solid #333;
border-bottom-width: 2px;*/
}
::-webkit-scrollbar-track {
/*滚动条里面轨道*/
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
border-radius: 10px;
background: #eee;
}
/* common class */
/*bfc model*/
.bfc-o {
overflow: hidden;
position: relative;
}
.bfc-d {
display: inline-block;
vertical-align: top;
position: relative;
}
.bfc-p {
position: absolute;
}
.fl {
float: left;
position: relative;
}
.fr {
float: right;
position: relative;
}
.al {
text-align: left;
}
.ac {
text-align: center;
}
.ar {
text-align: right;
}
.hide {
display: none;
}
/*top-fixed and bottom-fixed*/
.tf,
.bf {
position: fixed;
width: 100%;
height: 50px;
z-index: 999;
}
.tf {
top: 0;
}
.bf {
bottom: 0;
}
/*mask*/
.mask {
position: fixed;
width: 100%;
height: 100%;
background: rgba(39, 39, 39, 0.76);
left: 0;
bottom: 0;
margin: auto;
z-index: 9;
}
/*center-center*/
.cc {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
overflow: auto;
}
/*t-o-h-e*/
.toe {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/*close*/
.close {
position: relative;
float: right;
width: 20px;
height: 20px;
line-height: 20px;
background: #f8f8f8;
text-align: center;
cursor: pointer;
}
/* pc frame */
.wrapper {
position: relative;
max-width: 1920px;
min-width: 1020px;
margin: 0 auto;
padding: 0 15px;
overflow: hidden;
}
.cp {
cursor: pointer;
}
@color: #42b9fd;
@colorSub: #4ee699;
@colorSubDeep: #34b071;
@borderColor: #106ed2;
@inputBgColor: #14344b;
@fontColor: #999;
// 画三角形
.triangle(@_, @wwww, @ccccc) {
width: 0px;
height: 0px;
overflow: hidden;
}
.triangle(L, @w, @c) {
border-width: @w;
border-style: dashed solid dashed dashed;
border-color: transparent @c transparent transparent;
}
.triangle(R, @w, @c) {
border-width: @w;
border-style: dashed dashed dashed solid;
border-color: transparent transparent transparent @c;
}
.triangle(T, @w, @c) {
border-width: @w;
border-style: dashed dashed solid dashed;
border-color: transparent transparent @c transparent;
}
.triangle(B, @w, @c) {
border-width: @w;
border-style: solid dashed dashed dashed;
border-color: @c transparent transparent transparent;
}
// 单边框
.border(single, @position: bottom, @color, @width: 1px) {
border-@{position}: @width solid @color;
}
// 全边框
.border(@color, @width: 1px) when (default()) {
border: @width solid @color;
}
import axios from axios
import config from "@/config"
function createAxios(baseUrl) {
const instance = axios.create({
baseUrl,
headers: {
Auth_token: ""
},
timeout: 3000,
})
// 请求拦截
instance.interceptors.request.use(config => {
// console.log('request config: ' + JSON.stringify(config))
return config
}, error => {
return Promise.reject(error)
})
// 响应拦截
instance.interceptors.response.use(res => {
// console.log('res: ' + res)
const { data, status } = res
// code 0:成功,-1/其它:错误
if (status === 200 && data.code === 0) {
return JSON.stringify(data.result) ? data.result : data.data
} else if (data.code === 201) {
// Message.error({
// content: `产品已存在`,
// duration: 3
// })
} else {
addErrorLog(res)
}
if (process.env.NODE_ENV === 'development') {
return Promise.reject(res) // 这样控制台会显示报错日志
} else {
return new Promise(() => { }) // 中断promise
}
}, error => {
if (error.response) {
addErrorLog(error.response)
} else {
// Message.error({
// content: `服务器未启动或连接超时`,
// duration: 3
// })
console.error("服务器未启动或连接超时")
}
return Promise.reject(error)
})
// 错误日志
const addErrorLog = errorInfo => {
const { data, statusText, status, request: { responseText, responseURL } } = errorInfo
// let info = {
// type: 'ajax',
// code: status,
// mes: statusText,
// url: responseURL
// }
// if (!responseURL.includes('save_error_logger')) store.dispatch('addErrorLog', info)
process.env.NODE_ENV === 'development'
? console.error(`错误: 路径: ${responseURL}, 返回值 : ${responseText}`,)
: console.error(`${JSON.parse(responseText).message}`,)
}
return instance
}
// const httpRequest = createAxios()
export default createAxios(config.domain)
\ No newline at end of file
const path = require('path')
const resolve = (dir) => {
return path.join(__dirname, dir)
}
process.env.VUE_APP_TITLE = require('./package.json').description
// 项目部署基础
// 默认情况下,我们假设你的应用将被部署在域的根目录下,
// 例如:https://www.my-app.com/
// 默认:'/'
// 如果您的应用程序部署在子路径中,则需要在这指定子路径
// 例如:https://www.my-app.com/my-app/
// 需要将它改为'/my-app/'
const BASE_URL = process.env.NODE_ENV === 'development' ? '/' : '/mobile'
module.exports = {
publicPath: BASE_URL,
outputDir: 'mobile', // 打包名称
// 打包时不生成.map文件
productionSourceMap: false,
// 如果你不需要使用eslint,把lintOnSave设为false即可
lintOnSave: false,
// 这里写你调用接口的基础路径,来解决跨域,如果设置了代理,那你本地开发环境的axios的baseUrl要写为 '' ,即空字符串
devServer: {
host: '0.0.0.0',
port: 8082,
// 自动打开浏览器
open: true,
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
['http']: {
target: process.env.VUE_APP_BASE_API,
changeOrigin: true,
// pathRewrite: {
// ['^' + process.env.VUE_APP_BASE_API]: ''
// }
},
},
disableHostCheck: true,
},
pluginOptions: {
'style-resources-loader': {
preProcessor: 'less',
patterns: [path.resolve(__dirname, './src/styles/varibles.less')],
},
},
configureWebpack: {
resolve: {
alias: {
'@': resolve('src'),
},
},
},
chainWebpack(config) {
config.plugin('preload').tap(() => [
{
rel: 'preload',
// to ignore runtime.js
fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
include: 'initial',
},
])
config.when(process.env.NODE_ENV !== 'development', (config) => {
config
.plugin('ScriptExtHtmlWebpackPlugin')
.after('html')
.use('script-ext-html-webpack-plugin', [
{
// `runtime` must same as runtimeChunk name. default is `runtime`
inline: /runtime\..*\.js$/,
},
])
.end()
config.optimization.minimizer('terser').tap((options) => {
options[0].terserOptions.compress.drop_console = true
options[0].terserOptions.compress.drop_debugger = true
return options
})
config.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial', // only package third parties that are initially dependent
},
elementUI: {
name: 'chunk-vant', // split vant into a single package
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
test: /[\\/]node_modules[\\/]_?vant(.*)/, // in order to adapt to cnpm
},
commons: {
name: 'chunk-commons',
test: resolve('src/components'), // can customize your rules
minChunks: 3, // minimum common number
priority: 5,
reuseExistingChunk: true,
},
},
})
config.optimization.runtimeChunk('single')
})
},
}
package com.linkwechat.wecom.client;
import com.dtflys.forest.annotation.Request;
import com.linkwechat.wecom.domain.WeH5TicketDto;
/**
* @author danmo
* @description h5获取签名
* @date 2021/1/6 11:51
**/
public interface WeTicketClient {
/**
* 获取去企业jsapi_ticket
*
* @return
*/
@Request(url = "/get_jsapi_ticket")
WeH5TicketDto getJsapiTicket();
/**
* 获取应用jsapi_ticket
*
* @return
*/
@Request(url = "/ticket/get")
WeH5TicketDto getTicket();
}
package com.linkwechat.wecom.domain;
import com.linkwechat.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 聊天工具 侧边栏栏 素材收藏
*
* @author kwen
*/
@Data
public class WeChatCollection extends BaseEntity {
/**
* id
*/
private Long collectionId;
/**
* 素材id
*/
private Long materialId;
/**
* 用户id
*/
private Long userId;
}
package com.linkwechat.wecom.domain;
import com.linkwechat.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 聊天工具侧边栏
* @author kewen
*/
@Data
public class WeChatItem extends BaseEntity {
/**
* id
*/
private Long itemId;
/**
* 侧边栏id
*/
private Long sideId;
/**
* 素材id
*/
private Long materialId;
}
package com.linkwechat.wecom.domain;
import com.linkwechat.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 聊天工具侧边栏
* @author kewen
*/
@Data
public class WeChatSide extends BaseEntity {
/**
* 主键id
*/
private Long sideId;
/**
* 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file) 4 文本 5 海报
*/
private Long mediaType;
/**
* 聊天工具栏名称
*/
private String sideName;
/**
* 已抓取素材数量
*/
private Integer total;
/**
* 是否启用 0 启用 1 未启用
*/
private Integer using;
/**
* 0 未删除 1 已删除
*/
private int delFlag;
}
package com.linkwechat.wecom.domain;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import lombok.Data;
/**
* @author danmo
* @description h5签名
* @date 2020/12/3 10:26
**/
@Data
public class WeH5TicketDto extends WeResultDto {
/**
* 生成签名所需的jsapi_ticket,最长为512字节
*/
private String ticket;
/**
* 凭证的有效时间(秒)
*/
private Integer expiresIn;
}
package com.linkwechat.wecom.domain.dto;
import lombok.Data;
import java.util.List;
/**
* 侧边栏素材
*
* @author kewen
*/
@Data
public class WeChatItemDto {
/**
* 素材id列表
*/
private List<Long> materialIds;
/**
* 侧边栏id
*/
private Long sideId;
/**
* 素材类型 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file) 4 文本 5 海报
*/
private String mediaType;
/**
* 是否全选 0 全选 1 非全选
*/
private String checkAll;
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeChatCollection;
import org.apache.ibatis.annotations.Param;
/**
* 聊天工具 侧边栏栏 素材收藏
*
* @author kwen
*/
public interface WeChatCollectionMapper extends BaseMapper<WeChatCollection> {
/**
* 添加收藏
*
* @param chatCollection 收藏的素材信息
* @return 结果
*/
public int addCollection(WeChatCollection chatCollection);
/**
* 取消收藏
*
* @param materialId 素材id
* @param userId 用户id
* @return 结果
*/
public int dropCollection(@Param("materialId") Long materialId,@Param("userId") Long userId);
/**
* 通过素材id和用户id查询当前素材的收藏条数
*
* @param materialId 素材id
* @param userId 用户id
* @return 当前素材收藏的条数
*/
public int countCollectionByMaterialIdAndUserId(@Param("materialId") Long materialId,@Param("userId") Long userId);
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeChatItem;
import com.linkwechat.wecom.domain.dto.WeChatItemDto;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 聊天工具侧边栏
* @author kewen
*/
public interface WeChatItemMapper extends BaseMapper<WeChatItem> {
/**
* 批量添加侧边栏素材
* @param items 侧边栏素材列表
* @return 结果
*/
public int addItem(@Param("items") List<WeChatItem> items);
/**
* 删除侧边栏素材
* @param sideId 侧边栏id
* @return 结果
*/
public int dropItem(@Param("sideId") Long sideId);
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeChatSide;
import java.util.List;
/**
* 聊天工具侧边栏
* @author kewen
*/
public interface WeChatSideMapper extends BaseMapper<WeChatSide> {
/**
* 查询侧边栏列表
*
* @return {@link WeChatSide}s
*/
public List<WeChatSide> selectWeChatSides();
/**
* 更新侧边栏信息
*
* @param weChatSide 侧边栏信息
* @return 结果
*/
public int updateWeChatSideById(WeChatSide weChatSide);
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeChatCollection;
/**
* 聊天工具 侧边栏栏 素材收藏
*
* @author kwen
*/
public interface IWeChatCollectionService extends IService<WeChatCollection> {
/**
* 添加收藏
*
* @param materialId 素材id
* @param userId 用户id
* @return 结果
*/
public int addCollection( Long materialId, Long userId);
/**
* 取消收藏
*
* @param materialId 素材id
* @param userId 用户id
* @return 结果
*/
public int cancleCollection( Long materialId, Long userId);
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeChatItem;
import com.linkwechat.wecom.domain.dto.WeChatItemDto;
/**
* 聊天工具侧边栏
* @author kewen
*/
public interface IWeChatItemService extends IService<WeChatItem> {
/**
* 侧边栏抓取素材
*
* @param chatItemDto 侧边栏素材
* @return 结果
*/
public int checkItems(WeChatItemDto chatItemDto);
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeChatSide;
import java.util.List;
/**
* 聊天工具侧边栏
* @author kewen
*/
public interface IWeChatSideService extends IService<WeChatSide> {
/**
* 群发侧边栏列表
*
* @return {@link WeChatSide}s
*/
public List<WeChatSide> chatSides();
/**
* 更新侧边栏信息
*
* @param weChatSide 侧边栏信息
* @return 结果
*/
public int updateWeChatSide(WeChatSide weChatSide);
}
package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.wecom.domain.WeChatCollection;
import com.linkwechat.wecom.mapper.WeChatCollectionMapper;
import com.linkwechat.wecom.service.IWeChatCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 聊天工具 侧边栏栏 素材收藏
*
* @author kwen
*/
@Service
public class WeChatCollectionServiceImpl extends ServiceImpl<WeChatCollectionMapper, WeChatCollection> implements IWeChatCollectionService {
@Autowired
private WeChatCollectionMapper weChatCollectionMapper;
@Override
public int addCollection(Long materialId, Long userId) {
WeChatCollection chatCollection=new WeChatCollection();
chatCollection.setCollectionId(SnowFlakeUtil.nextId());
chatCollection.setMaterialId(materialId);
chatCollection.setUserId(userId);
return weChatCollectionMapper.addCollection(chatCollection);
}
@Override
public int cancleCollection(Long materialId, Long userId) {
return weChatCollectionMapper.dropCollection(materialId,userId);
}
}
package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.wecom.domain.WeChatItem;
import com.linkwechat.wecom.domain.WeChatSide;
import com.linkwechat.wecom.domain.WeMaterial;
import com.linkwechat.wecom.domain.dto.WeChatItemDto;
import com.linkwechat.wecom.mapper.WeChatItemMapper;
import com.linkwechat.wecom.mapper.WeChatSideMapper;
import com.linkwechat.wecom.service.IWeChatItemService;
import com.linkwechat.wecom.service.IWeMaterialService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
*
* 聊天工具侧边栏
* @author kewen
*/
@Service
public class WeChatItemServiceImpl extends ServiceImpl<WeChatItemMapper, WeChatItem> implements IWeChatItemService {
@Autowired
private WeChatItemMapper weChatItemMapper;
@Autowired
private IWeMaterialService weMaterialService;
@Autowired
private WeChatSideMapper weChatSideMapper;
@Override
public int checkItems(WeChatItemDto chatItemDto) {
List<Long> materialIds=new ArrayList<>();
if(chatItemDto.getCheckAll().equals("0")){
List<WeMaterial> weMaterials = weMaterialService.findWeMaterials(null, null, chatItemDto.getMediaType());
if(CollectionUtils.isNotEmpty(weMaterials)){
materialIds= weMaterials.stream().map(WeMaterial::getId).collect(Collectors.toList());
}
}else {
materialIds= chatItemDto.getMaterialIds();
}
List<Long> finalMaterialIds = materialIds;
Optional.ofNullable(materialIds).ifPresent(
s->{
List<WeChatItem> items=new ArrayList<>();
finalMaterialIds.forEach(materialId->{
WeChatItem item=new WeChatItem();
item.setItemId(SnowFlakeUtil.nextId());
item.setMaterialId(materialId);
item.setSideId(chatItemDto.getSideId());
items.add(item);
});
weChatItemMapper.dropItem(chatItemDto.getSideId());
weChatItemMapper.addItem(items);
checkItemsTotal(chatItemDto, finalMaterialIds);
}
);
return 1;
}
/**
* 更新该次选择的素材数
*
* @param chatItemDto 侧边栏信息
* @param finalMaterialIds 素材id列表
*/
private void checkItemsTotal(WeChatItemDto chatItemDto, List<Long> finalMaterialIds) {
WeChatSide side=new WeChatSide();
side.setSideId(chatItemDto.getSideId());
side.setTotal(finalMaterialIds.size());
weChatSideMapper.updateWeChatSideById(side);
}
}
package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.wecom.domain.WeChatSide;
import com.linkwechat.wecom.mapper.WeChatSideMapper;
import com.linkwechat.wecom.service.IWeChatSideService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 聊天工具侧边栏
* @author kewen
*/
@Service
public class WeChatSideServiceImpl extends ServiceImpl<WeChatSideMapper, WeChatSide> implements IWeChatSideService {
@Autowired
private WeChatSideMapper weChatSideMapper;
@Override
public List<WeChatSide> chatSides() {
return weChatSideMapper.selectWeChatSides();
}
@Override
public int updateWeChatSide(WeChatSide weChatSide) {
return weChatSideMapper.updateWeChatSideById(weChatSide);
}
}
......@@ -26,6 +26,7 @@ import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
import com.linkwechat.wecom.mapper.WeCustomerMapper;
import com.linkwechat.wecom.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
......@@ -121,21 +122,18 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
* @return
*/
@Override
@Async
@Transactional(rollbackFor = Exception.class)
public void synchWeCustomer() {
FollowUserList followUserList = weCustomerClient.getFollowUserList();
if (WeConstans.WE_SUCCESS_CODE.equals(followUserList.getErrcode())
&& ArrayUtil.isNotEmpty(followUserList.getFollow_user())) {
SecurityContext securityContext = SecurityContextHolder.getContext();
Arrays.asList(followUserList.getFollow_user())
.stream().forEach(k -> {
.parallelStream().forEach(k -> {
try {
Threads.SINGLE_THREAD_POOL.execute(() -> {
SecurityContextHolder.setContext(securityContext);
weFlowerCustomerHandle(k);
});
SecurityContextHolder.setContext(securityContext);
weFlowerCustomerHandle(k);
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -2,8 +2,6 @@ package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.constant.WeConstans;
......@@ -14,11 +12,16 @@ import com.linkwechat.wecom.domain.WeAllocateGroup;
import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.WeGroupMember;
import com.linkwechat.wecom.domain.dto.AllocateWeGroupDto;
import com.linkwechat.wecom.domain.dto.customer.*;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupDetail;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupList;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupMember;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.mapper.WeGroupMapper;
import com.linkwechat.wecom.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -33,8 +36,7 @@ import java.util.stream.Collectors;
* @Date: create in 2020/9/22 0022 0:03
*/
@Service
public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> implements IWeGroupService {
public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper, WeGroup> implements IWeGroupService {
@Autowired
......@@ -69,6 +71,7 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
/**
* 离职员工群分配
*
* @param weLeaveUserInfoAllocateVo
* @return
*/
......@@ -78,10 +81,10 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
List<WeGroup> weGroups
= this.list(new LambdaQueryWrapper<WeGroup>().eq(WeGroup::getOwner, weLeaveUserInfoAllocateVo.getHandoverUserid()));
if(CollectionUtil.isNotEmpty(weGroups)){
List<WeAllocateGroup> weAllocateGroups=new ArrayList<>();
if (CollectionUtil.isNotEmpty(weGroups)) {
List<WeAllocateGroup> weAllocateGroups = new ArrayList<>();
//更改本地群主
weGroups.stream().forEach(k->{
weGroups.stream().forEach(k -> {
k.setOwner(weLeaveUserInfoAllocateVo.getTakeoverUserid());
weAllocateGroups.add(WeAllocateGroup.builder()
.allocateTime(new Date())
......@@ -92,13 +95,13 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
});
this.saveOrUpdateBatch(weGroups);
//分配记录保存
if(CollectionUtil.isNotEmpty(weAllocateGroups)){
if(iWeAllocateGroupService.saveOrUpdateBatch(weAllocateGroups)){
if (CollectionUtil.isNotEmpty(weAllocateGroups)) {
if (iWeAllocateGroupService.saveOrUpdateBatch(weAllocateGroups)) {
//同步企业微信端
weUserClient.allocateGroup(
AllocateWeGroupDto.builder()
.chat_id_list(ArrayUtil.toArray(weAllocateGroups.stream().map(WeAllocateGroup::getChatId).collect(Collectors.toList()),String.class))
.chat_id_list(ArrayUtil.toArray(weAllocateGroups.stream().map(WeAllocateGroup::getChatId).collect(Collectors.toList()), String.class))
.new_owner(weLeaveUserInfoAllocateVo.getTakeoverUserid())
.build()
);
......@@ -114,27 +117,28 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
* 客户群同步
*/
@Override
@Async
@Transactional(rollbackFor = Exception.class)
public void synchWeGroup() {
CustomerGroupList customerGroupList =
weCustomerGroupClient.groupChatLists(new CustomerGroupList().new Params());
if(customerGroupList.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)
&& CollectionUtil.isNotEmpty(customerGroupList.getGroup_chat_list())){
if (customerGroupList.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)
&& CollectionUtil.isNotEmpty(customerGroupList.getGroup_chat_list())) {
List<WeGroup> weGroups=new ArrayList<>();
List<WeGroupMember> weGroupMembers=new ArrayList<>();
customerGroupList.getGroup_chat_list().stream().forEach(k->{
List<WeGroup> weGroups = new ArrayList<>();
List<WeGroupMember> weGroupMembers = new ArrayList<>();
customerGroupList.getGroup_chat_list().stream().forEach(k -> {
CustomerGroupDetail customerGroupDetail = weCustomerGroupClient.groupChatDetail(
new CustomerGroupDetail().new Params(k.getChat_id())
);
if(customerGroupDetail.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)
&& CollectionUtil.isNotEmpty(customerGroupDetail.getGroup_chat())){
if (customerGroupDetail.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)
&& CollectionUtil.isNotEmpty(customerGroupDetail.getGroup_chat())) {
customerGroupDetail.getGroup_chat().stream().forEach(kk->{
customerGroupDetail.getGroup_chat().stream().forEach(kk -> {
weGroups.add(
WeGroup.builder()
.chatId(kk.getChat_id())
......@@ -146,8 +150,8 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
.build()
);
List<CustomerGroupMember> memberLists = kk.getMember_list();
if(CollectionUtil.isNotEmpty(memberLists)){
memberLists.stream().forEach(member->{
if (CollectionUtil.isNotEmpty(memberLists)) {
memberLists.stream().forEach(member -> {
//unionid不为空,获取非好友客户相关消息
......@@ -171,8 +175,6 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
// }
//
// }
weGroupMembers.add(
WeGroupMember.builder()
.chatId(kk.getChat_id())
......@@ -192,17 +194,33 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
}
});
//同步组织架构成员
weUserService.synchWeUser();
//同步客户
weCustomerService.synchWeCustomer();
/**
* 此处不同步成员和客户理由
* 1、如果是存量同步,不存在新客户新成员问题
* 2、增量同步的,成员和客户增删改群变更都会走回调通知,不用考虑新增成员和客户回调通知没有处理问题
*/
//同步组织架构成员
//weUserService.synchWeUser();
//同步客户
//weCustomerService.synchWeCustomer();
this.saveOrUpdateBatch(weGroups);
iWeGroupMemberService.remove(new LambdaQueryWrapper<WeGroupMember>().in(WeGroupMember::getChatId,
this.saveOrUpdateBatch(weGroups);
List<WeGroupMember> weGroupMemberList = iWeGroupMemberService.list(new LambdaQueryWrapper<WeGroupMember>().in(WeGroupMember::getChatId,
weGroups.stream().map(WeGroup::getChatId).collect(Collectors.toList())));
iWeGroupMemberService.saveOrUpdateBatch(weGroupMembers);
//存量去重
if (CollectionUtil.isNotEmpty(weGroupMemberList)){
List<WeGroupMember> groupMemberList = weGroupMembers.stream().filter(e -> {
for (WeGroupMember weGroupMember : weGroupMemberList) {
if (e.getUserId().equals(weGroupMember.getUserId())) {
return false;
}
}
return true;
}).collect(Collectors.toList());
iWeGroupMemberService.saveBatch(groupMemberList);
}else {
iWeGroupMemberService.saveBatch(weGroupMembers);
}
}
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeChatCollectionMapper">
<insert id="addCollection">
INSERT INTO
we_chat_collection(collection_id,material_id,user_id,create_by,create_time,update_by,update_time)
VALUES(#{collectionId},#{materialId},#{userId},#{createBy},#{createTime},#{updateBy},#{updateTime})
</insert>
<delete id="dropCollection">
DELETE FROM
we_chat_collection
<where>
material_id=#{materialId} AND user_id=#{userId}
</where>
</delete>
<select id="countCollectionByMaterialIdAndUserId" resultType="java.lang.Integer">
SELECT COUNT(1) FROM we_chat_collection
<where>
material_id=#{materialId} AND user_id=#{userId}
</where>
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeChatItemMapper">
<insert id="addItem">
INSERT INTO
we_chat_item(item_id,side_id,material_id,create_by,create_time,update_by,update_time)
VALUES
<if test="items!=null and items.size()>0">
<foreach collection="items" open="(" separator="," item="item" close=")">
#{item.itemId},#{item.sideId},#{item.materialId},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime}
</foreach>
</if>
</insert>
<delete id="dropItem">
DELETE FROM
we_chat_item
<where>
side_id=#{sideId}
</where>
</delete>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeChatSideMapper">
<update id="updateWeChatSideById">
UPDATE
we_chat_side
<set>
<if test="sideName!=null and sideName!=''">
side_name=#{sideName},
</if>
<if test="total!=null">
total=#{total},
</if>
<if test="using!=null">
`using`=#{using}
</if>
</set>
<where>
side_id=#{sideId}
</where>
</update>
<select id="selectWeChatSides" resultType="com.linkwechat.wecom.domain.WeChatSide">
SELECT
side_id,
media_type,
side_name,
total,
`using`
FROM
we_chat_side
<where>
`using`=0
</where>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!