存酒接口

This commit is contained in:
张松
2025-02-27 13:58:04 +08:00
parent 250ce131d2
commit 2bce1acb69
27 changed files with 807 additions and 63 deletions

View File

@@ -1,78 +0,0 @@
package com.czg.controller.admin;
import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.storage.ShopStorageGoodDTO;
import com.czg.account.entity.ShopStorageGood;
import com.czg.account.service.ShopStorageGoodService;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.utils.PageUtil;
import com.czg.validator.group.DefaultGroup;
import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 存酒商品管理
* @author Administrator
*/
@RestController
@RequestMapping("/admin/storageGood")
public class ShopStorageGoodController {
@Resource
private ShopStorageGoodService shopStorageGoodService;
/**
* 获取存酒商品列表
* @param name 商品名
* @return 列表
*/
@SaAdminCheckPermission(value = "storageGood:list", name = "获取存酒商品列表")
@GetMapping
public CzgResult<Page<ShopStorageGood>> list(String name) {
QueryWrapper queryWrapper = new QueryWrapper().eq(ShopStorageGood::getShopId, StpKit.USER.getShopId());
if (StrUtil.isNotBlank(name)) {
queryWrapper.eq(ShopStorageGood::getName, name);
}
return CzgResult.success(shopStorageGoodService.page(PageUtil.buildPage(), queryWrapper));
}
/**
* 获取存酒商品详情
* @param id 商品id
* @return 列表
*/
@SaAdminCheckPermission(value = "storageGood:detail", name = "获取存酒商品详情")
@GetMapping("/detail")
public CzgResult<ShopStorageGood> detail(@RequestParam Integer id) {
return CzgResult.success(shopStorageGoodService.getOne(new QueryWrapper().eq(ShopStorageGood::getShopId, StpKit.USER.getShopId()).eq(ShopStorageGood::getId, id)));
}
/**
* 编辑存酒商品
* @return 列表
*/
@SaAdminCheckPermission(value = "storageGood:edit", name = "存酒商品编辑")
@PutMapping("/edit")
public CzgResult<Boolean> edit(@RequestBody @Validated({UpdateGroup.class}) ShopStorageGoodDTO shopStorageGoodDTO) {
return CzgResult.success(shopStorageGoodService.edit(StpKit.USER.getShopId(), shopStorageGoodDTO));
}
/**
* 编辑存酒商品
* @return 列表
*/
@SaAdminCheckPermission(value = "storageGood:add", name = "存酒商品新增")
@PutMapping("/add")
public CzgResult<Boolean> add(@RequestBody @Validated({InsertGroup.class}) ShopStorageGoodDTO shopStorageGoodDTO) {
return CzgResult.success(shopStorageGoodService.saveInfo(StpKit.USER.getShopId(), shopStorageGoodDTO));
}
}

View File

@@ -29,8 +29,8 @@ public class UShopUserController {
* @return 店铺会员信息
*/
@GetMapping
public CzgResult<ShopUser> get() {
return CzgResult.success(shopUserService.getShopUserInfo(StpKit.USER.getShopId(), StpKit.USER.getLoginIdAsLong()));
public CzgResult<ShopUser> get(Long shopId) {
return CzgResult.success(shopUserService.getShopUserInfo(shopId == null ? StpKit.USER.getShopId() : shopId, StpKit.USER.getLoginIdAsLong()));
}
/**
@@ -49,8 +49,8 @@ public class UShopUserController {
* @return 店铺会员信息列表
*/
@GetMapping("/code")
public CzgResult<String> code() {
return shopUserService.getCode(StpKit.USER.getLoginIdAsLong(), StpKit.USER.getShopId());
public CzgResult<String> code(Long shopId) {
return shopUserService.getCode(StpKit.USER.getLoginIdAsLong(), shopId == null ? StpKit.USER.getShopId() : shopId);
}
}

View File

@@ -38,7 +38,7 @@ public class UserAuthorizationController {
*/
@PostMapping("/test")
public CzgResult<String> login() {
// StpKit.USER.login(1L, null, MyStpLogic.LoginType.USER, false);
StpKit.USER.login(1L, "2342", null, MyStpLogic.LoginType.USER, false);
return CzgResult.success(StpKit.USER.getTokenValue());
}
}