[feat] 微信管理模块初始化
This commit is contained in:
parent
f47569e426
commit
1cf452b498
@ -0,0 +1,82 @@
|
||||
package com.czsj.web.controller.wechat;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.czsj.wechat.entity.Article;
|
||||
import com.czsj.wechat.enums.ArticleTypeEnum;
|
||||
import com.czsj.wechat.service.ArticleService;
|
||||
import com.czsj.wechat.utils.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* cms文章
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/article")
|
||||
@Api(tags = {"CMS文章"})
|
||||
public class ArticleController {
|
||||
@Autowired
|
||||
ArticleService articleService;
|
||||
|
||||
/**
|
||||
* 查看文章详情
|
||||
*
|
||||
* @param articleId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperation(value = "文章详情",notes = "")
|
||||
public R getArticle(int articleId) {
|
||||
Article article = articleService.findById(articleId);
|
||||
return R.ok().put(article);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看目录
|
||||
*
|
||||
* @param category
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/category")
|
||||
@ApiOperation(value = "目录信息",notes = "")
|
||||
public R getQuestions(String type, String category) {
|
||||
ArticleTypeEnum articleType = ArticleTypeEnum.of(type);
|
||||
if (articleType == null) {
|
||||
return R.error("文章类型有误");
|
||||
}
|
||||
List<Article> articles = articleService.selectCategory(articleType, category);
|
||||
return R.ok().put(articles);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章搜索
|
||||
*
|
||||
* @param category
|
||||
* @param keywords
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/search")
|
||||
@ApiOperation(value = "文章搜索",notes = "")
|
||||
public R getQuestions(String type,
|
||||
@RequestParam(required = false) String category,
|
||||
@RequestParam(required = false) String keywords) {
|
||||
ArticleTypeEnum articleType = ArticleTypeEnum.of(type);
|
||||
if (articleType == null) {
|
||||
return R.error("文章类型有误");
|
||||
}
|
||||
if (!StringUtils.hasText(keywords)) {
|
||||
return R.error("关键词不得为空");
|
||||
}
|
||||
List<Article> articles = articleService.search(articleType, category, keywords);
|
||||
return R.ok().put(articles);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.czsj.web.controller.wechat;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.czsj.common.annotation.Log;
|
||||
import com.czsj.common.core.controller.BaseController;
|
||||
import com.czsj.common.core.domain.AjaxResult;
|
||||
import com.czsj.common.enums.BusinessType;
|
||||
import com.czsj.wechat.domain.CzsjWxAccount;
|
||||
import com.czsj.wechat.service.ICzsjWxAccountService;
|
||||
import com.czsj.common.utils.poi.ExcelUtil;
|
||||
import com.czsj.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 微信公众号Controller
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wechat/account")
|
||||
public class CzsjWxAccountController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ICzsjWxAccountService czsjWxAccountService;
|
||||
|
||||
/**
|
||||
* 查询微信公众号列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:account:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CzsjWxAccount czsjWxAccount)
|
||||
{
|
||||
startPage();
|
||||
List<CzsjWxAccount> list = czsjWxAccountService.selectCzsjWxAccountList(czsjWxAccount);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出微信公众号列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:account:export')")
|
||||
@Log(title = "微信公众号", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CzsjWxAccount czsjWxAccount)
|
||||
{
|
||||
List<CzsjWxAccount> list = czsjWxAccountService.selectCzsjWxAccountList(czsjWxAccount);
|
||||
ExcelUtil<CzsjWxAccount> util = new ExcelUtil<CzsjWxAccount>(CzsjWxAccount.class);
|
||||
util.exportExcel(response, list, "微信公众号数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信公众号详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:account:query')")
|
||||
@GetMapping(value = "/{uid}")
|
||||
public AjaxResult getInfo(@PathVariable("uid") Long uid)
|
||||
{
|
||||
return success(czsjWxAccountService.selectCzsjWxAccountByUid(uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增微信公众号
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:account:add')")
|
||||
@Log(title = "微信公众号", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CzsjWxAccount czsjWxAccount)
|
||||
{
|
||||
return toAjax(czsjWxAccountService.insertCzsjWxAccount(czsjWxAccount));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改微信公众号
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:account:edit')")
|
||||
@Log(title = "微信公众号", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CzsjWxAccount czsjWxAccount)
|
||||
{
|
||||
return toAjax(czsjWxAccountService.updateCzsjWxAccount(czsjWxAccount));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除微信公众号
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:account:remove')")
|
||||
@Log(title = "微信公众号", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{uids}")
|
||||
public AjaxResult remove(@PathVariable Long[] uids)
|
||||
{
|
||||
return toAjax(czsjWxAccountService.deleteCzsjWxAccountByUids(uids));
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.czsj.web.controller.wechat;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.czsj.common.annotation.Log;
|
||||
import com.czsj.common.core.controller.BaseController;
|
||||
import com.czsj.common.core.domain.AjaxResult;
|
||||
import com.czsj.common.enums.BusinessType;
|
||||
import com.czsj.wechat.domain.CzsjWxMessage;
|
||||
import com.czsj.wechat.service.ICzsjWxMessageService;
|
||||
import com.czsj.common.utils.poi.ExcelUtil;
|
||||
import com.czsj.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 微信消息Controller
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wechat/message")
|
||||
public class CzsjWxMessageController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ICzsjWxMessageService czsjWxMessageService;
|
||||
|
||||
/**
|
||||
* 查询微信消息列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:message:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CzsjWxMessage czsjWxMessage)
|
||||
{
|
||||
startPage();
|
||||
List<CzsjWxMessage> list = czsjWxMessageService.selectCzsjWxMessageList(czsjWxMessage);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出微信消息列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:message:export')")
|
||||
@Log(title = "微信消息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CzsjWxMessage czsjWxMessage)
|
||||
{
|
||||
List<CzsjWxMessage> list = czsjWxMessageService.selectCzsjWxMessageList(czsjWxMessage);
|
||||
ExcelUtil<CzsjWxMessage> util = new ExcelUtil<CzsjWxMessage>(CzsjWxMessage.class);
|
||||
util.exportExcel(response, list, "微信消息数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信消息详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:message:query')")
|
||||
@GetMapping(value = "/{uid}")
|
||||
public AjaxResult getInfo(@PathVariable("uid") Long uid)
|
||||
{
|
||||
return success(czsjWxMessageService.selectCzsjWxMessageByUid(uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增微信消息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:message:add')")
|
||||
@Log(title = "微信消息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CzsjWxMessage czsjWxMessage)
|
||||
{
|
||||
return toAjax(czsjWxMessageService.insertCzsjWxMessage(czsjWxMessage));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改微信消息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:message:edit')")
|
||||
@Log(title = "微信消息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CzsjWxMessage czsjWxMessage)
|
||||
{
|
||||
return toAjax(czsjWxMessageService.updateCzsjWxMessage(czsjWxMessage));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除微信消息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:message:remove')")
|
||||
@Log(title = "微信消息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{uids}")
|
||||
public AjaxResult remove(@PathVariable Long[] uids)
|
||||
{
|
||||
return toAjax(czsjWxMessageService.deleteCzsjWxMessageByUids(uids));
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.czsj.web.controller.wechat;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.czsj.common.annotation.Log;
|
||||
import com.czsj.common.core.controller.BaseController;
|
||||
import com.czsj.common.core.domain.AjaxResult;
|
||||
import com.czsj.common.enums.BusinessType;
|
||||
import com.czsj.wechat.domain.CzsjWxQrCode;
|
||||
import com.czsj.wechat.service.ICzsjWxQrCodeService;
|
||||
import com.czsj.common.utils.poi.ExcelUtil;
|
||||
import com.czsj.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 公众号二维码Controller
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wechat/code")
|
||||
public class CzsjWxQrCodeController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ICzsjWxQrCodeService czsjWxQrCodeService;
|
||||
|
||||
/**
|
||||
* 查询公众号二维码列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:code:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CzsjWxQrCode czsjWxQrCode)
|
||||
{
|
||||
startPage();
|
||||
List<CzsjWxQrCode> list = czsjWxQrCodeService.selectCzsjWxQrCodeList(czsjWxQrCode);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出公众号二维码列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:code:export')")
|
||||
@Log(title = "公众号二维码", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CzsjWxQrCode czsjWxQrCode)
|
||||
{
|
||||
List<CzsjWxQrCode> list = czsjWxQrCodeService.selectCzsjWxQrCodeList(czsjWxQrCode);
|
||||
ExcelUtil<CzsjWxQrCode> util = new ExcelUtil<CzsjWxQrCode>(CzsjWxQrCode.class);
|
||||
util.exportExcel(response, list, "公众号二维码数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公众号二维码详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:code:query')")
|
||||
@GetMapping(value = "/{uid}")
|
||||
public AjaxResult getInfo(@PathVariable("uid") Long uid)
|
||||
{
|
||||
return success(czsjWxQrCodeService.selectCzsjWxQrCodeByUid(uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增公众号二维码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:code:add')")
|
||||
@Log(title = "公众号二维码", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CzsjWxQrCode czsjWxQrCode)
|
||||
{
|
||||
return toAjax(czsjWxQrCodeService.insertCzsjWxQrCode(czsjWxQrCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改公众号二维码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:code:edit')")
|
||||
@Log(title = "公众号二维码", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CzsjWxQrCode czsjWxQrCode)
|
||||
{
|
||||
return toAjax(czsjWxQrCodeService.updateCzsjWxQrCode(czsjWxQrCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除公众号二维码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:code:remove')")
|
||||
@Log(title = "公众号二维码", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{uids}")
|
||||
public AjaxResult remove(@PathVariable Long[] uids)
|
||||
{
|
||||
return toAjax(czsjWxQrCodeService.deleteCzsjWxQrCodeByUids(uids));
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.czsj.web.controller.wechat;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.czsj.common.annotation.Log;
|
||||
import com.czsj.common.core.controller.BaseController;
|
||||
import com.czsj.common.core.domain.AjaxResult;
|
||||
import com.czsj.common.enums.BusinessType;
|
||||
import com.czsj.wechat.domain.CzsjWxReplyRule;
|
||||
import com.czsj.wechat.service.ICzsjWxReplyRuleService;
|
||||
import com.czsj.common.utils.poi.ExcelUtil;
|
||||
import com.czsj.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 微信消息回复规则Controller
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wechat/rule")
|
||||
public class CzsjWxReplyRuleController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ICzsjWxReplyRuleService czsjWxReplyRuleService;
|
||||
|
||||
/**
|
||||
* 查询微信消息回复规则列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:rule:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CzsjWxReplyRule czsjWxReplyRule)
|
||||
{
|
||||
startPage();
|
||||
List<CzsjWxReplyRule> list = czsjWxReplyRuleService.selectCzsjWxReplyRuleList(czsjWxReplyRule);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出微信消息回复规则列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:rule:export')")
|
||||
@Log(title = "微信消息回复规则", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CzsjWxReplyRule czsjWxReplyRule)
|
||||
{
|
||||
List<CzsjWxReplyRule> list = czsjWxReplyRuleService.selectCzsjWxReplyRuleList(czsjWxReplyRule);
|
||||
ExcelUtil<CzsjWxReplyRule> util = new ExcelUtil<CzsjWxReplyRule>(CzsjWxReplyRule.class);
|
||||
util.exportExcel(response, list, "微信消息回复规则数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信消息回复规则详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:rule:query')")
|
||||
@GetMapping(value = "/{uid}")
|
||||
public AjaxResult getInfo(@PathVariable("uid") Long uid)
|
||||
{
|
||||
return success(czsjWxReplyRuleService.selectCzsjWxReplyRuleByUid(uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增微信消息回复规则
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:rule:add')")
|
||||
@Log(title = "微信消息回复规则", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CzsjWxReplyRule czsjWxReplyRule)
|
||||
{
|
||||
return toAjax(czsjWxReplyRuleService.insertCzsjWxReplyRule(czsjWxReplyRule));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改微信消息回复规则
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:rule:edit')")
|
||||
@Log(title = "微信消息回复规则", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CzsjWxReplyRule czsjWxReplyRule)
|
||||
{
|
||||
return toAjax(czsjWxReplyRuleService.updateCzsjWxReplyRule(czsjWxReplyRule));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除微信消息回复规则
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:rule:remove')")
|
||||
@Log(title = "微信消息回复规则", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{uids}")
|
||||
public AjaxResult remove(@PathVariable Long[] uids)
|
||||
{
|
||||
return toAjax(czsjWxReplyRuleService.deleteCzsjWxReplyRuleByUids(uids));
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.czsj.web.controller.wechat;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.czsj.common.annotation.Log;
|
||||
import com.czsj.common.core.controller.BaseController;
|
||||
import com.czsj.common.core.domain.AjaxResult;
|
||||
import com.czsj.common.enums.BusinessType;
|
||||
import com.czsj.wechat.domain.CzsjWxTemplate;
|
||||
import com.czsj.wechat.service.ICzsjWxTemplateService;
|
||||
import com.czsj.common.utils.poi.ExcelUtil;
|
||||
import com.czsj.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 微信消息模板Controller
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wechat/template")
|
||||
public class CzsjWxTemplateController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ICzsjWxTemplateService czsjWxTemplateService;
|
||||
|
||||
/**
|
||||
* 查询微信消息模板列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:template:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CzsjWxTemplate czsjWxTemplate)
|
||||
{
|
||||
startPage();
|
||||
List<CzsjWxTemplate> list = czsjWxTemplateService.selectCzsjWxTemplateList(czsjWxTemplate);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出微信消息模板列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:template:export')")
|
||||
@Log(title = "微信消息模板", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CzsjWxTemplate czsjWxTemplate)
|
||||
{
|
||||
List<CzsjWxTemplate> list = czsjWxTemplateService.selectCzsjWxTemplateList(czsjWxTemplate);
|
||||
ExcelUtil<CzsjWxTemplate> util = new ExcelUtil<CzsjWxTemplate>(CzsjWxTemplate.class);
|
||||
util.exportExcel(response, list, "微信消息模板数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信消息模板详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:template:query')")
|
||||
@GetMapping(value = "/{uid}")
|
||||
public AjaxResult getInfo(@PathVariable("uid") Long uid)
|
||||
{
|
||||
return success(czsjWxTemplateService.selectCzsjWxTemplateByUid(uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增微信消息模板
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:template:add')")
|
||||
@Log(title = "微信消息模板", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CzsjWxTemplate czsjWxTemplate)
|
||||
{
|
||||
return toAjax(czsjWxTemplateService.insertCzsjWxTemplate(czsjWxTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改微信消息模板
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:template:edit')")
|
||||
@Log(title = "微信消息模板", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CzsjWxTemplate czsjWxTemplate)
|
||||
{
|
||||
return toAjax(czsjWxTemplateService.updateCzsjWxTemplate(czsjWxTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除微信消息模板
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:template:remove')")
|
||||
@Log(title = "微信消息模板", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{uids}")
|
||||
public AjaxResult remove(@PathVariable Long[] uids)
|
||||
{
|
||||
return toAjax(czsjWxTemplateService.deleteCzsjWxTemplateByUids(uids));
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.czsj.web.controller.wechat;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.czsj.common.annotation.Log;
|
||||
import com.czsj.common.core.controller.BaseController;
|
||||
import com.czsj.common.core.domain.AjaxResult;
|
||||
import com.czsj.common.enums.BusinessType;
|
||||
import com.czsj.wechat.domain.CzsjWxTemplateLog;
|
||||
import com.czsj.wechat.service.ICzsjWxTemplateLogService;
|
||||
import com.czsj.common.utils.poi.ExcelUtil;
|
||||
import com.czsj.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 微信消息模板日志Controller
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wechat/log")
|
||||
public class CzsjWxTemplateLogController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ICzsjWxTemplateLogService czsjWxTemplateLogService;
|
||||
|
||||
/**
|
||||
* 查询微信消息模板日志列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:log:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CzsjWxTemplateLog czsjWxTemplateLog)
|
||||
{
|
||||
startPage();
|
||||
List<CzsjWxTemplateLog> list = czsjWxTemplateLogService.selectCzsjWxTemplateLogList(czsjWxTemplateLog);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出微信消息模板日志列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:log:export')")
|
||||
@Log(title = "微信消息模板日志", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CzsjWxTemplateLog czsjWxTemplateLog)
|
||||
{
|
||||
List<CzsjWxTemplateLog> list = czsjWxTemplateLogService.selectCzsjWxTemplateLogList(czsjWxTemplateLog);
|
||||
ExcelUtil<CzsjWxTemplateLog> util = new ExcelUtil<CzsjWxTemplateLog>(CzsjWxTemplateLog.class);
|
||||
util.exportExcel(response, list, "微信消息模板日志数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信消息模板日志详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:log:query')")
|
||||
@GetMapping(value = "/{uid}")
|
||||
public AjaxResult getInfo(@PathVariable("uid") Long uid)
|
||||
{
|
||||
return success(czsjWxTemplateLogService.selectCzsjWxTemplateLogByUid(uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增微信消息模板日志
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:log:add')")
|
||||
@Log(title = "微信消息模板日志", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CzsjWxTemplateLog czsjWxTemplateLog)
|
||||
{
|
||||
return toAjax(czsjWxTemplateLogService.insertCzsjWxTemplateLog(czsjWxTemplateLog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改微信消息模板日志
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:log:edit')")
|
||||
@Log(title = "微信消息模板日志", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CzsjWxTemplateLog czsjWxTemplateLog)
|
||||
{
|
||||
return toAjax(czsjWxTemplateLogService.updateCzsjWxTemplateLog(czsjWxTemplateLog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除微信消息模板日志
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('wechat:log:remove')")
|
||||
@Log(title = "微信消息模板日志", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{uids}")
|
||||
public AjaxResult remove(@PathVariable Long[] uids)
|
||||
{
|
||||
return toAjax(czsjWxTemplateLogService.deleteCzsjWxTemplateLogByUids(uids));
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
package com.czsj.web.controller.wechat;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
|
||||
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import com.czsj.wechat.entity.WxUser;
|
||||
import com.czsj.wechat.form.WxH5OuthrizeForm;
|
||||
import com.czsj.wechat.utils.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 微信网页授权相关
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wxAuth")
|
||||
@Api(tags = {"微信网页授权"})
|
||||
@RequiredArgsConstructor
|
||||
public class WxAuthController {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final WxMpService wxMpService;
|
||||
|
||||
/**
|
||||
* 使用微信授权code换取openid
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param form
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/codeToOpenid")
|
||||
@CrossOrigin
|
||||
@ApiOperation(value = "网页登录-code换取openid",notes = "scope为snsapi_base")
|
||||
public R codeToOpenid(HttpServletRequest request, HttpServletResponse response,
|
||||
@CookieValue String appid, @RequestBody WxH5OuthrizeForm form) {
|
||||
try {
|
||||
this.wxMpService.switchoverTo(appid);
|
||||
WxOAuth2AccessToken token = wxMpService.getOAuth2Service().getAccessToken(form.getCode());
|
||||
String openid = token.getOpenId();
|
||||
CookieUtil.setCookie(response, "openid", openid, 365 * 24 * 60 * 60);
|
||||
String openidToken = MD5Util.getMd5AndSalt(openid);
|
||||
CookieUtil.setCookie(response, "openidToken", openidToken, 365 * 24 * 60 * 60);
|
||||
return R.ok().put(openid);
|
||||
} catch (WxErrorException e) {
|
||||
logger.error("code换取openid失败", e);
|
||||
return R.error(e.getError().getErrorMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用微信授权code换取用户信息(需scope为 snsapi_userinfo)
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param form
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/codeToUserInfo")
|
||||
@CrossOrigin
|
||||
@ApiOperation(value = "网页登录-code换取用户信息",notes = "需scope为 snsapi_userinfo")
|
||||
public R codeToUserInfo(HttpServletRequest request, HttpServletResponse response,
|
||||
@CookieValue String appid, @RequestBody WxH5OuthrizeForm form) {
|
||||
try {
|
||||
this.wxMpService.switchoverTo(appid);
|
||||
WxOAuth2AccessToken token = wxMpService.getOAuth2Service().getAccessToken(form.getCode());
|
||||
WxOAuth2UserInfo userInfo = wxMpService.getOAuth2Service().getUserInfo(token,"zh_CN");
|
||||
String openid = userInfo.getOpenid();
|
||||
CookieUtil.setCookie(response, "openid", openid, 365 * 24 * 60 * 60);
|
||||
String openidToken = MD5Util.getMd5AndSalt(openid);
|
||||
CookieUtil.setCookie(response, "openidToken", openidToken, 365 * 24 * 60 * 60);
|
||||
return R.ok().put(new WxUser(userInfo,appid));
|
||||
} catch (WxErrorException e) {
|
||||
logger.error("code换取用户信息失败", e);
|
||||
return R.error(e.getError().getErrorMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信分享的签名配置
|
||||
* 允许跨域(只有微信公众号添加了js安全域名的网站才能加载微信分享,故这里不对域名进行校验)
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getShareSignature")
|
||||
@ApiOperation(value = "获取微信分享的签名配置",notes = "微信公众号添加了js安全域名的网站才能加载微信分享")
|
||||
public R getShareSignature(HttpServletRequest request, HttpServletResponse response,@CookieValue String appid) throws WxErrorException {
|
||||
this.wxMpService.switchoverTo(appid);
|
||||
// 1.拼接url(当前网页的URL,不包含#及其后面部分)
|
||||
String wxShareUrl = request.getHeader(Constant.WX_CLIENT_HREF_HEADER);
|
||||
if (!StringUtils.hasText(wxShareUrl)) {
|
||||
return R.error("header中缺少"+Constant.WX_CLIENT_HREF_HEADER+"参数,微信分享加载失败");
|
||||
}
|
||||
wxShareUrl = wxShareUrl.split("#")[0];
|
||||
Map<String, String> wxMap = new TreeMap<>();
|
||||
String wxNoncestr = UUID.randomUUID().toString();
|
||||
String wxTimestamp = (System.currentTimeMillis() / 1000) + "";
|
||||
wxMap.put("noncestr", wxNoncestr);
|
||||
wxMap.put("timestamp", wxTimestamp);
|
||||
wxMap.put("jsapi_ticket", wxMpService.getJsapiTicket());
|
||||
wxMap.put("url", wxShareUrl);
|
||||
|
||||
// 加密获取signature
|
||||
StringBuilder wxBaseString = new StringBuilder();
|
||||
wxMap.forEach((key, value) -> wxBaseString.append(key).append("=").append(value).append("&"));
|
||||
String wxSignString = wxBaseString.substring(0, wxBaseString.length() - 1);
|
||||
// signature
|
||||
String wxSignature = SHA1Util.sha1(wxSignString);
|
||||
Map<String, String> resMap = new TreeMap<>();
|
||||
resMap.put("appId", appid);
|
||||
resMap.put("wxTimestamp", wxTimestamp);
|
||||
resMap.put("wxNoncestr", wxNoncestr);
|
||||
resMap.put("wxSignature", wxSignature);
|
||||
return R.ok().put(resMap);
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
package com.czsj.web.controller.wechat;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 微信消息
|
||||
* @author Binary Wang
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/wx/msg/{appid}")
|
||||
@Api(tags = {"微信消息 - 腾讯会调用"})
|
||||
public class WxMpPortalController {
|
||||
private final WxMpService wxService;
|
||||
private final WxMpMessageRouter messageRouter;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@GetMapping(produces = "text/plain;charset=utf-8")
|
||||
@ApiOperation(value = "微信服务器的认证消息",notes = "公众号接入开发模式时腾讯调用此接口")
|
||||
public String authGet(@PathVariable String appid,
|
||||
@RequestParam(name = "signature", required = false) String signature,
|
||||
@RequestParam(name = "timestamp", required = false) String timestamp,
|
||||
@RequestParam(name = "nonce", required = false) String nonce,
|
||||
@RequestParam(name = "echostr", required = false) String echostr) {
|
||||
|
||||
logger.info("\n接收到来自微信服务器的认证消息:[{}, {}, {}, {}]", signature,
|
||||
timestamp, nonce, echostr);
|
||||
if (StringUtils.isAnyBlank(signature, timestamp, nonce, echostr)) {
|
||||
throw new IllegalArgumentException("请求参数非法,请核实!");
|
||||
}
|
||||
this.wxService.switchoverTo(appid);
|
||||
|
||||
if (wxService.checkSignature(timestamp, nonce, signature)) {
|
||||
return echostr;
|
||||
}
|
||||
|
||||
return "非法请求";
|
||||
}
|
||||
|
||||
@PostMapping(produces = "application/xml; charset=UTF-8")
|
||||
@ApiOperation(value = "微信各类消息",notes = "公众号接入开发模式后才有效")
|
||||
public String post(@PathVariable String appid,
|
||||
@RequestBody String requestBody,
|
||||
@RequestParam("signature") String signature,
|
||||
@RequestParam("timestamp") String timestamp,
|
||||
@RequestParam("nonce") String nonce,
|
||||
@RequestParam("openid") String openid,
|
||||
@RequestParam(name = "encrypt_type", required = false) String encType,
|
||||
@RequestParam(name = "msg_signature", required = false) String msgSignature) {
|
||||
// logger.debug("\n接收微信请求:[openid=[{}], [signature=[{}], encType=[{}], msgSignature=[{}],"
|
||||
// + " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ",
|
||||
// openid, signature, encType, msgSignature, timestamp, nonce, requestBody);
|
||||
this.wxService.switchoverTo(appid);
|
||||
if (!wxService.checkSignature(timestamp, nonce, signature)) {
|
||||
throw new IllegalArgumentException("非法请求,可能属于伪造的请求!");
|
||||
}
|
||||
|
||||
String out = null;
|
||||
if (encType == null) {
|
||||
// 明文传输的消息
|
||||
WxMpXmlMessage inMessage = WxMpXmlMessage.fromXml(requestBody);
|
||||
WxMpXmlOutMessage outMessage = this.route(appid,inMessage);
|
||||
if (outMessage == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
out = outMessage.toXml();
|
||||
} else if ("aes".equalsIgnoreCase(encType)) {
|
||||
// aes加密的消息
|
||||
WxMpXmlMessage inMessage = WxMpXmlMessage.fromEncryptedXml(requestBody, wxService.getWxMpConfigStorage(),
|
||||
timestamp, nonce, msgSignature);
|
||||
logger.debug("\n消息解密后内容为:\n{} ", inMessage.toString());
|
||||
WxMpXmlOutMessage outMessage = this.route(appid,inMessage);
|
||||
if (outMessage == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
out = outMessage.toEncryptedXml(wxService.getWxMpConfigStorage());
|
||||
}
|
||||
|
||||
logger.debug("\n组装回复信息:{}", out);
|
||||
return out;
|
||||
}
|
||||
|
||||
private WxMpXmlOutMessage route(String appid,WxMpXmlMessage message) {
|
||||
try {
|
||||
return this.messageRouter.route(appid,message);
|
||||
} catch (Exception e) {
|
||||
logger.error("路由消息时出现异常!", e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.czsj.web.controller.wechat;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import com.czsj.wechat.entity.WxUser;
|
||||
import com.czsj.wechat.service.WxUserService;
|
||||
import com.czsj.wechat.utils.R;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CookieValue;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 微信用户(粉丝)
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wxUser")
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = {"微信粉丝"})
|
||||
public class WxUserController {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
@Autowired
|
||||
WxUserService wxUserService;
|
||||
private final WxMpService wxMpService;
|
||||
|
||||
@GetMapping("/getUserInfo")
|
||||
@ApiOperation(value = "获取粉丝信息")
|
||||
public R getUserInfo(@CookieValue String appid,@CookieValue String openid){
|
||||
this.wxMpService.switchoverTo(appid);
|
||||
WxUser wxUser = wxUserService.getById(openid);
|
||||
return R.ok().put(wxUser);
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.czsj.web.controller.wechat;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import com.czsj.wechat.entity.WxUser;
|
||||
import com.czsj.wechat.form.WxUserTaggingForm;
|
||||
import com.czsj.wechat.service.WxUserService;
|
||||
import com.czsj.wechat.service.WxUserTagsService;
|
||||
import com.czsj.wechat.utils.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 粉丝标签
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wxUserTags")
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = {"粉丝标签"})
|
||||
public class WxUserTagsController {
|
||||
@Autowired
|
||||
WxUserTagsService wxUserTagsService;
|
||||
@Autowired
|
||||
WxUserService wxUserService;
|
||||
private final WxMpService wxMpService;
|
||||
|
||||
@GetMapping("/userTags")
|
||||
@ApiOperation(value = "当前用户的标签")
|
||||
public R userTags(@CookieValue String appid,@CookieValue String openid){
|
||||
if(openid==null){
|
||||
return R.error("none_openid");
|
||||
}
|
||||
this.wxMpService.switchoverTo(appid);
|
||||
WxUser wxUser = wxUserService.getById(openid);
|
||||
if(wxUser==null){
|
||||
wxUser=wxUserService.refreshUserInfo(openid,appid);
|
||||
if(wxUser==null) {
|
||||
return R.error("not_subscribed");
|
||||
}
|
||||
}
|
||||
return R.ok().put(wxUser.getTagidList());
|
||||
}
|
||||
|
||||
@PostMapping("/tagging")
|
||||
@ApiOperation(value = "给用户绑定标签")
|
||||
public R tagging(@CookieValue String appid,@CookieValue String openid , @RequestBody WxUserTaggingForm form) {
|
||||
this.wxMpService.switchoverTo(appid);
|
||||
try {
|
||||
wxUserTagsService.tagging(form.getTagid(),openid);
|
||||
}catch (WxErrorException e){
|
||||
WxError error = e.getError();
|
||||
if(50005==error.getErrorCode()){//未关注公众号
|
||||
return R.error("not_subscribed");
|
||||
}else {
|
||||
return R.error(error.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/untagging")
|
||||
@ApiOperation(value = "解绑标签")
|
||||
public R untagging(@CookieValue String appid,@CookieValue String openid , @RequestBody WxUserTaggingForm form) throws WxErrorException {
|
||||
this.wxMpService.switchoverTo(appid);
|
||||
wxUserTagsService.untagging(form.getTagid(),openid);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
@ -124,6 +124,18 @@
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -23,6 +23,31 @@
|
||||
<artifactId>czsj-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis-plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>weixin-java-mp</artifactId>
|
||||
<version>4.6.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--Swagger2依赖 -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<!--Swagger UI依赖 -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -2,6 +2,7 @@ package com.czsj.account.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.account.domain.CzsjMemberWxFans;
|
||||
import com.czsj.wechat.entity.WxUser;
|
||||
|
||||
/**
|
||||
* 会员微信粉丝Service接口
|
||||
@ -11,6 +12,21 @@ import com.czsj.account.domain.CzsjMemberWxFans;
|
||||
*/
|
||||
public interface ICzsjMemberWxFansService
|
||||
{
|
||||
|
||||
/**
|
||||
* 取消关注,更新关注状态
|
||||
*
|
||||
* @param openid
|
||||
*/
|
||||
void unsubscribe(String openid);
|
||||
/**
|
||||
* 根据openid更新会员微信粉丝
|
||||
*
|
||||
* @param openid
|
||||
* @return
|
||||
*/
|
||||
void refreshUserInfo(String openid, String appid);
|
||||
|
||||
/**
|
||||
* 查询会员微信粉丝
|
||||
*
|
||||
|
@ -1,7 +1,16 @@
|
||||
package com.czsj.account.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.czsj.common.core.domain.entity.SysUser;
|
||||
import com.czsj.common.core.domain.model.LoginUser;
|
||||
import com.czsj.common.utils.DateUtils;
|
||||
import com.czsj.common.utils.SecurityUtils;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.czsj.account.mapper.CzsjMemberWxFansMapper;
|
||||
@ -17,8 +26,56 @@ import com.czsj.account.service.ICzsjMemberWxFansService;
|
||||
@Service
|
||||
public class CzsjMemberWxFansServiceImpl implements ICzsjMemberWxFansService
|
||||
{
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private CzsjMemberWxFansMapper czsjMemberWxFansMapper;
|
||||
@Autowired
|
||||
private WxMpService wxMpService;
|
||||
|
||||
@Override
|
||||
public void unsubscribe(String openid) {
|
||||
CzsjMemberWxFans fans = new CzsjMemberWxFans();
|
||||
fans.setOpenId(openid);
|
||||
fans.setSubscribeStatus(1);
|
||||
fans.setUnsubscribeTime(new Date());
|
||||
czsjMemberWxFansMapper.updateCzsjMemberWxFans(fans);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshUserInfo(String openid, String appid) {
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
SysUser currentUser = loginUser.getUser();
|
||||
// 获取微信用户基本信息
|
||||
logger.info("更新用户信息,openid={}",openid);
|
||||
wxMpService.switchover(appid);
|
||||
WxMpUser userWxInfo = wxMpService.getUserService().userInfo(openid, null);
|
||||
if (userWxInfo == null) {
|
||||
logger.error("获取不到用户信息,无法更新,openid:{}",openid);
|
||||
return ;
|
||||
}
|
||||
CzsjMemberWxFans fans = new CzsjMemberWxFans();
|
||||
fans.setOpenId(openid);
|
||||
List<CzsjMemberWxFans> czsjMemberWxFans = czsjMemberWxFansMapper.selectCzsjMemberWxFansList(fans);
|
||||
fans.setAppId(appid);
|
||||
fans.setCreateUserId(currentUser.getUserId());
|
||||
fans.setUpdateUserId(currentUser.getUserId());
|
||||
fans.setUpdateTime(new Date());
|
||||
fans.setName(userWxInfo.getNickname());
|
||||
fans.setImageUrl(userWxInfo.getHeadImgUrl());
|
||||
fans.setSubscribeStatus(0);
|
||||
fans.setRemark(userWxInfo.getRemark());
|
||||
if (!czsjMemberWxFans.isEmpty()){
|
||||
czsjMemberWxFansMapper.updateCzsjMemberWxFans(fans);
|
||||
}else {
|
||||
fans.setCreateTime(new Date());
|
||||
czsjMemberWxFansMapper.insertCzsjMemberWxFans(fans);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("更新用户信息失败,openid:{}",openid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询会员微信粉丝
|
||||
|
@ -0,0 +1,52 @@
|
||||
package com.czsj.wechat.config;
|
||||
|
||||
import com.czsj.wechat.listener.WxAccountChangedMessageListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.listener.ChannelTopic;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* @Auther: cheng.tang
|
||||
* @Date: 2023/11/11
|
||||
* @Description: wx-api
|
||||
*/
|
||||
@Configuration
|
||||
public class EventMessageListenerContainerConfig {
|
||||
|
||||
public static final String WX_ACCOUNT_UPDATE = "event_wx_accounts_changed";
|
||||
|
||||
@Autowired
|
||||
private WxAccountChangedMessageListener wxAccountChangedMessageListener;
|
||||
|
||||
@Bean
|
||||
public TaskExecutor taskExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(2);
|
||||
executor.setMaxPoolSize(50);
|
||||
executor.setQueueCapacity(100);
|
||||
executor.setKeepAliveSeconds(600);
|
||||
executor.setThreadNamePrefix("rEvent-");
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
return executor;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory redisConnectionFactory,
|
||||
@Qualifier("taskExecutor")ThreadPoolTaskExecutor threadPoolTaskExecutor) {
|
||||
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||
container.setConnectionFactory(redisConnectionFactory);
|
||||
container.setTaskExecutor(threadPoolTaskExecutor);
|
||||
container.addMessageListener(wxAccountChangedMessageListener, new ChannelTopic(WX_ACCOUNT_UPDATE));
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.czsj.wechat.config;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* 系统线程池,系统各种任务使用同一个线程池,以防止创建过多线程池
|
||||
*/
|
||||
public class TaskExcutor {
|
||||
private TaskExcutor(){}
|
||||
|
||||
/**
|
||||
* 使用静态内部类实现单例懒加载
|
||||
*/
|
||||
private static class ExcutorHolder{
|
||||
/**
|
||||
* 线程池
|
||||
* corePoolSize=5 核心线程数
|
||||
* maximumPoolSize=30 最大线程数
|
||||
* keepAliveTime=10,unit=TimeUnit.SECOND 线程最大空闲时间为10秒
|
||||
* workQueue=new SynchronousQueue<Runnable>() 链表队列
|
||||
* handler=new ThreadPoolExecutor.CallerRunsPolicy()
|
||||
*/
|
||||
private static final ExecutorService EXCUTOR = new ThreadPoolExecutor(
|
||||
5,30,60L, TimeUnit.SECONDS,
|
||||
new SynchronousQueue<Runnable>(),
|
||||
new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
}
|
||||
/**
|
||||
* 使用静态内部类实现单例懒加载
|
||||
*/
|
||||
private static class SchedulerHolder{
|
||||
private static final ScheduledExecutorService SCHEDULER =
|
||||
Executors.newScheduledThreadPool(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将任务提交到系统线程池中执行
|
||||
* 1.如果线程数未达核心线程,创建核心线程
|
||||
* 2.已达核心线程数,添加到任务队列
|
||||
* 3.核心线程已满、队列已满,创建新空闲线程
|
||||
* 4.核心线程已满、队列已满、无法创建新空闲线程,执行拒绝策略
|
||||
* 本工具类拒绝策略使用内置ThreadPoolExecutor.CallerRunsPolicy,即让添加任务的主线程来执行任务,这样主线程被占用无法继续添加任务,相当于线程池全满后添加任务的线程会被阻塞
|
||||
* @param task
|
||||
* @return
|
||||
*/
|
||||
public static Future<?> submit(Runnable task){
|
||||
return ExcutorHolder.EXCUTOR.submit(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将定时任务添加到系统线程池
|
||||
* @param task
|
||||
* @param delay
|
||||
* @param unit
|
||||
* @return
|
||||
*/
|
||||
public static ScheduledFuture<?> schedule(Runnable task,long delay, TimeUnit unit){
|
||||
return SchedulerHolder.SCHEDULER.schedule(task,delay,unit);
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.czsj.wechat.config;
|
||||
|
||||
import com.czsj.wechat.handler.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static me.chanjar.weixin.common.api.WxConsts.EventType;
|
||||
import static me.chanjar.weixin.common.api.WxConsts.EventType.*;
|
||||
import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType.EVENT;
|
||||
import static me.chanjar.weixin.mp.constant.WxMpEventConstants.CustomerService.KF_CREATE_SESSION;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Configuration
|
||||
public class WxMpMessageRouterConfiguration {
|
||||
private final LogHandler logHandler;
|
||||
private final NullHandler nullHandler;
|
||||
private final KfSessionHandler kfSessionHandler;
|
||||
private final MenuHandler menuHandler;
|
||||
private final MsgHandler msgHandler;
|
||||
private final ScanHandler scanHandler;
|
||||
private final UnsubscribeHandler unsubscribeHandler;
|
||||
private final SubscribeHandler subscribeHandler;
|
||||
|
||||
@Bean
|
||||
public WxMpMessageRouter messageRouter(WxMpService wxMpService) {
|
||||
final WxMpMessageRouter newRouter = new WxMpMessageRouter(wxMpService);
|
||||
|
||||
// 记录所有事件的日志
|
||||
newRouter.rule().async(false).handler(this.logHandler).next();
|
||||
|
||||
// 接收客服会话管理事件
|
||||
newRouter.rule().async(false).msgType(EVENT).event(KF_CREATE_SESSION).handler(this.kfSessionHandler).end();
|
||||
// 自定义菜单事件
|
||||
newRouter.rule().async(false).msgType(EVENT).event(EventType.CLICK).handler(this.menuHandler).end();
|
||||
// 关注事件
|
||||
newRouter.rule().async(false).msgType(EVENT).event(SUBSCRIBE).handler(this.subscribeHandler).end();
|
||||
// 取消关注事件
|
||||
newRouter.rule().async(false).msgType(EVENT).event(UNSUBSCRIBE).handler(this.unsubscribeHandler).end();
|
||||
//扫描带参二维码事件
|
||||
newRouter.rule().async(false).msgType(EVENT).event(SCAN).handler(this.scanHandler).end();
|
||||
//其他事件
|
||||
newRouter.rule().async(false).msgType(EVENT).handler(this.nullHandler).end();
|
||||
|
||||
// 默认
|
||||
newRouter.rule().async(false).handler(this.msgHandler).end();
|
||||
|
||||
return newRouter;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.czsj.wechat.config;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps;
|
||||
import me.chanjar.weixin.common.redis.WxRedisOps;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Configuration
|
||||
public class WxMpServiceConfiguration {
|
||||
|
||||
@Bean
|
||||
public WxMpService wxMpService() {
|
||||
WxMpService wxMpService = new WxMpServiceImpl();
|
||||
wxMpService.setMaxRetryTimes(3);
|
||||
return wxMpService;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WxRedisOps wxRedisOps(StringRedisTemplate stringRedisTemplate) {
|
||||
return new RedisTemplateWxRedisOps(stringRedisTemplate);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
package com.czsj.wechat.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.czsj.common.annotation.Excel;
|
||||
import com.czsj.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 微信公众号对象 czsj_wx_account
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public class CzsjWxAccount extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 微信公众号ID */
|
||||
private Long uid;
|
||||
|
||||
/** 公众号appID */
|
||||
@Excel(name = "公众号appID")
|
||||
private String appId;
|
||||
|
||||
/** 公众号名称 */
|
||||
@Excel(name = "公众号名称")
|
||||
private String name;
|
||||
|
||||
/** 认证状态 */
|
||||
@Excel(name = "认证状态")
|
||||
private Integer verified;
|
||||
|
||||
/** 公众号secret */
|
||||
@Excel(name = "公众号secret")
|
||||
private String secret;
|
||||
|
||||
/** 公众号aesKey */
|
||||
@Excel(name = "公众号aesKey")
|
||||
private String aesKey;
|
||||
|
||||
/** 公众号token */
|
||||
@Excel(name = "公众号token")
|
||||
private String token;
|
||||
|
||||
/** 有效标识,0有效,1无效 */
|
||||
private Integer delFlag;
|
||||
|
||||
/** 创建人ID */
|
||||
@Excel(name = "创建人ID")
|
||||
private Long createUserId;
|
||||
|
||||
/** 修改人ID */
|
||||
@Excel(name = "修改人ID")
|
||||
private Long updateUserId;
|
||||
|
||||
public void setUid(Long uid)
|
||||
{
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public Long getUid()
|
||||
{
|
||||
return uid;
|
||||
}
|
||||
public void setAppId(String appId)
|
||||
{
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppId()
|
||||
{
|
||||
return appId;
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public void setVerified(Integer verified)
|
||||
{
|
||||
this.verified = verified;
|
||||
}
|
||||
|
||||
public Integer getVerified()
|
||||
{
|
||||
return verified;
|
||||
}
|
||||
public void setSecret(String secret)
|
||||
{
|
||||
this.secret = secret;
|
||||
}
|
||||
|
||||
public String getSecret()
|
||||
{
|
||||
return secret;
|
||||
}
|
||||
public void setAesKey(String aesKey)
|
||||
{
|
||||
this.aesKey = aesKey;
|
||||
}
|
||||
|
||||
public String getAesKey()
|
||||
{
|
||||
return aesKey;
|
||||
}
|
||||
public void setToken(String token)
|
||||
{
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getToken()
|
||||
{
|
||||
return token;
|
||||
}
|
||||
public void setDelFlag(Integer delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Integer getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
public void setCreateUserId(Long createUserId)
|
||||
{
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
public Long getCreateUserId()
|
||||
{
|
||||
return createUserId;
|
||||
}
|
||||
public void setUpdateUserId(Long updateUserId)
|
||||
{
|
||||
this.updateUserId = updateUserId;
|
||||
}
|
||||
|
||||
public Long getUpdateUserId()
|
||||
{
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("uid", getUid())
|
||||
.append("appId", getAppId())
|
||||
.append("name", getName())
|
||||
.append("verified", getVerified())
|
||||
.append("secret", getSecret())
|
||||
.append("aesKey", getAesKey())
|
||||
.append("token", getToken())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createUserId", getCreateUserId())
|
||||
.append("updateUserId", getUpdateUserId())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
package com.czsj.wechat.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.czsj.common.annotation.Excel;
|
||||
import com.czsj.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 微信消息对象 czsj_wx_message
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public class CzsjWxMessage extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 微信消息ID */
|
||||
private Long uid;
|
||||
|
||||
/** 公众号appID */
|
||||
@Excel(name = "公众号appID")
|
||||
private String appId;
|
||||
|
||||
/** 微信openID */
|
||||
@Excel(name = "微信openID")
|
||||
private String openId;
|
||||
|
||||
/** 消息方向 */
|
||||
@Excel(name = "消息方向")
|
||||
private Long inOut;
|
||||
|
||||
/** 消息类型 */
|
||||
@Excel(name = "消息类型")
|
||||
private String msgType;
|
||||
|
||||
/** 消息详情 */
|
||||
@Excel(name = "消息详情")
|
||||
private String detail;
|
||||
|
||||
/** 有效标识,0有效,1无效 */
|
||||
private Integer delFlag;
|
||||
|
||||
/** 创建人ID */
|
||||
@Excel(name = "创建人ID")
|
||||
private Long createUserId;
|
||||
|
||||
/** 修改人ID */
|
||||
@Excel(name = "修改人ID")
|
||||
private Long updateUserId;
|
||||
|
||||
public void setUid(Long uid)
|
||||
{
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public Long getUid()
|
||||
{
|
||||
return uid;
|
||||
}
|
||||
public void setAppId(String appId)
|
||||
{
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppId()
|
||||
{
|
||||
return appId;
|
||||
}
|
||||
public void setOpenId(String openId)
|
||||
{
|
||||
this.openId = openId;
|
||||
}
|
||||
|
||||
public String getOpenId()
|
||||
{
|
||||
return openId;
|
||||
}
|
||||
public void setInOut(Long inOut)
|
||||
{
|
||||
this.inOut = inOut;
|
||||
}
|
||||
|
||||
public Long getInOut()
|
||||
{
|
||||
return inOut;
|
||||
}
|
||||
public void setMsgType(String msgType)
|
||||
{
|
||||
this.msgType = msgType;
|
||||
}
|
||||
|
||||
public String getMsgType()
|
||||
{
|
||||
return msgType;
|
||||
}
|
||||
public void setDetail(String detail)
|
||||
{
|
||||
this.detail = detail;
|
||||
}
|
||||
|
||||
public String getDetail()
|
||||
{
|
||||
return detail;
|
||||
}
|
||||
public void setDelFlag(Integer delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Integer getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
public void setCreateUserId(Long createUserId)
|
||||
{
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
public Long getCreateUserId()
|
||||
{
|
||||
return createUserId;
|
||||
}
|
||||
public void setUpdateUserId(Long updateUserId)
|
||||
{
|
||||
this.updateUserId = updateUserId;
|
||||
}
|
||||
|
||||
public Long getUpdateUserId()
|
||||
{
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("uid", getUid())
|
||||
.append("appId", getAppId())
|
||||
.append("openId", getOpenId())
|
||||
.append("inOut", getInOut())
|
||||
.append("msgType", getMsgType())
|
||||
.append("detail", getDetail())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createUserId", getCreateUserId())
|
||||
.append("updateUserId", getUpdateUserId())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,167 @@
|
||||
package com.czsj.wechat.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.czsj.common.annotation.Excel;
|
||||
import com.czsj.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 公众号二维码对象 czsj_wx_qr_code
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public class CzsjWxQrCode extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 公众号二维码ID */
|
||||
private Long uid;
|
||||
|
||||
/** 公众号appID */
|
||||
@Excel(name = "公众号appID")
|
||||
private String appId;
|
||||
|
||||
/** 二维码类型 */
|
||||
@Excel(name = "二维码类型")
|
||||
private Integer isTemp;
|
||||
|
||||
/** 场景值ID */
|
||||
@Excel(name = "场景值ID")
|
||||
private String sceneStr;
|
||||
|
||||
/** 二维码ticket */
|
||||
@Excel(name = "二维码ticket")
|
||||
private String ticket;
|
||||
|
||||
/** 二维码图片解析地址 */
|
||||
@Excel(name = "二维码图片解析地址")
|
||||
private String imageUrl;
|
||||
|
||||
/** 该二维码失效时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "该二维码失效时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date expireTime;
|
||||
|
||||
/** 有效标识,0有效,1无效 */
|
||||
private Integer delFlag;
|
||||
|
||||
/** 创建人ID */
|
||||
@Excel(name = "创建人ID")
|
||||
private Long createUserId;
|
||||
|
||||
/** 修改人ID */
|
||||
@Excel(name = "修改人ID")
|
||||
private Long updateUserId;
|
||||
|
||||
public void setUid(Long uid)
|
||||
{
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public Long getUid()
|
||||
{
|
||||
return uid;
|
||||
}
|
||||
public void setAppId(String appId)
|
||||
{
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppId()
|
||||
{
|
||||
return appId;
|
||||
}
|
||||
public void setIsTemp(Integer isTemp)
|
||||
{
|
||||
this.isTemp = isTemp;
|
||||
}
|
||||
|
||||
public Integer getIsTemp()
|
||||
{
|
||||
return isTemp;
|
||||
}
|
||||
public void setSceneStr(String sceneStr)
|
||||
{
|
||||
this.sceneStr = sceneStr;
|
||||
}
|
||||
|
||||
public String getSceneStr()
|
||||
{
|
||||
return sceneStr;
|
||||
}
|
||||
public void setTicket(String ticket)
|
||||
{
|
||||
this.ticket = ticket;
|
||||
}
|
||||
|
||||
public String getTicket()
|
||||
{
|
||||
return ticket;
|
||||
}
|
||||
public void setImageUrl(String imageUrl)
|
||||
{
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public String getImageUrl()
|
||||
{
|
||||
return imageUrl;
|
||||
}
|
||||
public void setExpireTime(Date expireTime)
|
||||
{
|
||||
this.expireTime = expireTime;
|
||||
}
|
||||
|
||||
public Date getExpireTime()
|
||||
{
|
||||
return expireTime;
|
||||
}
|
||||
public void setDelFlag(Integer delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Integer getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
public void setCreateUserId(Long createUserId)
|
||||
{
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
public Long getCreateUserId()
|
||||
{
|
||||
return createUserId;
|
||||
}
|
||||
public void setUpdateUserId(Long updateUserId)
|
||||
{
|
||||
this.updateUserId = updateUserId;
|
||||
}
|
||||
|
||||
public Long getUpdateUserId()
|
||||
{
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("uid", getUid())
|
||||
.append("appId", getAppId())
|
||||
.append("isTemp", getIsTemp())
|
||||
.append("sceneStr", getSceneStr())
|
||||
.append("ticket", getTicket())
|
||||
.append("imageUrl", getImageUrl())
|
||||
.append("expireTime", getExpireTime())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createUserId", getCreateUserId())
|
||||
.append("updateUserId", getUpdateUserId())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,196 @@
|
||||
package com.czsj.wechat.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.czsj.common.annotation.Excel;
|
||||
import com.czsj.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 微信消息回复规则对象 czsj_wx_reply_rule
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public class CzsjWxReplyRule extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 回复规则ID */
|
||||
private Long uid;
|
||||
|
||||
/** 公众号appID */
|
||||
@Excel(name = "公众号appID")
|
||||
private String appId;
|
||||
|
||||
/** 规则名称 */
|
||||
@Excel(name = "规则名称")
|
||||
private String ruleName;
|
||||
|
||||
/** 匹配关键词 */
|
||||
@Excel(name = "匹配关键词")
|
||||
private String matchValue;
|
||||
|
||||
/** 是否精确匹配 */
|
||||
@Excel(name = "是否精确匹配")
|
||||
private Integer exactMatch;
|
||||
|
||||
/** 回复类型 */
|
||||
@Excel(name = "回复类型")
|
||||
private String replyType;
|
||||
|
||||
/** 回复内容 */
|
||||
@Excel(name = "回复内容")
|
||||
private String replyContent;
|
||||
|
||||
/** 开始时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date startTime;
|
||||
|
||||
/** 结束时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date endTime;
|
||||
|
||||
/** 有效标识,0有效,1无效 */
|
||||
private Integer delFlag;
|
||||
|
||||
/** 创建人ID */
|
||||
@Excel(name = "创建人ID")
|
||||
private Long createUserId;
|
||||
|
||||
/** 修改人ID */
|
||||
@Excel(name = "修改人ID")
|
||||
private Long updateUserId;
|
||||
|
||||
public void setUid(Long uid)
|
||||
{
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public Long getUid()
|
||||
{
|
||||
return uid;
|
||||
}
|
||||
public void setAppId(String appId)
|
||||
{
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppId()
|
||||
{
|
||||
return appId;
|
||||
}
|
||||
public void setRuleName(String ruleName)
|
||||
{
|
||||
this.ruleName = ruleName;
|
||||
}
|
||||
|
||||
public String getRuleName()
|
||||
{
|
||||
return ruleName;
|
||||
}
|
||||
public void setMatchValue(String matchValue)
|
||||
{
|
||||
this.matchValue = matchValue;
|
||||
}
|
||||
|
||||
public String getMatchValue()
|
||||
{
|
||||
return matchValue;
|
||||
}
|
||||
public void setExactMatch(Integer exactMatch)
|
||||
{
|
||||
this.exactMatch = exactMatch;
|
||||
}
|
||||
|
||||
public Integer getExactMatch()
|
||||
{
|
||||
return exactMatch;
|
||||
}
|
||||
public void setReplyType(String replyType)
|
||||
{
|
||||
this.replyType = replyType;
|
||||
}
|
||||
|
||||
public String getReplyType()
|
||||
{
|
||||
return replyType;
|
||||
}
|
||||
public void setReplyContent(String replyContent)
|
||||
{
|
||||
this.replyContent = replyContent;
|
||||
}
|
||||
|
||||
public String getReplyContent()
|
||||
{
|
||||
return replyContent;
|
||||
}
|
||||
public void setStartTime(Date startTime)
|
||||
{
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Date getStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
public void setEndTime(Date endTime)
|
||||
{
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public Date getEndTime()
|
||||
{
|
||||
return endTime;
|
||||
}
|
||||
public void setDelFlag(Integer delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Integer getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
public void setCreateUserId(Long createUserId)
|
||||
{
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
public Long getCreateUserId()
|
||||
{
|
||||
return createUserId;
|
||||
}
|
||||
public void setUpdateUserId(Long updateUserId)
|
||||
{
|
||||
this.updateUserId = updateUserId;
|
||||
}
|
||||
|
||||
public Long getUpdateUserId()
|
||||
{
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("uid", getUid())
|
||||
.append("appId", getAppId())
|
||||
.append("ruleName", getRuleName())
|
||||
.append("matchValue", getMatchValue())
|
||||
.append("exactMatch", getExactMatch())
|
||||
.append("replyType", getReplyType())
|
||||
.append("replyContent", getReplyContent())
|
||||
.append("startTime", getStartTime())
|
||||
.append("endTime", getEndTime())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createUserId", getCreateUserId())
|
||||
.append("updateUserId", getUpdateUserId())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,178 @@
|
||||
package com.czsj.wechat.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.czsj.common.annotation.Excel;
|
||||
import com.czsj.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 微信消息模板对象 czsj_wx_template
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public class CzsjWxTemplate extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 消息模板ID */
|
||||
private Long uid;
|
||||
|
||||
/** 公众号ID */
|
||||
@Excel(name = "公众号ID")
|
||||
private String appId;
|
||||
|
||||
/** 模板ID */
|
||||
@Excel(name = "模板ID")
|
||||
private String templateId;
|
||||
|
||||
/** 模板标题 */
|
||||
@Excel(name = "模板标题")
|
||||
private String title;
|
||||
|
||||
/** 主行业分类 */
|
||||
@Excel(name = "主行业分类")
|
||||
private String primaryIndustry;
|
||||
|
||||
/** 副行业分类 */
|
||||
@Excel(name = "副行业分类")
|
||||
private String deputyIndustry;
|
||||
|
||||
/** 内容 */
|
||||
@Excel(name = "内容")
|
||||
private String content;
|
||||
|
||||
/** 示例 */
|
||||
@Excel(name = "示例")
|
||||
private String example;
|
||||
|
||||
/** 有效标识,0有效,1无效 */
|
||||
private Integer delFlag;
|
||||
|
||||
/** 创建人ID */
|
||||
@Excel(name = "创建人ID")
|
||||
private Long createUserId;
|
||||
|
||||
/** 修改人ID */
|
||||
@Excel(name = "修改人ID")
|
||||
private Long updateUserId;
|
||||
|
||||
public void setUid(Long uid)
|
||||
{
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public Long getUid()
|
||||
{
|
||||
return uid;
|
||||
}
|
||||
public void setAppId(String appId)
|
||||
{
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppId()
|
||||
{
|
||||
return appId;
|
||||
}
|
||||
public void setTemplateId(String templateId)
|
||||
{
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public String getTemplateId()
|
||||
{
|
||||
return templateId;
|
||||
}
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
public void setPrimaryIndustry(String primaryIndustry)
|
||||
{
|
||||
this.primaryIndustry = primaryIndustry;
|
||||
}
|
||||
|
||||
public String getPrimaryIndustry()
|
||||
{
|
||||
return primaryIndustry;
|
||||
}
|
||||
public void setDeputyIndustry(String deputyIndustry)
|
||||
{
|
||||
this.deputyIndustry = deputyIndustry;
|
||||
}
|
||||
|
||||
public String getDeputyIndustry()
|
||||
{
|
||||
return deputyIndustry;
|
||||
}
|
||||
public void setContent(String content)
|
||||
{
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContent()
|
||||
{
|
||||
return content;
|
||||
}
|
||||
public void setExample(String example)
|
||||
{
|
||||
this.example = example;
|
||||
}
|
||||
|
||||
public String getExample()
|
||||
{
|
||||
return example;
|
||||
}
|
||||
public void setDelFlag(Integer delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Integer getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
public void setCreateUserId(Long createUserId)
|
||||
{
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
public Long getCreateUserId()
|
||||
{
|
||||
return createUserId;
|
||||
}
|
||||
public void setUpdateUserId(Long updateUserId)
|
||||
{
|
||||
this.updateUserId = updateUserId;
|
||||
}
|
||||
|
||||
public Long getUpdateUserId()
|
||||
{
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("uid", getUid())
|
||||
.append("appId", getAppId())
|
||||
.append("templateId", getTemplateId())
|
||||
.append("title", getTitle())
|
||||
.append("primaryIndustry", getPrimaryIndustry())
|
||||
.append("deputyIndustry", getDeputyIndustry())
|
||||
.append("content", getContent())
|
||||
.append("example", getExample())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createUserId", getCreateUserId())
|
||||
.append("updateUserId", getUpdateUserId())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,178 @@
|
||||
package com.czsj.wechat.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.czsj.common.annotation.Excel;
|
||||
import com.czsj.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 微信消息模板日志对象 czsj_wx_template_log
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public class CzsjWxTemplateLog extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 消息模板日志ID */
|
||||
private Long uid;
|
||||
|
||||
/** 公众号ID */
|
||||
@Excel(name = "公众号ID")
|
||||
private String appId;
|
||||
|
||||
/** 接收者OpenID */
|
||||
@Excel(name = "接收者OpenID")
|
||||
private String toUser;
|
||||
|
||||
/** 模板ID */
|
||||
@Excel(name = "模板ID")
|
||||
private Long templateUid;
|
||||
|
||||
/** 消息体 */
|
||||
@Excel(name = "消息体")
|
||||
private String data;
|
||||
|
||||
/** URL链接 */
|
||||
@Excel(name = "URL链接")
|
||||
private String url;
|
||||
|
||||
/** 跳转的小程序 */
|
||||
@Excel(name = "跳转的小程序")
|
||||
private String miniProgram;
|
||||
|
||||
/** 发送结果 */
|
||||
@Excel(name = "发送结果")
|
||||
private String sendResult;
|
||||
|
||||
/** 有效标识,0有效,1无效 */
|
||||
private Integer delFlag;
|
||||
|
||||
/** 创建人ID */
|
||||
@Excel(name = "创建人ID")
|
||||
private Long createUserId;
|
||||
|
||||
/** 修改人ID */
|
||||
@Excel(name = "修改人ID")
|
||||
private Long updateUserId;
|
||||
|
||||
public void setUid(Long uid)
|
||||
{
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public Long getUid()
|
||||
{
|
||||
return uid;
|
||||
}
|
||||
public void setAppId(String appId)
|
||||
{
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppId()
|
||||
{
|
||||
return appId;
|
||||
}
|
||||
public void setToUser(String toUser)
|
||||
{
|
||||
this.toUser = toUser;
|
||||
}
|
||||
|
||||
public String getToUser()
|
||||
{
|
||||
return toUser;
|
||||
}
|
||||
public void setTemplateUid(Long templateUid)
|
||||
{
|
||||
this.templateUid = templateUid;
|
||||
}
|
||||
|
||||
public Long getTemplateUid()
|
||||
{
|
||||
return templateUid;
|
||||
}
|
||||
public void setData(String data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getData()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
public void setUrl(String url)
|
||||
{
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUrl()
|
||||
{
|
||||
return url;
|
||||
}
|
||||
public void setMiniProgram(String miniProgram)
|
||||
{
|
||||
this.miniProgram = miniProgram;
|
||||
}
|
||||
|
||||
public String getMiniProgram()
|
||||
{
|
||||
return miniProgram;
|
||||
}
|
||||
public void setSendResult(String sendResult)
|
||||
{
|
||||
this.sendResult = sendResult;
|
||||
}
|
||||
|
||||
public String getSendResult()
|
||||
{
|
||||
return sendResult;
|
||||
}
|
||||
public void setDelFlag(Integer delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Integer getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
public void setCreateUserId(Long createUserId)
|
||||
{
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
public Long getCreateUserId()
|
||||
{
|
||||
return createUserId;
|
||||
}
|
||||
public void setUpdateUserId(Long updateUserId)
|
||||
{
|
||||
this.updateUserId = updateUserId;
|
||||
}
|
||||
|
||||
public Long getUpdateUserId()
|
||||
{
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("uid", getUid())
|
||||
.append("appId", getAppId())
|
||||
.append("toUser", getToUser())
|
||||
.append("templateUid", getTemplateUid())
|
||||
.append("data", getData())
|
||||
.append("url", getUrl())
|
||||
.append("miniProgram", getMiniProgram())
|
||||
.append("sendResult", getSendResult())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createUserId", getCreateUserId())
|
||||
.append("updateUserId", getUpdateUserId())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.czsj.wechat.dto;
|
||||
|
||||
public class PageSizeConstant {
|
||||
/**
|
||||
* 默认分页大小
|
||||
*/
|
||||
public static final int PAGE_SIZE_SMALL = 20;
|
||||
public static final int PAGE_SIZE_MEDIUM = 50;
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.czsj.wechat.dto;
|
||||
|
||||
/**
|
||||
* 常用正则表达式
|
||||
*/
|
||||
public class RegexConstant {
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
public static final String PHONE_NUM = "1\\d{10}";
|
||||
/**
|
||||
* 六位数字
|
||||
*/
|
||||
public static final String SIX_NUMBER = "\\d{6}";
|
||||
/**
|
||||
* 六位字符
|
||||
*/
|
||||
public static final String SIX_CHAR = ".{6}";
|
||||
/**
|
||||
* 图片文件名
|
||||
*/
|
||||
public static final String IMAGE_FILE_NAME = ".*\\.(jpg|JPG|jpeg|JPEG|gif|GIF|png|PNG)$";
|
||||
/**
|
||||
* SQL注入常用字符
|
||||
*/
|
||||
public static final String SQL_INJECTION_WORDS = ".*([';]+|(--)+).*";
|
||||
/**
|
||||
* 逗号分割的数字列表
|
||||
*/
|
||||
public static final String NUMBER_ARRAY = "^\\d+(,\\d+)*$";
|
||||
/**
|
||||
* 时间戳,毫秒标识的时间格式
|
||||
*/
|
||||
public static final String TIME_MILLIS = "^[0-9]{10,}$";
|
||||
/**
|
||||
* 日期字符串格式,如 2018-01-01
|
||||
*/
|
||||
public static final String DATE_STRING = "^\\d{2}-\\d{2}-\\d{2}$";
|
||||
/**
|
||||
* 时间字符串格式,如 12:00:00
|
||||
*/
|
||||
public static final String TIME_STRING = "^\\d{2}:\\d{2}:\\d{2}$";
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.czsj.wechat.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.czsj.wechat.utils.Json;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* cms文章
|
||||
*/
|
||||
@Data
|
||||
@TableName("cms_article")
|
||||
public class Article implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
private int type;
|
||||
@TableField(insertStrategy = FieldStrategy.IGNORED)//title重复则不插入
|
||||
@NotEmpty(message = "标题不得为空")
|
||||
private String title;
|
||||
private String tags;
|
||||
private String summary;
|
||||
private String content;
|
||||
private String category;
|
||||
private String subCategory;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
private int openCount;
|
||||
private String targetLink;
|
||||
private String image;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Json.toJsonString(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.czsj.wechat.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.czsj.wechat.utils.Json;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Time;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 自动回复规则
|
||||
* @author Nifury
|
||||
* @date 2017-11-1
|
||||
*/
|
||||
@Data
|
||||
@TableName("wx_msg_reply_rule")
|
||||
public class MsgReplyRule implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long ruleId;
|
||||
private String appid;
|
||||
@NotEmpty(message = "规则名称不得为空")
|
||||
private String ruleName;
|
||||
@NotEmpty(message = "匹配关键词不得为空")
|
||||
private String matchValue;
|
||||
private boolean exactMatch;
|
||||
private String replyType;
|
||||
@NotEmpty(message = "回复内容不得为空")
|
||||
private String replyContent;
|
||||
@TableField(value = "`status`")
|
||||
private boolean status;
|
||||
@TableField(value = "`desc`")
|
||||
private String desc;
|
||||
private Time effectTimeStart;
|
||||
private Time effectTimeEnd;
|
||||
private int priority;
|
||||
private Date updateTime;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Json.toJsonString(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.czsj.wechat.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.czsj.wechat.utils.Json;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 模板消息模板
|
||||
* @author Nifury
|
||||
* @date 2017-9-27
|
||||
*/
|
||||
@Data
|
||||
@TableName("wx_msg_template")
|
||||
public class MsgTemplate implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
private String appid;
|
||||
private String templateId;
|
||||
@TableField(value = "`name`")
|
||||
private String name;
|
||||
private String title;
|
||||
private String content;
|
||||
private JSONArray data;
|
||||
private String url;
|
||||
private JSONObject miniprogram;
|
||||
@TableField(value = "`status`")
|
||||
private boolean status;
|
||||
private Date updateTime;
|
||||
public MsgTemplate() {
|
||||
|
||||
}
|
||||
public MsgTemplate(WxMpTemplate mpTemplate,String appid) {
|
||||
this.appid = appid;
|
||||
this.templateId=mpTemplate.getTemplateId();
|
||||
this.title=mpTemplate.getTitle();
|
||||
this.name=mpTemplate.getTemplateId();
|
||||
this.content = mpTemplate.getContent();
|
||||
this.status=true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Json.toJsonString(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.czsj.wechat.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.czsj.wechat.utils.Json;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 模板消息日志
|
||||
* @author Nifury
|
||||
* @date 2017-9-27
|
||||
*/
|
||||
@Data
|
||||
@TableName("wx_template_msg_log")
|
||||
public class TemplateMsgLog implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long logId;
|
||||
private String appid;
|
||||
private String touser;
|
||||
private String templateId;
|
||||
private JSONArray data;
|
||||
private String url;
|
||||
private JSONObject miniprogram;
|
||||
private Date sendTime;
|
||||
private String sendResult;
|
||||
|
||||
public TemplateMsgLog() {
|
||||
}
|
||||
|
||||
public TemplateMsgLog(WxMpTemplateMessage msg,String appid, String sendResult) {
|
||||
this.appid = appid;
|
||||
this.touser = msg.getToUser();
|
||||
this.templateId = msg.getTemplateId();
|
||||
this.url = msg.getUrl();
|
||||
this.miniprogram = JSONObject.parseObject(JSON.toJSONString(msg.getMiniProgram()));
|
||||
this.data = JSONArray.parseArray(JSON.toJSONString(msg.getData()));
|
||||
this.sendTime = new Date();
|
||||
this.sendResult = sendResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Json.toJsonString(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.czsj.wechat.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 公众号账号
|
||||
*
|
||||
* @author niefy
|
||||
* @date 2020-06-17 13:56:51
|
||||
*/
|
||||
@Data
|
||||
@TableName("wx_account")
|
||||
public class WxAccount implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
@NotEmpty(message = "appid不得为空")
|
||||
private String appid;
|
||||
/**
|
||||
* 公众号名称
|
||||
*/
|
||||
@NotEmpty(message = "名称不得为空")
|
||||
private String name;
|
||||
/**
|
||||
* 账号类型
|
||||
*/
|
||||
private int type;
|
||||
/**
|
||||
* 认证状态
|
||||
*/
|
||||
private boolean verified;
|
||||
/**
|
||||
* appsecret
|
||||
*/
|
||||
@NotEmpty(message = "appSecret不得为空")
|
||||
private String secret;
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
private String token;
|
||||
/**
|
||||
* aesKey
|
||||
*/
|
||||
private String aesKey;
|
||||
|
||||
public WxMpDefaultConfigImpl toWxMpConfigStorage(){
|
||||
WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
|
||||
configStorage.setAppId(appid);
|
||||
configStorage.setSecret(secret);
|
||||
configStorage.setToken(token);
|
||||
configStorage.setAesKey(aesKey);
|
||||
return configStorage;
|
||||
}
|
||||
|
||||
}
|
103
czsj-system/src/main/java/com/czsj/wechat/entity/WxMsg.java
Normal file
103
czsj-system/src/main/java/com/czsj/wechat/entity/WxMsg.java
Normal file
@ -0,0 +1,103 @@
|
||||
package com.czsj.wechat.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.util.WxMpConfigStorageHolder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 微信消息
|
||||
*
|
||||
* @author niefy
|
||||
* @date 2020-05-14 17:28:34
|
||||
*/
|
||||
@Data
|
||||
@TableName("wx_msg")
|
||||
public class WxMsg implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
private String appid;
|
||||
/**
|
||||
* 微信用户ID
|
||||
*/
|
||||
private String openid;
|
||||
/**
|
||||
* 消息方向
|
||||
*/
|
||||
private byte inOut;
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private String msgType;
|
||||
/**
|
||||
* 消息详情
|
||||
*/
|
||||
private JSONObject detail;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
public static class WxMsgInOut{
|
||||
static final byte IN=0;
|
||||
static final byte OUT=1;
|
||||
}
|
||||
|
||||
public WxMsg() {
|
||||
}
|
||||
public WxMsg(WxMpXmlMessage wxMessage) {
|
||||
this.openid=wxMessage.getFromUser();
|
||||
this.appid= WxMpConfigStorageHolder.get();
|
||||
this.inOut = WxMsgInOut.IN;
|
||||
this.msgType = wxMessage.getMsgType();
|
||||
this.detail = new JSONObject();
|
||||
Long createTime = wxMessage.getCreateTime();
|
||||
this.createTime = createTime==null?new Date():new Date(createTime*1000);
|
||||
if(WxConsts.XmlMsgType.TEXT.equals(this.msgType)){
|
||||
this.detail.put("content",wxMessage.getContent());
|
||||
}else if(WxConsts.XmlMsgType.IMAGE.equals(this.msgType)){
|
||||
this.detail.put("picUrl",wxMessage.getPicUrl());
|
||||
this.detail.put("mediaId",wxMessage.getMediaId());
|
||||
}else if(WxConsts.XmlMsgType.VOICE.equals(this.msgType)){
|
||||
this.detail.put("format",wxMessage.getFormat());
|
||||
this.detail.put("mediaId",wxMessage.getMediaId());
|
||||
}else if(WxConsts.XmlMsgType.VIDEO.equals(this.msgType) ||
|
||||
WxConsts.XmlMsgType.SHORTVIDEO.equals(this.msgType)){
|
||||
this.detail.put("thumbMediaId",wxMessage.getThumbMediaId());
|
||||
this.detail.put("mediaId",wxMessage.getMediaId());
|
||||
}else if(WxConsts.XmlMsgType.LOCATION.equals(this.msgType)){
|
||||
this.detail.put("locationX",wxMessage.getLocationX());
|
||||
this.detail.put("locationY",wxMessage.getLocationY());
|
||||
this.detail.put("scale",wxMessage.getScale());
|
||||
this.detail.put("label",wxMessage.getLabel());
|
||||
}else if(WxConsts.XmlMsgType.LINK.equals(this.msgType)){
|
||||
this.detail.put("title",wxMessage.getTitle());
|
||||
this.detail.put("description",wxMessage.getDescription());
|
||||
this.detail.put("url",wxMessage.getUrl());
|
||||
}else if(WxConsts.XmlMsgType.EVENT.equals(this.msgType)){
|
||||
this.detail.put("event",wxMessage.getEvent());
|
||||
this.detail.put("eventKey",wxMessage.getEventKey());
|
||||
}
|
||||
}
|
||||
public static WxMsg buildOutMsg(String msgType,String openid,JSONObject detail){
|
||||
WxMsg wxMsg = new WxMsg();
|
||||
wxMsg.appid= WxMpConfigStorageHolder.get();
|
||||
wxMsg.msgType = msgType;
|
||||
wxMsg.openid = openid;
|
||||
wxMsg.detail = detail;
|
||||
wxMsg.createTime=new Date();
|
||||
wxMsg.inOut = WxMsgInOut.OUT;
|
||||
return wxMsg;
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.czsj.wechat.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.czsj.wechat.form.WxQrCodeForm;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 公众号带参二维码
|
||||
*
|
||||
* @author niefy
|
||||
* @email niefy@qq.com
|
||||
* @date 2020-01-02 11:11:55
|
||||
*/
|
||||
@Data
|
||||
@TableName("wx_qr_code")
|
||||
public class WxQrCode implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
private String appid;
|
||||
/**
|
||||
* 二维码类型
|
||||
*/
|
||||
private Boolean isTemp;
|
||||
/**
|
||||
* 场景值ID
|
||||
*/
|
||||
private String sceneStr;
|
||||
/**
|
||||
* 二维码ticket
|
||||
*/
|
||||
private String ticket;
|
||||
/**
|
||||
* 二维码图片解析后的地址
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 该二维码失效时间
|
||||
*/
|
||||
private Date expireTime;
|
||||
/**
|
||||
* 该二维码创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
public WxQrCode() {
|
||||
}
|
||||
|
||||
public WxQrCode(WxQrCodeForm form,String appid) {
|
||||
this.appid = appid;
|
||||
this.isTemp = form.getIsTemp();
|
||||
this.sceneStr = form.getSceneStr();
|
||||
this.createTime = new Date();
|
||||
}
|
||||
}
|
85
czsj-system/src/main/java/com/czsj/wechat/entity/WxUser.java
Normal file
85
czsj-system/src/main/java/com/czsj/wechat/entity/WxUser.java
Normal file
@ -0,0 +1,85 @@
|
||||
package com.czsj.wechat.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.czsj.wechat.utils.Json;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 微信粉丝
|
||||
* @author Nifury
|
||||
* @date 2017-9-27
|
||||
*/
|
||||
@Data
|
||||
@TableName("wx_user")
|
||||
public class WxUser implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String openid;
|
||||
private String appid;
|
||||
private String phone;
|
||||
private String nickname;
|
||||
private int sex;
|
||||
private String city;
|
||||
private String province;
|
||||
private String headimgurl;
|
||||
@JSONField(name = "subscribe_time")
|
||||
private Date subscribeTime;
|
||||
private boolean subscribe;
|
||||
private String unionid;
|
||||
private String remark;
|
||||
private JSONArray tagidList;
|
||||
private String subscribeScene;
|
||||
private String qrSceneStr;
|
||||
|
||||
public WxUser() {
|
||||
}
|
||||
|
||||
public WxUser(String openid) {
|
||||
this.openid = openid;
|
||||
}
|
||||
|
||||
public WxUser(WxMpUser wxMpUser,String appid) {
|
||||
this.openid = wxMpUser.getOpenId();
|
||||
this.appid = appid;
|
||||
this.subscribe=wxMpUser.getSubscribe();
|
||||
if(wxMpUser.getSubscribe()){
|
||||
this.nickname = wxMpUser.getNickname();
|
||||
this.headimgurl = wxMpUser.getHeadImgUrl();
|
||||
this.subscribeTime = new Date(wxMpUser.getSubscribeTime()*1000);
|
||||
this.unionid=wxMpUser.getUnionId();
|
||||
this.remark=wxMpUser.getRemark();
|
||||
this.tagidList=JSONArray.parseArray(JSONObject.toJSONString(wxMpUser.getTagIds()));
|
||||
this.subscribeScene=wxMpUser.getSubscribeScene();
|
||||
String qrScene = wxMpUser.getQrScene();
|
||||
this.qrSceneStr= !StringUtils.hasText(qrScene) ? wxMpUser.getQrSceneStr() : qrScene;
|
||||
}
|
||||
}
|
||||
|
||||
public WxUser(WxOAuth2UserInfo wxMpUser, String appid) {
|
||||
this.openid = wxMpUser.getOpenid();
|
||||
this.appid = appid;
|
||||
this.subscribe=wxMpUser.getNickname()!=null;
|
||||
if(this.subscribe){
|
||||
this.nickname = wxMpUser.getNickname();
|
||||
this.headimgurl = wxMpUser.getHeadImgUrl();
|
||||
this.unionid=wxMpUser.getUnionId();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Json.toJsonString(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.czsj.wechat.enums;
|
||||
|
||||
/**
|
||||
* 定义文章类型
|
||||
*/
|
||||
public enum ArticleTypeEnum {
|
||||
/**
|
||||
* 普通文章
|
||||
*/
|
||||
COMMON(1),
|
||||
/**
|
||||
* 帮助中心文章
|
||||
*/
|
||||
QUESTION(5);
|
||||
/**
|
||||
* 数据库属性值
|
||||
*/
|
||||
private int value;
|
||||
|
||||
ArticleTypeEnum(int type) {
|
||||
this.value = type;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public static ArticleTypeEnum of(String name) {
|
||||
try {
|
||||
return ArticleTypeEnum.valueOf(name);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.czsj.wechat.exception;
|
||||
|
||||
/**
|
||||
* 自定义异常
|
||||
* @author Mark sunlightcs@gmail.com
|
||||
*/
|
||||
public class RRException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String msg;
|
||||
private int code = 500;
|
||||
|
||||
public RRException(String msg) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public RRException(String msg, Throwable e) {
|
||||
super(msg, e);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public RRException(String msg, int code) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public RRException(String msg, int code, Throwable e) {
|
||||
super(msg, e);
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.czsj.wechat.exception;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import com.czsj.wechat.utils.R;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.web.bind.MissingRequestCookieException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
* 异常处理器
|
||||
* @author Mark sunlightcs@gmail.com
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
public class RRExceptionHandler {
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
/**
|
||||
* 处理自定义异常
|
||||
*/
|
||||
@ExceptionHandler(RRException.class)
|
||||
public R handleRrException(RRException e) {
|
||||
R r = new R();
|
||||
r.put("code", e.getCode());
|
||||
r.put("msg", e.getMessage());
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// @ExceptionHandler(NoHandlerFoundException.class)
|
||||
// public R handlerNoFoundException(Exception e) {
|
||||
// logger.error(e.getMessage(), e);
|
||||
// return R.error(404, "路径不存在,请检查路径是否正确");
|
||||
// }
|
||||
|
||||
@ExceptionHandler(DuplicateKeyException.class)
|
||||
public R handleDuplicateKeyException(DuplicateKeyException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return R.error("数据库中已存在该记录");
|
||||
}
|
||||
|
||||
// @ExceptionHandler(AuthorizationException.class)
|
||||
// public R handleAuthorizationException(AuthorizationException e) {
|
||||
// logger.error(e.getMessage(), e);
|
||||
// return R.error("没有权限,请联系管理员授权");
|
||||
// }
|
||||
|
||||
@ExceptionHandler(MissingRequestCookieException.class)
|
||||
public R handleMissingRequestCookieException(MissingRequestCookieException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return R.error("请先添加公众号");
|
||||
}
|
||||
|
||||
@ExceptionHandler({WxErrorException.class})
|
||||
public R handleWxErrorException(WxErrorException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return R.error("微信公众平台接口错误:" + e.getError().getErrorMsg());
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public R handleException(Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return R.error();
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.czsj.wechat.form;
|
||||
|
||||
import com.czsj.wechat.utils.Json;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AccountBindForm {
|
||||
String phoneNum;
|
||||
String idCodeSuffix;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Json.toJsonString(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.czsj.wechat.form;
|
||||
|
||||
import com.czsj.wechat.utils.Json;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MaterialFileDeleteForm {
|
||||
String mediaId;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Json.toJsonString(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.czsj.wechat.form;
|
||||
|
||||
import com.czsj.wechat.utils.Json;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 批量发送模板消息表单
|
||||
* 通过用户筛选条件(一般使用标签筛选),将消息发送给数据库中所有符合筛选条件的用户
|
||||
* 若所有筛选条件都为空,则表示发送给所有用户
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class TemplateMsgBatchForm {
|
||||
@NotNull(message = "需用户筛选条件参数")
|
||||
Map<String, Object> wxUserFilterParams;
|
||||
@NotEmpty(message = "模板ID不得为空")
|
||||
private String templateId;
|
||||
private String url;
|
||||
private WxMpTemplateMessage.MiniProgram miniprogram;
|
||||
@NotEmpty(message = "消息模板数据不得为空")
|
||||
private List<WxMpTemplateData> data;
|
||||
@Override
|
||||
public String toString() {
|
||||
return Json.toJsonString(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.czsj.wechat.form;
|
||||
|
||||
import com.czsj.wechat.exception.RRException;
|
||||
import com.czsj.wechat.utils.Json;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TemplateMsgForm {
|
||||
private String openid;
|
||||
private String msg;
|
||||
private String template;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Json.toJsonString(this);
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
if (openid == null || openid.isEmpty() || msg == null || msg.isEmpty() || template == null || template.isEmpty()) {
|
||||
throw new RRException("缺少必要参数");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.czsj.wechat.form;
|
||||
|
||||
import com.czsj.wechat.utils.Json;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
@Data
|
||||
public class WxH5OuthrizeForm {
|
||||
@NotEmpty(message = "code不得为空")
|
||||
private String code;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Json.toJsonString(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.czsj.wechat.form;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@Data
|
||||
public class WxMsgReplyForm {
|
||||
@NotEmpty(message = "用户信息不得为空")
|
||||
private String openid;
|
||||
@NotEmpty(message = "回复类型不得为空")
|
||||
private String replyType;
|
||||
@NotEmpty(message = "回复内容不得为空")
|
||||
private String replyContent;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.czsj.wechat.form;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Data
|
||||
public class WxQrCodeForm {
|
||||
@NotEmpty(message = "场景值ID不得为空")
|
||||
@Size(min = 1, max = 64, message = "场景值长度限制为1到64")
|
||||
private String sceneStr;
|
||||
@Max(value = 2592000, message = "过期时间不得超过30天")
|
||||
private Integer expireSeconds;
|
||||
private Boolean isTemp = true;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.czsj.wechat.form;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
@Data
|
||||
public class WxUserBatchTaggingForm {
|
||||
@NotNull(message = "标签ID不得为空")
|
||||
private Long tagid;
|
||||
@NotNull(message = "openid列表不得为空")
|
||||
@Length(min = 1,max = 50,message = "每次处理数量1-50个")
|
||||
private String[] openidList;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.czsj.wechat.form;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Data
|
||||
public class WxUserTagForm {
|
||||
private Long id;
|
||||
@NotEmpty(message = "标签名称不得为空")
|
||||
@Size(min = 1,max = 30,message = "标签名称长度必须为1-30字符")
|
||||
private String name;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.czsj.wechat.form;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class WxUserTaggingForm {
|
||||
@NotNull(message = "标签ID不得为空")
|
||||
private Long tagid;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.czsj.wechat.handler;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Binary Wang
|
||||
*/
|
||||
public abstract class AbstractHandler implements WxMpMessageHandler {
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.czsj.wechat.handler;
|
||||
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Binary Wang
|
||||
*/
|
||||
@Component
|
||||
public class KfSessionHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
|
||||
Map<String, Object> context, WxMpService wxMpService,
|
||||
WxSessionManager sessionManager) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.czsj.wechat.handler;
|
||||
|
||||
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType;
|
||||
|
||||
/**
|
||||
* @author Binary Wang
|
||||
*/
|
||||
@Component
|
||||
public class LocationHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
|
||||
Map<String, Object> context, WxMpService wxMpService,
|
||||
WxSessionManager sessionManager) {
|
||||
if (wxMessage.getMsgType().equals(XmlMsgType.LOCATION)) {
|
||||
//TODO 接收处理用户发送的地理位置消息
|
||||
|
||||
}
|
||||
|
||||
//上报地理位置事件
|
||||
this.logger.info("\n上报地理位置 。。。 ");
|
||||
this.logger.info("\n纬度 : " + wxMessage.getLatitude());
|
||||
this.logger.info("\n经度 : " + wxMessage.getLongitude());
|
||||
this.logger.info("\n精度 : " + wxMessage.getPrecision());
|
||||
|
||||
//TODO 可以将用户地理位置信息保存到本地数据库,以便以后使用
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.czsj.wechat.handler;
|
||||
|
||||
import com.czsj.wechat.utils.Json;
|
||||
import com.czsj.wechat.entity.WxMsg;
|
||||
import com.czsj.wechat.service.WxMsgService;
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Binary Wang
|
||||
*/
|
||||
@Component
|
||||
public class LogHandler extends AbstractHandler {
|
||||
@Autowired
|
||||
WxMsgService wxMsgService;
|
||||
|
||||
@Override
|
||||
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
|
||||
Map<String, Object> context, WxMpService wxMpService,
|
||||
WxSessionManager sessionManager) {
|
||||
try {
|
||||
this.logger.debug("\n接收到请求消息,内容:{}", Json.toJsonString(wxMessage));
|
||||
wxMsgService.addWxMsg(new WxMsg(wxMessage));
|
||||
} catch (Exception e) {
|
||||
this.logger.error("记录消息异常",e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.czsj.wechat.handler;
|
||||
|
||||
import com.czsj.wechat.service.MsgReplyService;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.util.WxMpConfigStorageHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Binary Wang
|
||||
*/
|
||||
@Component
|
||||
public class MenuHandler extends AbstractHandler {
|
||||
@Autowired
|
||||
MsgReplyService msgReplyService;
|
||||
|
||||
@Override
|
||||
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
|
||||
Map<String, Object> context, WxMpService weixinService,
|
||||
WxSessionManager sessionManager) {
|
||||
if (WxConsts.EventType.VIEW.equals(wxMessage.getEvent())) {
|
||||
return null;
|
||||
}
|
||||
String appid = WxMpConfigStorageHolder.get();
|
||||
logger.info("菜单事件:" + wxMessage.getEventKey());
|
||||
msgReplyService.tryAutoReply(appid, true, wxMessage.getFromUser(), wxMessage.getEventKey());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.czsj.wechat.handler;
|
||||
|
||||
|
||||
import com.czsj.wechat.entity.WxMsg;
|
||||
import com.czsj.wechat.service.MsgReplyService;
|
||||
import com.czsj.wechat.service.WxMsgService;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.util.WxMpConfigStorageHolder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Binary Wang
|
||||
*/
|
||||
@Component
|
||||
public class MsgHandler extends AbstractHandler {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
@Autowired
|
||||
MsgReplyService msgReplyService;
|
||||
@Autowired
|
||||
WxMsgService wxMsgService;
|
||||
private static final String TRANSFER_CUSTOMER_SERVICE_KEY = "人工";
|
||||
|
||||
@Override
|
||||
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
|
||||
Map<String, Object> context, WxMpService wxMpService,
|
||||
WxSessionManager sessionManager) {
|
||||
|
||||
String textContent = wxMessage.getContent();
|
||||
String fromUser = wxMessage.getFromUser();
|
||||
String appid = WxMpConfigStorageHolder.get();
|
||||
boolean autoReplyed = msgReplyService.tryAutoReply(appid,false, fromUser, textContent);
|
||||
//当用户输入关键词如“你好”,“客服”等,并且有客服在线时,把消息转发给在线客服
|
||||
if (TRANSFER_CUSTOMER_SERVICE_KEY.equals(textContent) || !autoReplyed) {
|
||||
wxMsgService.addWxMsg(WxMsg.buildOutMsg(WxConsts.KefuMsgType.TRANSFER_CUSTOMER_SERVICE,fromUser,null));
|
||||
return WxMpXmlOutMessage
|
||||
.TRANSFER_CUSTOMER_SERVICE().fromUser(wxMessage.getToUser())
|
||||
.toUser(fromUser).build();
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.czsj.wechat.handler;
|
||||
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Binary Wang
|
||||
*/
|
||||
@Component
|
||||
public class NullHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
|
||||
Map<String, Object> context, WxMpService wxMpService,
|
||||
WxSessionManager sessionManager) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.czsj.wechat.handler;
|
||||
|
||||
import com.czsj.wechat.service.MsgReplyService;
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.util.WxMpConfigStorageHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Binary Wang
|
||||
*/
|
||||
@Component
|
||||
public class ScanHandler extends AbstractHandler {
|
||||
@Autowired
|
||||
MsgReplyService msgReplyService;
|
||||
|
||||
@Override
|
||||
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map<String, Object> map,
|
||||
WxMpService wxMpService, WxSessionManager wxSessionManager) {
|
||||
//扫码事件处理
|
||||
this.logger.info("用户扫描带参二维码 OPENID: " + wxMpXmlMessage.getFromUser());
|
||||
String appid = WxMpConfigStorageHolder.get();
|
||||
msgReplyService.tryAutoReply(appid, true, wxMpXmlMessage.getFromUser(), wxMpXmlMessage.getEventKey());
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.czsj.wechat.handler;
|
||||
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 门店审核事件处理
|
||||
*
|
||||
* @author 王彬 (Binary Wang)
|
||||
*/
|
||||
@Component
|
||||
public class StoreCheckNotifyHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
|
||||
Map<String, Object> context, WxMpService wxMpService,
|
||||
WxSessionManager sessionManager) {
|
||||
// TODO 处理门店审核事件
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.czsj.wechat.handler;
|
||||
|
||||
import com.czsj.account.service.ICzsjMemberWxFansService;
|
||||
import com.czsj.wechat.service.MsgReplyService;
|
||||
import com.czsj.wechat.service.WxUserService;
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.util.WxMpConfigStorageHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Binary Wang
|
||||
*/
|
||||
@Component
|
||||
public class SubscribeHandler extends AbstractHandler {
|
||||
@Autowired
|
||||
MsgReplyService msgReplyService;
|
||||
@Autowired
|
||||
private ICzsjMemberWxFansService iCzsjMemberWxFansService;
|
||||
@Autowired
|
||||
WxUserService userService;
|
||||
|
||||
@Override
|
||||
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService,
|
||||
WxSessionManager sessionManager) {
|
||||
|
||||
this.logger.info("新关注用户 OPENID: " + wxMessage.getFromUser() + ",事件:" + wxMessage.getEventKey());
|
||||
String appid = WxMpConfigStorageHolder.get();
|
||||
this.logger.info("appid:{}",appid);
|
||||
iCzsjMemberWxFansService.refreshUserInfo(wxMessage.getFromUser(),appid);
|
||||
|
||||
msgReplyService.tryAutoReply(appid, true, wxMessage.getFromUser(), wxMessage.getEvent());
|
||||
|
||||
if (StringUtils.hasText(wxMessage.getEventKey())) {// 处理特殊事件,如用户扫描带参二维码关注
|
||||
msgReplyService.tryAutoReply(appid, true, wxMessage.getFromUser(), wxMessage.getEventKey());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理特殊请求,比如如果是扫码进来的,可以做相应处理
|
||||
*/
|
||||
protected WxMpXmlOutMessage handleSpecial(WxMpXmlMessage wxMessage) {
|
||||
this.logger.info("特殊请求-新关注用户 OPENID: " + wxMessage.getFromUser());
|
||||
//对关注事件和扫码事件分别处理
|
||||
String appid = WxMpConfigStorageHolder.get();
|
||||
userService.refreshUserInfo(wxMessage.getFromUser(),appid);
|
||||
msgReplyService.tryAutoReply(appid, true, wxMessage.getFromUser(), wxMessage.getEvent());
|
||||
if (StringUtils.hasText(wxMessage.getEventKey())) {
|
||||
msgReplyService.tryAutoReply(appid, true, wxMessage.getFromUser(), wxMessage.getEventKey());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.czsj.wechat.handler;
|
||||
|
||||
import com.czsj.account.service.ICzsjMemberWxFansService;
|
||||
import com.czsj.wechat.service.WxUserService;
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Binary Wang
|
||||
*/
|
||||
@Component
|
||||
public class UnsubscribeHandler extends AbstractHandler {
|
||||
@Autowired
|
||||
WxUserService userService;
|
||||
@Autowired
|
||||
ICzsjMemberWxFansService iCzsjMemberWxFansService;
|
||||
|
||||
@Override
|
||||
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
|
||||
Map<String, Object> context, WxMpService wxMpService,
|
||||
WxSessionManager sessionManager) {
|
||||
String openid = wxMessage.getFromUser();
|
||||
this.logger.info("取消关注用户 OPENID: " + openid);
|
||||
iCzsjMemberWxFansService.unsubscribe(openid);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.czsj.wechat.listener;
|
||||
|
||||
import com.czsj.wechat.service.WxAccountService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.connection.Message;
|
||||
import org.springframework.data.redis.connection.MessageListener;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Auther: cheng.tang
|
||||
* @Date: 2023/11/11
|
||||
* @Description: wx-api
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class WxAccountChangedMessageListener implements MessageListener {
|
||||
|
||||
@Autowired
|
||||
private WxAccountService wxAccountService;
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
log.info("receiving channel {} body {} pattern {} ", new String(message.getChannel()), new String(message.getBody()), new String(pattern));
|
||||
try {
|
||||
wxAccountService.loadWxMpConfigStorages();
|
||||
log.info("finish ");
|
||||
} catch (Exception e) {
|
||||
log.error("消息处理失败了 {} ", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.czsj.wechat.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.CacheNamespace;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.czsj.wechat.entity.Article;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
@Mapper
|
||||
@CacheNamespace(flushInterval = 300000L)//缓存五分钟过期
|
||||
public interface ArticleMapper extends BaseMapper<Article> {
|
||||
@Async
|
||||
void addOpenCount(int id);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.czsj.wechat.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.wechat.domain.CzsjWxAccount;
|
||||
|
||||
/**
|
||||
* 微信公众号Mapper接口
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface CzsjWxAccountMapper
|
||||
{
|
||||
/**
|
||||
* 查询微信公众号
|
||||
*
|
||||
* @param uid 微信公众号主键
|
||||
* @return 微信公众号
|
||||
*/
|
||||
public CzsjWxAccount selectCzsjWxAccountByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 查询微信公众号列表
|
||||
*
|
||||
* @param czsjWxAccount 微信公众号
|
||||
* @return 微信公众号集合
|
||||
*/
|
||||
public List<CzsjWxAccount> selectCzsjWxAccountList(CzsjWxAccount czsjWxAccount);
|
||||
|
||||
/**
|
||||
* 新增微信公众号
|
||||
*
|
||||
* @param czsjWxAccount 微信公众号
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCzsjWxAccount(CzsjWxAccount czsjWxAccount);
|
||||
|
||||
/**
|
||||
* 修改微信公众号
|
||||
*
|
||||
* @param czsjWxAccount 微信公众号
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCzsjWxAccount(CzsjWxAccount czsjWxAccount);
|
||||
|
||||
/**
|
||||
* 删除微信公众号
|
||||
*
|
||||
* @param uid 微信公众号主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxAccountByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 批量删除微信公众号
|
||||
*
|
||||
* @param uids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxAccountByUids(Long[] uids);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.czsj.wechat.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.wechat.domain.CzsjWxMessage;
|
||||
|
||||
/**
|
||||
* 微信消息Mapper接口
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface CzsjWxMessageMapper
|
||||
{
|
||||
/**
|
||||
* 查询微信消息
|
||||
*
|
||||
* @param uid 微信消息主键
|
||||
* @return 微信消息
|
||||
*/
|
||||
public CzsjWxMessage selectCzsjWxMessageByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 查询微信消息列表
|
||||
*
|
||||
* @param czsjWxMessage 微信消息
|
||||
* @return 微信消息集合
|
||||
*/
|
||||
public List<CzsjWxMessage> selectCzsjWxMessageList(CzsjWxMessage czsjWxMessage);
|
||||
|
||||
/**
|
||||
* 新增微信消息
|
||||
*
|
||||
* @param czsjWxMessage 微信消息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCzsjWxMessage(CzsjWxMessage czsjWxMessage);
|
||||
|
||||
/**
|
||||
* 修改微信消息
|
||||
*
|
||||
* @param czsjWxMessage 微信消息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCzsjWxMessage(CzsjWxMessage czsjWxMessage);
|
||||
|
||||
/**
|
||||
* 删除微信消息
|
||||
*
|
||||
* @param uid 微信消息主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxMessageByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 批量删除微信消息
|
||||
*
|
||||
* @param uids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxMessageByUids(Long[] uids);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.czsj.wechat.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.wechat.domain.CzsjWxQrCode;
|
||||
|
||||
/**
|
||||
* 公众号二维码Mapper接口
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface CzsjWxQrCodeMapper
|
||||
{
|
||||
/**
|
||||
* 查询公众号二维码
|
||||
*
|
||||
* @param uid 公众号二维码主键
|
||||
* @return 公众号二维码
|
||||
*/
|
||||
public CzsjWxQrCode selectCzsjWxQrCodeByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 查询公众号二维码列表
|
||||
*
|
||||
* @param czsjWxQrCode 公众号二维码
|
||||
* @return 公众号二维码集合
|
||||
*/
|
||||
public List<CzsjWxQrCode> selectCzsjWxQrCodeList(CzsjWxQrCode czsjWxQrCode);
|
||||
|
||||
/**
|
||||
* 新增公众号二维码
|
||||
*
|
||||
* @param czsjWxQrCode 公众号二维码
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCzsjWxQrCode(CzsjWxQrCode czsjWxQrCode);
|
||||
|
||||
/**
|
||||
* 修改公众号二维码
|
||||
*
|
||||
* @param czsjWxQrCode 公众号二维码
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCzsjWxQrCode(CzsjWxQrCode czsjWxQrCode);
|
||||
|
||||
/**
|
||||
* 删除公众号二维码
|
||||
*
|
||||
* @param uid 公众号二维码主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxQrCodeByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 批量删除公众号二维码
|
||||
*
|
||||
* @param uids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxQrCodeByUids(Long[] uids);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.czsj.wechat.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.wechat.domain.CzsjWxReplyRule;
|
||||
|
||||
/**
|
||||
* 微信消息回复规则Mapper接口
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface CzsjWxReplyRuleMapper
|
||||
{
|
||||
/**
|
||||
* 查询微信消息回复规则
|
||||
*
|
||||
* @param uid 微信消息回复规则主键
|
||||
* @return 微信消息回复规则
|
||||
*/
|
||||
public CzsjWxReplyRule selectCzsjWxReplyRuleByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 查询微信消息回复规则列表
|
||||
*
|
||||
* @param czsjWxReplyRule 微信消息回复规则
|
||||
* @return 微信消息回复规则集合
|
||||
*/
|
||||
public List<CzsjWxReplyRule> selectCzsjWxReplyRuleList(CzsjWxReplyRule czsjWxReplyRule);
|
||||
|
||||
/**
|
||||
* 新增微信消息回复规则
|
||||
*
|
||||
* @param czsjWxReplyRule 微信消息回复规则
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCzsjWxReplyRule(CzsjWxReplyRule czsjWxReplyRule);
|
||||
|
||||
/**
|
||||
* 修改微信消息回复规则
|
||||
*
|
||||
* @param czsjWxReplyRule 微信消息回复规则
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCzsjWxReplyRule(CzsjWxReplyRule czsjWxReplyRule);
|
||||
|
||||
/**
|
||||
* 删除微信消息回复规则
|
||||
*
|
||||
* @param uid 微信消息回复规则主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxReplyRuleByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 批量删除微信消息回复规则
|
||||
*
|
||||
* @param uids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxReplyRuleByUids(Long[] uids);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.czsj.wechat.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.wechat.domain.CzsjWxTemplateLog;
|
||||
|
||||
/**
|
||||
* 微信消息模板日志Mapper接口
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface CzsjWxTemplateLogMapper
|
||||
{
|
||||
/**
|
||||
* 查询微信消息模板日志
|
||||
*
|
||||
* @param uid 微信消息模板日志主键
|
||||
* @return 微信消息模板日志
|
||||
*/
|
||||
public CzsjWxTemplateLog selectCzsjWxTemplateLogByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 查询微信消息模板日志列表
|
||||
*
|
||||
* @param czsjWxTemplateLog 微信消息模板日志
|
||||
* @return 微信消息模板日志集合
|
||||
*/
|
||||
public List<CzsjWxTemplateLog> selectCzsjWxTemplateLogList(CzsjWxTemplateLog czsjWxTemplateLog);
|
||||
|
||||
/**
|
||||
* 新增微信消息模板日志
|
||||
*
|
||||
* @param czsjWxTemplateLog 微信消息模板日志
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCzsjWxTemplateLog(CzsjWxTemplateLog czsjWxTemplateLog);
|
||||
|
||||
/**
|
||||
* 修改微信消息模板日志
|
||||
*
|
||||
* @param czsjWxTemplateLog 微信消息模板日志
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCzsjWxTemplateLog(CzsjWxTemplateLog czsjWxTemplateLog);
|
||||
|
||||
/**
|
||||
* 删除微信消息模板日志
|
||||
*
|
||||
* @param uid 微信消息模板日志主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxTemplateLogByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 批量删除微信消息模板日志
|
||||
*
|
||||
* @param uids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxTemplateLogByUids(Long[] uids);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.czsj.wechat.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.wechat.domain.CzsjWxTemplate;
|
||||
|
||||
/**
|
||||
* 微信消息模板Mapper接口
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface CzsjWxTemplateMapper
|
||||
{
|
||||
/**
|
||||
* 查询微信消息模板
|
||||
*
|
||||
* @param uid 微信消息模板主键
|
||||
* @return 微信消息模板
|
||||
*/
|
||||
public CzsjWxTemplate selectCzsjWxTemplateByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 查询微信消息模板列表
|
||||
*
|
||||
* @param czsjWxTemplate 微信消息模板
|
||||
* @return 微信消息模板集合
|
||||
*/
|
||||
public List<CzsjWxTemplate> selectCzsjWxTemplateList(CzsjWxTemplate czsjWxTemplate);
|
||||
|
||||
/**
|
||||
* 新增微信消息模板
|
||||
*
|
||||
* @param czsjWxTemplate 微信消息模板
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCzsjWxTemplate(CzsjWxTemplate czsjWxTemplate);
|
||||
|
||||
/**
|
||||
* 修改微信消息模板
|
||||
*
|
||||
* @param czsjWxTemplate 微信消息模板
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCzsjWxTemplate(CzsjWxTemplate czsjWxTemplate);
|
||||
|
||||
/**
|
||||
* 删除微信消息模板
|
||||
*
|
||||
* @param uid 微信消息模板主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxTemplateByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 批量删除微信消息模板
|
||||
*
|
||||
* @param uids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxTemplateByUids(Long[] uids);
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.czsj.wechat.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.CacheNamespace;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.czsj.wechat.entity.MsgReplyRule;
|
||||
|
||||
@Mapper
|
||||
@CacheNamespace(flushInterval = 300000L)//缓存五分钟过期
|
||||
public interface MsgReplyRuleMapper extends BaseMapper<MsgReplyRule> {
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.czsj.wechat.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.CacheNamespace;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.czsj.wechat.entity.MsgTemplate;
|
||||
|
||||
@Mapper
|
||||
@CacheNamespace(flushInterval = 300000L)//缓存五分钟过期
|
||||
public interface MsgTemplateMapper extends BaseMapper<MsgTemplate> {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.czsj.wechat.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.czsj.wechat.entity.TemplateMsgLog;
|
||||
|
||||
@Mapper
|
||||
public interface TemplateMsgLogMapper extends BaseMapper<TemplateMsgLog> {
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.czsj.wechat.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.CacheNamespace;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.czsj.wechat.entity.WxAccount;
|
||||
|
||||
/**
|
||||
* 公众号账号
|
||||
*
|
||||
* @author niefy
|
||||
* @date 2020-06-17 13:56:51
|
||||
*/
|
||||
@Mapper
|
||||
@CacheNamespace(flushInterval = 300000L)//缓存五分钟过期
|
||||
public interface WxAccountMapper extends BaseMapper<WxAccount> {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.czsj.wechat.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.CacheNamespace;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.czsj.wechat.entity.WxMsg;
|
||||
|
||||
/**
|
||||
* 微信消息
|
||||
*
|
||||
* @author niefy
|
||||
* @date 2020-05-14 17:28:34
|
||||
*/
|
||||
@Mapper
|
||||
@CacheNamespace(flushInterval = 10*1000L)//缓存过期时间(毫秒)
|
||||
public interface WxMsgMapper extends BaseMapper<WxMsg> {
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.czsj.wechat.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.CacheNamespace;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.czsj.wechat.entity.WxQrCode;
|
||||
|
||||
/**
|
||||
* 公众号带参二维码
|
||||
*
|
||||
* @author niefy
|
||||
* @email niefy@qq.com
|
||||
* @date 2020-01-02 11:11:55
|
||||
*/
|
||||
@Mapper
|
||||
@CacheNamespace(flushInterval = 300000L)//缓存五分钟过期
|
||||
public interface WxQrCodeMapper extends BaseMapper<WxQrCode> {
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.czsj.wechat.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.CacheNamespace;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.czsj.wechat.entity.WxUser;
|
||||
|
||||
@Mapper
|
||||
@CacheNamespace(flushInterval = 300000L)//缓存五分钟过期
|
||||
public interface WxUserMapper extends BaseMapper<WxUser> {
|
||||
|
||||
void unsubscribe(String openid);
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.czsj.wechat.utils.PageUtils;
|
||||
import com.czsj.wechat.entity.Article;
|
||||
import com.czsj.wechat.enums.ArticleTypeEnum;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ArticleService extends IService<Article> {
|
||||
/**
|
||||
* 分页查询用户数据
|
||||
* @param params 查询参数
|
||||
* @return PageUtils 分页结果
|
||||
*/
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 查询文章详情,每次查询后增加点击次数
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Article findById(int id);
|
||||
|
||||
/**
|
||||
* 添加或编辑文章,同名文章不可重复添加
|
||||
*
|
||||
* @param article
|
||||
*/
|
||||
boolean saveArticle(Article article);
|
||||
|
||||
/**
|
||||
* 按条件分页查询
|
||||
*
|
||||
* @param title
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
IPage<Article> getArticles(String title, int page);
|
||||
|
||||
/**
|
||||
* 查看目录,不返回文章详情字段
|
||||
*
|
||||
* @param articleType
|
||||
* @param category
|
||||
* @return
|
||||
*/
|
||||
List<Article> selectCategory(ArticleTypeEnum articleType, String category);
|
||||
|
||||
/**
|
||||
* 文章查找,不返回文章详情字段
|
||||
*
|
||||
* @param articleType
|
||||
* @param category
|
||||
* @param keywords
|
||||
* @return
|
||||
*/
|
||||
List<Article> search(ArticleTypeEnum articleType, String category, String keywords);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.wechat.domain.CzsjWxAccount;
|
||||
|
||||
/**
|
||||
* 微信公众号Service接口
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface ICzsjWxAccountService
|
||||
{
|
||||
/**
|
||||
* 查询微信公众号
|
||||
*
|
||||
* @param uid 微信公众号主键
|
||||
* @return 微信公众号
|
||||
*/
|
||||
public CzsjWxAccount selectCzsjWxAccountByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 查询微信公众号列表
|
||||
*
|
||||
* @param czsjWxAccount 微信公众号
|
||||
* @return 微信公众号集合
|
||||
*/
|
||||
public List<CzsjWxAccount> selectCzsjWxAccountList(CzsjWxAccount czsjWxAccount);
|
||||
|
||||
/**
|
||||
* 新增微信公众号
|
||||
*
|
||||
* @param czsjWxAccount 微信公众号
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCzsjWxAccount(CzsjWxAccount czsjWxAccount);
|
||||
|
||||
/**
|
||||
* 修改微信公众号
|
||||
*
|
||||
* @param czsjWxAccount 微信公众号
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCzsjWxAccount(CzsjWxAccount czsjWxAccount);
|
||||
|
||||
/**
|
||||
* 批量删除微信公众号
|
||||
*
|
||||
* @param uids 需要删除的微信公众号主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxAccountByUids(Long[] uids);
|
||||
|
||||
/**
|
||||
* 删除微信公众号信息
|
||||
*
|
||||
* @param uid 微信公众号主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxAccountByUid(Long uid);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.wechat.domain.CzsjWxMessage;
|
||||
|
||||
/**
|
||||
* 微信消息Service接口
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface ICzsjWxMessageService
|
||||
{
|
||||
/**
|
||||
* 查询微信消息
|
||||
*
|
||||
* @param uid 微信消息主键
|
||||
* @return 微信消息
|
||||
*/
|
||||
public CzsjWxMessage selectCzsjWxMessageByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 查询微信消息列表
|
||||
*
|
||||
* @param czsjWxMessage 微信消息
|
||||
* @return 微信消息集合
|
||||
*/
|
||||
public List<CzsjWxMessage> selectCzsjWxMessageList(CzsjWxMessage czsjWxMessage);
|
||||
|
||||
/**
|
||||
* 新增微信消息
|
||||
*
|
||||
* @param czsjWxMessage 微信消息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCzsjWxMessage(CzsjWxMessage czsjWxMessage);
|
||||
|
||||
/**
|
||||
* 修改微信消息
|
||||
*
|
||||
* @param czsjWxMessage 微信消息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCzsjWxMessage(CzsjWxMessage czsjWxMessage);
|
||||
|
||||
/**
|
||||
* 批量删除微信消息
|
||||
*
|
||||
* @param uids 需要删除的微信消息主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxMessageByUids(Long[] uids);
|
||||
|
||||
/**
|
||||
* 删除微信消息信息
|
||||
*
|
||||
* @param uid 微信消息主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxMessageByUid(Long uid);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.wechat.domain.CzsjWxQrCode;
|
||||
|
||||
/**
|
||||
* 公众号二维码Service接口
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface ICzsjWxQrCodeService
|
||||
{
|
||||
/**
|
||||
* 查询公众号二维码
|
||||
*
|
||||
* @param uid 公众号二维码主键
|
||||
* @return 公众号二维码
|
||||
*/
|
||||
public CzsjWxQrCode selectCzsjWxQrCodeByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 查询公众号二维码列表
|
||||
*
|
||||
* @param czsjWxQrCode 公众号二维码
|
||||
* @return 公众号二维码集合
|
||||
*/
|
||||
public List<CzsjWxQrCode> selectCzsjWxQrCodeList(CzsjWxQrCode czsjWxQrCode);
|
||||
|
||||
/**
|
||||
* 新增公众号二维码
|
||||
*
|
||||
* @param czsjWxQrCode 公众号二维码
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCzsjWxQrCode(CzsjWxQrCode czsjWxQrCode);
|
||||
|
||||
/**
|
||||
* 修改公众号二维码
|
||||
*
|
||||
* @param czsjWxQrCode 公众号二维码
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCzsjWxQrCode(CzsjWxQrCode czsjWxQrCode);
|
||||
|
||||
/**
|
||||
* 批量删除公众号二维码
|
||||
*
|
||||
* @param uids 需要删除的公众号二维码主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxQrCodeByUids(Long[] uids);
|
||||
|
||||
/**
|
||||
* 删除公众号二维码信息
|
||||
*
|
||||
* @param uid 公众号二维码主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxQrCodeByUid(Long uid);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.wechat.domain.CzsjWxReplyRule;
|
||||
|
||||
/**
|
||||
* 微信消息回复规则Service接口
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface ICzsjWxReplyRuleService
|
||||
{
|
||||
/**
|
||||
* 查询微信消息回复规则
|
||||
*
|
||||
* @param uid 微信消息回复规则主键
|
||||
* @return 微信消息回复规则
|
||||
*/
|
||||
public CzsjWxReplyRule selectCzsjWxReplyRuleByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 查询微信消息回复规则列表
|
||||
*
|
||||
* @param czsjWxReplyRule 微信消息回复规则
|
||||
* @return 微信消息回复规则集合
|
||||
*/
|
||||
public List<CzsjWxReplyRule> selectCzsjWxReplyRuleList(CzsjWxReplyRule czsjWxReplyRule);
|
||||
|
||||
/**
|
||||
* 新增微信消息回复规则
|
||||
*
|
||||
* @param czsjWxReplyRule 微信消息回复规则
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCzsjWxReplyRule(CzsjWxReplyRule czsjWxReplyRule);
|
||||
|
||||
/**
|
||||
* 修改微信消息回复规则
|
||||
*
|
||||
* @param czsjWxReplyRule 微信消息回复规则
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCzsjWxReplyRule(CzsjWxReplyRule czsjWxReplyRule);
|
||||
|
||||
/**
|
||||
* 批量删除微信消息回复规则
|
||||
*
|
||||
* @param uids 需要删除的微信消息回复规则主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxReplyRuleByUids(Long[] uids);
|
||||
|
||||
/**
|
||||
* 删除微信消息回复规则信息
|
||||
*
|
||||
* @param uid 微信消息回复规则主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxReplyRuleByUid(Long uid);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.wechat.domain.CzsjWxTemplateLog;
|
||||
|
||||
/**
|
||||
* 微信消息模板日志Service接口
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface ICzsjWxTemplateLogService
|
||||
{
|
||||
/**
|
||||
* 查询微信消息模板日志
|
||||
*
|
||||
* @param uid 微信消息模板日志主键
|
||||
* @return 微信消息模板日志
|
||||
*/
|
||||
public CzsjWxTemplateLog selectCzsjWxTemplateLogByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 查询微信消息模板日志列表
|
||||
*
|
||||
* @param czsjWxTemplateLog 微信消息模板日志
|
||||
* @return 微信消息模板日志集合
|
||||
*/
|
||||
public List<CzsjWxTemplateLog> selectCzsjWxTemplateLogList(CzsjWxTemplateLog czsjWxTemplateLog);
|
||||
|
||||
/**
|
||||
* 新增微信消息模板日志
|
||||
*
|
||||
* @param czsjWxTemplateLog 微信消息模板日志
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCzsjWxTemplateLog(CzsjWxTemplateLog czsjWxTemplateLog);
|
||||
|
||||
/**
|
||||
* 修改微信消息模板日志
|
||||
*
|
||||
* @param czsjWxTemplateLog 微信消息模板日志
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCzsjWxTemplateLog(CzsjWxTemplateLog czsjWxTemplateLog);
|
||||
|
||||
/**
|
||||
* 批量删除微信消息模板日志
|
||||
*
|
||||
* @param uids 需要删除的微信消息模板日志主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxTemplateLogByUids(Long[] uids);
|
||||
|
||||
/**
|
||||
* 删除微信消息模板日志信息
|
||||
*
|
||||
* @param uid 微信消息模板日志主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxTemplateLogByUid(Long uid);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.wechat.domain.CzsjWxTemplate;
|
||||
|
||||
/**
|
||||
* 微信消息模板Service接口
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface ICzsjWxTemplateService
|
||||
{
|
||||
/**
|
||||
* 查询微信消息模板
|
||||
*
|
||||
* @param uid 微信消息模板主键
|
||||
* @return 微信消息模板
|
||||
*/
|
||||
public CzsjWxTemplate selectCzsjWxTemplateByUid(Long uid);
|
||||
|
||||
/**
|
||||
* 查询微信消息模板列表
|
||||
*
|
||||
* @param czsjWxTemplate 微信消息模板
|
||||
* @return 微信消息模板集合
|
||||
*/
|
||||
public List<CzsjWxTemplate> selectCzsjWxTemplateList(CzsjWxTemplate czsjWxTemplate);
|
||||
|
||||
/**
|
||||
* 新增微信消息模板
|
||||
*
|
||||
* @param czsjWxTemplate 微信消息模板
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCzsjWxTemplate(CzsjWxTemplate czsjWxTemplate);
|
||||
|
||||
/**
|
||||
* 修改微信消息模板
|
||||
*
|
||||
* @param czsjWxTemplate 微信消息模板
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCzsjWxTemplate(CzsjWxTemplate czsjWxTemplate);
|
||||
|
||||
/**
|
||||
* 批量删除微信消息模板
|
||||
*
|
||||
* @param uids 需要删除的微信消息模板主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxTemplateByUids(Long[] uids);
|
||||
|
||||
/**
|
||||
* 删除微信消息模板信息
|
||||
*
|
||||
* @param uid 微信消息模板主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCzsjWxTemplateByUid(Long uid);
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.czsj.wechat.utils.PageUtils;
|
||||
import com.czsj.wechat.entity.MsgReplyRule;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface MsgReplyRuleService extends IService<MsgReplyRule> {
|
||||
/**
|
||||
* 分页查询用户数据
|
||||
* @param params 查询参数
|
||||
* @return PageUtils 分页结果
|
||||
*/
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 保存自动回复规则
|
||||
*
|
||||
* @param msgReplyRule
|
||||
*/
|
||||
|
||||
@Override
|
||||
boolean save(MsgReplyRule msgReplyRule);
|
||||
|
||||
/**
|
||||
* 获取所有的回复规则
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<MsgReplyRule> getRules();
|
||||
|
||||
/**
|
||||
* 获取当前时段内所有有效的回复规则
|
||||
*
|
||||
* @return 有效的规则列表
|
||||
*/
|
||||
List<MsgReplyRule> getValidRules();
|
||||
|
||||
/**
|
||||
* 筛选符合条件的回复规则
|
||||
*
|
||||
*
|
||||
* @param appid
|
||||
* @param exactMatch 是否精确匹配
|
||||
* @param keywords 关键词
|
||||
* @return 规则列表
|
||||
*/
|
||||
List<MsgReplyRule> getMatchedRules(String appid, boolean exactMatch, String keywords);
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* 公众号消息处理
|
||||
* 官方文档:https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Service_Center_messages.html#7
|
||||
* WxJava客服消息文档:https://github.com/Wechat-Group/WxJava/wiki/MP_主动发送消息(客服消息)
|
||||
*/
|
||||
public interface MsgReplyService {
|
||||
Logger logger = LoggerFactory.getLogger(MsgReplyService.class);
|
||||
|
||||
/**
|
||||
* 根据规则配置通过微信客服消息接口自动回复消息
|
||||
*
|
||||
*
|
||||
* @param appid
|
||||
* @param exactMatch 是否精确匹配
|
||||
* @param toUser 用户openid
|
||||
* @param keywords 匹配关键词
|
||||
* @return 是否已自动回复,无匹配规则则不自动回复
|
||||
*/
|
||||
boolean tryAutoReply(String appid, boolean exactMatch, String toUser, String keywords);
|
||||
|
||||
default void reply(String toUser,String replyType, String replyContent){
|
||||
try {
|
||||
if (WxConsts.KefuMsgType.TEXT.equals(replyType)) {
|
||||
this.replyText(toUser, replyContent);
|
||||
} else if (WxConsts.KefuMsgType.IMAGE.equals(replyType)) {
|
||||
this.replyImage(toUser, replyContent);
|
||||
} else if (WxConsts.KefuMsgType.VOICE.equals(replyType)) {
|
||||
this.replyVoice(toUser, replyContent);
|
||||
} else if (WxConsts.KefuMsgType.VIDEO.equals(replyType)) {
|
||||
this.replyVideo(toUser, replyContent);
|
||||
} else if (WxConsts.KefuMsgType.MUSIC.equals(replyType)) {
|
||||
this.replyMusic(toUser, replyContent);
|
||||
} else if (WxConsts.KefuMsgType.NEWS.equals(replyType)) {
|
||||
this.replyNews(toUser, replyContent);
|
||||
} else if (WxConsts.KefuMsgType.MPNEWS.equals(replyType)) {
|
||||
this.replyMpNews(toUser, replyContent);
|
||||
} else if (WxConsts.KefuMsgType.WXCARD.equals(replyType)) {
|
||||
this.replyWxCard(toUser, replyContent);
|
||||
} else if (WxConsts.KefuMsgType.MINIPROGRAMPAGE.equals(replyType)) {
|
||||
this.replyMiniProgram(toUser, replyContent);
|
||||
} else if (WxConsts.KefuMsgType.MSGMENU.equals(replyType)) {
|
||||
this.replyMsgMenu(toUser, replyContent);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("自动回复出错:", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 回复文字消息
|
||||
*/
|
||||
void replyText(String toUser, String replyContent) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 回复图片消息
|
||||
*/
|
||||
void replyImage(String toUser, String mediaId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 回复录音消息
|
||||
*/
|
||||
void replyVoice(String toUser, String mediaId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 回复视频消息
|
||||
*/
|
||||
void replyVideo(String toUser, String mediaId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 回复音乐消息
|
||||
*/
|
||||
void replyMusic(String toUser, String mediaId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 回复图文消息(点击跳转到外链)
|
||||
* 图文消息条数限制在1条以内
|
||||
*/
|
||||
void replyNews(String toUser, String newsInfoJson) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 回复公众号文章消息(点击跳转到图文消息页面)
|
||||
* 图文消息条数限制在1条以内
|
||||
*/
|
||||
void replyMpNews(String toUser, String mediaId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 回复卡券消息
|
||||
*/
|
||||
void replyWxCard(String toUser, String cardId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 回复小程序消息
|
||||
*/
|
||||
void replyMiniProgram(String toUser, String miniProgramInfoJson) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 回复菜单消息
|
||||
*/
|
||||
void replyMsgMenu(String toUser, String msgMenusJson) throws WxErrorException;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.czsj.wechat.utils.PageUtils;
|
||||
import com.czsj.wechat.entity.MsgTemplate;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消息模板
|
||||
*
|
||||
* @author niefy
|
||||
* @email niefy@qq.com
|
||||
* @date 2019-11-12 18:30:15
|
||||
*/
|
||||
public interface MsgTemplateService extends IService<MsgTemplate> {
|
||||
/**
|
||||
* 分页查询用户数据
|
||||
* @param params 查询参数
|
||||
* @return PageUtils 分页结果
|
||||
*/
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 通过模板名称查询
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
MsgTemplate selectByName(String name);
|
||||
|
||||
/**
|
||||
* 同步公众号已添加的消息模板
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
void syncWxTemplate(String appid, List<WxMpTemplate> allPrivateTemplateList) throws WxErrorException;
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.czsj.wechat.utils.PageUtils;
|
||||
import com.czsj.wechat.entity.TemplateMsgLog;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface TemplateMsgLogService extends IService<TemplateMsgLog> {
|
||||
/**
|
||||
* 分页查询用户数据
|
||||
* @param params 查询参数
|
||||
* @return PageUtils 分页结果
|
||||
*/
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 记录log,异步入库
|
||||
*
|
||||
* @param log
|
||||
*/
|
||||
void addLog(TemplateMsgLog log);
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import com.czsj.wechat.form.TemplateMsgBatchForm;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
||||
|
||||
public interface TemplateMsgService {
|
||||
/**
|
||||
* 发送微信模版消息
|
||||
*/
|
||||
void sendTemplateMsg(WxMpTemplateMessage msg,String appid);
|
||||
|
||||
/**
|
||||
* 批量消息发送
|
||||
* @param form
|
||||
* @param appid
|
||||
*/
|
||||
void sendMsgBatch(TemplateMsgBatchForm form,String appid);
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.czsj.wechat.utils.PageUtils;
|
||||
import com.czsj.wechat.entity.WxAccount;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 公众号账号
|
||||
*
|
||||
* @author niefy
|
||||
* @date 2020-06-17 13:56:51
|
||||
*/
|
||||
public interface WxAccountService extends IService<WxAccount> {
|
||||
/**
|
||||
* 分页查询用户数据
|
||||
* @param params 查询参数
|
||||
* @return PageUtils 分页结果
|
||||
*/
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
void loadWxMpConfigStorages();
|
||||
|
||||
boolean saveOrUpdateWxAccount(WxAccount entity);
|
||||
|
||||
@Override
|
||||
boolean removeByIds(Collection<?> idList);
|
||||
}
|
||||
|
@ -0,0 +1,89 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.bean.draft.WxMpDraftArticles;
|
||||
import me.chanjar.weixin.mp.bean.draft.WxMpUpdateDraft;
|
||||
import me.chanjar.weixin.mp.bean.material.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface WxAssetsService {
|
||||
/**
|
||||
* 获取素材总数
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
* @param appid
|
||||
*/
|
||||
WxMpMaterialCountResult materialCount(String appid) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取图文素材详情
|
||||
*
|
||||
* @param appid
|
||||
* @param mediaId
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMpMaterialNews materialNewsInfo(String appid, String mediaId) throws WxErrorException;
|
||||
/**
|
||||
* 根据类别分页获取非图文素材列表
|
||||
*
|
||||
* @param appid
|
||||
* @param type
|
||||
* @param page
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMpMaterialFileBatchGetResult materialFileBatchGet(String appid, String type, int page) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 分页获取图文素材列表
|
||||
*
|
||||
* @param appid
|
||||
* @param page
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMpMaterialNewsBatchGetResult materialNewsBatchGet(String appid, int page) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 添加图文永久素材
|
||||
*
|
||||
* @param appid
|
||||
* @param articles
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMpMaterialUploadResult materialNewsUpload(String appid, List<WxMpDraftArticles> articles)throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 更新图文素材中的某篇文章
|
||||
* @param appid
|
||||
* @param form
|
||||
*/
|
||||
void materialArticleUpdate(String appid, WxMpUpdateDraft form) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 添加多媒体永久素材
|
||||
*
|
||||
* @param appid
|
||||
* @param mediaType
|
||||
* @param fileName
|
||||
* @param file
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMpMaterialUploadResult materialFileUpload(String appid, String mediaType, String fileName, MultipartFile file) throws WxErrorException, IOException;
|
||||
|
||||
/**
|
||||
* 删除素材
|
||||
*
|
||||
* @param appid
|
||||
* @param mediaId
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
boolean materialDelete(String appid, String mediaId)throws WxErrorException;
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.czsj.wechat.utils.PageUtils;
|
||||
import com.czsj.wechat.entity.WxMsg;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 微信消息
|
||||
*
|
||||
* @author niefy
|
||||
* @date 2020-05-14 17:28:34
|
||||
*/
|
||||
public interface WxMsgService extends IService<WxMsg> {
|
||||
/**
|
||||
* 分页查询用户数据
|
||||
* @param params 查询参数
|
||||
* @return PageUtils 分页结果
|
||||
*/
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 记录msg,异步入库
|
||||
* @param msg
|
||||
*/
|
||||
void addWxMsg(WxMsg msg);
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.czsj.wechat.utils.PageUtils;
|
||||
import com.czsj.wechat.entity.WxQrCode;
|
||||
import com.czsj.wechat.form.WxQrCodeForm;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 公众号带参二维码
|
||||
*
|
||||
* @author niefy
|
||||
* @email niefy@qq.com
|
||||
* @date 2020-01-02 11:11:55
|
||||
*/
|
||||
public interface WxQrCodeService extends IService<WxQrCode> {
|
||||
/**
|
||||
* 分页查询用户数据
|
||||
* @param params 查询参数
|
||||
* @return PageUtils 分页结果
|
||||
*/
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 创建公众号带参二维码
|
||||
*
|
||||
*
|
||||
* @param appid
|
||||
* @param form
|
||||
* @return
|
||||
*/
|
||||
WxMpQrCodeTicket createQrCode(String appid, WxQrCodeForm form) throws WxErrorException;
|
||||
}
|
||||
|
@ -0,0 +1,56 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.czsj.wechat.entity.WxUser;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface WxUserService extends IService<WxUser> {
|
||||
/**
|
||||
* 分页查询用户数据
|
||||
* @param params 查询参数
|
||||
* @return PageUtils 分页结果
|
||||
*/
|
||||
IPage<WxUser> queryPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 根据openid更新用户信息
|
||||
*
|
||||
* @param openid
|
||||
* @return
|
||||
*/
|
||||
WxUser refreshUserInfo(String openid,String appid);
|
||||
|
||||
/**
|
||||
* 异步批量更新用户信息
|
||||
* @param openidList
|
||||
*/
|
||||
void refreshUserInfoAsync(String[] openidList,String appid);
|
||||
|
||||
/**
|
||||
* 数据存在时更新,否则新增
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
void updateOrInsert(WxUser user);
|
||||
|
||||
/**
|
||||
* 取消关注,更新关注状态
|
||||
*
|
||||
* @param openid
|
||||
*/
|
||||
void unsubscribe(String openid);
|
||||
/**
|
||||
* 同步用户列表
|
||||
*/
|
||||
void syncWxUsers(String appid);
|
||||
|
||||
/**
|
||||
* 通过传入的openid列表,同步用户列表
|
||||
* @param openids
|
||||
*/
|
||||
void syncWxUsers(List<String> openids,String appid);
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.czsj.wechat.service;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.bean.tag.WxUserTag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface WxUserTagsService {
|
||||
/**
|
||||
* 获取公众号用户标签
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
* @param appid
|
||||
*/
|
||||
List<WxUserTag> getWxTags(String appid) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 创建标签
|
||||
* @param appid
|
||||
* @param name 标签名称
|
||||
*/
|
||||
void creatTag(String appid, String name) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 修改标签
|
||||
* @param appid
|
||||
* @param tagid 标签ID
|
||||
* @param name 标签名称
|
||||
*/
|
||||
void updateTag(String appid, Long tagid, String name) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 删除标签
|
||||
*
|
||||
* @param appid
|
||||
* @param tagid 标签ID
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
void deleteTag(String appid, Long tagid) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 批量给用户打标签
|
||||
*
|
||||
* @param appid
|
||||
* @param tagid 标签ID
|
||||
* @param openidList 用户openid列表
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
void batchTagging(String appid, Long tagid, String[] openidList) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 批量取消用户标签
|
||||
*
|
||||
* @param appid
|
||||
* @param tagid 标签ID
|
||||
* @param openidList 用户openid列表
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
void batchUnTagging(String appid, Long tagid, String[] openidList) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 为用户绑定标签
|
||||
* @param tagid
|
||||
* @param openid
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
void tagging(Long tagid, String openid) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 取消用户所绑定的某一个标签
|
||||
* @param tagid
|
||||
* @param openid
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
void untagging(Long tagid, String openid) throws WxErrorException;
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,153 @@
|
||||
package com.czsj.wechat.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.czsj.wechat.exception.RRException;
|
||||
import com.czsj.wechat.utils.PageUtils;
|
||||
import com.czsj.wechat.utils.Query;
|
||||
import com.czsj.wechat.mapper.ArticleMapper;
|
||||
import com.czsj.wechat.dto.PageSizeConstant;
|
||||
import com.czsj.wechat.entity.Article;
|
||||
import com.czsj.wechat.enums.ArticleTypeEnum;
|
||||
import com.czsj.wechat.service.ArticleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Nifury
|
||||
* @date 2017-10-27
|
||||
*/
|
||||
@Service
|
||||
public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> implements ArticleService {
|
||||
private static final String ID_PLACEHOLDER = "${articleId}";
|
||||
/**
|
||||
* 查询文章列表时返回的字段(过滤掉详情字段以加快速度)
|
||||
*/
|
||||
private static final String LIST_FILEDS = "id,summary,image,sub_category,update_time,title,type,tags,create_time,target_link,open_count,category";
|
||||
@Autowired
|
||||
ArticleMapper articleMapper;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String title = (String) params.get("title");
|
||||
String type = (String) params.get("type");
|
||||
String category = (String) params.get("category");
|
||||
String subCategory = (String) params.get("subCategory");
|
||||
IPage<Article> page = this.page(
|
||||
new Query<Article>().getPage(params),
|
||||
new QueryWrapper<Article>()
|
||||
.select(LIST_FILEDS)
|
||||
.eq(StringUtils.hasText(type), "type", type)
|
||||
.like(StringUtils.hasText(category), "category", category)
|
||||
.like(StringUtils.hasText(subCategory), "sub_category", subCategory)
|
||||
.like(StringUtils.hasText(title), "title", title)
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文章详情,每次查询后增加点击次数
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Article findById(int id) {
|
||||
if (id <= 0) {
|
||||
return null;
|
||||
}
|
||||
Article article = articleMapper.selectById(id);
|
||||
if (article != null) {
|
||||
articleMapper.addOpenCount(id);
|
||||
}
|
||||
return article;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加或编辑文章,同名文章不可重复添加
|
||||
*
|
||||
* @param article
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean saveArticle(Article article) {
|
||||
article.setUpdateTime(new Date());
|
||||
if (null != article.getId() && article.getId() > 0) {
|
||||
articleMapper.updateById(article);
|
||||
} else {
|
||||
String title = article.getTitle();
|
||||
long count = articleMapper.selectCount(
|
||||
new QueryWrapper<Article>().eq("title", title)
|
||||
.eq("category", article.getCategory())
|
||||
.eq("sub_category", article.getSubCategory())
|
||||
);
|
||||
if (count > 0) {
|
||||
throw new RRException("同目录下文章[" + title + "]已存在,不可重复添加");
|
||||
}
|
||||
article.setCreateTime(new Date());
|
||||
articleMapper.insert(article);
|
||||
}
|
||||
String targetLink = article.getTargetLink();
|
||||
if (targetLink.indexOf(ID_PLACEHOLDER) > -1) {
|
||||
article.setTargetLink(targetLink.replace(ID_PLACEHOLDER, article.getId() + ""));
|
||||
articleMapper.updateById(article);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按条件分页查询
|
||||
*
|
||||
* @param title
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public IPage<Article> getArticles(String title, int page) {
|
||||
return this.page(new Page<Article>(page, PageSizeConstant.PAGE_SIZE_SMALL),
|
||||
new QueryWrapper<Article>().like(StringUtils.hasText("title"), "title", title)
|
||||
.select(LIST_FILEDS)
|
||||
.orderBy(true, false, "update_time"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看目录,不返回文章详情字段
|
||||
*
|
||||
* @param articleType
|
||||
* @param category
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Article> selectCategory(ArticleTypeEnum articleType, String category) {
|
||||
return this.list(new QueryWrapper<Article>()
|
||||
.select(LIST_FILEDS)
|
||||
.eq("type", articleType.getValue())
|
||||
.eq("category", category));
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章查找,不返回文章详情字段
|
||||
*
|
||||
* @param articleType
|
||||
* @param category
|
||||
* @param keywords
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Article> search(ArticleTypeEnum articleType, String category, String keywords) {
|
||||
return this.list(new QueryWrapper<Article>()
|
||||
.select(LIST_FILEDS)
|
||||
.eq("type", articleType.getValue())
|
||||
.eq(StringUtils.hasText(category), "category", category)
|
||||
.and(i -> i.like("summary", keywords).or().like("title", keywords)));
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.czsj.wechat.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.czsj.wechat.mapper.CzsjWxAccountMapper;
|
||||
import com.czsj.wechat.domain.CzsjWxAccount;
|
||||
import com.czsj.wechat.service.ICzsjWxAccountService;
|
||||
|
||||
/**
|
||||
* 微信公众号Service业务层处理
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@Service
|
||||
public class CzsjWxAccountServiceImpl implements ICzsjWxAccountService
|
||||
{
|
||||
@Autowired
|
||||
private CzsjWxAccountMapper czsjWxAccountMapper;
|
||||
|
||||
/**
|
||||
* 查询微信公众号
|
||||
*
|
||||
* @param uid 微信公众号主键
|
||||
* @return 微信公众号
|
||||
*/
|
||||
@Override
|
||||
public CzsjWxAccount selectCzsjWxAccountByUid(Long uid)
|
||||
{
|
||||
return czsjWxAccountMapper.selectCzsjWxAccountByUid(uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询微信公众号列表
|
||||
*
|
||||
* @param czsjWxAccount 微信公众号
|
||||
* @return 微信公众号
|
||||
*/
|
||||
@Override
|
||||
public List<CzsjWxAccount> selectCzsjWxAccountList(CzsjWxAccount czsjWxAccount)
|
||||
{
|
||||
return czsjWxAccountMapper.selectCzsjWxAccountList(czsjWxAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增微信公众号
|
||||
*
|
||||
* @param czsjWxAccount 微信公众号
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCzsjWxAccount(CzsjWxAccount czsjWxAccount)
|
||||
{
|
||||
czsjWxAccount.setCreateTime(DateUtils.getNowDate());
|
||||
return czsjWxAccountMapper.insertCzsjWxAccount(czsjWxAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改微信公众号
|
||||
*
|
||||
* @param czsjWxAccount 微信公众号
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCzsjWxAccount(CzsjWxAccount czsjWxAccount)
|
||||
{
|
||||
czsjWxAccount.setUpdateTime(DateUtils.getNowDate());
|
||||
return czsjWxAccountMapper.updateCzsjWxAccount(czsjWxAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除微信公众号
|
||||
*
|
||||
* @param uids 需要删除的微信公众号主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCzsjWxAccountByUids(Long[] uids)
|
||||
{
|
||||
return czsjWxAccountMapper.deleteCzsjWxAccountByUids(uids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除微信公众号信息
|
||||
*
|
||||
* @param uid 微信公众号主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCzsjWxAccountByUid(Long uid)
|
||||
{
|
||||
return czsjWxAccountMapper.deleteCzsjWxAccountByUid(uid);
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.czsj.wechat.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.czsj.wechat.mapper.CzsjWxMessageMapper;
|
||||
import com.czsj.wechat.domain.CzsjWxMessage;
|
||||
import com.czsj.wechat.service.ICzsjWxMessageService;
|
||||
|
||||
/**
|
||||
* 微信消息Service业务层处理
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@Service
|
||||
public class CzsjWxMessageServiceImpl implements ICzsjWxMessageService
|
||||
{
|
||||
@Autowired
|
||||
private CzsjWxMessageMapper czsjWxMessageMapper;
|
||||
|
||||
/**
|
||||
* 查询微信消息
|
||||
*
|
||||
* @param uid 微信消息主键
|
||||
* @return 微信消息
|
||||
*/
|
||||
@Override
|
||||
public CzsjWxMessage selectCzsjWxMessageByUid(Long uid)
|
||||
{
|
||||
return czsjWxMessageMapper.selectCzsjWxMessageByUid(uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询微信消息列表
|
||||
*
|
||||
* @param czsjWxMessage 微信消息
|
||||
* @return 微信消息
|
||||
*/
|
||||
@Override
|
||||
public List<CzsjWxMessage> selectCzsjWxMessageList(CzsjWxMessage czsjWxMessage)
|
||||
{
|
||||
return czsjWxMessageMapper.selectCzsjWxMessageList(czsjWxMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增微信消息
|
||||
*
|
||||
* @param czsjWxMessage 微信消息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCzsjWxMessage(CzsjWxMessage czsjWxMessage)
|
||||
{
|
||||
czsjWxMessage.setCreateTime(DateUtils.getNowDate());
|
||||
return czsjWxMessageMapper.insertCzsjWxMessage(czsjWxMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改微信消息
|
||||
*
|
||||
* @param czsjWxMessage 微信消息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCzsjWxMessage(CzsjWxMessage czsjWxMessage)
|
||||
{
|
||||
czsjWxMessage.setUpdateTime(DateUtils.getNowDate());
|
||||
return czsjWxMessageMapper.updateCzsjWxMessage(czsjWxMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除微信消息
|
||||
*
|
||||
* @param uids 需要删除的微信消息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCzsjWxMessageByUids(Long[] uids)
|
||||
{
|
||||
return czsjWxMessageMapper.deleteCzsjWxMessageByUids(uids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除微信消息信息
|
||||
*
|
||||
* @param uid 微信消息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCzsjWxMessageByUid(Long uid)
|
||||
{
|
||||
return czsjWxMessageMapper.deleteCzsjWxMessageByUid(uid);
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.czsj.wechat.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.czsj.wechat.mapper.CzsjWxQrCodeMapper;
|
||||
import com.czsj.wechat.domain.CzsjWxQrCode;
|
||||
import com.czsj.wechat.service.ICzsjWxQrCodeService;
|
||||
|
||||
/**
|
||||
* 公众号二维码Service业务层处理
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@Service
|
||||
public class CzsjWxQrCodeServiceImpl implements ICzsjWxQrCodeService
|
||||
{
|
||||
@Autowired
|
||||
private CzsjWxQrCodeMapper czsjWxQrCodeMapper;
|
||||
|
||||
/**
|
||||
* 查询公众号二维码
|
||||
*
|
||||
* @param uid 公众号二维码主键
|
||||
* @return 公众号二维码
|
||||
*/
|
||||
@Override
|
||||
public CzsjWxQrCode selectCzsjWxQrCodeByUid(Long uid)
|
||||
{
|
||||
return czsjWxQrCodeMapper.selectCzsjWxQrCodeByUid(uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询公众号二维码列表
|
||||
*
|
||||
* @param czsjWxQrCode 公众号二维码
|
||||
* @return 公众号二维码
|
||||
*/
|
||||
@Override
|
||||
public List<CzsjWxQrCode> selectCzsjWxQrCodeList(CzsjWxQrCode czsjWxQrCode)
|
||||
{
|
||||
return czsjWxQrCodeMapper.selectCzsjWxQrCodeList(czsjWxQrCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增公众号二维码
|
||||
*
|
||||
* @param czsjWxQrCode 公众号二维码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCzsjWxQrCode(CzsjWxQrCode czsjWxQrCode)
|
||||
{
|
||||
czsjWxQrCode.setCreateTime(DateUtils.getNowDate());
|
||||
return czsjWxQrCodeMapper.insertCzsjWxQrCode(czsjWxQrCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改公众号二维码
|
||||
*
|
||||
* @param czsjWxQrCode 公众号二维码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCzsjWxQrCode(CzsjWxQrCode czsjWxQrCode)
|
||||
{
|
||||
czsjWxQrCode.setUpdateTime(DateUtils.getNowDate());
|
||||
return czsjWxQrCodeMapper.updateCzsjWxQrCode(czsjWxQrCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除公众号二维码
|
||||
*
|
||||
* @param uids 需要删除的公众号二维码主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCzsjWxQrCodeByUids(Long[] uids)
|
||||
{
|
||||
return czsjWxQrCodeMapper.deleteCzsjWxQrCodeByUids(uids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除公众号二维码信息
|
||||
*
|
||||
* @param uid 公众号二维码主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCzsjWxQrCodeByUid(Long uid)
|
||||
{
|
||||
return czsjWxQrCodeMapper.deleteCzsjWxQrCodeByUid(uid);
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.czsj.wechat.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.czsj.wechat.mapper.CzsjWxReplyRuleMapper;
|
||||
import com.czsj.wechat.domain.CzsjWxReplyRule;
|
||||
import com.czsj.wechat.service.ICzsjWxReplyRuleService;
|
||||
|
||||
/**
|
||||
* 微信消息回复规则Service业务层处理
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@Service
|
||||
public class CzsjWxReplyRuleServiceImpl implements ICzsjWxReplyRuleService
|
||||
{
|
||||
@Autowired
|
||||
private CzsjWxReplyRuleMapper czsjWxReplyRuleMapper;
|
||||
|
||||
/**
|
||||
* 查询微信消息回复规则
|
||||
*
|
||||
* @param uid 微信消息回复规则主键
|
||||
* @return 微信消息回复规则
|
||||
*/
|
||||
@Override
|
||||
public CzsjWxReplyRule selectCzsjWxReplyRuleByUid(Long uid)
|
||||
{
|
||||
return czsjWxReplyRuleMapper.selectCzsjWxReplyRuleByUid(uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询微信消息回复规则列表
|
||||
*
|
||||
* @param czsjWxReplyRule 微信消息回复规则
|
||||
* @return 微信消息回复规则
|
||||
*/
|
||||
@Override
|
||||
public List<CzsjWxReplyRule> selectCzsjWxReplyRuleList(CzsjWxReplyRule czsjWxReplyRule)
|
||||
{
|
||||
return czsjWxReplyRuleMapper.selectCzsjWxReplyRuleList(czsjWxReplyRule);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增微信消息回复规则
|
||||
*
|
||||
* @param czsjWxReplyRule 微信消息回复规则
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCzsjWxReplyRule(CzsjWxReplyRule czsjWxReplyRule)
|
||||
{
|
||||
czsjWxReplyRule.setCreateTime(DateUtils.getNowDate());
|
||||
return czsjWxReplyRuleMapper.insertCzsjWxReplyRule(czsjWxReplyRule);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改微信消息回复规则
|
||||
*
|
||||
* @param czsjWxReplyRule 微信消息回复规则
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCzsjWxReplyRule(CzsjWxReplyRule czsjWxReplyRule)
|
||||
{
|
||||
czsjWxReplyRule.setUpdateTime(DateUtils.getNowDate());
|
||||
return czsjWxReplyRuleMapper.updateCzsjWxReplyRule(czsjWxReplyRule);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除微信消息回复规则
|
||||
*
|
||||
* @param uids 需要删除的微信消息回复规则主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCzsjWxReplyRuleByUids(Long[] uids)
|
||||
{
|
||||
return czsjWxReplyRuleMapper.deleteCzsjWxReplyRuleByUids(uids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除微信消息回复规则信息
|
||||
*
|
||||
* @param uid 微信消息回复规则主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCzsjWxReplyRuleByUid(Long uid)
|
||||
{
|
||||
return czsjWxReplyRuleMapper.deleteCzsjWxReplyRuleByUid(uid);
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.czsj.wechat.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.czsj.wechat.mapper.CzsjWxTemplateLogMapper;
|
||||
import com.czsj.wechat.domain.CzsjWxTemplateLog;
|
||||
import com.czsj.wechat.service.ICzsjWxTemplateLogService;
|
||||
|
||||
/**
|
||||
* 微信消息模板日志Service业务层处理
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@Service
|
||||
public class CzsjWxTemplateLogServiceImpl implements ICzsjWxTemplateLogService
|
||||
{
|
||||
@Autowired
|
||||
private CzsjWxTemplateLogMapper czsjWxTemplateLogMapper;
|
||||
|
||||
/**
|
||||
* 查询微信消息模板日志
|
||||
*
|
||||
* @param uid 微信消息模板日志主键
|
||||
* @return 微信消息模板日志
|
||||
*/
|
||||
@Override
|
||||
public CzsjWxTemplateLog selectCzsjWxTemplateLogByUid(Long uid)
|
||||
{
|
||||
return czsjWxTemplateLogMapper.selectCzsjWxTemplateLogByUid(uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询微信消息模板日志列表
|
||||
*
|
||||
* @param czsjWxTemplateLog 微信消息模板日志
|
||||
* @return 微信消息模板日志
|
||||
*/
|
||||
@Override
|
||||
public List<CzsjWxTemplateLog> selectCzsjWxTemplateLogList(CzsjWxTemplateLog czsjWxTemplateLog)
|
||||
{
|
||||
return czsjWxTemplateLogMapper.selectCzsjWxTemplateLogList(czsjWxTemplateLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增微信消息模板日志
|
||||
*
|
||||
* @param czsjWxTemplateLog 微信消息模板日志
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCzsjWxTemplateLog(CzsjWxTemplateLog czsjWxTemplateLog)
|
||||
{
|
||||
czsjWxTemplateLog.setCreateTime(DateUtils.getNowDate());
|
||||
return czsjWxTemplateLogMapper.insertCzsjWxTemplateLog(czsjWxTemplateLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改微信消息模板日志
|
||||
*
|
||||
* @param czsjWxTemplateLog 微信消息模板日志
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCzsjWxTemplateLog(CzsjWxTemplateLog czsjWxTemplateLog)
|
||||
{
|
||||
czsjWxTemplateLog.setUpdateTime(DateUtils.getNowDate());
|
||||
return czsjWxTemplateLogMapper.updateCzsjWxTemplateLog(czsjWxTemplateLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除微信消息模板日志
|
||||
*
|
||||
* @param uids 需要删除的微信消息模板日志主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCzsjWxTemplateLogByUids(Long[] uids)
|
||||
{
|
||||
return czsjWxTemplateLogMapper.deleteCzsjWxTemplateLogByUids(uids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除微信消息模板日志信息
|
||||
*
|
||||
* @param uid 微信消息模板日志主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCzsjWxTemplateLogByUid(Long uid)
|
||||
{
|
||||
return czsjWxTemplateLogMapper.deleteCzsjWxTemplateLogByUid(uid);
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.czsj.wechat.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.czsj.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.czsj.wechat.mapper.CzsjWxTemplateMapper;
|
||||
import com.czsj.wechat.domain.CzsjWxTemplate;
|
||||
import com.czsj.wechat.service.ICzsjWxTemplateService;
|
||||
|
||||
/**
|
||||
* 微信消息模板Service业务层处理
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@Service
|
||||
public class CzsjWxTemplateServiceImpl implements ICzsjWxTemplateService
|
||||
{
|
||||
@Autowired
|
||||
private CzsjWxTemplateMapper czsjWxTemplateMapper;
|
||||
|
||||
/**
|
||||
* 查询微信消息模板
|
||||
*
|
||||
* @param uid 微信消息模板主键
|
||||
* @return 微信消息模板
|
||||
*/
|
||||
@Override
|
||||
public CzsjWxTemplate selectCzsjWxTemplateByUid(Long uid)
|
||||
{
|
||||
return czsjWxTemplateMapper.selectCzsjWxTemplateByUid(uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询微信消息模板列表
|
||||
*
|
||||
* @param czsjWxTemplate 微信消息模板
|
||||
* @return 微信消息模板
|
||||
*/
|
||||
@Override
|
||||
public List<CzsjWxTemplate> selectCzsjWxTemplateList(CzsjWxTemplate czsjWxTemplate)
|
||||
{
|
||||
return czsjWxTemplateMapper.selectCzsjWxTemplateList(czsjWxTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增微信消息模板
|
||||
*
|
||||
* @param czsjWxTemplate 微信消息模板
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCzsjWxTemplate(CzsjWxTemplate czsjWxTemplate)
|
||||
{
|
||||
czsjWxTemplate.setCreateTime(DateUtils.getNowDate());
|
||||
return czsjWxTemplateMapper.insertCzsjWxTemplate(czsjWxTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改微信消息模板
|
||||
*
|
||||
* @param czsjWxTemplate 微信消息模板
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCzsjWxTemplate(CzsjWxTemplate czsjWxTemplate)
|
||||
{
|
||||
czsjWxTemplate.setUpdateTime(DateUtils.getNowDate());
|
||||
return czsjWxTemplateMapper.updateCzsjWxTemplate(czsjWxTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除微信消息模板
|
||||
*
|
||||
* @param uids 需要删除的微信消息模板主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCzsjWxTemplateByUids(Long[] uids)
|
||||
{
|
||||
return czsjWxTemplateMapper.deleteCzsjWxTemplateByUids(uids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除微信消息模板信息
|
||||
*
|
||||
* @param uid 微信消息模板主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCzsjWxTemplateByUid(Long uid)
|
||||
{
|
||||
return czsjWxTemplateMapper.deleteCzsjWxTemplateByUid(uid);
|
||||
}
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
package com.czsj.wechat.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.czsj.wechat.utils.PageUtils;
|
||||
import com.czsj.wechat.utils.Query;
|
||||
import com.czsj.wechat.mapper.MsgReplyRuleMapper;
|
||||
import com.czsj.wechat.entity.MsgReplyRule;
|
||||
import com.czsj.wechat.service.MsgReplyRuleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class MsgReplyRuleServiceImpl extends ServiceImpl<MsgReplyRuleMapper, MsgReplyRule> implements MsgReplyRuleService {
|
||||
@Autowired
|
||||
MsgReplyRuleMapper msgReplyRuleMapper;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String matchValue = (String) params.get("matchValue");
|
||||
String appid = (String) params.get("appid");
|
||||
IPage<MsgReplyRule> page = this.page(
|
||||
new Query<MsgReplyRule>().getPage(params),
|
||||
new QueryWrapper<MsgReplyRule>()
|
||||
.eq(StringUtils.hasText(appid), "appid", appid)
|
||||
.or()
|
||||
.apply("appid is null or appid = ''")
|
||||
.like(StringUtils.hasText(matchValue), "match_value", matchValue)
|
||||
.orderByDesc("update_time")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存自动回复规则
|
||||
*
|
||||
* @param msgReplyRule
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean save(MsgReplyRule msgReplyRule) {
|
||||
if (msgReplyRule.getRuleId() > 0) {
|
||||
msgReplyRuleMapper.updateById(msgReplyRule);
|
||||
} else {
|
||||
msgReplyRuleMapper.insert(msgReplyRule);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的回复规则
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<MsgReplyRule> getRules() {
|
||||
return msgReplyRuleMapper.selectList(new QueryWrapper<MsgReplyRule>().orderByDesc("rule_id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时段内所有有效的回复规则
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<MsgReplyRule> getValidRules() {
|
||||
return msgReplyRuleMapper.selectList(
|
||||
new QueryWrapper<MsgReplyRule>()
|
||||
.eq("status", 1)
|
||||
.isNotNull("match_value")
|
||||
.ne("match_value", "")
|
||||
.orderByDesc("priority"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选符合条件的回复规则
|
||||
*
|
||||
*
|
||||
* @param appid 公众号appid
|
||||
* @param exactMatch 是否精确匹配
|
||||
* @param keywords 关键词
|
||||
* @return 规则列表
|
||||
*/
|
||||
@Override
|
||||
public List<MsgReplyRule> getMatchedRules(String appid, boolean exactMatch, String keywords) {
|
||||
LocalTime now = LocalTime.now();
|
||||
return this.getValidRules().stream()
|
||||
.filter(rule->!StringUtils.hasText(rule.getAppid()) || appid.equals(rule.getAppid())) // 检测是否是对应公众号的规则,如果appid为空则为通用规则
|
||||
.filter(rule->null == rule.getEffectTimeStart() || rule.getEffectTimeStart().toLocalTime().isBefore(now))// 检测是否在有效时段,effectTimeStart为null则一直有效
|
||||
.filter(rule->null == rule.getEffectTimeEnd() || rule.getEffectTimeEnd().toLocalTime().isAfter(now)) // 检测是否在有效时段,effectTimeEnd为null则一直有效
|
||||
.filter(rule->isMatch(exactMatch || rule.isExactMatch(),rule.getMatchValue().split(","),keywords)) //检测是否符合匹配规则
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测文字是否匹配规则
|
||||
* 精确匹配时,需关键词与规则词语一致
|
||||
* 非精确匹配时,检测文字需包含任意一个规则词语
|
||||
*
|
||||
* @param exactMatch 是否精确匹配
|
||||
* @param ruleWords 规则列表
|
||||
* @param checkWords 需检测的文字
|
||||
* @return
|
||||
*/
|
||||
public static boolean isMatch(boolean exactMatch, String[] ruleWords, String checkWords) {
|
||||
if (!StringUtils.hasText(checkWords)) {
|
||||
return false;
|
||||
}
|
||||
for (String words : ruleWords) {
|
||||
if (exactMatch && words.equals(checkWords)) {
|
||||
return true;//精确匹配,需关键词与规则词语一致
|
||||
}
|
||||
if (!exactMatch && checkWords.contains(words)) {
|
||||
return true;//模糊匹配
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user