feat(后台管理): 栏目管理

完善菜单
master
wayn 4 years ago
parent 751d877b3f
commit 94e6340c08

@ -1,9 +1,15 @@
package com.wayn.admin.api.controller.shop; package com.wayn.admin.api.controller.shop;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.base.controller.BaseController; import com.wayn.common.base.controller.BaseController;
import com.wayn.common.core.domain.shop.Column; import com.wayn.common.core.domain.shop.Column;
import com.wayn.common.core.domain.shop.ColumnGoodsRelation;
import com.wayn.common.core.domain.shop.Goods;
import com.wayn.common.core.service.shop.IColumnGoodsRelationService;
import com.wayn.common.core.service.shop.IColumnService; import com.wayn.common.core.service.shop.IColumnService;
import com.wayn.common.core.service.shop.IGoodsService;
import com.wayn.common.util.R; import com.wayn.common.util.R;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -11,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@RestController @RestController
@RequestMapping("shop/column") @RequestMapping("shop/column")
@ -19,6 +26,12 @@ public class ColumnController extends BaseController {
@Autowired @Autowired
private IColumnService iColumnService; private IColumnService iColumnService;
@Autowired
private IColumnGoodsRelationService iColumnGoodsRelationService;
@Autowired
private IGoodsService iGoodsService;
@GetMapping("/list") @GetMapping("/list")
public R list(Column column) { public R list(Column column) {
Page<Column> page = getPage(); Page<Column> page = getPage();
@ -47,4 +60,33 @@ public class ColumnController extends BaseController {
return R.result(iColumnService.removeByIds(columnIds)); return R.result(iColumnService.removeByIds(columnIds));
} }
@GetMapping("bindGoodsList")
public R bindGoodsList(Goods goods, Long columnId) {
Page<Goods> page = getPage();
List<ColumnGoodsRelation> goodsRelationList = iColumnGoodsRelationService.list(new QueryWrapper<ColumnGoodsRelation>()
.eq("column_id", columnId));
List<Long> columnGoodsIds = goodsRelationList.stream().map(ColumnGoodsRelation::getGoodsId).collect(Collectors.toList());
IPage<Goods> listPage = iGoodsService.listColumnBindGoodsPage(page, goods, columnGoodsIds);
return R.success().add("page", listPage);
}
@GetMapping("unBindGoodsList")
public R unBindGoodsList(Goods goods, Long columnId) {
Page<Goods> page = getPage();
List<ColumnGoodsRelation> goodsRelationList = iColumnGoodsRelationService.list(new QueryWrapper<ColumnGoodsRelation>()
.eq("column_id", columnId));
List<Long> columnGoodsIds = goodsRelationList.stream().map(ColumnGoodsRelation::getGoodsId).collect(Collectors.toList());
IPage<Goods> listPage = iGoodsService.listColumnUnBindGoodsPage(page, goods, columnGoodsIds);
return R.success().add("page", listPage);
}
@PostMapping("goods")
public R addGoods(@RequestBody ColumnGoodsRelation columnGoodsRelation) {
return R.result(iColumnGoodsRelationService.save(columnGoodsRelation));
}
@DeleteMapping("goods/{id}")
public R deleteGoods(@PathVariable Long id) {
return R.result(iColumnGoodsRelationService.removeById(id));
}
} }

@ -29,12 +29,12 @@ public class ColumnGoodsRelation implements Serializable {
/** /**
* ID * ID
*/ */
private Integer columnId; private Long columnId;
/** /**
* ID * ID
*/ */
private Integer goodsId; private Long goodsId;
} }

@ -23,4 +23,8 @@ public interface GoodsMapper extends BaseMapper<Goods> {
IPage<Goods> selectGoodsListPageByl2CateId(Page<Goods> page, List<Long> cateList); IPage<Goods> selectGoodsListPageByl2CateId(Page<Goods> page, List<Long> cateList);
List<Goods> searchResult(Page<SearchVO> page, SearchVO searchVO); List<Goods> searchResult(Page<SearchVO> page, SearchVO searchVO);
IPage<Goods> selectColumnBindGoodsListPage(Page<Goods> page, Goods goods, List<Long> columnGoodsIds);
IPage<Goods> selectColumnUnBindGoodsListPage(Page<Goods> page, Goods goods, List<Long> columnGoodsIds);
} }

@ -31,6 +31,10 @@ public interface IGoodsService extends IService<Goods> {
*/ */
IPage<Goods> listPage(Page<Goods> page, Goods goods); IPage<Goods> listPage(Page<Goods> page, Goods goods);
IPage<Goods> listColumnBindGoodsPage(Page<Goods> page, Goods goods, List<Long> columnGoodsIds);
IPage<Goods> listColumnUnBindGoodsPage(Page<Goods> page, Goods goods, List<Long> columnGoodsIds);
/** /**
* *
* *
@ -65,6 +69,7 @@ public interface IGoodsService extends IService<Goods> {
/** /**
* *
*
* @param goodsSaveRelatedVO VO * @param goodsSaveRelatedVO VO
* @return R * @return R
*/ */
@ -72,7 +77,8 @@ public interface IGoodsService extends IService<Goods> {
/** /**
* Id * Id
* @param page *
* @param page
* @param l2cateList Id * @param l2cateList Id
* @return r * @return r
*/ */

@ -55,6 +55,16 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
return goodsMapper.selectGoodsListPage(page, goods); return goodsMapper.selectGoodsListPage(page, goods);
} }
@Override
public IPage<Goods> listColumnBindGoodsPage(Page<Goods> page, Goods goods, List<Long> columnGoodsIds) {
return goodsMapper.selectColumnBindGoodsListPage(page, goods, columnGoodsIds);
}
@Override
public IPage<Goods> listColumnUnBindGoodsPage(Page<Goods> page, Goods goods, List<Long> columnGoodsIds) {
return goodsMapper.selectColumnUnBindGoodsListPage(page, goods, columnGoodsIds);
}
@Override @Override
public Map<String, Object> getGoodsInfoById(Long goodsId) { public Map<String, Object> getGoodsInfoById(Long goodsId) {
Goods goods = goodsMapper.selectById(goodsId); Goods goods = goodsMapper.selectById(goodsId);

@ -24,6 +24,12 @@
<if test="column.name != null and column.name != ''"> <if test="column.name != null and column.name != ''">
AND name like concat('%', #{column.name}, '%') AND name like concat('%', #{column.name}, '%')
</if> </if>
<if test="column.startTime != null and column.startTime != ''">
and DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ >= ]]> DATE_FORMAT(#{column.startTime},'%Y-%m-%d')
</if>
<if test="column.endTime != null and column.endTime != ''">
and DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ <= ]]> DATE_FORMAT(#{column.endTime},'%Y-%m-%d')
</if>
</where> </where>
order by create_time desc order by create_time desc
</select> </select>

@ -93,4 +93,48 @@
</if> </if>
</where> </where>
</select> </select>
<select id="selectColumnBindGoodsListPage" resultMap="ShopGoodsResult">
<include refid="selectGoodsVo"/>
<where>
del_flag = 0
and is_on_sale = 1
<if test="goods.goodsSn != null and goods.goodsSn != ''">
AND goods_sn like concat('%', #{goods.goodsSn}, '%')
</if>
<if test="goods.name != null and goods.name != ''">
AND name like concat('%', #{goods.name}, '%')
</if>
<if test="columnGoodsIds.size() > 0">
and id in
(
<foreach collection="columnGoodsIds" item="columnGoodsId" separator=",">
#{columnGoodsId}
</foreach>
)
</if>
</where>
</select>
<select id="selectColumnUnBindGoodsListPage" resultMap="ShopGoodsResult">
<include refid="selectGoodsVo"/>
<where>
del_flag = 0
and is_on_sale = 1
<if test="goods.goodsSn != null and goods.goodsSn != ''">
AND goods_sn like concat('%', #{goods.goodsSn}, '%')
</if>
<if test="goods.name != null and goods.name != ''">
AND name like concat('%', #{goods.name}, '%')
</if>
<if test="columnGoodsIds.size() > 0">
and id not in
(
<foreach collection="columnGoodsIds" item="columnGoodsId" separator=",">
#{columnGoodsId}
</foreach>
)
</if>
</where>
</select>
</mapper> </mapper>

Loading…
Cancel
Save