| @@ -8,6 +8,8 @@ import com.iformall.domain.po.Product; | |||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| import com.iformall.domain.po.sm.PersonPhoto; | import com.iformall.domain.po.sm.PersonPhoto; | ||||
| import com.iformall.enums.EnumMouldSendType; | import com.iformall.enums.EnumMouldSendType; | ||||
| import com.iformall.enums.EnumProductType; | |||||
| import com.iformall.enums.EnumProject; | |||||
| import com.iformall.enums.EnumaMouldPatchStatus; | import com.iformall.enums.EnumaMouldPatchStatus; | ||||
| import com.iformall.service.ProductService; | import com.iformall.service.ProductService; | ||||
| import com.iformall.service.sm.MouldPatchSignService; | import com.iformall.service.sm.MouldPatchSignService; | ||||
| @@ -25,6 +27,8 @@ import org.springframework.util.ObjectUtils; | |||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | import org.springframework.web.multipart.MultipartFile; | ||||
| import java.util.List; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("/api/product") | @RequestMapping("/api/product") | ||||
| @@ -50,4 +54,26 @@ public class ProductController extends BaseController { | |||||
| } | } | ||||
| @AuthIgnore | |||||
| @ApiOperation("获取商品列表") | |||||
| @GetMapping("list_v1") | |||||
| @ApiImplicitParams({}) | |||||
| public ResultData list_v1(@ModelAttribute Product record) { | |||||
| logger.debug("[" + getIpAddr() + "] ProductController::list_v1"); | |||||
| if(record.getType() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"type为空"); | |||||
| } | |||||
| Integer projectType = record.getProjectType(); | |||||
| if(projectType == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"projectType为空"); | |||||
| } | |||||
| if(EnumProductType.product_2.getCode().equals(record.getType())){ | |||||
| record.setProjectType(EnumProject.PROJECT_0.getCode()); | |||||
| } | |||||
| record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||||
| List<Product> listDetail = productService.findListDetail(record, projectType); | |||||
| return new ResultData(listDetail); | |||||
| } | |||||
| } | } | ||||
| @@ -49,4 +49,7 @@ public class LevelPackage extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private Date endDate; | private Date endDate; | ||||
| @TableField(exist = false) | |||||
| private ProjectPackageDetail projectPackageDetail; | |||||
| } | } | ||||
| @@ -56,4 +56,7 @@ public class Product extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private Date endDate; | private Date endDate; | ||||
| @TableField(exist = false) | |||||
| private LevelPackage levelPackage; | |||||
| } | } | ||||
| @@ -2,6 +2,7 @@ package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.ProjectPackageDetail; | import com.iformall.domain.po.ProjectPackageDetail; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| import java.util.List; | import java.util.List; | ||||
| @@ -9,4 +10,6 @@ public interface ProjectPackageDetailMapper extends CommonMapper<ProjectPackageD | |||||
| List<ProjectPackageDetail> findList(ProjectPackageDetail record); | List<ProjectPackageDetail> findList(ProjectPackageDetail record); | ||||
| ProjectPackageDetail selectByProject(@Param("packageId")Long packageId, @Param("projectType")Integer projectType); | |||||
| } | } | ||||
| @@ -3,6 +3,8 @@ package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.Product; | import com.iformall.domain.po.Product; | ||||
| import java.util.List; | |||||
| public interface ProductService { | public interface ProductService { | ||||
| /** | /** | ||||
| @@ -17,4 +19,6 @@ public interface ProductService { | |||||
| Product getById(Long id); | Product getById(Long id); | ||||
| List<Product> findListDetail(Product record, Integer projectType); | |||||
| } | } | ||||
| @@ -2,9 +2,12 @@ package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.LevelPackage; | |||||
| import com.iformall.domain.po.Product; | import com.iformall.domain.po.Product; | ||||
| import com.iformall.enums.EnumProductType; | |||||
| import com.iformall.mapper.ProductMapper; | import com.iformall.mapper.ProductMapper; | ||||
| import com.iformall.service.ProductService; | import com.iformall.service.ProductService; | ||||
| import com.iformall.service.sm.LevelPackageService; | |||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -12,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | |||||
| @Service | @Service | ||||
| @Slf4j | @Slf4j | ||||
| @@ -20,16 +24,31 @@ public class ProductServiceImpl implements ProductService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | @Autowired | ||||
| ProductMapper productFromMapper; | |||||
| ProductMapper productMapper; | |||||
| @Autowired | |||||
| LevelPackageService levelPackageService; | |||||
| @Override | @Override | ||||
| public PageInfo<Product> listAsPage(Product record, Integer pageIndex, Integer pageSize) { | public PageInfo<Product> listAsPage(Product record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> productFromMapper.findList(record)); | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> productMapper.findList(record)); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public Product getById(Long id) { | public Product getById(Long id) { | ||||
| return productFromMapper.selectById(id); | |||||
| return productMapper.selectById(id); | |||||
| } | |||||
| @Override | |||||
| public List<Product> findListDetail(Product record, Integer projectType) { | |||||
| List<Product> list = productMapper.findList(record); | |||||
| for (Product prod: list) { | |||||
| if(EnumProductType.product_2.getCode().equals(prod.getType())){ | |||||
| LevelPackage levelPackage = levelPackageService.getDetailById(prod.getExtraId(),projectType); | |||||
| prod.setLevelPackage(levelPackage); | |||||
| } | |||||
| } | |||||
| return list; | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,10 +1,12 @@ | |||||
| package com.iformall.service.sm; | package com.iformall.service.sm; | ||||
| import com.iformall.domain.po.LevelPackage; | |||||
| import java.util.List; | import java.util.List; | ||||
| public interface LevelPackageService { | public interface LevelPackageService { | ||||
| LevelPackage getDetailById(Long id, Integer projectType); | |||||
| } | } | ||||
| @@ -1,10 +1,14 @@ | |||||
| package com.iformall.service.sm.impl; | package com.iformall.service.sm.impl; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
| import com.iformall.domain.po.LevelPackage; | |||||
| import com.iformall.domain.po.ProjectPackageDetail; | |||||
| import com.iformall.domain.po.sm.UserConsumptionPackage; | import com.iformall.domain.po.sm.UserConsumptionPackage; | ||||
| import com.iformall.domain.po.sm.UserPackageDetail; | import com.iformall.domain.po.sm.UserPackageDetail; | ||||
| import com.iformall.enums.EnumYesOrNo; | import com.iformall.enums.EnumYesOrNo; | ||||
| import com.iformall.enums.sm.*; | import com.iformall.enums.sm.*; | ||||
| import com.iformall.mapper.LevelPackageMapper; | |||||
| import com.iformall.mapper.ProjectPackageDetailMapper; | |||||
| import com.iformall.mapper.UserConsumptionPackageMapper; | import com.iformall.mapper.UserConsumptionPackageMapper; | ||||
| import com.iformall.service.sm.LevelPackageService; | import com.iformall.service.sm.LevelPackageService; | ||||
| import com.iformall.service.sm.UserConsumptionPackageService; | import com.iformall.service.sm.UserConsumptionPackageService; | ||||
| @@ -22,4 +26,22 @@ import java.util.List; | |||||
| public class LevelPackageServiceImpl implements LevelPackageService { | public class LevelPackageServiceImpl implements LevelPackageService { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| LevelPackageMapper levelPackageMapper; | |||||
| @Autowired | |||||
| ProjectPackageDetailMapper projectPackageDetailMapper; | |||||
| @Override | |||||
| public LevelPackage getDetailById(Long id, Integer projectType) { | |||||
| if(id == null){ | |||||
| return null; | |||||
| } | |||||
| LevelPackage levelPackage = levelPackageMapper.selectById(id); | |||||
| if(levelPackage != null){ | |||||
| ProjectPackageDetail projectPackageDetail = projectPackageDetailMapper.selectByProject(levelPackage.getId(),projectType); | |||||
| levelPackage.setProjectPackageDetail(projectPackageDetail); | |||||
| } | |||||
| return levelPackage; | |||||
| } | |||||
| } | } | ||||
| @@ -72,4 +72,12 @@ | |||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||
| <select id="selectByProject" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> | |||||
| from project_package_detail | |||||
| where `package_id` = #{packageId} | |||||
| and `project_type` = #{projectType} | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||