补全后端基础相关模块

This commit is contained in:
陈博文
2025-06-24 08:59:52 +08:00
committed by chenbowen
parent 9408e9fd2b
commit c3844f76bb
1151 changed files with 77508 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.mp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* 项目的启动类
*
* 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
* 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
* 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
*
* @author 芋道源码
*/
@SpringBootApplication
public class MpServerApplication {
public static void main(String[] args) {
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
SpringApplication.run(MpServerApplication.class, args);
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
}
}

View File

@@ -0,0 +1,98 @@
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.MpAccountService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
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 java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 公众号账号")
@RestController
@RequestMapping("/mp/account")
@Validated
public class MpAccountController {
@Resource
private MpAccountService mpAccountService;
@PostMapping("/create")
@Operation(summary = "创建公众号账号")
@PreAuthorize("@ss.hasPermission('mp:account:create')")
public CommonResult<Long> createAccount(@Valid @RequestBody MpAccountCreateReqVO createReqVO) {
return success(mpAccountService.createAccount(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新公众号账号")
@PreAuthorize("@ss.hasPermission('mp:account:update')")
public CommonResult<Boolean> updateAccount(@Valid @RequestBody MpAccountUpdateReqVO updateReqVO) {
mpAccountService.updateAccount(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除公众号账号")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('mp:account:delete')")
public CommonResult<Boolean> deleteAccount(@RequestParam("id") Long id) {
mpAccountService.deleteAccount(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得公众号账号")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('mp:account:query')")
public CommonResult<MpAccountRespVO> getAccount(@RequestParam("id") Long id) {
MpAccountDO wxAccount = mpAccountService.getAccount(id);
return success(MpAccountConvert.INSTANCE.convert(wxAccount));
}
@GetMapping("/page")
@Operation(summary = "获得公众号账号分页")
@PreAuthorize("@ss.hasPermission('mp:account:query')")
public CommonResult<PageResult<MpAccountRespVO>> getAccountPage(@Valid MpAccountPageReqVO pageVO) {
PageResult<MpAccountDO> pageResult = mpAccountService.getAccountPage(pageVO);
return success(MpAccountConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/list-all-simple")
@Operation(summary = "获取公众号账号精简信息列表")
@PreAuthorize("@ss.hasPermission('mp:account:query')")
public CommonResult<List<MpAccountSimpleRespVO>> getSimpleAccounts() {
List<MpAccountDO> list = mpAccountService.getAccountList();
return success(MpAccountConvert.INSTANCE.convertList02(list));
}
@PutMapping("/generate-qr-code")
@Operation(summary = "生成公众号二维码")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('mp:account:qr-code')")
public CommonResult<Boolean> generateAccountQrCode(@RequestParam("id") Long id) {
mpAccountService.generateAccountQrCode(id);
return success(true);
}
@PutMapping("/clear-quota")
@Operation(summary = "清空公众号 API 配额")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('mp:account:clear-quota')")
public CommonResult<Boolean> clearAccountQuota(@RequestParam("id") Long id) {
mpAccountService.clearAccountQuota(id);
return success(true);
}
}

View File

@@ -0,0 +1,43 @@
package cn.iocoder.yudao.module.mp.controller.admin.account.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
/**
* 公众号账号 Base VO提供给添加、修改、详细的子 VO 使用
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
*
* @author fengdan
*/
@Data
public class MpAccountBaseVO {
@Schema(description = "公众号名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
@NotEmpty(message = "公众号名称不能为空")
private String name;
@Schema(description = "公众号微信号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudaoyuanma")
@NotEmpty(message = "公众号微信号不能为空")
private String account;
@Schema(description = "公众号 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx5b23ba7a5589ecbb")
@NotEmpty(message = "公众号 appId 不能为空")
private String appId;
@Schema(description = "公众号密钥", requiredMode = Schema.RequiredMode.REQUIRED, example = "3a7b3b20c537e52e74afd395eb85f61f")
@NotEmpty(message = "公众号密钥不能为空")
private String appSecret;
@Schema(description = "公众号 token", requiredMode = Schema.RequiredMode.REQUIRED, example = "kangdayuzhen")
@NotEmpty(message = "公众号 token 不能为空")
private String token;
@Schema(description = "加密密钥", example = "gjN+Ksei")
private String aesKey;
@Schema(description = "备注", example = "请关注芋道源码,学习技术")
private String remark;
}

View File

@@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.mp.controller.admin.account.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - 公众号账号创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MpAccountCreateReqVO extends MpAccountBaseVO {
}

View File

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

View File

@@ -0,0 +1,25 @@
package cn.iocoder.yudao.module.mp.controller.admin.account.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 公众号账号 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MpAccountRespVO extends MpAccountBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
@Schema(description = "二维码图片URL", example = "https://www.iocoder.cn/1024.png")
private String qrCodeUrl;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.mp.controller.admin.account.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 公众号账号精简信息 Response VO")
@Data
public class MpAccountSimpleRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
@Schema(description = "公众号名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
private String name;
}

View File

@@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.mp.controller.admin.account.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 公众号账号更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MpAccountUpdateReqVO extends MpAccountBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "编号不能为空")
private Long id;
}

View File

@@ -0,0 +1,5 @@
### 请求 /mp/material/page 接口 => 成功
GET {{baseUrl}}/mp/material/page?permanent=true&pageNo=1&pageSize=10
Content-Type: application/json
Authorization: Bearer {{token}}
tenant-id: {{adminTenantId}}

View File

@@ -0,0 +1,74 @@
package cn.iocoder.yudao.module.mp.controller.admin.material;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.mp.controller.admin.material.vo.*;
import cn.iocoder.yudao.module.mp.convert.material.MpMaterialConvert;
import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO;
import cn.iocoder.yudao.module.mp.service.material.MpMaterialService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
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 java.io.IOException;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 公众号素材")
@RestController
@RequestMapping("/mp/material")
@Validated
public class MpMaterialController {
@Resource
private MpMaterialService mpMaterialService;
@Operation(summary = "上传临时素材")
@PostMapping("/upload-temporary")
@PreAuthorize("@ss.hasPermission('mp:material:upload-temporary')")
public CommonResult<MpMaterialUploadRespVO> uploadTemporaryMaterial(
@Valid MpMaterialUploadTemporaryReqVO reqVO) throws IOException {
MpMaterialDO material = mpMaterialService.uploadTemporaryMaterial(reqVO);
return success(MpMaterialConvert.INSTANCE.convert(material));
}
@Operation(summary = "上传永久素材")
@PostMapping("/upload-permanent")
@PreAuthorize("@ss.hasPermission('mp:material:upload-permanent')")
public CommonResult<MpMaterialUploadRespVO> uploadPermanentMaterial(
@Valid MpMaterialUploadPermanentReqVO reqVO) throws IOException {
MpMaterialDO material = mpMaterialService.uploadPermanentMaterial(reqVO);
return success(MpMaterialConvert.INSTANCE.convert(material));
}
@Operation(summary = "删除素材")
@DeleteMapping("/delete-permanent")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('mp:material:delete')")
public CommonResult<Boolean> deleteMaterial(@RequestParam("id") Long id) {
mpMaterialService.deleteMaterial(id);
return success(true);
}
@Operation(summary = "上传图文内容中的图片")
@PostMapping("/upload-news-image")
@PreAuthorize("@ss.hasPermission('mp:material:upload-news-image')")
public CommonResult<String> uploadNewsImage(@Valid MpMaterialUploadNewsImageReqVO reqVO)
throws IOException {
return success(mpMaterialService.uploadNewsImage(reqVO));
}
@Operation(summary = "获得素材分页")
@GetMapping("/page")
@PreAuthorize("@ss.hasPermission('mp:material:query')")
public CommonResult<PageResult<MpMaterialRespVO>> getMaterialPage(@Valid MpMaterialPageReqVO pageReqVO) {
PageResult<MpMaterialDO> pageResult = mpMaterialService.getMaterialPage(pageReqVO);
return success(MpMaterialConvert.INSTANCE.convertPage(pageResult));
}
}

Some files were not shown because too many files have changed in this diff Show More