From 9c6d450157c387c4c2f6fb36a38c0fed2f81116f Mon Sep 17 00:00:00 2001 From: gxwebsoft Date: Tue, 30 Apr 2024 18:25:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=95=86=E6=88=B7=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MerchantApplyController.java | 27 +++++++++++++++---- .../controller/MerchantTypeController.java | 10 +++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gxwebsoft/common/system/controller/MerchantApplyController.java b/src/main/java/com/gxwebsoft/common/system/controller/MerchantApplyController.java index c9c2269..c719819 100644 --- a/src/main/java/com/gxwebsoft/common/system/controller/MerchantApplyController.java +++ b/src/main/java/com/gxwebsoft/common/system/controller/MerchantApplyController.java @@ -1,14 +1,16 @@ package com.gxwebsoft.common.system.controller; -import com.gxwebsoft.common.core.web.ApiResult; -import com.gxwebsoft.common.core.web.BaseController; -import com.gxwebsoft.common.core.web.BatchParam; -import com.gxwebsoft.common.core.web.PageResult; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.gxwebsoft.common.core.web.*; +import com.gxwebsoft.common.system.entity.Merchant; import com.gxwebsoft.common.system.entity.MerchantApply; +import com.gxwebsoft.common.system.entity.User; import com.gxwebsoft.common.system.param.MerchantApplyParam; import com.gxwebsoft.common.system.service.MerchantApplyService; +import com.gxwebsoft.common.system.service.MerchantService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -24,9 +26,12 @@ import java.util.List; @RestController @RequestMapping("/api/system/merchant-apply") public class MerchantApplyController extends BaseController { + @Resource + private MerchantService merchantService; @Resource private MerchantApplyService merchantApplyService; + @PreAuthorize("hasAuthority('sys:merchantApply:list')") @ApiOperation("分页查询商户入驻申请") @GetMapping("/page") public ApiResult> page(MerchantApplyParam param) { @@ -34,6 +39,7 @@ public class MerchantApplyController extends BaseController { return success(merchantApplyService.pageRel(param)); } + @PreAuthorize("hasAuthority('sys:merchantApply:list')") @ApiOperation("查询全部商户入驻申请") @GetMapping() public ApiResult> list(MerchantApplyParam param) { @@ -41,6 +47,7 @@ public class MerchantApplyController extends BaseController { return success(merchantApplyService.listRel(param)); } + @PreAuthorize("hasAuthority('sys:merchantApply:list')") @ApiOperation("根据id查询商户入驻申请") @GetMapping("/{id}") public ApiResult get(@PathVariable("id") Integer id) { @@ -51,12 +58,19 @@ public class MerchantApplyController extends BaseController { @ApiOperation("添加商户入驻申请") @PostMapping() public ApiResult save(@RequestBody MerchantApply merchantApply) { + if (merchantService.count(new LambdaQueryWrapper().eq(Merchant::getMerchantName,merchantApply.getMerchantName())) > 0) { + return fail("该租户名称已存在"); + } + if (merchantService.count(new LambdaQueryWrapper().eq(Merchant::getPhone,merchantApply.getPhone())) > 0) { + return fail("该手机号码已存在"); + } if (merchantApplyService.save(merchantApply)) { return success("添加成功"); } return fail("添加失败"); } + @PreAuthorize("hasAuthority('sys:merchantApply:update')") @ApiOperation("修改商户入驻申请") @PutMapping() public ApiResult update(@RequestBody MerchantApply merchantApply) { @@ -66,6 +80,7 @@ public class MerchantApplyController extends BaseController { return fail("修改失败"); } + @PreAuthorize("hasAuthority('sys:merchantApply:remove')") @ApiOperation("删除商户入驻申请") @DeleteMapping("/{id}") public ApiResult remove(@PathVariable("id") Integer id) { @@ -75,6 +90,7 @@ public class MerchantApplyController extends BaseController { return fail("删除失败"); } + @PreAuthorize("hasAuthority('sys:merchantApply:save')") @ApiOperation("批量添加商户入驻申请") @PostMapping("/batch") public ApiResult saveBatch(@RequestBody List list) { @@ -84,6 +100,7 @@ public class MerchantApplyController extends BaseController { return fail("添加失败"); } + @PreAuthorize("hasAuthority('sys:merchantApply:update')") @ApiOperation("批量修改商户入驻申请") @PutMapping("/batch") public ApiResult removeBatch(@RequestBody BatchParam batchParam) { @@ -93,6 +110,7 @@ public class MerchantApplyController extends BaseController { return fail("修改失败"); } + @PreAuthorize("hasAuthority('sys:merchantApply:remove')") @ApiOperation("批量删除商户入驻申请") @DeleteMapping("/batch") public ApiResult removeBatch(@RequestBody List ids) { @@ -101,5 +119,4 @@ public class MerchantApplyController extends BaseController { } return fail("删除失败"); } - } diff --git a/src/main/java/com/gxwebsoft/common/system/controller/MerchantTypeController.java b/src/main/java/com/gxwebsoft/common/system/controller/MerchantTypeController.java index ee8ccb4..bcda344 100644 --- a/src/main/java/com/gxwebsoft/common/system/controller/MerchantTypeController.java +++ b/src/main/java/com/gxwebsoft/common/system/controller/MerchantTypeController.java @@ -10,6 +10,7 @@ import com.gxwebsoft.common.system.param.MerchantTypeParam; import com.gxwebsoft.common.system.service.MerchantTypeService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -28,6 +29,7 @@ public class MerchantTypeController extends BaseController { @Resource private MerchantTypeService merchantTypeService; + @PreAuthorize("hasAuthority('sys:merchantType:list')") @ApiOperation("分页查询商户类型") @GetMapping("/page") public ApiResult> page(MerchantTypeParam param) { @@ -35,6 +37,7 @@ public class MerchantTypeController extends BaseController { return success(merchantTypeService.pageRel(param)); } + @PreAuthorize("hasAuthority('sys:merchantType:list')") @ApiOperation("查询全部商户类型") @GetMapping() public ApiResult> list(MerchantTypeParam param) { @@ -42,6 +45,7 @@ public class MerchantTypeController extends BaseController { return success(merchantTypeService.listRel(param)); } + @PreAuthorize("hasAuthority('sys:merchantType:list')") @ApiOperation("根据id查询商户类型") @GetMapping("/{id}") public ApiResult get(@PathVariable("id") Integer id) { @@ -49,6 +53,7 @@ public class MerchantTypeController extends BaseController { return success(merchantTypeService.getByIdRel(id)); } + @PreAuthorize("hasAuthority('sys:merchantType:save')") @ApiOperation("添加商户类型") @PostMapping() public ApiResult save(@RequestBody MerchantType merchantType) { @@ -63,6 +68,7 @@ public class MerchantTypeController extends BaseController { return fail("添加失败"); } + @PreAuthorize("hasAuthority('sys:merchantType:update')") @ApiOperation("修改商户类型") @PutMapping() public ApiResult update(@RequestBody MerchantType merchantType) { @@ -72,6 +78,7 @@ public class MerchantTypeController extends BaseController { return fail("修改失败"); } + @PreAuthorize("hasAuthority('sys:merchantType:remove')") @ApiOperation("删除商户类型") @DeleteMapping("/{id}") public ApiResult remove(@PathVariable("id") Integer id) { @@ -81,6 +88,7 @@ public class MerchantTypeController extends BaseController { return fail("删除失败"); } + @PreAuthorize("hasAuthority('sys:merchantType:update')") @ApiOperation("批量添加商户类型") @PostMapping("/batch") public ApiResult saveBatch(@RequestBody List list) { @@ -90,6 +98,7 @@ public class MerchantTypeController extends BaseController { return fail("添加失败"); } + @PreAuthorize("hasAuthority('sys:merchantType:update')") @ApiOperation("批量修改商户类型") @PutMapping("/batch") public ApiResult removeBatch(@RequestBody BatchParam batchParam) { @@ -99,6 +108,7 @@ public class MerchantTypeController extends BaseController { return fail("修改失败"); } + @PreAuthorize("hasAuthority('sys:merchantType:remove')") @ApiOperation("批量删除商户类型") @DeleteMapping("/batch") public ApiResult removeBatch(@RequestBody List ids) {