mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 12:39:05 +08:00
🔥 Removing code or files. 删除mybatis-plus 热加载配置
This commit is contained in:
1 parent
1535eec2e9
commit
98af4e3da9
14 files changed
+262
-134
No files matched your search
@@ -62,10 +62,6 @@
|
||||
tableOption: tableOption
|
||||
}
|
||||
},
|
||||
created() {
|
||||
},
|
||||
mounted: function () {
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['permissions']),
|
||||
permissionList() {
|
||||
@@ -98,11 +94,7 @@
|
||||
return delObj(row.$pk.lowerAttrName)
|
||||
}).then(data => {
|
||||
_this.tableData.splice(index, 1)
|
||||
_this.$message({
|
||||
showClose: true,
|
||||
message: '删除成功',
|
||||
type: 'success'
|
||||
})
|
||||
_this.$message.success('删除成功')
|
||||
this.getList(this.page)
|
||||
}).catch(function (err) {
|
||||
})
|
||||
@@ -117,11 +109,7 @@
|
||||
handleUpdate: function (row, index, done) {
|
||||
putObj(row).then(data => {
|
||||
this.tableData.splice(index, 1, Object.assign({}, row))
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: '修改成功',
|
||||
type: 'success'
|
||||
})
|
||||
_this.$message.success('修改成功')
|
||||
done()
|
||||
this.getList(this.page)
|
||||
})
|
||||
@@ -135,11 +123,7 @@
|
||||
handleSave: function (row, done) {
|
||||
addObj(row).then(data => {
|
||||
this.tableData.push(Object.assign({}, row))
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: '添加成功',
|
||||
type: 'success'
|
||||
})
|
||||
_this.$message.success('添加成功')
|
||||
done()
|
||||
this.getList(this.page)
|
||||
})
|
||||
|
||||
+10
-10
@@ -44,7 +44,7 @@ public class WxFansMsgController {
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param wxFansMsg lengleng
|
||||
* @param wxFansMsg 消息
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@@ -54,7 +54,7 @@ public class WxFansMsgController {
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询lengleng
|
||||
* 通过id查询消息
|
||||
*
|
||||
* @param id id
|
||||
* @return R
|
||||
@@ -65,12 +65,12 @@ public class WxFansMsgController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增lengleng
|
||||
* 新增消息
|
||||
*
|
||||
* @param wxFansMsg lengleng
|
||||
* @param wxFansMsg 消息
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("新增lengleng")
|
||||
@SysLog("新增消息")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxfansmsg_add')")
|
||||
public R save(@RequestBody WxFansMsg wxFansMsg) {
|
||||
@@ -78,12 +78,12 @@ public class WxFansMsgController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改lengleng
|
||||
* 修改消息
|
||||
*
|
||||
* @param wxFansMsg lengleng
|
||||
* @param wxFansMsg 消息
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("修改lengleng")
|
||||
@SysLog("修改消息")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxfansmsg_edit')")
|
||||
public R updateById(@RequestBody WxFansMsg wxFansMsg) {
|
||||
@@ -91,12 +91,12 @@ public class WxFansMsgController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除lengleng
|
||||
* 通过id删除消息
|
||||
*
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("删除lengleng")
|
||||
@SysLog("删除消息")
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxfansmsg_del')")
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
|
||||
+11
-11
@@ -44,7 +44,7 @@ public class WxFansMsgResController {
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param wxFansMsgRes lengleng
|
||||
* @param wxFansMsgRes 回复
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@@ -54,7 +54,7 @@ public class WxFansMsgResController {
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询lengleng
|
||||
* 通过id查询回复
|
||||
*
|
||||
* @param id id
|
||||
* @return R
|
||||
@@ -65,25 +65,25 @@ public class WxFansMsgResController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增lengleng
|
||||
* 新增回复
|
||||
*
|
||||
* @param wxFansMsgRes lengleng
|
||||
* @param wxFansMsgRes 回复
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("新增lengleng")
|
||||
@SysLog("新增回复")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxfansmsgres_add')")
|
||||
public R save(@RequestBody WxFansMsgRes wxFansMsgRes) {
|
||||
return new R<>(wxFansMsgResService.save(wxFansMsgRes));
|
||||
return wxFansMsgResService.saveAndSend(wxFansMsgRes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改lengleng
|
||||
* 修改回复
|
||||
*
|
||||
* @param wxFansMsgRes lengleng
|
||||
* @param wxFansMsgRes 回复
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("修改lengleng")
|
||||
@SysLog("修改回复")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxfansmsgres_edit')")
|
||||
public R updateById(@RequestBody WxFansMsgRes wxFansMsgRes) {
|
||||
@@ -91,12 +91,12 @@ public class WxFansMsgResController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除lengleng
|
||||
* 通过id删除回复
|
||||
*
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("删除lengleng")
|
||||
@SysLog("删除回复")
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxfansmsgres_del')")
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
|
||||
+24
-36
@@ -16,11 +16,12 @@
|
||||
*/
|
||||
package com.pig4cloud.pigx.mp.controller;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import com.pig4cloud.pigx.mp.entity.WxMenu;
|
||||
import com.pig4cloud.pigx.mp.entity.WxMpMenu;
|
||||
import com.pig4cloud.pigx.mp.service.WxMenuService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -43,64 +44,51 @@ public class WxMenuController {
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param wxMenu lengleng
|
||||
* @param page 分页对象
|
||||
* @param WxMpMenu lengleng
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getWxMenuPage(Page page, WxMenu wxMenu) {
|
||||
return new R<>(wxMenuService.page(page, Wrappers.query(wxMenu)));
|
||||
public R getWxMpMenuPage(Page page, WxMpMenu WxMpMenu) {
|
||||
return new R<>(wxMenuService.page(page, Wrappers.query(WxMpMenu)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询lengleng
|
||||
* 通过appid查询微信菜单
|
||||
*
|
||||
* @param id id
|
||||
* @param appId 公众号
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable("id") Integer id) {
|
||||
return new R<>(wxMenuService.getById(id));
|
||||
@GetMapping("/{appId}")
|
||||
public R getById(@PathVariable("appId") String appId) {
|
||||
return wxMenuService.getByAppId(appId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增lengleng
|
||||
* 新增微信菜单
|
||||
*
|
||||
* @param wxMenu lengleng
|
||||
* @param WxMpMenus 微信菜单列表
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("新增lengleng")
|
||||
@PostMapping
|
||||
@SysLog("新增微信菜单")
|
||||
@PostMapping("/{appId}")
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxmenu_add')")
|
||||
public R save(@RequestBody WxMenu wxMenu) {
|
||||
return new R<>(wxMenuService.save(wxMenu));
|
||||
public R save(@RequestBody JSONObject WxMpMenus, @PathVariable String appId) {
|
||||
return new R(wxMenuService.save(WxMpMenus, appId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改lengleng
|
||||
* 发布微信菜单
|
||||
*
|
||||
* @param wxMenu lengleng
|
||||
* @param appId 公众号
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("修改lengleng")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxmenu_edit')")
|
||||
public R updateById(@RequestBody WxMenu wxMenu) {
|
||||
return new R<>(wxMenuService.updateById(wxMenu));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除lengleng
|
||||
*
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("删除lengleng")
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxmenu_del')")
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
return new R<>(wxMenuService.removeById(id));
|
||||
@SysLog("发布微信菜单")
|
||||
@PutMapping("/{appId}")
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxmenu_push')")
|
||||
public R updateById(@PathVariable String appId) {
|
||||
return wxMenuService.push(appId);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -89,7 +89,7 @@ public class WxAccountFans extends Model<WxAccountFans> {
|
||||
/**
|
||||
* 微信公众号ID
|
||||
*/
|
||||
private String wxAccountId;
|
||||
private Integer wxAccountId;
|
||||
/**
|
||||
* 微信公众号appid
|
||||
*/
|
||||
|
||||
+2
-2
@@ -44,7 +44,7 @@ public class WxFansMsgRes extends Model<WxFansMsgRes> {
|
||||
/**
|
||||
* 粉丝消息ID
|
||||
*/
|
||||
private String fansMsgId;
|
||||
private Integer fansMsgId;
|
||||
/**
|
||||
* 回复内容
|
||||
*/
|
||||
@@ -52,7 +52,7 @@ public class WxFansMsgRes extends Model<WxFansMsgRes> {
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String userId;
|
||||
private Integer userId;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
|
||||
+20
-33
@@ -17,6 +17,7 @@
|
||||
package com.pig4cloud.pigx.mp.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
@@ -33,7 +34,7 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
@TableName("t_wx_menu")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WxMenu extends Model<WxMenu> {
|
||||
public class WxMpMenu extends Model<WxMpMenu> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
@@ -41,46 +42,26 @@ public class WxMenu extends Model<WxMenu> {
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 父ID
|
||||
* 菜单
|
||||
*/
|
||||
private String parentId;
|
||||
private String menu;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
* 微信公众号ID
|
||||
*/
|
||||
private String menuName;
|
||||
private Integer wxAccountId;
|
||||
/**
|
||||
* 菜单类型 1文本消息;2图文消息;3网址链接;4小程序
|
||||
* 微信公众号appid
|
||||
*/
|
||||
private String menuType;
|
||||
private String wxAccountAppid;
|
||||
|
||||
/**
|
||||
* 菜单等级
|
||||
* 微信公众号名
|
||||
*/
|
||||
private String menuLevel;
|
||||
/**
|
||||
* 模板ID
|
||||
*/
|
||||
private String tplId;
|
||||
/**
|
||||
* 菜单URL
|
||||
*/
|
||||
private String menuUrl;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private String menuSort;
|
||||
/**
|
||||
* 微信账号ID
|
||||
*/
|
||||
private String wxAccountId;
|
||||
/**
|
||||
* 小程序appid
|
||||
*/
|
||||
private String miniprogramAppid;
|
||||
/**
|
||||
* 小程序页面路径
|
||||
*/
|
||||
private String miniprogramPagepath;
|
||||
private String wxAccountName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@@ -90,4 +71,10 @@ public class WxMenu extends Model<WxMenu> {
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 是否删除 -1:已删除 0:正常
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
}
|
||||
+2
-2
@@ -17,7 +17,7 @@
|
||||
package com.pig4cloud.pigx.mp.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.pig4cloud.pigx.mp.entity.WxMenu;
|
||||
import com.pig4cloud.pigx.mp.entity.WxMpMenu;
|
||||
|
||||
/**
|
||||
* lengleng
|
||||
@@ -25,6 +25,6 @@ import com.pig4cloud.pigx.mp.entity.WxMenu;
|
||||
* @author pigx code generator
|
||||
* @date 2019-03-27 20:45:18
|
||||
*/
|
||||
public interface WxMenuMapper extends BaseMapper<WxMenu> {
|
||||
public interface WxMenuMapper extends BaseMapper<WxMpMenu> {
|
||||
|
||||
}
|
||||
+8
@@ -17,6 +17,7 @@
|
||||
package com.pig4cloud.pigx.mp.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.mp.entity.WxFansMsgRes;
|
||||
|
||||
/**
|
||||
@@ -27,4 +28,11 @@ import com.pig4cloud.pigx.mp.entity.WxFansMsgRes;
|
||||
*/
|
||||
public interface WxFansMsgResService extends IService<WxFansMsgRes> {
|
||||
|
||||
/**
|
||||
* 保存并发送回复
|
||||
*
|
||||
* @param wxFansMsgRes
|
||||
* @return
|
||||
*/
|
||||
R saveAndSend(WxFansMsgRes wxFansMsgRes);
|
||||
}
|
||||
+28
-2
@@ -16,8 +16,10 @@
|
||||
*/
|
||||
package com.pig4cloud.pigx.mp.service;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.pig4cloud.pigx.mp.entity.WxMenu;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.mp.entity.WxMpMenu;
|
||||
|
||||
/**
|
||||
* 微信菜单业务
|
||||
@@ -25,6 +27,30 @@ import com.pig4cloud.pigx.mp.entity.WxMenu;
|
||||
* @author lengleng
|
||||
* @date 2019-03-27 20:45:18
|
||||
*/
|
||||
public interface WxMenuService extends IService<WxMenu> {
|
||||
public interface WxMenuService extends IService<WxMpMenu> {
|
||||
|
||||
/**
|
||||
* 新增微信公众号按钮
|
||||
*
|
||||
* @param wxMenus json
|
||||
* @param appId 公众号信息
|
||||
* @return
|
||||
*/
|
||||
Boolean save(JSONObject wxMenus, String appId);
|
||||
|
||||
/**
|
||||
* 发布到微信
|
||||
*
|
||||
* @param appId 公众号信息
|
||||
* @return
|
||||
*/
|
||||
R push(String appId);
|
||||
|
||||
/**
|
||||
* 通过appid 查询菜单信息
|
||||
*
|
||||
* @param appId
|
||||
* @return
|
||||
*/
|
||||
R getByAppId(String appId);
|
||||
}
|
||||
+1
-1
@@ -117,7 +117,7 @@ public class WxAccountFansServiceImpl extends ServiceImpl<WxAccountFansMapper, W
|
||||
wxAccountFans.setCity(wxMpUser.getCity());
|
||||
wxAccountFans.setHeadimgUrl(wxMpUser.getHeadImgUrl());
|
||||
wxAccountFans.setRemark(wxMpUser.getRemark());
|
||||
wxAccountFans.setWxAccountId(String.valueOf(wxAccount.getId()));
|
||||
wxAccountFans.setWxAccountId(wxAccount.getId());
|
||||
wxAccountFans.setWxAccountAppid(wxAccount.getAppid());
|
||||
wxAccountFans.setWxAccountName(wxAccount.getName());
|
||||
wxAccountFansList.add(wxAccountFans);
|
||||
|
||||
+56
@@ -17,10 +17,23 @@
|
||||
package com.pig4cloud.pigx.mp.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.security.service.PigxUser;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import com.pig4cloud.pigx.mp.config.WxMpConfiguration;
|
||||
import com.pig4cloud.pigx.mp.entity.WxFansMsg;
|
||||
import com.pig4cloud.pigx.mp.entity.WxFansMsgRes;
|
||||
import com.pig4cloud.pigx.mp.mapper.WxFansMsgMapper;
|
||||
import com.pig4cloud.pigx.mp.mapper.WxFansMsgResMapper;
|
||||
import com.pig4cloud.pigx.mp.service.WxFansMsgResService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 微信消息回复业务
|
||||
@@ -28,7 +41,50 @@ import org.springframework.stereotype.Service;
|
||||
* @author lengleng
|
||||
* @date 2019-03-27 20:45:48
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class WxFansMsgResServiceImpl extends ServiceImpl<WxFansMsgResMapper, WxFansMsgRes> implements WxFansMsgResService {
|
||||
private final WxFansMsgMapper wxFansMsgMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 保存并发送回复
|
||||
* <p>
|
||||
* 1. 根据消息ID 查询消息的所属 公众号信息
|
||||
* 2. 构建文本客服消息并发送
|
||||
* 3. 完善回复消息并保存
|
||||
* 4. 更新微信消息为已回复
|
||||
*
|
||||
* @param wxFansMsgRes
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R saveAndSend(WxFansMsgRes wxFansMsgRes) {
|
||||
WxFansMsg wxFansMsg = wxFansMsgMapper.selectById(wxFansMsgRes.getFansMsgId());
|
||||
|
||||
String wxAccountAppid = wxFansMsg.getWxAccountAppid();
|
||||
WxMpService wxMpService = WxMpConfiguration.getMpServices().get(wxAccountAppid);
|
||||
|
||||
try {
|
||||
wxMpService.getKefuService().sendKefuMessage(WxMpKefuMessage
|
||||
.TEXT()
|
||||
.toUser(wxFansMsg.getOpenid())
|
||||
.content(wxFansMsgRes.getResContent())
|
||||
.build());
|
||||
} catch (WxErrorException e) {
|
||||
log.error("发送客服消息失败 ", e);
|
||||
return R.builder().code(CommonConstants.FAIL).msg(e.getError().getErrorMsg()).build();
|
||||
}
|
||||
|
||||
PigxUser user = SecurityUtils.getUser();
|
||||
wxFansMsgRes.setUserId(user.getId());
|
||||
wxFansMsgRes.setUserName(user.getUsername());
|
||||
baseMapper.insert(wxFansMsgRes);
|
||||
|
||||
wxFansMsg.setIsRes("1");
|
||||
wxFansMsgMapper.updateById(wxFansMsg);
|
||||
return R.builder().build();
|
||||
}
|
||||
}
|
||||
+96
-2
@@ -16,11 +16,27 @@
|
||||
*/
|
||||
package com.pig4cloud.pigx.mp.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.mp.entity.WxMenu;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.mp.config.WxMpConfiguration;
|
||||
import com.pig4cloud.pigx.mp.entity.WxAccount;
|
||||
import com.pig4cloud.pigx.mp.entity.WxMpMenu;
|
||||
import com.pig4cloud.pigx.mp.mapper.WxAccountMapper;
|
||||
import com.pig4cloud.pigx.mp.mapper.WxMenuMapper;
|
||||
import com.pig4cloud.pigx.mp.service.WxMenuService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.WxMpMenuService;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信菜单业务
|
||||
@@ -28,7 +44,85 @@ import org.springframework.stereotype.Service;
|
||||
* @author lengleng
|
||||
* @date 2019-03-27 20:45:18
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WxMenuServiceImpl extends ServiceImpl<WxMenuMapper, WxMenu> implements WxMenuService {
|
||||
@AllArgsConstructor
|
||||
public class WxMenuServiceImpl extends ServiceImpl<WxMenuMapper, WxMpMenu> implements WxMenuService {
|
||||
private static final String MENU = "menu";
|
||||
private final WxAccountMapper wxAccountMapper;
|
||||
|
||||
/**
|
||||
* 新增微信公众号按钮
|
||||
*
|
||||
* @param wxMenus json
|
||||
* @param appId 公众号
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean save(JSONObject wxMenus, String appId) {
|
||||
baseMapper.delete(Wrappers.<WxMpMenu>lambdaQuery()
|
||||
.eq(WxMpMenu::getWxAccountAppid, appId));
|
||||
|
||||
WxAccount wxAccount = wxAccountMapper
|
||||
.selectOne(Wrappers.<WxAccount>lambdaQuery()
|
||||
.eq(WxAccount::getAppid, appId));
|
||||
WxMpMenu wxMpMenu = new WxMpMenu();
|
||||
wxMpMenu.setMenu(wxMenus.toStringPretty());
|
||||
wxMpMenu.setWxAccountId(wxAccount.getId());
|
||||
wxMpMenu.setWxAccountAppid(wxAccount.getAppid());
|
||||
wxMpMenu.setWxAccountName(wxAccount.getName());
|
||||
baseMapper.insert(wxMpMenu);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布到微信
|
||||
*
|
||||
* @param appId 公众号信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R push(String appId) {
|
||||
List<WxMpMenu> wxMpMenuList = baseMapper.selectList(Wrappers.<WxMpMenu>lambdaQuery()
|
||||
.eq(WxMpMenu::getWxAccountAppid, appId));
|
||||
|
||||
if (CollUtil.isEmpty(wxMpMenuList)) {
|
||||
return R.builder()
|
||||
.code(CommonConstants.FAIL)
|
||||
.msg("微信菜单配置为空,不能发布").build();
|
||||
}
|
||||
|
||||
WxMpService wxMpService = WxMpConfiguration.getMpServices().get(appId);
|
||||
WxMpMenuService menuService = wxMpService.getMenuService();
|
||||
|
||||
// 给数据库保存的加一层
|
||||
JSONObject jsonObject = new JSONObject(wxMpMenuList.get(0).getMenu());
|
||||
jsonObject.put(MENU, jsonObject);
|
||||
try {
|
||||
menuService.menuCreate(jsonObject.toStringPretty());
|
||||
} catch (WxErrorException e) {
|
||||
return R.builder()
|
||||
.code(CommonConstants.FAIL)
|
||||
.msg(e.getError().getErrorMsg()).build();
|
||||
}
|
||||
return R.builder().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过appid 查询菜单信息
|
||||
*
|
||||
* @param appId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R getByAppId(String appId) {
|
||||
List<WxMpMenu> wxMpMenuList = baseMapper.selectList(Wrappers.<WxMpMenu>lambdaQuery()
|
||||
.eq(WxMpMenu::getWxAccountAppid, appId));
|
||||
|
||||
if (CollUtil.isEmpty(wxMpMenuList)) {
|
||||
return R.builder().build();
|
||||
}
|
||||
return R.builder().data(wxMpMenuList.get(0).getMenu()).build();
|
||||
}
|
||||
}
|
||||
@@ -23,19 +23,4 @@
|
||||
|
||||
<mapper namespace="com.pig4cloud.pigx.mp.mapper.WxMenuMapper">
|
||||
|
||||
<resultMap id="wxMenuMap" type="com.pig4cloud.pigx.mp.entity.WxMenu">
|
||||
<id property="id" column="id"/>
|
||||
<result property="parentId" column="parent_id"/>
|
||||
<result property="menuName" column="menu_name"/>
|
||||
<result property="menuType" column="menu_type"/>
|
||||
<result property="menuLevel" column="menu_level"/>
|
||||
<result property="tplId" column="tpl_id"/>
|
||||
<result property="menuUrl" column="menu_url"/>
|
||||
<result property="menuSort" column="menu_sort"/>
|
||||
<result property="wxAccountId" column="wx_account_id"/>
|
||||
<result property="miniprogramAppid" column="miniprogram_appid"/>
|
||||
<result property="miniprogramPagepath" column="miniprogram_pagepath"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user