提交 d569bfda 作者: xiaowang

新增:web首页分类信息

上级 54b07385
...@@ -3,14 +3,12 @@ package com.mmc.pms.controller; ...@@ -3,14 +3,12 @@ package com.mmc.pms.controller;
import com.mmc.pms.common.Page; import com.mmc.pms.common.Page;
import com.mmc.pms.common.ResultBody; import com.mmc.pms.common.ResultBody;
import com.mmc.pms.constant.TokenConstant; import com.mmc.pms.constant.TokenConstant;
import com.mmc.pms.model.categories.dto.CategoryTypeDTO;
import com.mmc.pms.model.lease.dto.LeaseGoodsInfoDTO; import com.mmc.pms.model.lease.dto.LeaseGoodsInfoDTO;
import com.mmc.pms.model.qo.WareInfoQO; import com.mmc.pms.model.qo.WareInfoQO;
import com.mmc.pms.model.sale.dto.MallGoodsDetailDTO; import com.mmc.pms.model.sale.dto.MallGoodsDetailDTO;
import com.mmc.pms.service.WebDeviceService; import com.mmc.pms.service.WebDeviceService;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
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;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -33,11 +31,12 @@ public class ProductMallController extends BaseController { ...@@ -33,11 +31,12 @@ public class ProductMallController extends BaseController {
@PostMapping("/deviceList") @PostMapping("/deviceList")
public ResultBody<LeaseGoodsInfoDTO> listWareInfoPage( public ResultBody<LeaseGoodsInfoDTO> listWareInfoPage(
@RequestBody @Validated(Page.class) WareInfoQO param, HttpServletRequest request) { @RequestBody @Validated(Page.class) WareInfoQO param, HttpServletRequest request) {
if (request.getHeader(TokenConstant.TOKEN) == null) {
return webDeviceService.listWareInfoPage(param, null, null);
}
return webDeviceService.listWareInfoPage( return webDeviceService.listWareInfoPage(
param, request, this.getUserLoginInfoFromRedis(request).getUserAccountId()); param,
request,
request.getHeader(TokenConstant.TOKEN) == null
? null
: this.getUserLoginInfoFromRedis(request).getUserAccountId());
} }
@ApiOperation(value = "设备设备详情") @ApiOperation(value = "设备设备详情")
...@@ -45,10 +44,19 @@ public class ProductMallController extends BaseController { ...@@ -45,10 +44,19 @@ public class ProductMallController extends BaseController {
@GetMapping("/getLeaseGoodsDetail") @GetMapping("/getLeaseGoodsDetail")
public ResultBody<MallGoodsDetailDTO> getLeaseGoodsDetail( public ResultBody<MallGoodsDetailDTO> getLeaseGoodsDetail(
Integer goodsId, HttpServletRequest request) { Integer goodsId, HttpServletRequest request) {
if (request.getHeader(TokenConstant.TOKEN) == null) {
return webDeviceService.getLeaseGoodsDetail(goodsId, null, null);
}
return webDeviceService.getLeaseGoodsDetail( return webDeviceService.getLeaseGoodsDetail(
goodsId, this.getUserLoginInfoFromRedis(request).getUserAccountId(), request); goodsId,
request.getHeader(TokenConstant.TOKEN) == null
? null
: this.getUserLoginInfoFromRedis(request).getUserAccountId(),
request);
}
@ApiOperation(value = "web-首页分类数据-展示")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = CategoryTypeDTO.class)})
@GetMapping("/getPageHomeCategories")
public ResultBody<CategoryTypeDTO> getPageHomeCategories(
@ApiParam(value = "类型:1:作业服务 2:设备 3:培训 4:产品商城") @RequestParam(value = "type") Integer type) {
return webDeviceService.getPageHomeCategories(type);
} }
} }
...@@ -60,4 +60,6 @@ public interface CategoriesDao { ...@@ -60,4 +60,6 @@ public interface CategoriesDao {
List<Categories> getCategoriesListByIds(@Param("ids") Set<Integer> ids); List<Categories> getCategoriesListByIds(@Param("ids") Set<Integer> ids);
List<Categories> selectCategoryByDirectoryId(List<Integer> directoryIds); List<Categories> selectCategoryByDirectoryId(List<Integer> directoryIds);
List<Categories> getCategoriesListByDirectoryIds(List<Integer> directoryIds);
} }
package com.mmc.pms.entity; package com.mmc.pms.entity;
import com.mmc.pms.model.categories.dto.CategoriesInfoListDTO; import com.mmc.pms.model.categories.dto.CategoriesInfoListDTO;
import com.mmc.pms.model.categories.dto.CategoryTypeDTO;
import com.mmc.pms.model.categories.dto.ClassifyDetailsDTO; import com.mmc.pms.model.categories.dto.ClassifyDetailsDTO;
import com.mmc.pms.model.categories.dto.ClassifyInfoDTO; import com.mmc.pms.model.categories.dto.ClassifyInfoDTO;
import com.mmc.pms.model.categories.vo.ClassifyInfoVO; import com.mmc.pms.model.categories.vo.ClassifyInfoVO;
...@@ -83,4 +84,8 @@ public class Categories implements Serializable { ...@@ -83,4 +84,8 @@ public class Categories implements Serializable {
.name(name) .name(name)
.build(); .build();
} }
public CategoryTypeDTO buildCategoryTypeDTO() {
return CategoryTypeDTO.builder().id(id).categoryName(name).build();
}
} }
package com.mmc.pms.model.categories.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @Author LW
*
* @date 2023/6/10 13:46 概要:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class CategoryTypeDTO implements Serializable {
private Integer id;
private String categoryName;
}
...@@ -474,6 +474,7 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -474,6 +474,7 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
} }
} }
} }
}
// 2、对自定义的sku进行操作 // 2、对自定义的sku进行操作
List<GoodsProdSpecVO> zdySpecInfo = List<GoodsProdSpecVO> zdySpecInfo =
goodsAddVO.getProductSpec().stream() goodsAddVO.getProductSpec().stream()
...@@ -483,7 +484,6 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -483,7 +484,6 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
updateCustomize(goodsInfo, zdySpecInfo, goodsAddVO.getId()); updateCustomize(goodsInfo, zdySpecInfo, goodsAddVO.getId());
} }
} }
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateCustomize(GoodsInfo goodsInfo, List<GoodsProdSpecVO> zdySpecInfo, Integer id) { public void updateCustomize(GoodsInfo goodsInfo, List<GoodsProdSpecVO> zdySpecInfo, Integer id) {
......
...@@ -4,6 +4,7 @@ import com.mmc.pms.auth.dto.UserAccountSimpleDTO; ...@@ -4,6 +4,7 @@ import com.mmc.pms.auth.dto.UserAccountSimpleDTO;
import com.mmc.pms.common.ResultBody; import com.mmc.pms.common.ResultBody;
import com.mmc.pms.common.ResultEnum; import com.mmc.pms.common.ResultEnum;
import com.mmc.pms.constant.TokenConstant; import com.mmc.pms.constant.TokenConstant;
import com.mmc.pms.dao.CategoriesDao;
import com.mmc.pms.dao.GoodsInfoDao; import com.mmc.pms.dao.GoodsInfoDao;
import com.mmc.pms.dao.ProductDao; import com.mmc.pms.dao.ProductDao;
import com.mmc.pms.dao.WebDeviceDao; import com.mmc.pms.dao.WebDeviceDao;
...@@ -19,6 +20,7 @@ import com.mmc.pms.model.sale.dto.MallGoodsDetailDTO; ...@@ -19,6 +20,7 @@ import com.mmc.pms.model.sale.dto.MallGoodsDetailDTO;
import com.mmc.pms.model.sale.dto.SkuInfoDTO; import com.mmc.pms.model.sale.dto.SkuInfoDTO;
import com.mmc.pms.page.PageResult; import com.mmc.pms.page.PageResult;
import com.mmc.pms.service.WebDeviceService; import com.mmc.pms.service.WebDeviceService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -41,8 +43,11 @@ public class WebDeviceServiceImpl implements WebDeviceService { ...@@ -41,8 +43,11 @@ public class WebDeviceServiceImpl implements WebDeviceService {
@Autowired ProductDao productDao; @Autowired ProductDao productDao;
@Autowired GoodsInfoDao goodsInfoDao; @Autowired GoodsInfoDao goodsInfoDao;
@Autowired GoodsInfoServiceImpl goodsInfoService; @Autowired GoodsInfoServiceImpl goodsInfoService;
@Autowired private CategoriesDao categoriesDao;
@Override @Override
public ResultBody listSecondDistrict() { public ResultBody listSecondDistrict() {
List<DistrictDO> list = webDeviceDao.listSecondDistrict(); List<DistrictDO> list = webDeviceDao.listSecondDistrict();
...@@ -246,6 +251,21 @@ public class WebDeviceServiceImpl implements WebDeviceService { ...@@ -246,6 +251,21 @@ public class WebDeviceServiceImpl implements WebDeviceService {
} }
@Override @Override
public ResultBody getPageHomeCategories(Integer type) {
List<DirectoryDO> directoryList = categoriesDao.getDirectoryList(type);
if (CollectionUtils.isNotEmpty(directoryList)) {
List<Integer> directoryIds =
directoryList.stream().map(DirectoryDO::getId).collect(Collectors.toList());
List<Categories> categoriesList = categoriesDao.getCategoriesListByDirectoryIds(directoryIds);
return ResultBody.success(
categoriesList.stream()
.map(Categories::buildCategoryTypeDTO)
.collect(Collectors.toList()));
}
return ResultBody.success();
}
@Override
public ResultBody<AdDTO> ad() { public ResultBody<AdDTO> ad() {
List<AdDO> ad = webDeviceDao.ad(); List<AdDO> ad = webDeviceDao.ad();
List<AdDTO> collect = List<AdDTO> collect =
......
package com.mmc.pms.service; package com.mmc.pms.service;
import com.mmc.pms.common.ResultBody; import com.mmc.pms.common.ResultBody;
import com.mmc.pms.model.categories.dto.CategoryTypeDTO;
import com.mmc.pms.model.lease.dto.WareInfoDTO; import com.mmc.pms.model.lease.dto.WareInfoDTO;
import com.mmc.pms.model.lease.vo.LeaseVo; import com.mmc.pms.model.lease.vo.LeaseVo;
import com.mmc.pms.model.other.dto.AdDTO; import com.mmc.pms.model.other.dto.AdDTO;
...@@ -42,4 +43,6 @@ public interface WebDeviceService { ...@@ -42,4 +43,6 @@ public interface WebDeviceService {
ResultBody getLeaseGoodsDetail( ResultBody getLeaseGoodsDetail(
Integer goodsId, Integer userAccountId, HttpServletRequest request); Integer goodsId, Integer userAccountId, HttpServletRequest request);
ResultBody<CategoryTypeDTO> getPageHomeCategories(Integer type);
} }
...@@ -204,6 +204,19 @@ ...@@ -204,6 +204,19 @@
where id = #{id} where id = #{id}
and is_default = 0 and is_default = 0
</select> </select>
<select id="getCategoriesListByDirectoryIds" resultType="com.mmc.pms.entity.Categories">
SELECT
id,
`name`
FROM
categories
<where>
is_deleted = 0
<foreach collection="list" item="d" index="index" open="directory_id IN (" close=")" separator=",">
#{d}
</foreach>
</where>
</select>
<update id="deleteById"> <update id="deleteById">
UPDATE `categories` UPDATE `categories`
......
...@@ -155,9 +155,8 @@ ...@@ -155,9 +155,8 @@
<select id="countListWareInfoPage" parameterType="com.mmc.pms.entity.GoodsInfo" resultType="int"> <select id="countListWareInfoPage" parameterType="com.mmc.pms.entity.GoodsInfo" resultType="int">
SELECT count(*) SELECT count(*)
FROM goods_info gi FROM goods_info gi
INNER JOIN goods_img img ON gi.id = img.goods_info_id
<where> <where>
gi.is_deleted = 0 and gi.shelf_status = 0 and gi.goods_type = #{type} gi.is_deleted = 0 and gi.shelf_status = 1 and gi.goods_type = #{type}
<if test="categoryIds != null and categoryIds.size != 0"> <if test="categoryIds != null and categoryIds.size != 0">
<foreach collection="categoryIds" item="item" index="index" open="and gi.category_by_one IN (" close=")" <foreach collection="categoryIds" item="item" index="index" open="and gi.category_by_one IN (" close=")"
separator=","> separator=",">
...@@ -180,7 +179,7 @@ ...@@ -180,7 +179,7 @@
goods_info gi goods_info gi
INNER JOIN goods_img img ON gi.id = img.goods_info_id and img.img_type = 0 INNER JOIN goods_img img ON gi.id = img.goods_info_id and img.img_type = 0
<where> <where>
gi.is_deleted = 0 and gi.shelf_status = 0 and gi.goods_type = #{type} gi.is_deleted = 0 and gi.shelf_status = 1 and gi.goods_type = #{type}
<if test="param.categoryId != null"> <if test="param.categoryId != null">
<foreach collection="param" item="item" index="index" open="and gi.category_by_one IN (" close=")" <foreach collection="param" item="item" index="index" open="and gi.category_by_one IN (" close=")"
separator=","> separator=",">
......
...@@ -10,3 +10,4 @@ data-filter: ...@@ -10,3 +10,4 @@ data-filter:
- /pms/product/mall/deviceList - /pms/product/mall/deviceList
- /pms/classify/queryCategoryInfoByType - /pms/classify/queryCategoryInfoByType
- /pms/product/mall/getLeaseGoodsDetail - /pms/product/mall/getLeaseGoodsDetail
- /pms/product/mall/getPageHomeCategories
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论