dev798
parent
94643ec29a
commit
3961567935
|
@ -0,0 +1,17 @@
|
||||||
|
package com.nuyu.product.domain.MallProduct;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: wangxinyuan
|
||||||
|
* @Date: 2024/5/12 下午3:20
|
||||||
|
*/
|
||||||
|
public enum Emen {;
|
||||||
|
|
||||||
|
private static final long PRIMARY0 = 0L;
|
||||||
|
|
||||||
|
private static final long PRIMARY1 = 1L;
|
||||||
|
|
||||||
|
private static final long PRIMARY2 = 2L;
|
||||||
|
|
||||||
|
private static final long PRIMARY3 = 3L;
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
package com.nuyu.product.domain;
|
package com.nuyu.product.domain;
|
||||||
|
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.web.controller.BaseController;
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -17,7 +19,7 @@ import java.io.Serializable;
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class MallProductText extends BaseController implements Serializable {
|
public class MallProductText extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -28,5 +30,12 @@ public class MallProductText extends BaseController implements Serializable {
|
||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
|
@Excel(name = "名稱")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@Excel(name = "性別")
|
||||||
|
private String sex;
|
||||||
|
|
||||||
|
@Excel(name = "年齡")
|
||||||
|
private Integer age;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,20 @@
|
||||||
package com.muyu.product.controller;
|
package com.muyu.product.controller;
|
||||||
|
|
||||||
|
import com.alibaba.csp.sentinel.log.LogTarget;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
import com.muyu.common.core.web.domain.AjaxResult;
|
import com.muyu.common.core.web.domain.AjaxResult;
|
||||||
|
import com.muyu.common.log.annotation.Log;
|
||||||
|
import com.muyu.common.log.enums.BusinessType;
|
||||||
import com.muyu.product.service.MallProductTextService;
|
import com.muyu.product.service.MallProductTextService;
|
||||||
import com.nuyu.product.domain.MallProductText;
|
import com.nuyu.product.domain.MallProductText;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: wangxinyuan
|
* @Author: wangxinyuan
|
||||||
* @Date: 2024/5/10 下午8:21
|
* @Date: 2024/5/10 下午8:21
|
||||||
|
@ -49,4 +56,13 @@ public class MallProductTextController {
|
||||||
public Result insert(@RequestBody MallProductText mallProductText){
|
public Result insert(@RequestBody MallProductText mallProductText){
|
||||||
return Result.success(mallProductTextService.mallTextInsert(mallProductText));
|
return Result.success(mallProductTextService.mallTextInsert(mallProductText));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log(title = "測試導出",businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response ,MallProductText mallProductText){
|
||||||
|
List<MallProductText>list=mallProductTextService.selectMallProductText(mallProductText);
|
||||||
|
ExcelUtil<MallProductText>excelUtil=new ExcelUtil<>(MallProductText.class);
|
||||||
|
excelUtil.exportExcel(response,list,"導出");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.product.mapper;
|
package com.muyu.product.mapper;
|
||||||
|
|
||||||
|
import com.nuyu.product.domain.MallProduct.Emen;
|
||||||
import com.nuyu.product.domain.MallProductText;
|
import com.nuyu.product.domain.MallProductText;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@ -24,4 +25,8 @@ public interface MallProductTextMapper {
|
||||||
Object selectById(Long id);
|
Object selectById(Long id);
|
||||||
|
|
||||||
Object mallTextInsert(MallProductText mallProductText);
|
Object mallTextInsert(MallProductText mallProductText);
|
||||||
|
|
||||||
|
List<MallProductText> selectMallProductText(MallProductText mallProductText);
|
||||||
|
|
||||||
|
Object findAll(Emen emen);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.muyu.product.mapper.MallProductTextMapper;
|
import com.muyu.product.mapper.MallProductTextMapper;
|
||||||
import com.muyu.product.service.MallProductTextService;
|
import com.muyu.product.service.MallProductTextService;
|
||||||
|
import com.nuyu.product.domain.MallProduct.Emen;
|
||||||
import com.nuyu.product.domain.MallProductText;
|
import com.nuyu.product.domain.MallProductText;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -20,6 +21,7 @@ public class MallProductTextServiceImpl implements MallProductTextService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MallProductTextMapper mallProductTextMapper;
|
private MallProductTextMapper mallProductTextMapper;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageInfo<MallProductText> list(MallProductText mallProductText) {
|
public PageInfo<MallProductText> list(MallProductText mallProductText) {
|
||||||
PageHelper.startPage(mallProductText.getPageNum(),mallProductText.getPageSize());
|
PageHelper.startPage(mallProductText.getPageNum(),mallProductText.getPageSize());
|
||||||
|
@ -40,6 +42,11 @@ public class MallProductTextServiceImpl implements MallProductTextService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object selectMallProductTextById(Long id) {
|
public Object selectMallProductTextById(Long id) {
|
||||||
|
MallProductText mallProductText = new MallProductText();
|
||||||
|
Emen emen=Emen.valueOf(mallProductText.getSex());
|
||||||
|
if(emen!=null){
|
||||||
|
return mallProductTextMapper.findAll(emen);
|
||||||
|
}
|
||||||
return mallProductTextMapper.selectMallProductTextById(id);
|
return mallProductTextMapper.selectMallProductTextById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +57,18 @@ public class MallProductTextServiceImpl implements MallProductTextService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object mallTextInsert(MallProductText mallProductText) {
|
public Object mallTextInsert(MallProductText mallProductText) {
|
||||||
|
mallProductText.setId(mallProductText.getId());
|
||||||
|
mallProductText.setUpdateBy(mallProductText.getUpdateBy());
|
||||||
|
mallProductText.setUpdateTime(mallProductText.getUpdateTime());
|
||||||
|
mallProductText.setCreateBy(mallProductText.getUpdateBy());
|
||||||
|
mallProductText.setCreateTime(mallProductText.getCreateTime());
|
||||||
return mallProductTextMapper.mallTextInsert(mallProductText);
|
return mallProductTextMapper.mallTextInsert(mallProductText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MallProductText> selectMallProductText(MallProductText mallProductText) {
|
||||||
|
return mallProductTextMapper.selectMallProductText(mallProductText);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,17 +114,15 @@ public class MallProductTypeInfoServiceImpl implements MallProductTypeInfoServic
|
||||||
public static final Long PARENT_ID=0L;
|
public static final Long PARENT_ID=0L;
|
||||||
@Override
|
@Override
|
||||||
public List<MallProductTypeInfoVO> listAll(MallProductTypeInfo mallProductTypeInfo) {
|
public List<MallProductTypeInfoVO> listAll(MallProductTypeInfo mallProductTypeInfo) {
|
||||||
/**
|
//根據查詢條件獲取商品類型信息列表
|
||||||
* 1.拉取数据中说有数据
|
|
||||||
* 2.寻找所有数据中二级目录
|
|
||||||
* 3.根据上级目录寻找子目录
|
|
||||||
*/
|
|
||||||
List<MallProductTypeInfo> mallProductTypeInfos = selectMallProductTypeInfoList(mallProductTypeInfo);
|
List<MallProductTypeInfo> mallProductTypeInfos = selectMallProductTypeInfoList(mallProductTypeInfo);
|
||||||
|
//將查詢到的商品類型信息進行换为為視圖對象,並包裝其子類型信息
|
||||||
List<MallProductTypeInfoVO>returnList= mallProductTypeInfos.stream().filter(item->PARENT_ID.equals(item.getParentCid())).map(newItem->{
|
List<MallProductTypeInfoVO>returnList= mallProductTypeInfos.stream().filter(item->PARENT_ID.equals(item.getParentCid())).map(newItem->{
|
||||||
MallProductTypeInfoVO mallProductTypeInfoVO = new MallProductTypeInfoVO();
|
MallProductTypeInfoVO mallProductTypeInfoVO = new MallProductTypeInfoVO();
|
||||||
BeanUtils.copyProperties(newItem,mallProductTypeInfoVO);
|
BeanUtils.copyProperties(newItem,mallProductTypeInfoVO);
|
||||||
return mallProductTypeInfoVO;
|
return mallProductTypeInfoVO;
|
||||||
}).map(mallProductTypeInfoVO -> {
|
}).map(mallProductTypeInfoVO -> {
|
||||||
|
//包裝子類信息
|
||||||
mallProductTypeInfoVO.setChildrenList(packageChildrenList(mallProductTypeInfoVO,mallProductTypeInfos));
|
mallProductTypeInfoVO.setChildrenList(packageChildrenList(mallProductTypeInfoVO,mallProductTypeInfos));
|
||||||
return mallProductTypeInfoVO;
|
return mallProductTypeInfoVO;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
@ -133,9 +131,11 @@ public class MallProductTypeInfoServiceImpl implements MallProductTypeInfoServic
|
||||||
|
|
||||||
private List<MallProductTypeInfoVO> packageChildrenList(MallProductTypeInfoVO mallProductTypeInfoVO, List<MallProductTypeInfo> mallProductTypeInfos) {
|
private List<MallProductTypeInfoVO> packageChildrenList(MallProductTypeInfoVO mallProductTypeInfoVO, List<MallProductTypeInfo> mallProductTypeInfos) {
|
||||||
Long parentId = mallProductTypeInfoVO.getCatId();
|
Long parentId = mallProductTypeInfoVO.getCatId();
|
||||||
|
//根據父類型ID查找並包裝子類型信息,遞歸處理
|
||||||
List<MallProductTypeInfoVO> collect = mallProductTypeInfos.stream().filter(item -> parentId.equals(item.getParentCid())).map(newItem -> {
|
List<MallProductTypeInfoVO> collect = mallProductTypeInfos.stream().filter(item -> parentId.equals(item.getParentCid())).map(newItem -> {
|
||||||
MallProductTypeInfoVO returnVo = new MallProductTypeInfoVO();
|
MallProductTypeInfoVO returnVo = new MallProductTypeInfoVO();
|
||||||
BeanUtils.copyProperties(newItem, returnVo);
|
BeanUtils.copyProperties(newItem, returnVo);
|
||||||
|
//遞歸包裝子類型信息
|
||||||
returnVo.setChildrenList(packageChildrenList(returnVo, mallProductTypeInfos));
|
returnVo.setChildrenList(packageChildrenList(returnVo, mallProductTypeInfos));
|
||||||
return returnVo;
|
return returnVo;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.product.service;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.nuyu.product.domain.MallProductText;
|
import com.nuyu.product.domain.MallProductText;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: wangxinyuan
|
* @Author: wangxinyuan
|
||||||
* @Date: 2024/5/10 下午8:22
|
* @Date: 2024/5/10 下午8:22
|
||||||
|
@ -23,4 +25,6 @@ public interface MallProductTextService {
|
||||||
Object selectById(Long id);
|
Object selectById(Long id);
|
||||||
|
|
||||||
Object mallTextInsert(MallProductText mallProductText);
|
Object mallTextInsert(MallProductText mallProductText);
|
||||||
|
|
||||||
|
List<MallProductText> selectMallProductText(MallProductText mallProductText);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,5 +24,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<select id="selectById" resultType="java.lang.Object">
|
<select id="selectById" resultType="java.lang.Object">
|
||||||
select * from mall_product_text where id = #{id}
|
select * from mall_product_text where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectMallProductText" resultType="com.nuyu.product.domain.MallProductText">
|
||||||
|
select * from mall_product_text
|
||||||
|
</select>
|
||||||
|
<select id="findAll" resultType="java.lang.Object">
|
||||||
|
select * from mall_product_text
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue