mp:完善公众号的账号管理

pull/2/head
YunaiV 2023-01-01 20:39:47 +08:00
parent 48520a456b
commit 627cb39517
26 changed files with 256 additions and 471 deletions

View File

@ -0,0 +1,71 @@
package cn.iocoder.yudao.module.mp.controller.admin.account;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.*;
import cn.iocoder.yudao.module.mp.convert.account.MpAccountConvert;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
import cn.iocoder.yudao.module.mp.service.account.WxAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Api(tags = "管理后台 - 公众号账户")
@RestController
@RequestMapping("/mp/account")
@Validated
public class MpAccountController {
@Resource
private WxAccountService wxAccountService;
@PostMapping("/create")
@ApiOperation("创建公众号账户")
@PreAuthorize("@ss.hasPermission('mp:account:create')")
public CommonResult<Long> createWxAccount(@Valid @RequestBody MpAccountCreateReqVO createReqVO) {
return success(wxAccountService.createAccount(createReqVO));
}
@PutMapping("/update")
@ApiOperation("更新公众号账户")
@PreAuthorize("@ss.hasPermission('mp:account:update')")
public CommonResult<Boolean> updateWxAccount(@Valid @RequestBody MpAccountUpdateReqVO updateReqVO) {
wxAccountService.updateAccount(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@ApiOperation("删除公众号账户")
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('mp:account:delete')")
public CommonResult<Boolean> deleteWxAccount(@RequestParam("id") Long id) {
wxAccountService.deleteAccount(id);
return success(true);
}
@GetMapping("/get")
@ApiOperation("获得公众号账户")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('mp:account:query')")
public CommonResult<MpAccountRespVO> getWxAccount(@RequestParam("id") Long id) {
MpAccountDO wxAccount = wxAccountService.getAccount(id);
return success(MpAccountConvert.INSTANCE.convert(wxAccount));
}
@GetMapping("/page")
@ApiOperation("获得公众号账户分页")
@PreAuthorize("@ss.hasPermission('mp:account:query')")
public CommonResult<PageResult<MpAccountRespVO>> getWxAccountPage(@Valid MpAccountPageReqVO pageVO) {
PageResult<MpAccountDO> pageResult = wxAccountService.getAccountPage(pageVO);
return success(MpAccountConvert.INSTANCE.convertPage(pageResult));
}
}

View File

@ -1,102 +0,0 @@
package cn.iocoder.yudao.module.mp.controller.admin.account;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.*;
import cn.iocoder.yudao.module.mp.convert.account.WxAccountConvert;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO;
import cn.iocoder.yudao.module.mp.service.account.WxAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
/**
* @author fengdan
*/
@Api(tags = "管理后台 - 公众号账户")
@RestController
@RequestMapping("/wechatMp/account")
@Validated
public class WxAccountController {
@Resource
private WxAccountService wxAccountService;
@PostMapping("/create")
@ApiOperation("创建公众号账户")
@PreAuthorize("@ss.hasPermission('wechatMp:account:create')")
public CommonResult<Long> createWxAccount(@Valid @RequestBody WxAccountCreateReqVO createReqVO) {
return success(wxAccountService.createWxAccount(createReqVO));
}
@PutMapping("/update")
@ApiOperation("更新公众号账户")
@PreAuthorize("@ss.hasPermission('wechatMp:account:update')")
public CommonResult<Boolean> updateWxAccount(@Valid @RequestBody WxAccountUpdateReqVO updateReqVO) {
wxAccountService.updateWxAccount(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@ApiOperation("删除公众号账户")
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('wechatMp:account:delete')")
public CommonResult<Boolean> deleteWxAccount(@RequestParam("id") Long id) {
wxAccountService.deleteWxAccount(id);
return success(true);
}
@GetMapping("/get")
@ApiOperation("获得公众号账户")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('wechatMp:account:query')")
public CommonResult<WxAccountRespVO> getWxAccount(@RequestParam("id") Long id) {
WxAccountDO wxAccount = wxAccountService.getWxAccount(id);
return success(WxAccountConvert.INSTANCE.convert(wxAccount));
}
@GetMapping("/list")
@ApiOperation("获得公众号账户列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
@PreAuthorize("@ss.hasPermission('wechatMp:account:query')")
public CommonResult<List<WxAccountRespVO>> getWxAccountList(@RequestParam("ids") Collection<Long> ids) {
List<WxAccountDO> list = wxAccountService.getWxAccountList(ids);
return success(WxAccountConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@ApiOperation("获得公众号账户分页")
@PreAuthorize("@ss.hasPermission('wechatMp:account:query')")
public CommonResult<PageResult<WxAccountRespVO>> getWxAccountPage(@Valid WxAccountPageReqVO pageVO) {
PageResult<WxAccountDO> pageResult = wxAccountService.getWxAccountPage(pageVO);
return success(WxAccountConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@ApiOperation("导出公众号账户 Excel")
@PreAuthorize("@ss.hasPermission('wechatMp:account:export')")
@OperateLog(type = EXPORT)
public void exportWxAccountExcel(@Valid WxAccountExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<WxAccountDO> list = wxAccountService.getWxAccountList(exportReqVO);
// 导出 Excel
List<WxAccountExcelVO> datas = WxAccountConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "公众号账户.xls", "数据", WxAccountExcelVO.class, datas);
}
}

View File

@ -12,7 +12,7 @@ import javax.validation.constraints.NotNull;
* @author fengdan * @author fengdan
*/ */
@Data @Data
public class WxAccountBaseVO { public class MpAccountBaseVO {
@ApiModelProperty(value = "公众号名称", required = true) @ApiModelProperty(value = "公众号名称", required = true)
@NotNull(message = "公众号名称不能为空") @NotNull(message = "公众号名称不能为空")
@ -30,7 +30,7 @@ public class WxAccountBaseVO {
@NotNull(message = "公众号密钥不能为空") @NotNull(message = "公众号密钥不能为空")
private String appSecret; private String appSecret;
@ApiModelProperty(value = "公众号token") @ApiModelProperty(value = "公众号 token", required = true)
private String token; private String token;
@ApiModelProperty(value = "加密密钥") @ApiModelProperty(value = "加密密钥")

View File

@ -5,13 +5,10 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
/**
* @author fengdan
*/
@ApiModel("管理后台 - 公众号账户创建 Request VO") @ApiModel("管理后台 - 公众号账户创建 Request VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class WxAccountCreateReqVO extends WxAccountBaseVO { public class MpAccountCreateReqVO extends MpAccountBaseVO {
} }

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.mp.controller.admin.account.vo;
import lombok.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@ApiModel("管理后台 - 公众号账户分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MpAccountPageReqVO extends PageParam {
@ApiModelProperty(value = "公众号名称", notes = "模糊匹配")
private String name;
@ApiModelProperty(value = "公众号账户", notes = "模糊匹配")
private String account;
@ApiModelProperty(value = "公众号 appid", notes = "模糊匹配")
private String appId;
}

View File

@ -15,14 +15,11 @@ import java.util.Date;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class WxAccountRespVO extends WxAccountBaseVO { public class MpAccountRespVO extends MpAccountBaseVO {
@ApiModelProperty(value = "编号", required = true) @ApiModelProperty(value = "编号", required = true)
private Long id; private Long id;
@ApiModelProperty(value = "公众号url")
private String url;
@ApiModelProperty(value = "二维码图片URL") @ApiModelProperty(value = "二维码图片URL")
private String qrCodeUrl; private String qrCodeUrl;
@ -31,4 +28,5 @@ public class WxAccountRespVO extends WxAccountBaseVO {
@ApiModelProperty(value = "公众号密钥", required = true) @ApiModelProperty(value = "公众号密钥", required = true)
private String appSecret; private String appSecret;
} }

View File

@ -11,7 +11,7 @@ import javax.validation.constraints.*;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class WxAccountUpdateReqVO extends WxAccountBaseVO { public class MpAccountUpdateReqVO extends MpAccountBaseVO {
@ApiModelProperty(value = "编号", required = true) @ApiModelProperty(value = "编号", required = true)
@NotNull(message = "编号不能为空") @NotNull(message = "编号不能为空")

View File

@ -1,46 +0,0 @@
package cn.iocoder.yudao.module.mp.controller.admin.account.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.util.Date;
/**
* Excel VO
*
* @author
*/
@Data
public class WxAccountExcelVO {
@ExcelProperty("编号")
private Long id;
@ExcelProperty("公众号名称")
private String name;
@ExcelProperty("公众号账户")
private String account;
@ExcelProperty("公众号appid")
private String appId;
@ExcelProperty("公众号url")
private String url;
@ExcelProperty("公众号token")
private String token;
@ExcelProperty("加密密钥")
private String aesKey;
@ExcelProperty("二维码图片URL")
private String qrCodeUrl;
@ExcelProperty("备注")
private String remark;
@ExcelProperty("创建时间")
private Date createTime;
}

View File

@ -1,34 +0,0 @@
package cn.iocoder.yudao.module.mp.controller.admin.account.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* @author fengdan
*/
@ApiModel(value = "管理后台 - 公众号账户 Excel 导出 Request VO", description = "参数和 WxAccountPageReqVO 是一致的")
@Data
public class WxAccountExportReqVO {
@ApiModelProperty(value = "公众号名称")
private String name;
@ApiModelProperty(value = "公众号账户")
private String account;
@ApiModelProperty(value = "公众号appid")
private String appId;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
}

View File

@ -1,35 +0,0 @@
package cn.iocoder.yudao.module.mp.controller.admin.account.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* @author fengdan
*/
@ApiModel("管理后台 - 公众号账户分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class WxAccountPageReqVO extends PageParam {
@ApiModelProperty(value = "公众号名称")
private String name;
@ApiModelProperty(value = "公众号账户")
private String account;
@ApiModelProperty(value = "公众号appid")
private String appId;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.mp.convert.account;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountCreateReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountRespVO;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReqVO;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface MpAccountConvert {
MpAccountConvert INSTANCE = Mappers.getMapper(MpAccountConvert.class);
MpAccountDO convert(MpAccountCreateReqVO bean);
MpAccountDO convert(MpAccountUpdateReqVO bean);
MpAccountRespVO convert(MpAccountDO bean);
List<MpAccountRespVO> convertList(List<MpAccountDO> list);
PageResult<MpAccountRespVO> convertPage(PageResult<MpAccountDO> page);
}

View File

@ -1,36 +0,0 @@
package cn.iocoder.yudao.module.mp.convert.account;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountCreateReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountExcelVO;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountRespVO;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountUpdateReqVO;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* Convert
*
* @author
*/
@Mapper
public interface WxAccountConvert {
WxAccountConvert INSTANCE = Mappers.getMapper(WxAccountConvert.class);
WxAccountDO convert(WxAccountCreateReqVO bean);
WxAccountDO convert(WxAccountUpdateReqVO bean);
WxAccountRespVO convert(WxAccountDO bean);
List<WxAccountRespVO> convertList(List<WxAccountDO> list);
PageResult<WxAccountRespVO> convertPage(PageResult<WxAccountDO> page);
List<WxAccountExcelVO> convertList02(List<WxAccountDO> list);
}

View File

@ -10,21 +10,20 @@ import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps;
import me.chanjar.weixin.mp.config.WxMpConfigStorage; import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl; import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl;
// TODO 亚洲:这个模块的相关类,使用 Mp 作为前缀哈
/** /**
* DO * DO
* *
* @author * @author
*/ */
@TableName("wx_account") @TableName("mp_account")
@KeySequence("wx_account_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @KeySequence("mp_account_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class WxAccountDO extends BaseDO { public class MpAccountDO extends BaseDO {
/** /**
* *
@ -47,10 +46,6 @@ public class WxAccountDO extends BaseDO {
* *
*/ */
private String appSecret; private String appSecret;
/**
* url
*/
private String url;
/** /**
* token * token
*/ */
@ -68,6 +63,7 @@ public class WxAccountDO extends BaseDO {
*/ */
private String remark; private String remark;
// TODO 芋艿:需要迁移走
public WxMpConfigStorage toWxMpConfigStorage(RedisTemplateWxRedisOps redisTemplateWxRedisOps, WxMpProperties wxMpProperties) { public WxMpConfigStorage toWxMpConfigStorage(RedisTemplateWxRedisOps redisTemplateWxRedisOps, WxMpProperties wxMpProperties) {
WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisTemplateWxRedisOps, wxMpProperties.getConfigStorage().getKeyPrefix()); WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisTemplateWxRedisOps, wxMpProperties.getConfigStorage().getKeyPrefix());
wxMpRedisConfig.setAppId(appId); wxMpRedisConfig.setAppId(appId);

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.mp.dal.mysql.account;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountPageReqVO;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MpAccountMapper extends BaseMapperX<MpAccountDO> {
default PageResult<MpAccountDO> selectPage(MpAccountPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MpAccountDO>()
.likeIfPresent(MpAccountDO::getName, reqVO.getName())
.likeIfPresent(MpAccountDO::getAccount, reqVO.getAccount())
.likeIfPresent(MpAccountDO::getAppId, reqVO.getAppId())
.orderByDesc(MpAccountDO::getId));
}
}

View File

@ -1,39 +0,0 @@
package cn.iocoder.yudao.module.mp.dal.mysql.account;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountExportReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountPageReqVO;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* Mapper
*
* @author
*/
@Mapper
public interface WxAccountMapper extends BaseMapperX<WxAccountDO> {
default PageResult<WxAccountDO> selectPage(WxAccountPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<WxAccountDO>()
.likeIfPresent(WxAccountDO::getName, reqVO.getName())
.eqIfPresent(WxAccountDO::getAccount, reqVO.getAccount())
.eqIfPresent(WxAccountDO::getAppId, reqVO.getAppId())
.betweenIfPresent(WxAccountDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(WxAccountDO::getId));
}
default List<WxAccountDO> selectList(WxAccountExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<WxAccountDO>()
.likeIfPresent(WxAccountDO::getName, reqVO.getName())
.eqIfPresent(WxAccountDO::getAccount, reqVO.getAccount())
.eqIfPresent(WxAccountDO::getAppId, reqVO.getAppId())
.betweenIfPresent(WxAccountDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(WxAccountDO::getId));
}
}

View File

@ -7,7 +7,7 @@ import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.module.infra.api.file.FileApi; import cn.iocoder.yudao.module.infra.api.file.FileApi;
import cn.iocoder.yudao.module.mp.builder.TextBuilder; import cn.iocoder.yudao.module.mp.builder.TextBuilder;
import cn.iocoder.yudao.module.mp.controller.admin.fansmsg.vo.WxFansMsgCreateReqVO; import cn.iocoder.yudao.module.mp.controller.admin.fansmsg.vo.WxFansMsgCreateReqVO;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO; import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
import cn.iocoder.yudao.module.mp.service.account.WxAccountService; import cn.iocoder.yudao.module.mp.service.account.WxAccountService;
import cn.iocoder.yudao.module.mp.service.fansmsg.WxFansMsgService; import cn.iocoder.yudao.module.mp.service.fansmsg.WxFansMsgService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -55,7 +55,7 @@ public class MsgHandler implements WxMpMessageHandler {
WxMpUser wxmpUser = weixinService.getUserService() WxMpUser wxmpUser = weixinService.getUserService()
.userInfo(wxMessage.getFromUser(), null); .userInfo(wxMessage.getFromUser(), null);
if (wxmpUser != null) { if (wxmpUser != null) {
WxAccountDO wxAccount = wxAccountService.findBy(WxAccountDO::getAccount, wxMessage.getToUser()); MpAccountDO wxAccount = wxAccountService.findBy(MpAccountDO::getAccount, wxMessage.getToUser());
if (wxAccount != null) { if (wxAccount != null) {
if (wxMessage.getMsgType().equals(WxConsts.XmlMsgType.TEXT)) { if (wxMessage.getMsgType().equals(WxConsts.XmlMsgType.TEXT)) {

View File

@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.module.mp.builder.TextBuilder; import cn.iocoder.yudao.module.mp.builder.TextBuilder;
import cn.iocoder.yudao.module.mp.controller.admin.accountfans.vo.WxAccountFansCreateReqVO; import cn.iocoder.yudao.module.mp.controller.admin.accountfans.vo.WxAccountFansCreateReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.accountfans.vo.WxAccountFansUpdateReqVO; import cn.iocoder.yudao.module.mp.controller.admin.accountfans.vo.WxAccountFansUpdateReqVO;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO; import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
import cn.iocoder.yudao.module.mp.dal.dataobject.accountfans.WxAccountFansDO; import cn.iocoder.yudao.module.mp.dal.dataobject.accountfans.WxAccountFansDO;
import cn.iocoder.yudao.module.mp.dal.dataobject.subscribetext.WxSubscribeTextDO; import cn.iocoder.yudao.module.mp.dal.dataobject.subscribetext.WxSubscribeTextDO;
import cn.iocoder.yudao.module.mp.dal.dataobject.texttemplate.WxTextTemplateDO; import cn.iocoder.yudao.module.mp.dal.dataobject.texttemplate.WxTextTemplateDO;
@ -60,7 +60,7 @@ public class SubscribeHandler implements WxMpMessageHandler {
.userInfo(wxMessage.getFromUser(), null); .userInfo(wxMessage.getFromUser(), null);
if (wxmpUser != null) { if (wxmpUser != null) {
// 可以添加关注用户到本地数据库 // 可以添加关注用户到本地数据库
WxAccountDO wxAccount = wxAccountService.findBy(WxAccountDO::getAccount, wxMessage.getToUser()); MpAccountDO wxAccount = wxAccountService.findBy(MpAccountDO::getAccount, wxMessage.getToUser());
if (wxAccount != null) { if (wxAccount != null) {
WxAccountFansDO wxAccountFans = wxAccountFansService.findBy(WxAccountFansDO::getOpenid, wxmpUser.getOpenId()); WxAccountFansDO wxAccountFans = wxAccountFansService.findBy(WxAccountFansDO::getOpenid, wxmpUser.getOpenId());
if (wxAccountFans == null) {//insert if (wxAccountFans == null) {//insert
@ -128,7 +128,7 @@ public class SubscribeHandler implements WxMpMessageHandler {
try { try {
String content = "感谢关注!";//默认 String content = "感谢关注!";//默认
WxAccountDO wxAccount = wxAccountService.findBy(WxAccountDO::getAccount, wxMessage.getToUser()); MpAccountDO wxAccount = wxAccountService.findBy(MpAccountDO::getAccount, wxMessage.getToUser());
if (wxAccount != null) { if (wxAccount != null) {
WxSubscribeTextDO wxSubscribeText = wxSubscribeTextService.findBy(WxSubscribeTextDO::getWxAccountId, String.valueOf(wxAccount.getId())); WxSubscribeTextDO wxSubscribeText = wxSubscribeTextService.findBy(WxSubscribeTextDO::getWxAccountId, String.valueOf(wxAccount.getId()));
if (wxSubscribeText != null) { if (wxSubscribeText != null) {

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.mp.handler; package cn.iocoder.yudao.module.mp.handler;
import cn.iocoder.yudao.module.mp.controller.admin.accountfans.vo.WxAccountFansUpdateReqVO; import cn.iocoder.yudao.module.mp.controller.admin.accountfans.vo.WxAccountFansUpdateReqVO;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO; import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
import cn.iocoder.yudao.module.mp.dal.dataobject.accountfans.WxAccountFansDO; import cn.iocoder.yudao.module.mp.dal.dataobject.accountfans.WxAccountFansDO;
import cn.iocoder.yudao.module.mp.service.account.WxAccountService; import cn.iocoder.yudao.module.mp.service.account.WxAccountService;
import cn.iocoder.yudao.module.mp.service.accountfans.WxAccountFansService; import cn.iocoder.yudao.module.mp.service.accountfans.WxAccountFansService;
@ -34,7 +34,7 @@ public class UnsubscribeHandler implements WxMpMessageHandler {
log.info("取消关注用户 OPENID: " + openId); log.info("取消关注用户 OPENID: " + openId);
// TODO 可以更新本地数据库为取消关注状态 // TODO 可以更新本地数据库为取消关注状态
WxAccountDO wxAccountDO = wxAccountService.findBy(WxAccountDO::getAccount, wxMessage.getToUser()); MpAccountDO wxAccountDO = wxAccountService.findBy(MpAccountDO::getAccount, wxMessage.getToUser());
if (wxAccountDO != null) { if (wxAccountDO != null) {
WxAccountFansDO wxAccountFansDO = wxAccountFansService.findBy(WxAccountFansDO::getOpenid, openId); WxAccountFansDO wxAccountFansDO = wxAccountFansService.findBy(WxAccountFansDO::getOpenid, openId);
if (wxAccountFansDO != null) { if (wxAccountFansDO != null) {

View File

@ -1,16 +1,13 @@
package cn.iocoder.yudao.module.mp.service.account; package cn.iocoder.yudao.module.mp.service.account;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountCreateReqVO; import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountCreateReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountExportReqVO; import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountPageReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountPageReqVO; import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountUpdateReqVO; import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
/** /**
* Service * Service
@ -25,21 +22,21 @@ public interface WxAccountService {
* @param createReqVO * @param createReqVO
* @return * @return
*/ */
Long createWxAccount(@Valid WxAccountCreateReqVO createReqVO); Long createAccount(@Valid MpAccountCreateReqVO createReqVO);
/** /**
* *
* *
* @param updateReqVO * @param updateReqVO
*/ */
void updateWxAccount(@Valid WxAccountUpdateReqVO updateReqVO); void updateAccount(@Valid MpAccountUpdateReqVO updateReqVO);
/** /**
* *
* *
* @param id * @param id
*/ */
void deleteWxAccount(Long id); void deleteAccount(Long id);
/** /**
* *
@ -47,15 +44,7 @@ public interface WxAccountService {
* @param id * @param id
* @return * @return
*/ */
WxAccountDO getWxAccount(Long id); MpAccountDO getAccount(Long id);
/**
*
*
* @param ids
* @return
*/
List<WxAccountDO> getWxAccountList(Collection<Long> ids);
/** /**
* *
@ -63,16 +52,9 @@ public interface WxAccountService {
* @param pageReqVO * @param pageReqVO
* @return * @return
*/ */
PageResult<WxAccountDO> getWxAccountPage(WxAccountPageReqVO pageReqVO); PageResult<MpAccountDO> getAccountPage(MpAccountPageReqVO pageReqVO);
/**
* , Excel
*
* @param exportReqVO
* @return
*/
List<WxAccountDO> getWxAccountList(WxAccountExportReqVO exportReqVO);
// TODO 芋艿:去除这样的方法
/** /**
* *
* *
@ -80,7 +62,7 @@ public interface WxAccountService {
* @param val * @param val
* @return * @return
*/ */
WxAccountDO findBy(SFunction<WxAccountDO, ?> field, Object val); MpAccountDO findBy(SFunction<MpAccountDO, ?> field, Object val);
/** /**
* *

View File

@ -3,13 +3,12 @@ package cn.iocoder.yudao.module.mp.service.account;
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountCreateReqVO; import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountCreateReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountExportReqVO; import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountPageReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountPageReqVO; import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountUpdateReqVO; import cn.iocoder.yudao.module.mp.convert.account.MpAccountConvert;
import cn.iocoder.yudao.module.mp.convert.account.WxAccountConvert; import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO; import cn.iocoder.yudao.module.mp.dal.mysql.account.MpAccountMapper;
import cn.iocoder.yudao.module.mp.dal.mysql.account.WxAccountMapper;
import cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants; import cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.mp.mq.producer.WxMpConfigDataProducer; import cn.iocoder.yudao.module.mp.mq.producer.WxMpConfigDataProducer;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
@ -27,7 +26,6 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -44,8 +42,9 @@ import java.util.Map;
public class WxAccountServiceImpl implements WxAccountService { public class WxAccountServiceImpl implements WxAccountService {
private static final long SCHEDULER_PERIOD = 5 * 60 * 1000L; private static final long SCHEDULER_PERIOD = 5 * 60 * 1000L;
@Resource @Resource
private WxAccountMapper wxAccountMapper; private MpAccountMapper wxAccountMapper;
@Resource @Resource
private WxMpConfigDataProducer wxMpConfigDataProducer; private WxMpConfigDataProducer wxMpConfigDataProducer;
@Resource @Resource
@ -59,31 +58,39 @@ public class WxAccountServiceImpl implements WxAccountService {
private WxAccountService self; private WxAccountService self;
@Override @Override
public Long createWxAccount(WxAccountCreateReqVO createReqVO) { public Long createAccount(MpAccountCreateReqVO createReqVO) {
// TODO 芋艿:校验唯一性
// 插入 // 插入
WxAccountDO wxAccount = WxAccountConvert.INSTANCE.convert(createReqVO); MpAccountDO wxAccount = MpAccountConvert.INSTANCE.convert(createReqVO);
wxAccountMapper.insert(wxAccount); wxAccountMapper.insert(wxAccount);
// TODO 芋艿:刷新的方式
wxMpConfigDataProducer.sendDictDataRefreshMessage(); wxMpConfigDataProducer.sendDictDataRefreshMessage();
// 返回 // 返回
return wxAccount.getId(); return wxAccount.getId();
} }
@Override @Override
public void updateWxAccount(WxAccountUpdateReqVO updateReqVO) { public void updateAccount(MpAccountUpdateReqVO updateReqVO) {
// TODO 芋艿:校验唯一性
// 校验存在 // 校验存在
this.validateWxAccountExists(updateReqVO.getId()); validateWxAccountExists(updateReqVO.getId());
// 更新 // 更新
WxAccountDO updateObj = WxAccountConvert.INSTANCE.convert(updateReqVO); MpAccountDO updateObj = MpAccountConvert.INSTANCE.convert(updateReqVO);
wxAccountMapper.updateById(updateObj); wxAccountMapper.updateById(updateObj);
// TODO 芋艿:刷新的方式
wxMpConfigDataProducer.sendDictDataRefreshMessage(); wxMpConfigDataProducer.sendDictDataRefreshMessage();
} }
@Override @Override
public void deleteWxAccount(Long id) { public void deleteAccount(Long id) {
// 校验存在 // 校验存在
this.validateWxAccountExists(id); validateWxAccountExists(id);
// 删除 // 删除
wxAccountMapper.deleteById(id); wxAccountMapper.deleteById(id);
// TODO 芋艿:刷新的方式
wxMpConfigDataProducer.sendDictDataRefreshMessage(); wxMpConfigDataProducer.sendDictDataRefreshMessage();
} }
@ -94,27 +101,17 @@ public class WxAccountServiceImpl implements WxAccountService {
} }
@Override @Override
public WxAccountDO getWxAccount(Long id) { public MpAccountDO getAccount(Long id) {
return wxAccountMapper.selectById(id); return wxAccountMapper.selectById(id);
} }
@Override @Override
public List<WxAccountDO> getWxAccountList(Collection<Long> ids) { public PageResult<MpAccountDO> getAccountPage(MpAccountPageReqVO pageReqVO) {
return wxAccountMapper.selectBatchIds(ids);
}
@Override
public PageResult<WxAccountDO> getWxAccountPage(WxAccountPageReqVO pageReqVO) {
return wxAccountMapper.selectPage(pageReqVO); return wxAccountMapper.selectPage(pageReqVO);
} }
@Override @Override
public List<WxAccountDO> getWxAccountList(WxAccountExportReqVO exportReqVO) { public MpAccountDO findBy(SFunction<MpAccountDO, ?> field, Object val) {
return wxAccountMapper.selectList(exportReqVO);
}
@Override
public WxAccountDO findBy(SFunction<WxAccountDO, ?> field, Object val) {
return wxAccountMapper.selectOne(field, val); return wxAccountMapper.selectOne(field, val);
} }
@ -122,7 +119,8 @@ public class WxAccountServiceImpl implements WxAccountService {
@TenantIgnore @TenantIgnore
@Override @Override
public void initLoadWxMpConfigStorages() { public void initLoadWxMpConfigStorages() {
List<WxAccountDO> wxAccountList = this.wxAccountMapper.selectList(); // TODO 芋艿:刷新的方式
List<MpAccountDO> wxAccountList = this.wxAccountMapper.selectList();
if (CollectionUtils.isEmpty(wxAccountList)) { if (CollectionUtils.isEmpty(wxAccountList)) {
log.info("未读取到公众号配置,请在管理后台添加"); log.info("未读取到公众号配置,请在管理后台添加");
return; return;
@ -137,7 +135,7 @@ public class WxAccountServiceImpl implements WxAccountService {
* *
* @param account * @param account
*/ */
private synchronized void addAccountToRuntime(WxAccountDO account, RedisTemplateWxRedisOps redisOps) { private synchronized void addAccountToRuntime(MpAccountDO account, RedisTemplateWxRedisOps redisOps) {
String appId = account.getAppId(); String appId = account.getAppId();
WxMpConfigStorage wxMpRedisConfig = account.toWxMpConfigStorage(redisOps, wxMpProperties); WxMpConfigStorage wxMpRedisConfig = account.toWxMpConfigStorage(redisOps, wxMpProperties);
try { try {

View File

@ -4,7 +4,7 @@ import java.util.*;
import javax.validation.*; import javax.validation.*;
import cn.iocoder.yudao.module.mp.controller.admin.accountfanstag.vo.*; import cn.iocoder.yudao.module.mp.controller.admin.accountfanstag.vo.*;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO; import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
import cn.iocoder.yudao.module.mp.dal.dataobject.accountfanstag.WxAccountFansTagDO; import cn.iocoder.yudao.module.mp.dal.dataobject.accountfanstag.WxAccountFansTagDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import me.chanjar.weixin.mp.bean.result.WxMpUser; import me.chanjar.weixin.mp.bean.result.WxMpUser;
@ -70,5 +70,5 @@ public interface WxAccountFansTagService {
*/ */
List<WxAccountFansTagDO> getWxAccountFansTagList(WxAccountFansTagExportReqVO exportReqVO); List<WxAccountFansTagDO> getWxAccountFansTagList(WxAccountFansTagExportReqVO exportReqVO);
void processFansTags(WxAccountDO wxAccount, WxMpUser wxmpUser); void processFansTags(MpAccountDO wxAccount, WxMpUser wxmpUser);
} }

View File

@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.mp.service.accountfanstag; package cn.iocoder.yudao.module.mp.service.accountfanstag;
import cn.hutool.core.date.DateUtil; import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO;
import me.chanjar.weixin.mp.bean.result.WxMpUser; import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -86,7 +85,7 @@ public class WxAccountFansTagServiceImpl implements WxAccountFansTagService {
} }
@Override @Override
public void processFansTags(WxAccountDO wxAccountDO, WxMpUser wxmpUser) { public void processFansTags(MpAccountDO wxAccountDO, WxMpUser wxmpUser) {
WxAccountFansTagExportReqVO wxAccountFansTagTpl = new WxAccountFansTagExportReqVO(); WxAccountFansTagExportReqVO wxAccountFansTagTpl = new WxAccountFansTagExportReqVO();
wxAccountFansTagTpl.setOpenid(wxmpUser.getOpenId()); wxAccountFansTagTpl.setOpenid(wxmpUser.getOpenId());
List<WxAccountFansTagDO> wxAccountFansTagList = this.getWxAccountFansTagList(wxAccountFansTagTpl); List<WxAccountFansTagDO> wxAccountFansTagList = this.getWxAccountFansTagList(wxAccountFansTagTpl);

View File

@ -4,7 +4,6 @@ import java.util.*;
import javax.validation.*; import javax.validation.*;
import cn.iocoder.yudao.module.mp.controller.admin.subscribetext.vo.*; import cn.iocoder.yudao.module.mp.controller.admin.subscribetext.vo.*;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO;
import cn.iocoder.yudao.module.mp.dal.dataobject.subscribetext.WxSubscribeTextDO; import cn.iocoder.yudao.module.mp.dal.dataobject.subscribetext.WxSubscribeTextDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.core.toolkit.support.SFunction;

View File

@ -3,7 +3,7 @@ import request from '@/utils/request'
// 创建公众号账户 // 创建公众号账户
export function createAccount(data) { export function createAccount(data) {
return request({ return request({
url: '/wechatMp/account/create', url: '/mp/account/create',
method: 'post', method: 'post',
data: data data: data
}) })
@ -12,7 +12,7 @@ export function createAccount(data) {
// 更新公众号账户 // 更新公众号账户
export function updateAccount(data) { export function updateAccount(data) {
return request({ return request({
url: '/wechatMp/account/update', url: '/mp/account/update',
method: 'put', method: 'put',
data: data data: data
}) })
@ -21,7 +21,7 @@ export function updateAccount(data) {
// 删除公众号账户 // 删除公众号账户
export function deleteAccount(id) { export function deleteAccount(id) {
return request({ return request({
url: '/wechatMp/account/delete?id=' + id, url: '/mp/account/delete?id=' + id,
method: 'delete' method: 'delete'
}) })
} }
@ -29,7 +29,7 @@ export function deleteAccount(id) {
// 获得公众号账户 // 获得公众号账户
export function getAccount(id) { export function getAccount(id) {
return request({ return request({
url: '/wechatMp/account/get?id=' + id, url: '/mp/account/get?id=' + id,
method: 'get' method: 'get'
}) })
} }
@ -37,7 +37,7 @@ export function getAccount(id) {
// 获得公众号账户分页 // 获得公众号账户分页
export function getAccountPage(query) { export function getAccountPage(query) {
return request({ return request({
url: '/wechatMp/account/page', url: '/mp/account/page',
method: 'get', method: 'get',
params: query params: query
}) })
@ -46,7 +46,7 @@ export function getAccountPage(query) {
// 导出公众号账户 Excel // 导出公众号账户 Excel
export function exportAccountExcel(query) { export function exportAccountExcel(query) {
return request({ return request({
url: '/wechatMp/account/export-excel', url: '/mp/account/export-excel',
method: 'get', method: 'get',
params: query, params: query,
responseType: 'blob' responseType: 'blob'

View File

@ -4,13 +4,9 @@
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="名称" prop="name"> <el-form-item label="名称" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入公众号名称" clearable <el-input v-model="queryParams.name" placeholder="请输入名称" clearable
@keyup.enter.native="handleQuery"/> @keyup.enter.native="handleQuery"/>
</el-form-item> </el-form-item>
<el-form-item label="创建时间">
<el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd"
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"/>
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button> <el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" @click="resetQuery"></el-button> <el-button icon="el-icon-refresh" @click="resetQuery"></el-button>
@ -21,13 +17,7 @@
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['wechatMp:account:create']">新增 v-hasPermi="['mp:account:create']">新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
:loading="exportLoading"
v-hasPermi="['wechatMp:account:export']">导出
</el-button> </el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
@ -35,13 +25,12 @@
<!-- 列表 --> <!-- 列表 -->
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column label="编号" align="center" prop="id"/>
<el-table-column label="名称" align="center" prop="name"/> <el-table-column label="名称" align="center" prop="name"/>
<el-table-column label="微信原始ID" align="center" prop="account"/> <el-table-column label="微信" align="center" prop="account" width="180"/>
<el-table-column label="appId" align="center" prop="appId"/> <el-table-column label="appId" align="center" prop="appId" width="180"/>
<el-table-column label="url" align="center" prop="url"/> <el-table-column label="appSecret" align="center" prop="appSecret" width="180"/>
<el-table-column label="Token" align="center" prop="token"/> <el-table-column label="Token" align="center" prop="token"/>
<el-table-column label="加密密钥" align="center" prop="aesKey"/> <el-table-column label="密钥" align="center" prop="aesKey"/>
<el-table-column label="二维码" align="center" prop="qrCodeUrl"/> <el-table-column label="二维码" align="center" prop="qrCodeUrl"/>
<el-table-column label="备注" align="center" prop="remark"/> <el-table-column label="备注" align="center" prop="remark"/>
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> <el-table-column label="创建时间" align="center" prop="createTime" width="180">
@ -52,10 +41,10 @@
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['wechatMp:account:update']">修改 v-hasPermi="['mp:account:update']">修改
</el-button> </el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['wechatMp:account:delete']">删除 v-hasPermi="['mp:account:delete']">删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -66,35 +55,37 @@
<!-- 对话框(添加 / 修改) --> <!-- 对话框(添加 / 修改) -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="公众号名称" prop="name"> <el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请输入公众号名称"/> <el-input v-model="form.name" placeholder="请输入名称"/>
</el-form-item>
<el-tooltip class="item" effect="dark"
content="在微信公众平台mp.weixin.qq.com的菜单【设置】-【公众号设置】-【帐号详情】中能找到原始ID"
placement="right">
<el-form-item label="微信原始ID" prop="account">
<el-input v-model="form.account" placeholder="请输入微信原始ID" :disabled='disabled'/>
</el-form-item> </el-form-item>
<el-form-item label="微信号" prop="account">
<span slot="label">
<el-tooltip content="在微信公众平台mp.weixin.qq.com的菜单【设置】-【公众号设置】-【帐号详情】中能找到原始ID" placement="top">
<i class="el-icon-question" />
</el-tooltip> </el-tooltip>
微信号
<el-tooltip class="item" effect="dark" </span>
content="在微信公众平台mp.weixin.qq.com的菜单【开发】-【基本配置】中能找到AppID " <el-input v-model="form.account" placeholder="请输入微信号"/>
placement="right">
<el-form-item label="AppID" prop="appId">
<el-input v-model="form.appId" placeholder="请输入公众号appId" :disabled='disabled'/>
</el-form-item> </el-form-item>
<el-form-item label="appId" prop="appId">
<span slot="label">
<el-tooltip content="在微信公众平台mp.weixin.qq.com的菜单【开发】-【基本配置】中能找到 appId" placement="top">
<i class="el-icon-question" />
</el-tooltip> </el-tooltip>
appId
<el-tooltip class="item" effect="dark" </span>
content="在微信公众平台mp.weixin.qq.com的菜单【开发】-【基本配置】中能找到AppSecret" <el-input v-model="form.appId" placeholder="请输入公众号 appId"/>
placement="right">
<el-form-item label="AppSecret" prop="appSecret">
<el-input v-model="form.appSecret" placeholder="请输入公众号密钥" :disabled='disabled'/>
</el-form-item> </el-form-item>
<el-form-item label="密钥" prop="appSecret">
<span slot="label">
<el-tooltip content="在微信公众平台mp.weixin.qq.com的菜单【开发】-【基本配置】中能找到密钥" placement="top">
<i class="el-icon-question" />
</el-tooltip> </el-tooltip>
密钥
</span>
<el-input v-model="form.appSecret" placeholder="请输入公众号 appSecret"/>
</el-form-item>
<el-form-item label="token" prop="token"> <el-form-item label="token" prop="token">
<el-input v-model="form.token" placeholder="请输入公众号token"/> <el-input v-model="form.token" placeholder="请输入公众号token"/>
</el-form-item> </el-form-item>
@ -114,17 +105,10 @@
</template> </template>
<script> <script>
import { import { createAccount, deleteAccount, getAccount, getAccountPage, updateAccount} from '@/api/mp/account'
createAccount,
deleteAccount,
exportAccountExcel,
getAccount,
getAccountPage,
updateAccount
} from '@/api/wechatMp/wxAccount'
export default { export default {
name: 'wxAccount', name: 'mpAccount',
components: {}, components: {},
data() { data() {
return { return {
@ -142,7 +126,6 @@ export default {
title: '', title: '',
// //
open: false, open: false,
dateRangeCreateTime: [],
// //
queryParams: { queryParams: {
pageNo: 1, pageNo: 1,
@ -155,10 +138,11 @@ export default {
form: {}, form: {},
// //
rules: { rules: {
name: [{required: true, message: '公众号名称不能为空', trigger: 'blur'}], name: [{required: true, message: '名称不能为空', trigger: 'blur'}],
account: [{required: true, message: '公众号账户不能为空', trigger: 'blur'}], account: [{required: true, message: '公众号账户不能为空', trigger: 'blur'}],
appId: [{required: true, message: '公众号appid不能为空', trigger: 'blur'}], appId: [{required: true, message: '公众号 appId 不能为空', trigger: 'blur'}],
appSecret: [{required: true, message: '公众号密钥不能为空', trigger: 'blur'}], appSecret: [{required: true, message: '公众号密钥不能为空', trigger: 'blur'}],
token: [{required: true, message: '公众号 token 不能为空', trigger: 'blur'}],
}, },
// //
disabled: false, disabled: false,
@ -173,7 +157,6 @@ export default {
this.loading = true this.loading = true
// //
let params = {...this.queryParams} let params = {...this.queryParams}
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime')
// //
getAccountPage(params).then(response => { getAccountPage(params).then(response => {
this.list = response.data.list this.list = response.data.list
@ -255,7 +238,7 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const id = row.id const id = row.id
this.$modal.confirm('是否确认删除公众号账户编号为"' + id + '"的数据项?').then(function () { this.$modal.confirm('是否确认删除公众号账户编号为"' + row.name + '"的数据项?').then(function () {
return deleteAccount(id) return deleteAccount(id)
}).then(() => { }).then(() => {
this.getList() this.getList()
@ -263,23 +246,6 @@ export default {
}).catch(() => { }).catch(() => {
}) })
}, },
/** 导出按钮操作 */
handleExport() {
//
let params = {...this.queryParams}
params.pageNo = undefined
params.pageSize = undefined
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime')
//
this.$modal.confirm('是否确认导出所有公众号账户数据项?').then(() => {
this.exportLoading = true
return exportAccountExcel(params)
}).then(response => {
this.$download.excel(response, '公众号账户.xls')
this.exportLoading = false
}).catch(() => {
})
}
} }
} }
</script> </script>

View File

@ -104,7 +104,7 @@ import {
getWxFansTagList, getWxFansTagList,
updateWxFansTag updateWxFansTag
} from '@/api/wechatMp/wxFansTag' } from '@/api/wechatMp/wxFansTag'
import {getAccountPage} from '@/api/wechatMp/wxAccount' import {getAccountPage} from '@/api/mp/account'
export default { export default {
name: 'WxFansTag', name: 'WxFansTag',