dev798
wxy 2024-05-12 15:49:31 +08:00
parent 94643ec29a
commit 3961567935
8 changed files with 80 additions and 6 deletions

View File

@ -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;
}

View File

@ -1,6 +1,8 @@
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.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -17,7 +19,7 @@ import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MallProductText extends BaseController implements Serializable {
public class MallProductText extends BaseEntity implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@ -28,5 +30,12 @@ public class MallProductText extends BaseController implements Serializable {
private Integer id;
@Excel(name = "名稱")
private String name;
@Excel(name = "性別")
private String sex;
@Excel(name = "年齡")
private Integer age;
}

View File

@ -1,13 +1,20 @@
package com.muyu.product.controller;
import com.alibaba.csp.sentinel.log.LogTarget;
import com.github.pagehelper.PageInfo;
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.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.product.service.MallProductTextService;
import com.nuyu.product.domain.MallProductText;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @Author: wangxinyuan
* @Date: 2024/5/10 8:21
@ -49,4 +56,13 @@ public class MallProductTextController {
public Result insert(@RequestBody MallProductText 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,"導出");
}
}

View File

@ -1,5 +1,6 @@
package com.muyu.product.mapper;
import com.nuyu.product.domain.MallProduct.Emen;
import com.nuyu.product.domain.MallProductText;
import org.apache.ibatis.annotations.Mapper;
@ -24,4 +25,8 @@ public interface MallProductTextMapper {
Object selectById(Long id);
Object mallTextInsert(MallProductText mallProductText);
List<MallProductText> selectMallProductText(MallProductText mallProductText);
Object findAll(Emen emen);
}

View File

@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.muyu.product.mapper.MallProductTextMapper;
import com.muyu.product.service.MallProductTextService;
import com.nuyu.product.domain.MallProduct.Emen;
import com.nuyu.product.domain.MallProductText;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -20,6 +21,7 @@ public class MallProductTextServiceImpl implements MallProductTextService {
@Autowired
private MallProductTextMapper mallProductTextMapper;
@Override
public PageInfo<MallProductText> list(MallProductText mallProductText) {
PageHelper.startPage(mallProductText.getPageNum(),mallProductText.getPageSize());
@ -40,6 +42,11 @@ public class MallProductTextServiceImpl implements MallProductTextService {
@Override
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);
}
@ -50,8 +57,18 @@ public class MallProductTextServiceImpl implements MallProductTextService {
@Override
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);
}
@Override
public List<MallProductText> selectMallProductText(MallProductText mallProductText) {
return mallProductTextMapper.selectMallProductText(mallProductText);
}
}

View File

@ -114,17 +114,15 @@ public class MallProductTypeInfoServiceImpl implements MallProductTypeInfoServic
public static final Long PARENT_ID=0L;
@Override
public List<MallProductTypeInfoVO> listAll(MallProductTypeInfo mallProductTypeInfo) {
/**
* 1.
* 2.
* 3.
*/
//根據查詢條件獲取商品類型信息列表
List<MallProductTypeInfo> mallProductTypeInfos = selectMallProductTypeInfoList(mallProductTypeInfo);
//將查詢到的商品類型信息進行换为為視圖對象,並包裝其子類型信息
List<MallProductTypeInfoVO>returnList= mallProductTypeInfos.stream().filter(item->PARENT_ID.equals(item.getParentCid())).map(newItem->{
MallProductTypeInfoVO mallProductTypeInfoVO = new MallProductTypeInfoVO();
BeanUtils.copyProperties(newItem,mallProductTypeInfoVO);
return mallProductTypeInfoVO;
}).map(mallProductTypeInfoVO -> {
//包裝子類信息
mallProductTypeInfoVO.setChildrenList(packageChildrenList(mallProductTypeInfoVO,mallProductTypeInfos));
return mallProductTypeInfoVO;
}).collect(Collectors.toList());
@ -133,9 +131,11 @@ public class MallProductTypeInfoServiceImpl implements MallProductTypeInfoServic
private List<MallProductTypeInfoVO> packageChildrenList(MallProductTypeInfoVO mallProductTypeInfoVO, List<MallProductTypeInfo> mallProductTypeInfos) {
Long parentId = mallProductTypeInfoVO.getCatId();
//根據父類型ID查找並包裝子類型信息,遞歸處理
List<MallProductTypeInfoVO> collect = mallProductTypeInfos.stream().filter(item -> parentId.equals(item.getParentCid())).map(newItem -> {
MallProductTypeInfoVO returnVo = new MallProductTypeInfoVO();
BeanUtils.copyProperties(newItem, returnVo);
//遞歸包裝子類型信息
returnVo.setChildrenList(packageChildrenList(returnVo, mallProductTypeInfos));
return returnVo;
}).collect(Collectors.toList());

View File

@ -3,6 +3,8 @@ package com.muyu.product.service;
import com.github.pagehelper.PageInfo;
import com.nuyu.product.domain.MallProductText;
import java.util.List;
/**
* @Author: wangxinyuan
* @Date: 2024/5/10 8:22
@ -23,4 +25,6 @@ public interface MallProductTextService {
Object selectById(Long id);
Object mallTextInsert(MallProductText mallProductText);
List<MallProductText> selectMallProductText(MallProductText mallProductText);
}

View File

@ -24,5 +24,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectById" resultType="java.lang.Object">
select * from mall_product_text where id = #{id}
</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>