|
@@ -1,31 +1,26 @@
|
|
|
package com.txz.mall.controller.appcontroller;
|
|
|
|
|
|
-import com.alibaba.fastjson.annotation.JSONField;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
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.StoreProduct;
|
|
|
+import com.txz.mall.service.StorePinkService;
|
|
|
import com.txz.mall.service.StoreProductService;
|
|
|
-import dto.StoreProductAddRequest;
|
|
|
+import com.txz.mall.web.vo.ProductCarouselVO;
|
|
|
import dto.StoreProductDTO;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
|
import tk.mybatis.mapper.entity.Example.Criteria;
|
|
|
import vo.StoreProductCountItemVO;
|
|
|
import vo.StoreProductInfoVO;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -35,77 +30,80 @@ import java.util.List;
|
|
|
@RestController
|
|
|
@RequestMapping("/app/product")
|
|
|
public class AppProductController {
|
|
|
-
|
|
|
+
|
|
|
private static Logger log = LoggerFactory.getLogger(AppProductController.class);
|
|
|
-
|
|
|
+
|
|
|
@Resource
|
|
|
private StoreProductService storeProductService;
|
|
|
-
|
|
|
-// @DeleteMapping("/delete")
|
|
|
-// @ApiOperation(value = "商品删除")
|
|
|
-// public Result delete(@RequestParam("ids") List<Long> ids) {
|
|
|
-// if (CollectionUtils.isEmpty(ids)) {
|
|
|
-// return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
-// }
|
|
|
-// try {
|
|
|
-// ids.forEach(id -> {
|
|
|
-// StoreProduct storeProduct = new StoreProduct();
|
|
|
-// storeProduct.setId(id);
|
|
|
-//// storeProduct.setIsRecycle(1);
|
|
|
-// storeProduct.setIsDelete(1);
|
|
|
-// storeProduct.setUpdateTime(new Date());
|
|
|
-// storeProductService.update(storeProduct);
|
|
|
-// });
|
|
|
-// } catch (Exception e) {
|
|
|
-// log.error("删除对象操作异常e:{}", e);
|
|
|
-// return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
-// }
|
|
|
-// return Result.success();
|
|
|
-// }
|
|
|
-
|
|
|
-// @PutMapping("/update")
|
|
|
-// @ApiOperation(value = "商品更新")
|
|
|
-// public Result update(@RequestBody @Validated StoreProductAddRequest request) {
|
|
|
-// if (request == null) {
|
|
|
-// return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
-// }
|
|
|
-// if (request.getId() == null) {
|
|
|
-// return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
-// }
|
|
|
-// storeProductService.update(request);
|
|
|
-// return Result.success();
|
|
|
-// }
|
|
|
-
|
|
|
-// @PostMapping("/updateShowStatus")
|
|
|
-// @ApiOperation(value = "商品上下架")
|
|
|
-// public Result updateShowStatus(@RequestParam Long id, @RequestParam Integer ShowStatus) {
|
|
|
-// if (ShowStatus == null) {
|
|
|
-// return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
-// }
|
|
|
-// if (id == null) {
|
|
|
-// return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
-// }
|
|
|
-//
|
|
|
-// try {
|
|
|
-// StoreProduct storeProduct = new StoreProduct();
|
|
|
-// storeProduct.setUpdateTime(new Date());
|
|
|
-//// storeProduct.setUpdateUserId(userId);
|
|
|
-// storeProduct.setId(id);
|
|
|
-// storeProduct.setIsShow(ShowStatus);
|
|
|
-// storeProductService.update(storeProduct);
|
|
|
-// } catch (Exception e) {
|
|
|
-// log.error("更新对象操作异常e:{}", e);
|
|
|
-// return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
-// }
|
|
|
-// return Result.success();
|
|
|
-// }
|
|
|
-
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private StorePinkService storePinkService;
|
|
|
+
|
|
|
+ // @DeleteMapping("/delete")
|
|
|
+ // @ApiOperation(value = "商品删除")
|
|
|
+ // public Result delete(@RequestParam("ids") List<Long> ids) {
|
|
|
+ // if (CollectionUtils.isEmpty(ids)) {
|
|
|
+ // return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ // }
|
|
|
+ // try {
|
|
|
+ // ids.forEach(id -> {
|
|
|
+ // StoreProduct storeProduct = new StoreProduct();
|
|
|
+ // storeProduct.setId(id);
|
|
|
+ //// storeProduct.setIsRecycle(1);
|
|
|
+ // storeProduct.setIsDelete(1);
|
|
|
+ // storeProduct.setUpdateTime(new Date());
|
|
|
+ // storeProductService.update(storeProduct);
|
|
|
+ // });
|
|
|
+ // } catch (Exception e) {
|
|
|
+ // log.error("删除对象操作异常e:{}", e);
|
|
|
+ // return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ // }
|
|
|
+ // return Result.success();
|
|
|
+ // }
|
|
|
+
|
|
|
+ // @PutMapping("/update")
|
|
|
+ // @ApiOperation(value = "商品更新")
|
|
|
+ // public Result update(@RequestBody @Validated StoreProductAddRequest request) {
|
|
|
+ // if (request == null) {
|
|
|
+ // return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
+ // }
|
|
|
+ // if (request.getId() == null) {
|
|
|
+ // return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ // }
|
|
|
+ // storeProductService.update(request);
|
|
|
+ // return Result.success();
|
|
|
+ // }
|
|
|
+
|
|
|
+ // @PostMapping("/updateShowStatus")
|
|
|
+ // @ApiOperation(value = "商品上下架")
|
|
|
+ // public Result updateShowStatus(@RequestParam Long id, @RequestParam Integer ShowStatus) {
|
|
|
+ // if (ShowStatus == null) {
|
|
|
+ // return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
+ // }
|
|
|
+ // if (id == null) {
|
|
|
+ // return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // try {
|
|
|
+ // StoreProduct storeProduct = new StoreProduct();
|
|
|
+ // storeProduct.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ /// / storeProduct.setUpdateUserId(userId);
|
|
|
+ // storeProduct.setId(id);
|
|
|
+ // storeProduct.setIsShow(ShowStatus);
|
|
|
+ // storeProductService.update(storeProduct);
|
|
|
+ // } catch (Exception e) {
|
|
|
+ // log.error("更新对象操作异常e:{}", e);
|
|
|
+ // return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ // }
|
|
|
+ // return Result.success();
|
|
|
+ // }
|
|
|
@PostMapping("/list")
|
|
|
@ApiOperation(value = "商品获取列表")
|
|
|
public Result<List<StoreProduct>> list(@RequestBody StoreProductDTO dto) {
|
|
|
-
|
|
|
+
|
|
|
PageHelper.startPage(dto.getPage(), dto.getSize());
|
|
|
-
|
|
|
+
|
|
|
Condition condition = new Condition(StoreProduct.class);
|
|
|
Criteria criteria = condition.createCriteria();
|
|
|
criteria.andEqualTo("isDelete", 0);
|
|
@@ -138,64 +136,71 @@ public class AppProductController {
|
|
|
}
|
|
|
return Result.success(pageInfo);
|
|
|
}
|
|
|
-
|
|
|
-// @ApiOperation("商品导入")
|
|
|
-// @PostMapping("/import")
|
|
|
-// public Result importFile(@JSONField(serialize = false) @RequestParam("file") MultipartFile file) {
|
|
|
-// storeProductService.importFile(file);
|
|
|
-// return Result.success();
|
|
|
-// }
|
|
|
-
|
|
|
-// @ApiOperation("商品导入模版")
|
|
|
-// @PostMapping("/export")
|
|
|
-// public Result exportFile(HttpServletResponse response) {
|
|
|
-// storeProductService.exportFile(response);
|
|
|
-// return Result.success();
|
|
|
-// }
|
|
|
-
|
|
|
+
|
|
|
+ // @ApiOperation("商品导入")
|
|
|
+ // @PostMapping("/import")
|
|
|
+ // public Result importFile(@JSONField(serialize = false) @RequestParam("file") MultipartFile file) {
|
|
|
+ // storeProductService.importFile(file);
|
|
|
+ // return Result.success();
|
|
|
+ // }
|
|
|
+
|
|
|
+ // @ApiOperation("商品导入模版")
|
|
|
+ // @PostMapping("/export")
|
|
|
+ // public Result exportFile(HttpServletResponse response) {
|
|
|
+ // storeProductService.exportFile(response);
|
|
|
+ // return Result.success();
|
|
|
+ // }
|
|
|
+
|
|
|
@ApiOperation(value = "商品详情")
|
|
|
@GetMapping(value = "/detail")
|
|
|
public Result<StoreProductInfoVO> info(@RequestParam Long id) {
|
|
|
return Result.success(storeProductService.getInfo(id));
|
|
|
}
|
|
|
-
|
|
|
-// @PostMapping("/batchShowStatus")
|
|
|
-// @ApiOperation(value = "批量商品上下架")
|
|
|
-// public Result batchShowStatus(@RequestParam("ids") List<Long> ids, @RequestParam("showStatus") Integer showStatus) {
|
|
|
-// if (showStatus == null) {
|
|
|
-// return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
-// }
|
|
|
-// if (CollectionUtils.isEmpty(ids)) {
|
|
|
-// return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
-// }
|
|
|
-//
|
|
|
-// try {
|
|
|
-// ids.forEach(id -> {
|
|
|
-// StoreProduct storeProduct = new StoreProduct();
|
|
|
-// storeProduct.setUpdateTime(new Date());
|
|
|
-//// storeProduct.setUpdateUserId(userId);
|
|
|
-// storeProduct.setId(id);
|
|
|
-// storeProduct.setIsShow(showStatus);
|
|
|
-// storeProductService.update(storeProduct);
|
|
|
-// });
|
|
|
-// } catch (Exception e) {
|
|
|
-// log.error("更新对象操作异常e:{}", e);
|
|
|
-// return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
-// }
|
|
|
-// return Result.success();
|
|
|
-// }
|
|
|
-
|
|
|
+
|
|
|
+ // @PostMapping("/batchShowStatus")
|
|
|
+ // @ApiOperation(value = "批量商品上下架")
|
|
|
+ // public Result batchShowStatus(@RequestParam("ids") List<Long> ids, @RequestParam("showStatus") Integer showStatus) {
|
|
|
+ // if (showStatus == null) {
|
|
|
+ // return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
+ // }
|
|
|
+ // if (CollectionUtils.isEmpty(ids)) {
|
|
|
+ // return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // try {
|
|
|
+ // ids.forEach(id -> {
|
|
|
+ // StoreProduct storeProduct = new StoreProduct();
|
|
|
+ // storeProduct.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ /// / storeProduct.setUpdateUserId(userId);
|
|
|
+ // storeProduct.setId(id);
|
|
|
+ // storeProduct.setIsShow(showStatus);
|
|
|
+ // storeProductService.update(storeProduct);
|
|
|
+ // });
|
|
|
+ // } catch (Exception e) {
|
|
|
+ // log.error("更新对象操作异常e:{}", e);
|
|
|
+ // return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ // }
|
|
|
+ // return Result.success();
|
|
|
+ // }
|
|
|
@ApiOperation(value = "获取商品各状态数量")
|
|
|
@GetMapping(value = "/status/num")
|
|
|
public Result<StoreProductCountItemVO> getOrderStatusNum() {
|
|
|
return Result.success(storeProductService.getOrderStatusNum());
|
|
|
}
|
|
|
-
|
|
|
-// @ApiOperation(value = "新增商品")
|
|
|
-// @PostMapping(value = "/add")
|
|
|
-// public Result<String> save(@RequestBody @Validated StoreProductAddRequest request) {
|
|
|
-// storeProductService.save(request);
|
|
|
-// return Result.success();
|
|
|
-// }
|
|
|
-
|
|
|
+
|
|
|
+ // @ApiOperation(value = "新增商品")
|
|
|
+ // @PostMapping(value = "/add")
|
|
|
+ // public Result<String> save(@RequestBody @Validated StoreProductAddRequest request) {
|
|
|
+ // storeProductService.save(request);
|
|
|
+ // return Result.success();
|
|
|
+ // }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商品轮播
|
|
|
+ */
|
|
|
+ @GetMapping("carousel/{productId:^\\d+$}")
|
|
|
+ public Result<List<ProductCarouselVO>> carousel(@PathVariable("productId") Long productId) {
|
|
|
+ return Result.success(storePinkService.carousel(productId));
|
|
|
+ }
|
|
|
}
|