商品接口完善
This commit is contained in:
@@ -2,6 +2,7 @@ package com.macro.mall.controller;
|
|||||||
|
|
||||||
import com.macro.mall.dto.CommonResult;
|
import com.macro.mall.dto.CommonResult;
|
||||||
import com.macro.mall.dto.PmsProductCategoryParam;
|
import com.macro.mall.dto.PmsProductCategoryParam;
|
||||||
|
import com.macro.mall.dto.PmsProductCategoryWithChildrenItem;
|
||||||
import com.macro.mall.model.PmsProductCategory;
|
import com.macro.mall.model.PmsProductCategory;
|
||||||
import com.macro.mall.service.PmsProductCategoryService;
|
import com.macro.mall.service.PmsProductCategoryService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -108,4 +109,12 @@ public class PmsProductCategoryController {
|
|||||||
return new CommonResult().failed();
|
return new CommonResult().failed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("查询所有一级分类及子分类")
|
||||||
|
@RequestMapping(value = "/list/withChildren", method = RequestMethod.GET)
|
||||||
|
@ResponseBody
|
||||||
|
public Object listWithChildren() {
|
||||||
|
List<PmsProductCategoryWithChildrenItem> list = productCategoryService.listWithChildren();
|
||||||
|
return new CommonResult().success(list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,4 +82,56 @@ public class PmsProductController {
|
|||||||
return new CommonResult().failed();
|
return new CommonResult().failed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("批量上下架")
|
||||||
|
@RequestMapping(value = "/update/publishStatus",method = RequestMethod.POST)
|
||||||
|
@ResponseBody
|
||||||
|
public Object updatePublishStatus(@RequestParam("ids") List<Long> ids,
|
||||||
|
@RequestParam("publishStatus") Integer publishStatus) {
|
||||||
|
int count = productService.updatePublishStatus(ids, publishStatus);
|
||||||
|
if (count > 0) {
|
||||||
|
return new CommonResult().success(count);
|
||||||
|
} else {
|
||||||
|
return new CommonResult().failed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("批量推荐商品")
|
||||||
|
@RequestMapping(value = "/update/recommendStatus",method = RequestMethod.POST)
|
||||||
|
@ResponseBody
|
||||||
|
public Object updateRecommendStatus(@RequestParam("ids") List<Long> ids,
|
||||||
|
@RequestParam("recommendStatus") Integer recommendStatus) {
|
||||||
|
int count = productService.updateRecommendStatus(ids, recommendStatus);
|
||||||
|
if (count > 0) {
|
||||||
|
return new CommonResult().success(count);
|
||||||
|
} else {
|
||||||
|
return new CommonResult().failed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("批量设为新品")
|
||||||
|
@RequestMapping(value = "/update/newStatus",method = RequestMethod.POST)
|
||||||
|
@ResponseBody
|
||||||
|
public Object updateNewStatus(@RequestParam("ids") List<Long> ids,
|
||||||
|
@RequestParam("newStatus") Integer newStatus) {
|
||||||
|
int count = productService.updateNewStatus(ids, newStatus);
|
||||||
|
if (count > 0) {
|
||||||
|
return new CommonResult().success(count);
|
||||||
|
} else {
|
||||||
|
return new CommonResult().failed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("批量修改删除状态")
|
||||||
|
@RequestMapping(value = "/update/deleteStatus",method = RequestMethod.POST)
|
||||||
|
@ResponseBody
|
||||||
|
public Object updateDeleteStatus(@RequestParam("ids") List<Long> ids,
|
||||||
|
@RequestParam("deleteStatus") Integer deleteStatus) {
|
||||||
|
int count = productService.updateDeleteStatus(ids, deleteStatus);
|
||||||
|
if (count > 0) {
|
||||||
|
return new CommonResult().success(count);
|
||||||
|
} else {
|
||||||
|
return new CommonResult().failed();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.macro.mall.dao;
|
||||||
|
|
||||||
|
import com.macro.mall.dto.PmsProductCategoryWithChildrenItem;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品分类自定义Dao
|
||||||
|
* Created by macro on 2018/5/25.
|
||||||
|
*/
|
||||||
|
public interface PmsProductCategoryDao {
|
||||||
|
List<PmsProductCategoryWithChildrenItem> listWithChildren();
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.macro.mall.dto;
|
||||||
|
|
||||||
|
import com.macro.mall.model.PmsProductCategory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by macro on 2018/5/25.
|
||||||
|
*/
|
||||||
|
public class PmsProductCategoryWithChildrenItem extends PmsProductCategory {
|
||||||
|
private List<PmsProductCategory> children;
|
||||||
|
|
||||||
|
public List<PmsProductCategory> getChildren() {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChildren(List<PmsProductCategory> children) {
|
||||||
|
this.children = children;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.macro.mall.service;
|
package com.macro.mall.service;
|
||||||
|
|
||||||
import com.macro.mall.dto.PmsProductCategoryParam;
|
import com.macro.mall.dto.PmsProductCategoryParam;
|
||||||
|
import com.macro.mall.dto.PmsProductCategoryWithChildrenItem;
|
||||||
import com.macro.mall.model.PmsProductCategory;
|
import com.macro.mall.model.PmsProductCategory;
|
||||||
import org.springframework.transaction.annotation.Isolation;
|
import org.springframework.transaction.annotation.Isolation;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
@@ -28,4 +29,6 @@ public interface PmsProductCategoryService {
|
|||||||
int updateNavStatus(List<Long> ids, Integer navStatus);
|
int updateNavStatus(List<Long> ids, Integer navStatus);
|
||||||
|
|
||||||
int updateShowStatus(List<Long> ids, Integer showStatus);
|
int updateShowStatus(List<Long> ids, Integer showStatus);
|
||||||
|
|
||||||
|
List<PmsProductCategoryWithChildrenItem> listWithChildren();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,4 +45,12 @@ public interface PmsProductService {
|
|||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
int updateVerifyStatus(List<Long> ids, Integer verifyStatus, String detail);
|
int updateVerifyStatus(List<Long> ids, Integer verifyStatus, String detail);
|
||||||
|
|
||||||
|
int updatePublishStatus(List<Long> ids, Integer publishStatus);
|
||||||
|
|
||||||
|
int updateRecommendStatus(List<Long> ids, Integer recommendStatus);
|
||||||
|
|
||||||
|
int updateNewStatus(List<Long> ids, Integer newStatus);
|
||||||
|
|
||||||
|
int updateDeleteStatus(List<Long> ids, Integer deleteStatus);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.macro.mall.service.impl;
|
|||||||
|
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.macro.mall.dao.PmsProductCategoryAttributeRelationDao;
|
import com.macro.mall.dao.PmsProductCategoryAttributeRelationDao;
|
||||||
|
import com.macro.mall.dao.PmsProductCategoryDao;
|
||||||
import com.macro.mall.dto.PmsProductCategoryParam;
|
import com.macro.mall.dto.PmsProductCategoryParam;
|
||||||
|
import com.macro.mall.dto.PmsProductCategoryWithChildrenItem;
|
||||||
import com.macro.mall.mapper.PmsProductCategoryAttributeRelationMapper;
|
import com.macro.mall.mapper.PmsProductCategoryAttributeRelationMapper;
|
||||||
import com.macro.mall.mapper.PmsProductCategoryMapper;
|
import com.macro.mall.mapper.PmsProductCategoryMapper;
|
||||||
import com.macro.mall.mapper.PmsProductMapper;
|
import com.macro.mall.mapper.PmsProductMapper;
|
||||||
@@ -30,6 +32,8 @@ public class PmsProductCategoryServiceImpl implements PmsProductCategoryService
|
|||||||
private PmsProductCategoryAttributeRelationDao productCategoryAttributeRelationDao;
|
private PmsProductCategoryAttributeRelationDao productCategoryAttributeRelationDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private PmsProductCategoryAttributeRelationMapper productCategoryAttributeRelationMapper;
|
private PmsProductCategoryAttributeRelationMapper productCategoryAttributeRelationMapper;
|
||||||
|
@Autowired
|
||||||
|
private PmsProductCategoryDao productCategoryDao;
|
||||||
@Override
|
@Override
|
||||||
public int create(PmsProductCategoryParam pmsProductCategoryParam) {
|
public int create(PmsProductCategoryParam pmsProductCategoryParam) {
|
||||||
PmsProductCategory productCategory = new PmsProductCategory();
|
PmsProductCategory productCategory = new PmsProductCategory();
|
||||||
@@ -125,6 +129,11 @@ public class PmsProductCategoryServiceImpl implements PmsProductCategoryService
|
|||||||
return productCategoryMapper.updateByExampleSelective(productCategory, example);
|
return productCategoryMapper.updateByExampleSelective(productCategory, example);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PmsProductCategoryWithChildrenItem> listWithChildren() {
|
||||||
|
return productCategoryDao.listWithChildren();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据分类的parentId设置分类的level
|
* 根据分类的parentId设置分类的level
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -190,9 +190,44 @@ public class PmsProductServiceImpl implements PmsProductService {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updatePublishStatus(List<Long> ids, Integer publishStatus) {
|
||||||
|
PmsProduct record = new PmsProduct();
|
||||||
|
record.setPublishStatus(publishStatus);
|
||||||
|
PmsProductExample example = new PmsProductExample();
|
||||||
|
example.createCriteria().andIdIn(ids);
|
||||||
|
return productMapper.updateByExampleSelective(record, example);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateRecommendStatus(List<Long> ids, Integer recommendStatus) {
|
||||||
|
PmsProduct record = new PmsProduct();
|
||||||
|
record.setRecommandStatus(recommendStatus);
|
||||||
|
PmsProductExample example = new PmsProductExample();
|
||||||
|
example.createCriteria().andIdIn(ids);
|
||||||
|
return productMapper.updateByExampleSelective(record, example);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateNewStatus(List<Long> ids, Integer newStatus) {
|
||||||
|
PmsProduct record = new PmsProduct();
|
||||||
|
record.setNewStatus(newStatus);
|
||||||
|
PmsProductExample example = new PmsProductExample();
|
||||||
|
example.createCriteria().andIdIn(ids);
|
||||||
|
return productMapper.updateByExampleSelective(record, example);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateDeleteStatus(List<Long> ids, Integer deleteStatus) {
|
||||||
|
PmsProduct record = new PmsProduct();
|
||||||
|
record.setDeleteStatus(deleteStatus);
|
||||||
|
PmsProductExample example = new PmsProductExample();
|
||||||
|
example.createCriteria().andIdIn(ids);
|
||||||
|
return productMapper.updateByExampleSelective(record, example);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated 旧版创建
|
||||||
* 旧版创建
|
|
||||||
*/
|
*/
|
||||||
public int createOld(PmsProductParam productParam) {
|
public int createOld(PmsProductParam productParam) {
|
||||||
int count;
|
int count;
|
||||||
|
|||||||
18
mall-admin/src/main/resources/dao/PmsProductCategoryDao.xml
Normal file
18
mall-admin/src/main/resources/dao/PmsProductCategoryDao.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.macro.mall.dao.PmsProductCategoryDao">
|
||||||
|
<resultMap id="listWithChildrenMap" type="com.macro.mall.dto.PmsProductCategoryWithChildrenItem"
|
||||||
|
extends="com.macro.mall.mapper.PmsProductCategoryMapper.BaseResultMap">
|
||||||
|
<collection property="children" resultMap="com.macro.mall.mapper.PmsProductCategoryMapper.BaseResultMap"
|
||||||
|
columnPrefix="child_"></collection>
|
||||||
|
</resultMap>
|
||||||
|
<select id="listWithChildren" resultMap="listWithChildrenMap">
|
||||||
|
select
|
||||||
|
c1.id,
|
||||||
|
c1.name,
|
||||||
|
c2.id child_id,
|
||||||
|
c2.name child_name
|
||||||
|
from pms_product_category c1 left join pms_product_category c2 on c1.id = c2.parent_id
|
||||||
|
where c1.parent_id = 0
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user