mp:完善公众号的账号管理
parent
48520a456b
commit
627cb39517
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -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;
|
||||
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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);
|
||||
|
||||
}
|
||||
@ -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);
|
||||
|
||||
}
|
||||
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue