商品模块代码提交

This commit is contained in:
Tankaikai 2025-02-17 10:12:45 +08:00
parent a6175be737
commit 4b725c36c8
11 changed files with 10 additions and 54 deletions

View File

@ -1,4 +1,4 @@
package com.czg.controller;
package com.czg.controller.admin;
import com.czg.log.annotation.OperationLog;
import com.czg.product.dto.ProductDTO;
@ -80,23 +80,4 @@ public class ProductController {
return CzgResult.success();
}
@PostMapping("disable/{id}")
@OperationLog("商品-禁用")
//@SaAdminCheckPermission("product:able")
public CzgResult<Void> disableProduct(@PathVariable("id") Long id) {
//效验数据
AssertUtil.isNull(id, "{}不能为空", "id");
productService.disableProduct(id);
return CzgResult.success();
}
@PostMapping("enable/{id}")
@OperationLog("商品-启用")
//@SaAdminCheckPermission("product:able")
public CzgResult<Void> enableProduct(@PathVariable("id") Long id) {
//效验数据
AssertUtil.isNull(id, "{}不能为空", "id");
productService.enableProduct(id);
return CzgResult.success();
}
}

View File

@ -1,4 +1,4 @@
package com.czg.controller;
package com.czg.controller.admin;
import com.czg.log.annotation.OperationLog;
import com.czg.product.dto.ShopProdCategoryDTO;

View File

@ -1,4 +1,4 @@
package com.czg.controller;
package com.czg.controller.admin;
import com.czg.log.annotation.OperationLog;
import com.czg.product.dto.ShopProdSpecDTO;

View File

@ -1,4 +1,4 @@
package com.czg.controller;
package com.czg.controller.admin;
import com.czg.log.annotation.OperationLog;
import com.czg.product.dto.ShopProdUnitDTO;

View File

@ -4,7 +4,6 @@ import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data;
import java.io.Serial;
@ -28,7 +27,7 @@ public class ProdSku implements Serializable {
/**
* id
*/
@Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
@Id(keyType = KeyType.Auto)
private Long id;
/**
* 店铺id

View File

@ -4,7 +4,6 @@ import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data;
import java.io.Serial;
@ -29,7 +28,7 @@ public class Product implements Serializable {
/**
* id
*/
@Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
@Id(keyType = KeyType.Auto)
private Long id;
/**
* 商品分类

View File

@ -4,7 +4,6 @@ import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data;
import java.io.Serial;
@ -27,7 +26,7 @@ public class ShopProdCategory implements Serializable {
/**
* id
*/
@Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
@Id(keyType = KeyType.Auto)
private Long id;
/**
* 分类名称

View File

@ -4,7 +4,6 @@ import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data;
import java.io.Serial;
@ -27,7 +26,7 @@ public class ShopProdSpec implements Serializable {
/**
* id
*/
@Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
@Id(keyType = KeyType.Auto)
private Long id;
/**
* 规格名称

View File

@ -4,7 +4,6 @@ import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data;
import java.io.Serial;
@ -27,7 +26,7 @@ public class ShopProdUnit implements Serializable {
/**
* id
*/
@Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
@Id(keyType = KeyType.Auto)
private Long id;
/**
* 单位名称

View File

@ -26,8 +26,4 @@ public interface ProductService extends IService<Product> {
boolean updateProduct(ProductDTO dto);
boolean disableProduct(Long id);
boolean enableProduct(Long id);
}

View File

@ -147,25 +147,9 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
@Override
public boolean deleteProduct(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
return super.remove(query().eq(Product::getId, id).eq(Product::getShopId, shopId));
}
@Override
public boolean disableProduct(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
return UpdateChain.of(Product.class)
//.set(Product::getStatus, StatusEnum.DISABLE.value())
.eq(Product::getId, id)
.eq(Product::getShopId, shopId)
.update();
}
@Override
public boolean enableProduct(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
return UpdateChain.of(Product.class)
//.set(Product::getStatus, StatusEnum.ENABLED.value())
.set(Product::getIsDel, DeleteEnum.DELETED.value())
.eq(Product::getId, id)
.eq(Product::getShopId, shopId)
.update();