From e3e0c9350221cf3570ab525a3c47ec19f2764a34 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 21 Aug 2024 10:16:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=97=E9=93=BA=E6=89=A9=E5=B1=95=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=20=E6=96=B0=E5=A2=9E=E6=97=B6=20key=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/shop/TbShopExtendController.java | 13 ++----------- .../mybatis/service/TbShopExtendService.java | 2 ++ .../service/impl/TbShopExtendServiceImpl.java | 12 ++++++++++++ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopExtendController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopExtendController.java index 2a1f6172..2b96b75f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopExtendController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopExtendController.java @@ -1,10 +1,5 @@ package cn.ysk.cashier.controller.shop; - -import cn.ysk.cashier.annotation.rest.AnonymousDeleteMapping; -import cn.ysk.cashier.annotation.rest.AnonymousGetMapping; -import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; -import cn.ysk.cashier.annotation.rest.AnonymousPutMapping; import cn.ysk.cashier.mybatis.entity.TbShopExtend; import cn.ysk.cashier.mybatis.service.TbShopExtendService; import org.springframework.web.bind.annotation.*; @@ -35,29 +30,26 @@ public class TbShopExtendController { @GetMapping @ApiOperation("分页查询") - @AnonymousGetMapping public ResponseEntity selectAll(TbShopExtendQueryCriteria criteria) { return new ResponseEntity<>(tbShopExtendService.queryAll(criteria), HttpStatus.OK); } @GetMapping("{id}") @ApiOperation("通过Id查询详情") - @AnonymousGetMapping public TbShopExtend selectOne(@PathVariable Serializable id) { return tbShopExtendService.getById(id); } @PostMapping @ApiOperation("新增") - @AnonymousPostMapping public ResponseEntity insert(@RequestBody TbShopExtend tbShopExtend) { tbShopExtend.setCreateTime(new Date()); - return new ResponseEntity<>(tbShopExtendService.save(tbShopExtend), HttpStatus.CREATED); + tbShopExtendService.saveInfo(tbShopExtend); + return new ResponseEntity<>(HttpStatus.CREATED); } @PutMapping @ApiOperation("通过id修改") - @AnonymousPutMapping public ResponseEntity update(@RequestBody TbShopExtend tbShopExtend) { tbShopExtend.setUpdateTime(new Date()); tbShopExtendService.updateById(tbShopExtend); @@ -66,7 +58,6 @@ public class TbShopExtendController { @DeleteMapping @ApiOperation("删除") - @AnonymousDeleteMapping public ResponseEntity delete(@RequestParam("idList") List idList) { tbShopExtendService.removeByIds(idList); return new ResponseEntity<>(HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopExtendService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopExtendService.java index 61a6b174..1eba9acb 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopExtendService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopExtendService.java @@ -16,5 +16,7 @@ public interface TbShopExtendService extends IService { Map queryAll(TbShopExtendQueryCriteria criteria); + void saveInfo(TbShopExtend tbShopExtend); + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopExtendServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopExtendServiceImpl.java index fe7bc2cc..08b31b82 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopExtendServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopExtendServiceImpl.java @@ -1,5 +1,6 @@ package cn.ysk.cashier.mybatis.service.impl; +import cn.ysk.cashier.exception.BadRequestException; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import cn.ysk.cashier.mybatis.mapper.TbShopExtendMapper; @@ -41,5 +42,16 @@ public class TbShopExtendServiceImpl extends ServiceImpl ipage = tbShopExtendmapper.selectPage(page, wrapper); return PageUtil.toPage(ipage.getRecords(), ipage.getTotal()); } + + @Override + public void saveInfo(TbShopExtend tbShopExtend) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("shop_id", tbShopExtend.getShopId()); + wrapper.like("autokey",tbShopExtend.getAutokey()); + if(tbShopExtendmapper.exists(wrapper)){ + throw new BadRequestException("该自定义key已存在"); + } + tbShopExtendmapper.insert(tbShopExtend); + } }