商品模块代码提交

This commit is contained in:
Tankaikai
2025-02-16 10:15:03 +08:00
parent 1eb4113233
commit 2244fee745
3 changed files with 41 additions and 49 deletions

View File

@@ -5,12 +5,12 @@ import com.czg.product.dto.ShopProdCategoryDTO;
import com.czg.product.service.ShopProdCategoryService;
import com.czg.resp.CzgResult;
import com.czg.utils.AssertUtil;
import com.czg.validator.ValidatorUtil;
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 lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -30,80 +30,72 @@ public class ShopProdCategoryController {
@GetMapping("page")
@OperationLog("商品分类-分页")
//@SaAdminCheckPermission("prod:category:page")
public CzgResult<Page<ShopProdCategoryDTO>> page(ShopProdCategoryDTO param) {
Page<ShopProdCategoryDTO> data = shopProdCategoryService.page(param);
//@SaAdminCheckPermission("shopProdCategory:page")
public CzgResult<Page<ShopProdCategoryDTO>> getShopProdCategoryPage(ShopProdCategoryDTO param) {
Page<ShopProdCategoryDTO> data = shopProdCategoryService.getShopProdCategoryPage(param);
return CzgResult.success(data);
}
@GetMapping("list")
@OperationLog("商品分类-列表")
//@SaAdminCheckPermission("prod:category:list")
public CzgResult<List<ShopProdCategoryDTO>> list(ShopProdCategoryDTO param) {
List<ShopProdCategoryDTO> data = shopProdCategoryService.list(param);
//@SaAdminCheckPermission("shopProdCategory:list")
public CzgResult<List<ShopProdCategoryDTO>> getShopProdCategoryList(ShopProdCategoryDTO param) {
List<ShopProdCategoryDTO> data = shopProdCategoryService.getShopProdCategoryList(param);
return CzgResult.success(data);
}
@GetMapping("{id}")
@OperationLog("商品分类-详情")
//@SaAdminCheckPermission("prod:category:info")
public CzgResult<ShopProdCategoryDTO> get(@PathVariable("id") Long id) {
//@SaAdminCheckPermission("shopProdCategory:info")
public CzgResult<ShopProdCategoryDTO> getShopProdCategoryById(@PathVariable("id") Long id) {
AssertUtil.isNull(id, "{}不能为空", "id");
ShopProdCategoryDTO data = shopProdCategoryService.get(id);
ShopProdCategoryDTO data = shopProdCategoryService.getShopProdCategoryById(id);
return CzgResult.success(data);
}
@PostMapping
@OperationLog("商品分类-新增")
//@SaAdminCheckPermission("prod:category:save")
public CzgResult<Void> save(@RequestBody ShopProdCategoryDTO dto) {
//效验数据
ValidatorUtil.validateEntity(dto, InsertGroup.class, DefaultGroup.class);
shopProdCategoryService.save(dto);
//@SaAdminCheckPermission("shopProdCategory:add")
public CzgResult<Void> addShopProdCategory(@RequestBody @Validated({InsertGroup.class, DefaultGroup.class}) ShopProdCategoryDTO dto) {
shopProdCategoryService.addShopProdCategory(dto);
return CzgResult.success();
}
@PutMapping
@OperationLog("商品分类-修改")
//@SaAdminCheckPermission("prod:category:update")
public CzgResult<Void> update(@RequestBody ShopProdCategoryDTO dto) {
//效验数据
ValidatorUtil.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
shopProdCategoryService.update(dto);
//@SaAdminCheckPermission("shopProdCategory:update")
public CzgResult<Void> updateShopProdCategory(@RequestBody @Validated({UpdateGroup.class, DefaultGroup.class}) ShopProdCategoryDTO dto) {
shopProdCategoryService.updateShopProdCategory(dto);
return CzgResult.success();
}
@DeleteMapping("{id}")
@OperationLog("商品分类-删除")
//@SaAdminCheckPermission("prod:unit:delete")
public CzgResult<Void> delete(@PathVariable("id") Long id) {
//@SaAdminCheckPermission("shopProdCategory:delete")
public CzgResult<Void> deleteShopProdCategory(@PathVariable("id") Long id) {
//效验数据
AssertUtil.isNull(id, "{}不能为空", "id");
shopProdCategoryService.delete(id);
shopProdCategoryService.deleteShopProdCategory(id);
return CzgResult.success();
}
@PostMapping("disable/{id}")
@OperationLog("商品分类-禁用")
//@SaAdminCheckPermission("prod:unit:able")
public CzgResult<Void> disable(@PathVariable("id") Long id) {
//@SaAdminCheckPermission("shopProdCategory:able")
public CzgResult<Void> disableShopProdCategory(@PathVariable("id") Long id) {
//效验数据
AssertUtil.isNull(id, "{}不能为空", "id");
shopProdCategoryService.disable(id);
shopProdCategoryService.disableShopProdCategory(id);
return CzgResult.success();
}
@PostMapping("enable/{id}")
@OperationLog("商品分类-启用")
//@SaAdminCheckPermission("prod:unit:able")
public CzgResult<Void> enable(@PathVariable("id") Long id) {
//@SaAdminCheckPermission("shopProdCategory:able")
public CzgResult<Void> enableShopProdCategory(@PathVariable("id") Long id) {
//效验数据
AssertUtil.isNull(id, "{}不能为空", "id");
shopProdCategoryService.enable(id);
shopProdCategoryService.enableShopProdCategory(id);
return CzgResult.success();
}