|
@@ -0,0 +1,137 @@
|
|
|
+package com.txz.mall.controller;
|
|
|
+
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.txz.mall.core.Result;
|
|
|
+import com.txz.mall.core.ResultCode;
|
|
|
+import com.txz.mall.model.StoreProductAttrResult;
|
|
|
+import com.txz.mall.service.StoreProductAttrResultService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import tk.mybatis.mapper.entity.Condition;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by CodeGenerator on 2025/07/11.
|
|
|
+ */
|
|
|
+@Api(tags = "[后台]商品属性管理")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/store/product/attr/result")
|
|
|
+public class StoreProductAttrResultController {
|
|
|
+
|
|
|
+ private static Logger log = LoggerFactory.getLogger(StoreProductAttrResultController.class);
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private StoreProductAttrResultService storeProductAttrResultService;
|
|
|
+
|
|
|
+ @PostMapping("/add")
|
|
|
+ @ApiOperation(value = "商品属性新增", httpMethod = "POST")
|
|
|
+ public Result add(@RequestBody StoreProductAttrResult storeProductAttrResult, Long userId) {
|
|
|
+ if (storeProductAttrResult == null) {
|
|
|
+ return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
+ }
|
|
|
+ if (userId == null) {
|
|
|
+ return Result.fail(ResultCode.USERID_IS_NULL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ storeProductAttrResult.setCreateTime(new Date());
|
|
|
+ storeProductAttrResult.setCreateUserId(userId);
|
|
|
+ storeProductAttrResultService.save(storeProductAttrResult);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("新增对象操作异常e:{}", e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/delete")
|
|
|
+ @ApiOperation(value = "商品属性删除", httpMethod = "POST")
|
|
|
+ public Result delete(@RequestParam Long id, Long userId) {
|
|
|
+ if (id == null) {
|
|
|
+ return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ }
|
|
|
+ if (userId == null) {
|
|
|
+ return Result.fail(ResultCode.USERID_IS_NULL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ StoreProductAttrResult storeProductAttrResult = new StoreProductAttrResult();
|
|
|
+ storeProductAttrResult.setId(id);
|
|
|
+ storeProductAttrResult.setIsDelete(1);
|
|
|
+ storeProductAttrResultService.update(storeProductAttrResult);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("删除对象操作异常e:{}", e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/update")
|
|
|
+ @ApiOperation(value = "商品属性更新", httpMethod = "POST")
|
|
|
+ public Result update(@RequestBody StoreProductAttrResult storeProductAttrResult, Long userId) {
|
|
|
+ if (storeProductAttrResult == null) {
|
|
|
+ return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
+ }
|
|
|
+ if (storeProductAttrResult.getId() == null) {
|
|
|
+ return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ }
|
|
|
+ if (userId == null) {
|
|
|
+ return Result.fail(ResultCode.USERID_IS_NULL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ storeProductAttrResult.setUpdateTime(new Date());
|
|
|
+ storeProductAttrResult.setUpdateUserId(userId);
|
|
|
+ storeProductAttrResultService.update(storeProductAttrResult);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("更新对象操作异常e:{}", e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/detail")
|
|
|
+ @ApiOperation(value = "商品属性获取详情", httpMethod = "POST")
|
|
|
+ public Result<StoreProductAttrResult> detail(@RequestParam Long id, Long userId) {
|
|
|
+ if (id == null) {
|
|
|
+ return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ }
|
|
|
+ if (userId == null) {
|
|
|
+ return Result.fail(ResultCode.USERID_IS_NULL);
|
|
|
+ }
|
|
|
+ StoreProductAttrResult storeProductAttrResult = null;
|
|
|
+ try {
|
|
|
+ storeProductAttrResult = storeProductAttrResultService.findById(id);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询对象操作异常e:{}", e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success(storeProductAttrResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/list")
|
|
|
+ @ApiOperation(value = "商品属性获取列表", httpMethod = "POST")
|
|
|
+ public Result<List<StoreProductAttrResult>> list(@RequestBody StoreProductAttrResult storeProductAttrResult, @RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, Long userId) {
|
|
|
+ if (userId == null) {
|
|
|
+ return Result.fail(ResultCode.USERID_IS_NULL);
|
|
|
+ }
|
|
|
+ PageHelper.startPage(page, size);
|
|
|
+
|
|
|
+ Condition condition = new Condition(storeProductAttrResult.getClass());
|
|
|
+// Criteria criteria = condition.createCriteria();
|
|
|
+// criteria.andEqualTo("name", city.getName());
|
|
|
+ PageInfo pageInfo = null;
|
|
|
+ try {
|
|
|
+ List<StoreProductAttrResult> list = storeProductAttrResultService.findByCondition(condition);
|
|
|
+ pageInfo = new PageInfo(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询对象操作异常e:{}", e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success(pageInfo);
|
|
|
+ }
|
|
|
+}
|