|
|
@@ -0,0 +1,104 @@
|
|
|
+package cn.iocoder.yudao.module.system.controller.admin.agreement;
|
|
|
+
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+
|
|
|
+import javax.validation.constraints.*;
|
|
|
+import javax.validation.*;
|
|
|
+import javax.servlet.http.*;
|
|
|
+import java.util.*;
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.agreement.vo.*;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.agreement.AgreementDO;
|
|
|
+import cn.iocoder.yudao.module.system.service.agreement.AgreementService;
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 平台协议")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/system/agreement")
|
|
|
+@Validated
|
|
|
+public class AgreementController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private AgreementService agreementService;
|
|
|
+
|
|
|
+ // @PostMapping("/create")
|
|
|
+ // @Operation(summary = "创建平台协议")
|
|
|
+ // @PreAuthorize("@ss.hasPermission('system:agreement:create')")
|
|
|
+ public CommonResult<Long> createAgreement(@Valid @RequestBody AgreementSaveReqVO createReqVO) {
|
|
|
+ return success(agreementService.createAgreement(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ // @PutMapping("/update")
|
|
|
+ // @Operation(summary = "更新平台协议")
|
|
|
+ // @PreAuthorize("@ss.hasPermission('system:agreement:update')")
|
|
|
+ public CommonResult<Boolean> updateAgreement(@Valid @RequestBody AgreementSaveReqVO updateReqVO) {
|
|
|
+ agreementService.updateAgreement(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ // @DeleteMapping("/delete")
|
|
|
+ // @Operation(summary = "删除平台协议")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ // @PreAuthorize("@ss.hasPermission('system:agreement:delete')")
|
|
|
+ public CommonResult<Boolean> deleteAgreement(@RequestParam("id") Long id) {
|
|
|
+ agreementService.deleteAgreement(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ // @GetMapping("/get")
|
|
|
+ // @Operation(summary = "获得平台协议")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ // @PreAuthorize("@ss.hasPermission('system:agreement:query')")
|
|
|
+ public CommonResult<AgreementRespVO> getAgreement(@RequestParam("id") Long id) {
|
|
|
+ AgreementDO agreement = agreementService.getAgreement(id);
|
|
|
+ return success(BeanUtils.toBean(agreement, AgreementRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get/type")
|
|
|
+ @Operation(summary = "根据类型获得平台协议", description = "type:1服务条款 2隐私声明")
|
|
|
+ @Parameter(name = "type", description = "类型", required = true, example = "1")
|
|
|
+ // @PreAuthorize("@ss.hasPermission('system:agreement:query')")
|
|
|
+ public CommonResult<AgreementRespVO> getAgreementByType(@RequestParam("type") Integer type) {
|
|
|
+ AgreementDO agreement = agreementService.getAgreementByType(type);
|
|
|
+ return success(BeanUtils.toBean(agreement, AgreementRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ // @GetMapping("/page")
|
|
|
+ // @Operation(summary = "获得平台协议分页")
|
|
|
+ // @PreAuthorize("@ss.hasPermission('system:agreement:query')")
|
|
|
+ public CommonResult<PageResult<AgreementRespVO>> getAgreementPage(@Valid AgreementPageReqVO pageReqVO) {
|
|
|
+ PageResult<AgreementDO> pageResult = agreementService.getAgreementPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, AgreementRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ // @GetMapping("/export-excel")
|
|
|
+ // @Operation(summary = "导出平台协议 Excel")
|
|
|
+ // @PreAuthorize("@ss.hasPermission('system:agreement:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportAgreementExcel(@Valid AgreementPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<AgreementDO> list = agreementService.getAgreementPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "平台协议.xls", "数据", AgreementRespVO.class,
|
|
|
+ BeanUtils.toBean(list, AgreementRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|