店员管理/店员等级/账户管理

This commit is contained in:
starrySky
2024-03-31 13:52:29 +08:00
parent ccaa00990f
commit c7f81acbe5
125 changed files with 2670 additions and 1033 deletions

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.builder;
import me.chanjar.weixin.mp.api.WxMpService;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.builder;
import me.chanjar.weixin.mp.api.WxMpService;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.config;
/**

View File

@@ -1,28 +1,28 @@
//package com.starry.admin.modules.weichat.config;
// package com.starry.admin.modules.weichat.config;
//
//
//import cn.hutool.core.util.StrUtil;
//import com.starry.admin.modules.weichat.entity.CustomWxMpProperties;
//import com.starry.admin.modules.weichat.handler.*;
//import com.starry.admin.modules.weichat.utils.WxMpPropertiesUtils;
//import lombok.AllArgsConstructor;
//import me.chanjar.weixin.common.api.WxConsts;
//import me.chanjar.weixin.mp.api.WxMpMessageRouter;
//import me.chanjar.weixin.mp.api.WxMpService;
//import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
//import me.chanjar.weixin.mp.config.WxMpConfigStorage;
//import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
// import cn.hutool.core.util.StrUtil;
// import com.starry.admin.modules.weichat.entity.CustomWxMpProperties;
// import com.starry.admin.modules.weichat.handler.*;
// import com.starry.admin.modules.weichat.utils.WxMpPropertiesUtils;
// import lombok.AllArgsConstructor;
// import me.chanjar.weixin.common.api.WxConsts;
// import me.chanjar.weixin.mp.api.WxMpMessageRouter;
// import me.chanjar.weixin.mp.api.WxMpService;
// import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
// import me.chanjar.weixin.mp.config.WxMpConfigStorage;
// import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
// import org.springframework.context.annotation.Bean;
// import org.springframework.context.annotation.Configuration;
//
//import java.util.HashMap;
//import java.util.Map;
// import java.util.HashMap;
// import java.util.Map;
//
//import static me.chanjar.weixin.common.api.WxConsts.EventType.SUBSCRIBE;
//import static me.chanjar.weixin.common.api.WxConsts.EventType.UNSUBSCRIBE;
//import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType.EVENT;
//import static me.chanjar.weixin.mp.constant.WxMpEventConstants.CustomerService.*;
//import static me.chanjar.weixin.mp.constant.WxMpEventConstants.POI_CHECK_NOTIFY;
// import static me.chanjar.weixin.common.api.WxConsts.EventType.SUBSCRIBE;
// import static me.chanjar.weixin.common.api.WxConsts.EventType.UNSUBSCRIBE;
// import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType.EVENT;
// import static me.chanjar.weixin.mp.constant.WxMpEventConstants.CustomerService.*;
// import static me.chanjar.weixin.mp.constant.WxMpEventConstants.POI_CHECK_NOTIFY;
//
///**
// * wechat mp configuration
@@ -31,7 +31,7 @@
// */
//@AllArgsConstructor
//@Configuration
//public class WxMpConfiguration {
// public class WxMpConfiguration {
// private final LogHandler logHandler;
// private final NullHandler nullHandler;
// private final KfSessionHandler kfSessionHandler;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.constant;
/**

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.constant;
/**

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.constant;
/**

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.constant;
/**

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.controller;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
@@ -25,103 +24,109 @@ import java.util.List;
@RestController
@AllArgsConstructor
@RequestMapping("/wxautoreply")
public class WxAutoReplyController {
public class WxAutoReplyController {
@Resource
@Resource
WxAutoReplyService wxAutoReplyService;
/**
* 分页查询
* @param page 分页对象
* @param wxAutoReply 消息自动回复
* @return
*/
* 分页查询
*
* @param page 分页对象
* @param wxAutoReply 消息自动回复
* @return
*/
@GetMapping("/page")
@PreAuthorize("@customSs.hasPermission('wxmp:wxautoreply:index')")
public R getWxAutoReplyPage(Page page, WxAutoReply wxAutoReply) {
return R.ok(wxAutoReplyService.page(page,Wrappers.query(wxAutoReply)));
return R.ok(wxAutoReplyService.page(page, Wrappers.query(wxAutoReply)));
}
/**
* 通过id查询消息自动回复
* @param id id
* @return R
*/
* 通过id查询消息自动回复
*
* @param id id
* @return R
*/
@GetMapping("/{id}")
@PreAuthorize("@customSs.hasPermission('wxmp:wxautoreply:get')")
public R getById(@PathVariable("id") String id){
return R.ok(wxAutoReplyService.getById(id));
public R getById(@PathVariable("id") String id) {
return R.ok(wxAutoReplyService.getById(id));
}
/**
* 新增消息自动回复
* @param wxAutoReply 消息自动回复
* @return R
*/
* 新增消息自动回复
*
* @param wxAutoReply 消息自动回复
* @return R
*/
@PostMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxautoreply:add')")
public R save(@RequestBody WxAutoReply wxAutoReply){
this.jude(wxAutoReply);
return R.ok(wxAutoReplyService.save(wxAutoReply));
public R save(@RequestBody WxAutoReply wxAutoReply) {
this.jude(wxAutoReply);
return R.ok(wxAutoReplyService.save(wxAutoReply));
}
/**
* 修改消息自动回复
* @param wxAutoReply 消息自动回复
* @return R
*/
* 修改消息自动回复
*
* @param wxAutoReply 消息自动回复
* @return R
*/
@PutMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxautoreply:edit')")
public R updateById(@RequestBody WxAutoReply wxAutoReply){
this.jude(wxAutoReply);
return R.ok(wxAutoReplyService.updateById(wxAutoReply));
public R updateById(@RequestBody WxAutoReply wxAutoReply) {
this.jude(wxAutoReply);
return R.ok(wxAutoReplyService.updateById(wxAutoReply));
}
/**
* 通过id删除消息自动回复
* @param id id
* @return R
*/
* 通过id删除消息自动回复
*
* @param id id
* @return R
*/
@DeleteMapping("/{id}")
@PreAuthorize("@customSs.hasPermission('wxmp:wxautoreply:del')")
public R removeById(@PathVariable String id){
return R.ok(wxAutoReplyService.removeById(id));
public R removeById(@PathVariable String id) {
return R.ok(wxAutoReplyService.removeById(id));
}
/**
* //校验参数
* @param wxAutoReply
*/
public void jude(WxAutoReply wxAutoReply){
if(ConfigConstant.WX_AUTO_REPLY_TYPE_2.equals(wxAutoReply.getType())){
Wrapper<WxAutoReply> queryWrapper = Wrappers.<WxAutoReply>lambdaQuery()
.eq(WxAutoReply::getReqType,wxAutoReply.getReqType());
List<WxAutoReply> list = wxAutoReplyService.list(queryWrapper);
if(StringUtils.isNotBlank(wxAutoReply.getId())){
if(list != null && list.size() == 1){
if(!list.get(0).getId().equals(wxAutoReply.getId())){
throw new RuntimeException("请求消息类型重复");
}
}
if(list != null && list.size()>1){
throw new RuntimeException("请求消息类型重复");
}
}
}
if(ConfigConstant.WX_AUTO_REPLY_TYPE_3.equals(wxAutoReply.getType())){
Wrapper<WxAutoReply> queryWrapper = Wrappers.<WxAutoReply>lambdaQuery()
.eq(WxAutoReply::getReqKey,wxAutoReply.getReqKey())
.eq(WxAutoReply::getRepType,wxAutoReply.getRepMate());
List<WxAutoReply> list = wxAutoReplyService.list(queryWrapper);
if(list != null && list.size() == 1){
if(!list.get(0).getId().equals(wxAutoReply.getId())){
throw new RuntimeException("关键词重复");
}
}
if(list != null && list.size()>1){
throw new RuntimeException("关键词重复");
}
}
}
/**
* //校验参数
*
* @param wxAutoReply
*/
public void jude(WxAutoReply wxAutoReply) {
if (ConfigConstant.WX_AUTO_REPLY_TYPE_2.equals(wxAutoReply.getType())) {
Wrapper<WxAutoReply> queryWrapper = Wrappers.<WxAutoReply>lambdaQuery()
.eq(WxAutoReply::getReqType, wxAutoReply.getReqType());
List<WxAutoReply> list = wxAutoReplyService.list(queryWrapper);
if (StringUtils.isNotBlank(wxAutoReply.getId())) {
if (list != null && list.size() == 1) {
if (!list.get(0).getId().equals(wxAutoReply.getId())) {
throw new RuntimeException("请求消息类型重复");
}
}
if (list != null && list.size() > 1) {
throw new RuntimeException("请求消息类型重复");
}
}
}
if (ConfigConstant.WX_AUTO_REPLY_TYPE_3.equals(wxAutoReply.getType())) {
Wrapper<WxAutoReply> queryWrapper = Wrappers.<WxAutoReply>lambdaQuery()
.eq(WxAutoReply::getReqKey, wxAutoReply.getReqKey())
.eq(WxAutoReply::getRepType, wxAutoReply.getRepMate());
List<WxAutoReply> list = wxAutoReplyService.list(queryWrapper);
if (list != null && list.size() == 1) {
if (!list.get(0).getId().equals(wxAutoReply.getId())) {
throw new RuntimeException("关键词重复");
}
}
if (list != null && list.size() > 1) {
throw new RuntimeException("关键词重复");
}
}
}
}

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.controller;
import cn.hutool.json.JSONArray;
@@ -32,98 +31,99 @@ import java.util.List;
@AllArgsConstructor
@RequestMapping("/wxdraft")
@Api(value = "wxdraft", tags = "微信草稿箱")
public class WxDraftController {
public class WxDraftController {
@Resource
WxMpService wxService;
@Resource
WxMpService wxService;
/**
* 新增图文消息
*
* @param data
* @return
*/
@ApiOperation(value = "新增草稿箱")
@PostMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:add')")
public R add(@RequestBody JSONObject data) throws Exception {
JSONArray jSONArray = data.getJSONArray("articles");
List<WxMpDraftArticles> articles = jSONArray.toList(WxMpDraftArticles.class);
WxMpAddDraft wxMpAddDraft = new WxMpAddDraft();
wxMpAddDraft.setArticles(articles);
WxMpDraftService wxMpDraftService = wxService.getDraftService();
String rs = wxMpDraftService.addDraft(wxMpAddDraft);
return R.ok(rs);
}
/**
* 新增图文消息
*
* @param data
* @return
*/
@ApiOperation(value = "新增草稿箱")
@PostMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:add')")
public R add(@RequestBody JSONObject data) throws Exception {
JSONArray jSONArray = data.getJSONArray("articles");
List<WxMpDraftArticles> articles = jSONArray.toList(WxMpDraftArticles.class);
WxMpAddDraft wxMpAddDraft = new WxMpAddDraft();
wxMpAddDraft.setArticles(articles);
WxMpDraftService wxMpDraftService = wxService.getDraftService();
String rs = wxMpDraftService.addDraft(wxMpAddDraft);
return R.ok(rs);
}
/**
* 修改微信草稿箱
*
* @param data
* @return
*/
@ApiOperation(value = "修改微信草稿箱")
@PutMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:edit')")
public R edit(@RequestBody JSONObject data) throws Exception {
String mediaId = data.getStr("mediaId");
JSONArray jSONArray = data.getJSONArray("articles");
List<WxMpDraftArticles> articles = jSONArray.toList(WxMpDraftArticles.class);
WxMpDraftService wxMpDraftService = wxService.getDraftService();
WxMpUpdateDraft wxMpUpdateDraft = new WxMpUpdateDraft();
wxMpUpdateDraft.setMediaId(mediaId);
int index = 0;
for (WxMpDraftArticles article : articles) {
wxMpUpdateDraft.setIndex(index);
wxMpUpdateDraft.setArticles(article);
wxMpDraftService.updateDraft(wxMpUpdateDraft);
index++;
}
return R.ok();
}
/**
* 修改微信草稿箱
*
* @param data
* @return
*/
@ApiOperation(value = "修改微信草稿箱")
@PutMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:edit')")
public R edit(@RequestBody JSONObject data) throws Exception {
String mediaId = data.getStr("mediaId");
JSONArray jSONArray = data.getJSONArray("articles");
List<WxMpDraftArticles> articles = jSONArray.toList(WxMpDraftArticles.class);
WxMpDraftService wxMpDraftService = wxService.getDraftService();
WxMpUpdateDraft wxMpUpdateDraft = new WxMpUpdateDraft();
wxMpUpdateDraft.setMediaId(mediaId);
int index = 0;
for (WxMpDraftArticles article : articles) {
wxMpUpdateDraft.setIndex(index);
wxMpUpdateDraft.setArticles(article);
wxMpDraftService.updateDraft(wxMpUpdateDraft);
index++;
}
return R.ok();
}
/**
* 通过id删除微信草稿箱
*
* @param
* @return R
*/
@ApiOperation(value = "通过id删除微信草稿箱")
@DeleteMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:del')")
public R del(String id) throws Exception {
WxMpDraftService wxMpDraftService = wxService.getDraftService();
return R.ok(wxMpDraftService.delDraft(id));
}
/**
* 通过id删除微信草稿箱
*
* @param
* @return R
*/
@ApiOperation(value = "通过id删除微信草稿箱")
@DeleteMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:del')")
public R del(String id) throws Exception {
WxMpDraftService wxMpDraftService = wxService.getDraftService();
return R.ok(wxMpDraftService.delDraft(id));
}
/**
* 分页查询
*
* @param page 分页对象
* @param
* @return
*/
@ApiOperation(value = "分页查询")
@GetMapping("/page")
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:index')")
public R getPage(Page page) throws Exception {
WxMpDraftService wxMpDraftService = wxService.getDraftService();
int count = (int) page.getSize();
int offset = (int) page.getCurrent() * count - count;
return R.ok(wxMpDraftService.listDraft(offset, count));
}
/**
* 分页查询
*
* @param page 分页对象
* @param
* @return
*/
@ApiOperation(value = "分页查询")
@GetMapping("/page")
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:index')")
public R getPage(Page page) throws Exception {
WxMpDraftService wxMpDraftService = wxService.getDraftService();
int count = (int) page.getSize();
int offset = (int) page.getCurrent() * count - count;
return R.ok(wxMpDraftService.listDraft(offset, count));
}
/**
* 发布草稿箱
* @param id
* @return
*/
@ApiOperation(value = "发布草稿箱")
@PostMapping("/publish/{id}")
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:publish')")
public R publish(@PathVariable String id) throws Exception {
WxMpFreePublishService wxMpFreePublishService = wxService.getFreePublishService();
wxMpFreePublishService.submit(id);
return R.ok();
}
/**
* 发布草稿箱
*
* @param id
* @return
*/
@ApiOperation(value = "发布草稿箱")
@PostMapping("/publish/{id}")
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:publish')")
public R publish(@PathVariable String id) throws Exception {
WxMpFreePublishService wxMpFreePublishService = wxService.getFreePublishService();
wxMpFreePublishService.submit(id);
return R.ok();
}
}

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.controller;
import cn.hutool.json.JSONUtil;
@@ -43,197 +42,205 @@ import java.util.Map;
@RestController
@AllArgsConstructor
@RequestMapping("/wxmaterial")
public class WxMaterialController {
public class WxMaterialController {
@Resource
WxMpService wxService;
@Resource
WxMpService wxService;
/**
* 上传非图文微信素材
* @param mulFile
* @param mediaType
* @return
*/
@PostMapping("/materialFileUpload")
// @PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:add')")
public R materialFileUpload(@RequestParam("file") MultipartFile mulFile,
@RequestParam("title") String title,
@RequestParam("introduction") String introduction,
@RequestParam("mediaType") String mediaType) {
try {
WxMpMaterial material = new WxMpMaterial();
material.setName(mulFile.getOriginalFilename());
if(WxConsts.MediaFileType.VIDEO.equals(mediaType)){
material.setVideoTitle(title);
material.setVideoIntroduction(introduction);
}
File file = FileUtils.multipartFileToFile(mulFile);
material.setFile(file);
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
WxMpMaterialUploadResult wxMpMaterialUploadResult = wxMpMaterialService.materialFileUpload(mediaType,material);
WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem wxMpMaterialFileBatchGetResult = new WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem();
wxMpMaterialFileBatchGetResult.setName(file.getName());
wxMpMaterialFileBatchGetResult.setMediaId(wxMpMaterialUploadResult.getMediaId());
wxMpMaterialFileBatchGetResult.setUrl(wxMpMaterialUploadResult.getUrl());
return R.ok(wxMpMaterialFileBatchGetResult);
} catch (WxErrorException e) {
log.error("上传非图文微信素材失败" + e);
return R.error(e.getMessage());
} catch (Exception e) {
log.error("上传失败", e);
return R.error(e.getLocalizedMessage());
}
}
/**
* 上传非图文微信素材
*
* @param mulFile
* @param mediaType
* @return
*/
@PostMapping("/materialFileUpload")
// @PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:add')")
public R materialFileUpload(@RequestParam("file") MultipartFile mulFile,
@RequestParam("title") String title,
@RequestParam("introduction") String introduction,
@RequestParam("mediaType") String mediaType) {
try {
WxMpMaterial material = new WxMpMaterial();
material.setName(mulFile.getOriginalFilename());
if (WxConsts.MediaFileType.VIDEO.equals(mediaType)) {
material.setVideoTitle(title);
material.setVideoIntroduction(introduction);
}
File file = FileUtils.multipartFileToFile(mulFile);
material.setFile(file);
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
WxMpMaterialUploadResult wxMpMaterialUploadResult = wxMpMaterialService.materialFileUpload(mediaType, material);
WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem wxMpMaterialFileBatchGetResult = new WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem();
wxMpMaterialFileBatchGetResult.setName(file.getName());
wxMpMaterialFileBatchGetResult.setMediaId(wxMpMaterialUploadResult.getMediaId());
wxMpMaterialFileBatchGetResult.setUrl(wxMpMaterialUploadResult.getUrl());
return R.ok(wxMpMaterialFileBatchGetResult);
} catch (WxErrorException e) {
log.error("上传非图文微信素材失败" + e);
return R.error(e.getMessage());
} catch (Exception e) {
log.error("上传失败", e);
return R.error(e.getLocalizedMessage());
}
}
/**
* 上传图文消息内的图片获取URL
* @param mulFile
* @return
*/
@PostMapping("/newsImgUpload")
// @PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:add')")
public String newsImgUpload(@RequestParam("file") MultipartFile mulFile) throws Exception {
File file = FileUtils.multipartFileToFile(mulFile);
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
WxMediaImgUploadResult wxMediaImgUploadResult = wxMpMaterialService.mediaImgUpload(file);
Map<Object, Object> responseData = new HashMap<>();
responseData.put("link", wxMediaImgUploadResult.getUrl());
return JSONUtil.toJsonStr(responseData);
}
/**
* 通过id删除微信素材
* @param
* @return R
*/
@DeleteMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:del')")
public R materialDel(String id){
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
try {
return R.ok(wxMpMaterialService.materialDelete(id));
} catch (WxErrorException e) {
log.error("删除微信素材失败", e);
return R.error(e.getMessage());
}
}
/**
* 分页查询
* @param page 分页对象
* @param type
* @return
*/
@GetMapping("/page")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:index')")
public R getWxMaterialPage(Page page, String type) {
try {
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
int count = (int)page.getSize();
int offset = (int)page.getCurrent()*count-count;
if(WxConsts.MaterialType.NEWS.equals(type)){
return R.ok(wxMpMaterialService.materialNewsBatchGet(offset,count));
}else{
return R.ok(wxMpMaterialService.materialFileBatchGet(type,offset,count));
}
} catch (WxErrorException e) {
log.error("查询素材失败", e);
return R.error(e.getMessage());
}
}
/**
* 分页查询2
* @param type
* @return
*/
@GetMapping("/page-manager")
// @PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:index')")
public String getWxMaterialPageManager(Integer count, Integer offset, String type) throws WxErrorException {
List<ImageManager> listImageManager = new ArrayList<>();
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
List<WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem> list = wxMpMaterialService.materialFileBatchGet(type,offset,count).getItems();
list.forEach(wxMaterialFileBatchGetNewsItem -> {
ImageManager imageManager = new ImageManager();
imageManager.setName(wxMaterialFileBatchGetNewsItem.getMediaId());
imageManager.setUrl(wxMaterialFileBatchGetNewsItem.getUrl());
imageManager.setThumb(wxMaterialFileBatchGetNewsItem.getUrl());
listImageManager.add(imageManager);
});
return JSONUtil.toJsonStr(listImageManager);
}
/**
* 获取微信视频素材
* @param
* @return R
*/
@GetMapping("/materialVideo")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:get')")
public R getMaterialVideo(String mediaId){
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
try {
return R.ok(wxMpMaterialService.materialVideoInfo(mediaId));
} catch (WxErrorException e) {
log.error("获取微信视频素材失败", e);
return R.error(e.getMessage());
}
}
/**
* 获取微信素材直接文件
* @param
* @return R
*/
@GetMapping("/materialOther")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:get')")
public ResponseEntity<byte[]> getMaterialOther(String mediaId, String fileName) throws Exception {
try {
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
//获取文件
InputStream is = wxMpMaterialService.materialImageOrVoiceDownload(mediaId);
byte[] body = new byte[is.available()];
is.read(body);
HttpHeaders headers = new HttpHeaders();
//设置文件类型
headers.add("Content-Disposition", "attchement;filename=" + URLEncoder.encode(fileName, "UTF-8"));
headers.add("Content-Type", "application/octet-stream");
HttpStatus statusCode = HttpStatus.OK;
//返回数据
return new ResponseEntity<>(body, headers, statusCode);
} catch (WxErrorException e) {
log.error("获取微信素材直接文件失败", e);
return null;
}
}
/**
* 获取微信临时素材直接文件
* @param
* @return R
*/
@GetMapping("/tempMaterialOther")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmsg:index')")
public ResponseEntity<byte[]> getTempMaterialOther(String mediaId, String fileName) throws Exception {
/**
* 上传图文消息内的图片获取URL
*
* @param mulFile
* @return
*/
@PostMapping("/newsImgUpload")
// @PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:add')")
public String newsImgUpload(@RequestParam("file") MultipartFile mulFile) throws Exception {
File file = FileUtils.multipartFileToFile(mulFile);
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
try (InputStream is = Files.newInputStream(wxMpMaterialService.mediaDownload(mediaId).toPath())){
byte[] body = new byte[is.available()];
is.read(body);
HttpHeaders headers = new HttpHeaders();
//设置文件类型
headers.add("Content-Disposition", "attchement;filename=" + URLEncoder.encode(fileName, "UTF-8"));
headers.add("Content-Type", "application/octet-stream");
HttpStatus statusCode = HttpStatus.OK;
//返回数据
WxMediaImgUploadResult wxMediaImgUploadResult = wxMpMaterialService.mediaImgUpload(file);
Map<Object, Object> responseData = new HashMap<>();
responseData.put("link", wxMediaImgUploadResult.getUrl());
return JSONUtil.toJsonStr(responseData);
}
/**
* 通过id删除微信素材
*
* @param
* @return R
*/
@DeleteMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:del')")
public R materialDel(String id) {
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
try {
return R.ok(wxMpMaterialService.materialDelete(id));
} catch (WxErrorException e) {
log.error("删除微信素材失败", e);
return R.error(e.getMessage());
}
}
/**
* 分页查询
*
* @param page 分页对象
* @param type
* @return
*/
@GetMapping("/page")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:index')")
public R getWxMaterialPage(Page page, String type) {
try {
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
int count = (int) page.getSize();
int offset = (int) page.getCurrent() * count - count;
if (WxConsts.MaterialType.NEWS.equals(type)) {
return R.ok(wxMpMaterialService.materialNewsBatchGet(offset, count));
} else {
return R.ok(wxMpMaterialService.materialFileBatchGet(type, offset, count));
}
} catch (WxErrorException e) {
log.error("查询素材失败", e);
return R.error(e.getMessage());
}
}
/**
* 分页查询2
*
* @param type
* @return
*/
@GetMapping("/page-manager")
// @PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:index')")
public String getWxMaterialPageManager(Integer count, Integer offset, String type) throws WxErrorException {
List<ImageManager> listImageManager = new ArrayList<>();
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
List<WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem> list = wxMpMaterialService.materialFileBatchGet(type, offset, count).getItems();
list.forEach(wxMaterialFileBatchGetNewsItem -> {
ImageManager imageManager = new ImageManager();
imageManager.setName(wxMaterialFileBatchGetNewsItem.getMediaId());
imageManager.setUrl(wxMaterialFileBatchGetNewsItem.getUrl());
imageManager.setThumb(wxMaterialFileBatchGetNewsItem.getUrl());
listImageManager.add(imageManager);
});
return JSONUtil.toJsonStr(listImageManager);
}
/**
* 获取微信视频素材
*
* @param
* @return R
*/
@GetMapping("/materialVideo")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:get')")
public R getMaterialVideo(String mediaId) {
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
try {
return R.ok(wxMpMaterialService.materialVideoInfo(mediaId));
} catch (WxErrorException e) {
log.error("获取微信视频素材失败", e);
return R.error(e.getMessage());
}
}
/**
* 获取微信素材直接文件
*
* @param
* @return R
*/
@GetMapping("/materialOther")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:get')")
public ResponseEntity<byte[]> getMaterialOther(String mediaId, String fileName) throws Exception {
try {
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
// 获取文件
InputStream is = wxMpMaterialService.materialImageOrVoiceDownload(mediaId);
byte[] body = new byte[is.available()];
is.read(body);
HttpHeaders headers = new HttpHeaders();
// 设置文件类型
headers.add("Content-Disposition", "attchement;filename=" + URLEncoder.encode(fileName, "UTF-8"));
headers.add("Content-Type", "application/octet-stream");
HttpStatus statusCode = HttpStatus.OK;
// 返回数据
return new ResponseEntity<>(body, headers, statusCode);
} catch (WxErrorException e) {
log.error("获取微信素材直接文件失败", e);
return null;
}
}
} catch (WxErrorException e) {
log.error("获取微信素材直接文件失败", e);
return null;
}
}
/**
* 获取微信临时素材直接文件
*
* @param
* @return R
*/
@GetMapping("/tempMaterialOther")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmsg:index')")
public ResponseEntity<byte[]> getTempMaterialOther(String mediaId, String fileName) throws Exception {
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
try (InputStream is = Files.newInputStream(wxMpMaterialService.mediaDownload(mediaId).toPath())) {
byte[] body = new byte[is.available()];
is.read(body);
HttpHeaders headers = new HttpHeaders();
// 设置文件类型
headers.add("Content-Disposition", "attchement;filename=" + URLEncoder.encode(fileName, "UTF-8"));
headers.add("Content-Type", "application/octet-stream");
HttpStatus statusCode = HttpStatus.OK;
// 返回数据
return new ResponseEntity<>(body, headers, statusCode);
} catch (WxErrorException e) {
log.error("获取微信素材直接文件失败", e);
return null;
}
}
}

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.controller;
import cn.hutool.json.JSONObject;
@@ -25,40 +24,40 @@ import javax.annotation.Resource;
@RequestMapping("/wxmenu")
public class WxMenuController {
@Resource
@Resource
WxMenuService wxMenuService;
/**
* 通过appId查询自定义菜单
*
* @return R
*/
@GetMapping("/list")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmenu:get')")
public R getWxMenuButton() {
return R.ok(wxMenuService.getWxMenuButton());
}
/**
* 通过appId查询自定义菜单
*
* @return R
*/
@GetMapping("/list")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmenu:get')")
public R getWxMenuButton() {
return R.ok(wxMenuService.getWxMenuButton());
}
/**
* 保存并发布菜单
*
* @param
* @return R
*/
@PostMapping("/release")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmenu:add')")
public R saveAndRelease(@RequestBody String data) {
JSONObject jSONObject = JSONUtil.parseObj(data);
String strWxMenu = jSONObject.getStr("strWxMenu");
String appId = jSONObject.getStr("appId");
try {
wxMenuService.saveAndRelease(strWxMenu);
return R.ok();
} catch (WxErrorException e) {
log.error("发布自定义菜单失败appID:" + appId + ":" + e.getMessage());
return R.error(e.getMessage());
}
}
/**
* 保存并发布菜单
*
* @param
* @return R
*/
@PostMapping("/release")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmenu:add')")
public R saveAndRelease(@RequestBody String data) {
JSONObject jSONObject = JSONUtil.parseObj(data);
String strWxMenu = jSONObject.getStr("strWxMenu");
String appId = jSONObject.getStr("appId");
try {
wxMenuService.saveAndRelease(strWxMenu);
return R.ok();
} catch (WxErrorException e) {
log.error("发布自定义菜单失败appID:" + appId + ":" + e.getMessage());
return R.error(e.getMessage());
}
}
}

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.controller;
import cn.hutool.json.JSONArray;
@@ -67,7 +66,7 @@ public class WxMsgController {
if (StringUtils.isNotBlank(wxMsgVO.getNotInRepType())) {
return R.ok(wxMsgService.listWxMsgMapGroup(page, wxMsgVO));
}
//标记为已读
// 标记为已读
if (StringUtils.isNotBlank(wxMsgVO.getWxUserId())) {
WxMsg wxMsg = new WxMsg();
wxMsg.setReadFlag(CommonConstants.YES);
@@ -100,7 +99,7 @@ public class WxMsgController {
public R save(@RequestBody WxMsg wxMsg) {
try {
WxUser wxUser = wxUserService.getById(wxMsg.getWxUserId());
//入库
// 入库
wxMsg.setNickName(wxUser.getNickName());
wxMsg.setHeadimgUrl(wxUser.getHeadimgUrl());
wxMsg.setCreateTime(LocalDateTime.now());
@@ -111,7 +110,7 @@ public class WxMsgController {
wxMpKefuMessage = WxMpKefuMessage.TEXT().build();
wxMpKefuMessage.setContent(wxMsg.getRepContent());
}
if (WxConsts.KefuMsgType.IMAGE.equals(wxMsg.getRepType())) {//图片
if (WxConsts.KefuMsgType.IMAGE.equals(wxMsg.getRepType())) {// 图片
wxMsg.setRepName(wxMsg.getRepName());
wxMsg.setRepUrl(wxMsg.getRepUrl());
wxMsg.setRepMediaId(wxMsg.getRepMediaId());

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.controller;
import lombok.AllArgsConstructor;
@@ -24,7 +23,7 @@ public class WxPortalController {
private final WxMpService wxService;
//@Resource
//private final WxMpMessageRouter messageRouter;
// private final WxMpMessageRouter messageRouter;
@GetMapping(produces = "text/plain;charset=utf-8")
public String authGet(@PathVariable String appid,
@@ -34,7 +33,7 @@ public class WxPortalController {
@RequestParam(name = "echostr", required = false) String echostr) {
log.info("\n接收到来自微信服务器的认证消息[{}, {}, {}, {}]", signature,
timestamp, nonce, echostr);
timestamp, nonce, echostr);
if (StringUtils.isAnyBlank(signature, timestamp, nonce, echostr)) {
throw new IllegalArgumentException("请求参数非法,请核实!");
}
@@ -60,8 +59,8 @@ public class WxPortalController {
@RequestParam(name = "encrypt_type", required = false) String encType,
@RequestParam(name = "msg_signature", required = false) String msgSignature) {
log.info("\n接收微信请求[openid=[{}], [signature=[{}], encType=[{}], msgSignature=[{}],"
+ " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ",
openid, signature, encType, msgSignature, timestamp, nonce, requestBody);
+ " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ",
openid, signature, encType, msgSignature, timestamp, nonce, requestBody);
if (!this.wxService.switchover(appid)) {
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
@@ -84,7 +83,7 @@ public class WxPortalController {
} else if ("aes".equalsIgnoreCase(encType)) {
// aes加密的消息
WxMpXmlMessage inMessage = WxMpXmlMessage.fromEncryptedXml(requestBody, wxService.getWxMpConfigStorage(),
timestamp, nonce, msgSignature);
timestamp, nonce, msgSignature);
log.debug("\n消息解密后内容为\n{} ", inMessage.toString());
WxMpXmlOutMessage outMessage = this.route(inMessage);
if (outMessage == null) {
@@ -99,7 +98,7 @@ public class WxPortalController {
}
private WxMpXmlOutMessage route(WxMpXmlMessage message) {
//try {
// try {
// return this.messageRouter.route(message);
//} catch (Exception e) {
// log.error("路由消息时出现异常!", e);

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.controller;
import com.starry.common.result.R;
@@ -45,11 +44,11 @@ public class WxSummaryController {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return R.ok(wxMpDataCubeService.getUserSummary(sdf.parse(startDate), sdf.parse(endDate)));
} catch (WxErrorException e) {
log.error("获取用户增减数据失败", e);
return R.error(e.getMessage());
} catch (Exception e) {
log.error("获取用户增减数据失败", e);
return R.error("获取用户增减数据失败");
}
@@ -71,11 +70,11 @@ public class WxSummaryController {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return R.ok(wxMpDataCubeService.getUserCumulate(sdf.parse(startDate), sdf.parse(endDate)));
} catch (WxErrorException e) {
log.error("获取累计用户数据失败", e);
return R.error(e.getMessage());
} catch (Exception e) {
log.error("获取用户增减数据失败", e);
return R.error("获取用户增减数据失败");
}
@@ -97,11 +96,11 @@ public class WxSummaryController {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return R.ok(wxMpDataCubeService.getInterfaceSummary(sdf.parse(startDate), sdf.parse(endDate)));
} catch (WxErrorException e) {
log.error("获取接口分析数据失败", e);
return R.error(e.getMessage());
} catch (Exception e) {
log.error("获取接口分析数据失败", e);
return R.error("获取接口分析数据失败");
}

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.controller;
import cn.hutool.core.util.StrUtil;
@@ -122,7 +121,7 @@ public class WxUserController {
wxUserService.synchroWxUser();
return R.ok();
} catch (WxErrorException e) {
log.error("同步微信用户失败", e);
return R.error(e.getMessage());
}
@@ -140,7 +139,7 @@ public class WxUserController {
try {
return R.ok(wxUserService.updateRemark(wxUser));
} catch (WxErrorException e) {
log.error("修改微信用户备注失败", e);
return R.error(e.getMessage());
}
@@ -166,7 +165,7 @@ public class WxUserController {
}
return R.ok();
} catch (WxErrorException e) {
log.error("修改微信用户备注失败", e);
return R.error(e.getMessage());
}

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.controller;
import cn.hutool.json.JSONObject;
@@ -32,124 +31,129 @@ import java.util.List;
@RequestMapping("/wxusertags")
public class WxUserTagsController {
@Resource
WxMpService wxService;
@Resource
WxMpService wxService;
@Resource
@Resource
WxUserService wxUserService;
/**
* 获取微信用户标签
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:list')")
@GetMapping("/list")
public R getWxUserList(String appId) {
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
List<WxUserTag> listWxUserTag = wxMpUserTagService.tagGet();
return R.ok(listWxUserTag);
} catch (WxErrorException e) {
log.error("获取微信用户标签失败", e);
return R.error(e.getMessage());
}
}
/**
* 获取微信用户标签
*
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:list')")
@GetMapping("/list")
public R getWxUserList(String appId) {
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
List<WxUserTag> listWxUserTag = wxMpUserTagService.tagGet();
return R.ok(listWxUserTag);
} catch (WxErrorException e) {
/**
* 获取微信用户标签字典
* @param appId
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:list')")
@GetMapping("/dict")
public R getWxUserTagsDict(String appId) {
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
List<WxUserTag> listWxUserTag = wxMpUserTagService.tagGet();
List<WxUserTagsDict> listWxUserTagsDict = new ArrayList<>();
WxUserTagsDict wxUserTagsDict;
for(WxUserTag wxUserTag : listWxUserTag){
wxUserTagsDict = new WxUserTagsDict();
wxUserTagsDict.setName(wxUserTag.getName());
wxUserTagsDict.setValue(wxUserTag.getId());
listWxUserTagsDict.add(wxUserTagsDict);
}
return R.ok(listWxUserTagsDict);
} catch (WxErrorException e) {
log.error("获取微信用户标签字典失败", e);
return R.error(e.getMessage());
}
}
log.error("获取微信用户标签失败", e);
return R.error(e.getMessage());
}
}
/**
* 新增微信用户标签
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:add')")
@PostMapping
public R save(@RequestBody JSONObject data){
String appId = data.getStr("appId");
String name = data.getStr("name");
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
return R.ok(wxMpUserTagService.tagCreate(name));
} catch (WxErrorException e) {
log.error("新增微信用户标签失败", e);
return R.error(e.getMessage());
}
}
/**
* 获取微信用户标签字典
*
* @param appId
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:list')")
@GetMapping("/dict")
public R getWxUserTagsDict(String appId) {
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
List<WxUserTag> listWxUserTag = wxMpUserTagService.tagGet();
List<WxUserTagsDict> listWxUserTagsDict = new ArrayList<>();
WxUserTagsDict wxUserTagsDict;
for (WxUserTag wxUserTag : listWxUserTag) {
wxUserTagsDict = new WxUserTagsDict();
wxUserTagsDict.setName(wxUserTag.getName());
wxUserTagsDict.setValue(wxUserTag.getId());
listWxUserTagsDict.add(wxUserTagsDict);
}
return R.ok(listWxUserTagsDict);
} catch (WxErrorException e) {
/**
* 修改微信用户标签
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:edit')")
@PutMapping
public R updateById(@RequestBody JSONObject data){
String appId = data.getStr("appId");
Long id = data.getLong("id");
String name = data.getStr("name");
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
return R.ok(wxMpUserTagService.tagUpdate(id,name));
} catch (WxErrorException e) {
log.error("修改微信用户标签失败", e);
return R.error(e.getMessage());
}
}
log.error("获取微信用户标签字典失败", e);
return R.error(e.getMessage());
}
}
/**
* 删除微信用户标签
* @param id
* @param appId
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:del')")
@DeleteMapping
public R removeById(Long id,String appId){
int count = (int) wxUserService.count(Wrappers.<WxUser>lambdaQuery()
.and(wrapper -> wrapper
.eq(WxUser::getTagidList,"["+id+"]")
.or()
.like(WxUser::getTagidList,","+id+",")
.or()
.likeRight(WxUser::getTagidList,"["+id+",")
.or()
.likeLeft(WxUser::getTagidList,","+id+"]")));
if(count>0){
return R.error("该标签下有用户存在,无法删除");
}
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
return R.ok(wxMpUserTagService.tagDelete(id));
} catch (WxErrorException e) {
log.error("删除微信用户标签失败", e);
return R.error(e.getMessage());
}
}
/**
* 新增微信用户标签
*
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:add')")
@PostMapping
public R save(@RequestBody JSONObject data) {
String appId = data.getStr("appId");
String name = data.getStr("name");
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
return R.ok(wxMpUserTagService.tagCreate(name));
} catch (WxErrorException e) {
log.error("新增微信用户标签失败", e);
return R.error(e.getMessage());
}
}
/**
* 修改微信用户标签
*
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:edit')")
@PutMapping
public R updateById(@RequestBody JSONObject data) {
String appId = data.getStr("appId");
Long id = data.getLong("id");
String name = data.getStr("name");
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
return R.ok(wxMpUserTagService.tagUpdate(id, name));
} catch (WxErrorException e) {
log.error("修改微信用户标签失败", e);
return R.error(e.getMessage());
}
}
/**
* 删除微信用户标签
*
* @param id
* @param appId
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:del')")
@DeleteMapping
public R removeById(Long id, String appId) {
int count = (int) wxUserService.count(Wrappers.<WxUser>lambdaQuery()
.and(wrapper -> wrapper
.eq(WxUser::getTagidList, "[" + id + "]")
.or()
.like(WxUser::getTagidList, "," + id + ",")
.or()
.likeRight(WxUser::getTagidList, "[" + id + ",")
.or()
.likeLeft(WxUser::getTagidList, "," + id + "]")));
if (count > 0) {
return R.error("该标签下有用户存在,无法删除");
}
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
return R.ok(wxMpUserTagService.tagDelete(id));
} catch (WxErrorException e) {
log.error("删除微信用户标签失败", e);
return R.error(e.getMessage());
}
}
}

View File

@@ -2,28 +2,31 @@ package com.starry.admin.modules.weichat.entity;
import lombok.Data;
/**
* @author admin
*/
@Data
public class CustomWxMpProperties {
/**
* 微信APPID
*/
public String appid;
public String appid = "wx917f3f747c7dc5dd";
/**
* 微信公众号的app secret
*/
public String secret;
public String secret = "85012dec2ba8bdc9d0174dd800ef1dec";
/**
* 微信公众号的token
*/
public String token;
public String token = "AkzAW8yqUhOWAFN550";
/**
* 微信公众号的EncodingAESKey
*/
public String aesKey;
public String aesKey = "tsoM88UUQ5uEHJ29xgNiaHHaoswZapS5ijWpaN6hUZF";
}

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.entity;
import lombok.Data;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.entity;
import cn.hutool.json.JSONUtil;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.entity;
import cn.hutool.json.JSONObject;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.entity;
import lombok.Data;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.entity;
import cn.hutool.json.JSONObject;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.entity;
import cn.hutool.json.JSONObject;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.entity;
import cn.hutool.json.JSONObject;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.entity;
import lombok.Data;

View File

@@ -4,6 +4,7 @@ import lombok.Data;
/**
* 微信开发数据
*
* @author admin
*/
@Data

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.entity;
import com.baomidou.mybatisplus.annotation.IdType;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.entity;
import lombok.Data;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.handler;
import me.chanjar.weixin.mp.api.WxMpMessageHandler;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.handler;
import me.chanjar.weixin.common.session.WxSessionManager;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.handler;
import com.starry.admin.modules.weichat.builder.TextBuilder;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.handler;
import cn.hutool.core.util.StrUtil;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.handler;
import cn.hutool.json.JSONObject;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.handler;
import cn.hutool.json.JSONObject;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.handler;
import me.chanjar.weixin.common.session.WxSessionManager;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.handler;
import me.chanjar.weixin.common.error.WxErrorException;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.handler;
import me.chanjar.weixin.common.session.WxSessionManager;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.handler;
import cn.hutool.json.JSONUtil;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.handler;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.mapper;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.mapper;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.service;
import com.baomidou.mybatisplus.extension.service.IService;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.service;
import com.baomidou.mybatisplus.extension.service.IService;

View File

@@ -65,7 +65,7 @@ public class WxMpApi {
return mpService.getOAuth2Service().buildAuthorizationUrl(url, "snsapi_userinfo", "mystate");
}
//public String oauth2Callback(String code, String appId) {
// public String oauth2Callback(String code, String appId) {
// if (StringUtils.isEmpty(code)) {
// throw new RuntimeException("授权码不能为空");
// }

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.service;
import com.baomidou.mybatisplus.core.metadata.IPage;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.utils;
import cn.hutool.core.lang.UUID;
@@ -12,6 +11,7 @@ import java.nio.file.Files;
/**
* file工具
*
* @author admin
*/
public class FileUtils {

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.utils;
import com.google.gson.Gson;

View File

@@ -1,4 +1,3 @@
package com.starry.admin.modules.weichat.utils;
import java.time.Instant;
@@ -10,6 +9,7 @@ import java.time.temporal.ChronoField;
/**
* LocalDateTime时间工具
*
* @author admin
*/
public class LocalDateTimeUtils {

View File

@@ -12,12 +12,6 @@ public class WxMpPropertiesUtils {
private static ISysTenantService tenantService;
@Autowired
public void setTenantService(ISysTenantService tenantService) {
WxMpPropertiesUtils.tenantService = tenantService;
}
public static CustomWxMpProperties getWeiChatProperties() {
CustomWxMpProperties properties = new CustomWxMpProperties();
String tenantId = CustomSecurityContextHolder.getTenantId();
@@ -46,4 +40,9 @@ public class WxMpPropertiesUtils {
return properties;
}
@Autowired
public void setTenantService(ISysTenantService tenantService) {
WxMpPropertiesUtils.tenantService = tenantService;
}
}