feat(api): 添加报价系统产品型号和类型搜索功能
- 在IProductModelService接口中新增searchForQuotation和getInfoForQuotation方法 - 在IProductTypeService接口中新增searchSimpleList方法 - 创建ProductModelController提供机型搜索和详情获取API - 创建ProductTypeController提供类型搜索API - 在ProductModelMapper中新增searchForQuotation1和getInfoForQuotation查询方法 - 在ProductTypeMapper中新增searchSimpleList查询方法 - 实现ProductModelService和ProductTypeService的服务层逻辑 - 添加QuotationProductModelSearchVO、QuotationProductModelInfoVO等数据传输对象 - 添加QuotationProductModelSearchRequest、QuotationProductTypeSearchRequest请求对象 - 配置MyBatis映射文件实现多语言支持的数据库查询逻辑
This commit is contained in:
parent
81a66b3c88
commit
ae942c85b0
|
|
@ -0,0 +1,20 @@
|
|||
package com.nflg.mobilebroken.common.pojo.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
public class QuotationProductModelSearchRequest {
|
||||
|
||||
/**
|
||||
* 类型批次号
|
||||
*/
|
||||
@NotBlank
|
||||
private String typeNumber;
|
||||
|
||||
/**
|
||||
* 机型
|
||||
*/
|
||||
private String name;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.nflg.mobilebroken.common.pojo.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QuotationProductTypeSearchRequest {
|
||||
|
||||
/**
|
||||
* 模块id
|
||||
*/
|
||||
private Long moduleId;
|
||||
|
||||
/**
|
||||
* 系列批次号
|
||||
*/
|
||||
private String seriesNumber;
|
||||
}
|
||||
|
|
@ -5,11 +5,26 @@ import lombok.Data;
|
|||
@Data
|
||||
public class ProductTypeSimpleVO {
|
||||
|
||||
/**
|
||||
* 模块名称
|
||||
*/
|
||||
private Integer moduleName;
|
||||
|
||||
/**
|
||||
* 系列名称
|
||||
*/
|
||||
private String seriesName;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
private String image;
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package com.nflg.mobilebroken.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QuotationProductModelInfoVO {
|
||||
|
||||
/**
|
||||
* 模块名称
|
||||
*/
|
||||
private String moduleName;
|
||||
|
||||
/**
|
||||
* 系列名称
|
||||
*/
|
||||
private String seriesName;
|
||||
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* 机型
|
||||
*/
|
||||
private String no;
|
||||
|
||||
/**
|
||||
* 机型图片
|
||||
*/
|
||||
private String image;
|
||||
|
||||
/**
|
||||
* 机型介绍
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* 机型特点
|
||||
*/
|
||||
private String feature;
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.nflg.mobilebroken.common.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
public class QuotationProductModelSearchVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 机型编号
|
||||
*/
|
||||
private String no;
|
||||
|
||||
/**
|
||||
* 批次编号
|
||||
*/
|
||||
private Long batchNumber;
|
||||
|
||||
/**
|
||||
* 是否新品
|
||||
*/
|
||||
private Boolean recommend;
|
||||
|
||||
public Boolean getRecommend() {
|
||||
return recommend && (Objects.nonNull(recommendExpireTime) && LocalDateTime.now().isBefore(recommendExpireTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新品过期时间
|
||||
*/
|
||||
private LocalDateTime recommendExpireTime;
|
||||
|
||||
/**
|
||||
* 是否有折扣
|
||||
*/
|
||||
@JsonProperty("hasDiscount")
|
||||
private Boolean hasDiscount;
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.nflg.mobilebroken.quotation.controller.app;
|
||||
|
||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||
import com.nflg.mobilebroken.common.pojo.request.QuotationProductModelSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductModelInfoVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.QuotationProductModelInfoVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.QuotationProductModelSearchVO;
|
||||
import com.nflg.mobilebroken.common.util.MultilingualUtil;
|
||||
import com.nflg.mobilebroken.quotation.controller.ControllerBase;
|
||||
import com.nflg.mobilebroken.repository.service.IProductModelService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 产品机型
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/product/model")
|
||||
public class ProductModelController extends ControllerBase {
|
||||
|
||||
@Resource
|
||||
private IProductModelService productModelService;
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/search")
|
||||
public ApiResult<List<QuotationProductModelSearchVO>> search(@Valid @RequestBody QuotationProductModelSearchRequest request){
|
||||
return ApiResult.success(productModelService.searchForQuotation(request, MultilingualUtil.getLanguage()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取详情
|
||||
*/
|
||||
@GetMapping("/getInfo")
|
||||
public ApiResult<QuotationProductModelInfoVO> getInfo(@RequestParam Long id){
|
||||
return ApiResult.success(productModelService.getInfoForQuotation(id, MultilingualUtil.getLanguage()));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.nflg.mobilebroken.quotation.controller.app;
|
||||
|
||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||
import com.nflg.mobilebroken.common.pojo.request.QuotationProductTypeSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductTypeSimpleVO;
|
||||
import com.nflg.mobilebroken.common.util.MultilingualUtil;
|
||||
import com.nflg.mobilebroken.quotation.controller.ControllerBase;
|
||||
import com.nflg.mobilebroken.repository.service.IProductTypeService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 产品类型
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/product/type")
|
||||
public class ProductTypeController extends ControllerBase {
|
||||
|
||||
@Resource
|
||||
private IProductTypeService productTypeService;
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/search")
|
||||
public ApiResult<List<ProductTypeSimpleVO>> search(@Valid @RequestBody QuotationProductTypeSearchRequest request){
|
||||
return ApiResult.success(productTypeService.searchSimpleList(request, MultilingualUtil.getLanguage()));
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.mobilebroken.common.pojo.request.ModelConfigSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.ProductModelSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.QuotationProductModelSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.*;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductModel;
|
||||
|
||||
|
|
@ -32,4 +33,8 @@ public interface ProductModelMapper extends BaseMapper<ProductModel> {
|
|||
List<ProductModelSearchVO> getListForSort(String typeNumber);
|
||||
|
||||
Page<ProductModel> searchForQuotation(ModelConfigSearchRequest request, Page<?> page);
|
||||
|
||||
List<QuotationProductModelSearchVO> searchForQuotation1(QuotationProductModelSearchRequest request, String language);
|
||||
|
||||
QuotationProductModelInfoVO getInfoForQuotation(Long id, String language);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.nflg.mobilebroken.repository.mapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.mobilebroken.common.pojo.request.ProductTypeSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.QuotationProductTypeSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.*;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductType;
|
||||
|
||||
|
|
@ -34,4 +35,6 @@ public interface ProductTypeMapper extends BaseMapper<ProductType> {
|
|||
List<ProductTypeSimpleVO> getSimpleListByLanguage(String batchNumber, String language);
|
||||
|
||||
List<ProductTypeSearchVO> getListForSort(String seriesNumber);
|
||||
|
||||
List<ProductTypeSimpleVO> searchSimpleList(QuotationProductTypeSearchRequest request,String language);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,4 +53,8 @@ public interface IProductModelService extends IService<ProductModel> {
|
|||
Page<ProductModel> searchForQuotation(ModelConfigSearchRequest request);
|
||||
|
||||
List<ProductModel> getEffectives();
|
||||
|
||||
List<QuotationProductModelSearchVO> searchForQuotation(QuotationProductModelSearchRequest request, String language);
|
||||
|
||||
QuotationProductModelInfoVO getInfoForQuotation(Long id, String language);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,4 +51,6 @@ public interface IProductTypeService extends IService<ProductType> {
|
|||
ProductTypeLanguageInfoVO getInfoByLanguage(@Valid @NotNull String typeNumber, String language);
|
||||
|
||||
List<ProductTypeSimpleVO> getSimpleListByLanguage(String batchNumber, String language);
|
||||
|
||||
List<ProductTypeSimpleVO> searchSimpleList(QuotationProductTypeSearchRequest request,String language);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -409,6 +409,16 @@ public class ProductModelServiceImpl extends ServiceImpl<ProductModelMapper, Pro
|
|||
.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuotationProductModelSearchVO> searchForQuotation(QuotationProductModelSearchRequest request, String language) {
|
||||
return baseMapper.searchForQuotation1(request,language);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuotationProductModelInfoVO getInfoForQuotation(Long id, String language) {
|
||||
return baseMapper.getInfoForQuotation(id,language);
|
||||
}
|
||||
|
||||
private ProductModelCompareInfoVO getModelCompareInfo(Integer modelId, String language){
|
||||
ProductModel productModel = getById(modelId);
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(productModel)).throwMessage("无效的数据");
|
||||
|
|
|
|||
|
|
@ -316,6 +316,11 @@ public class ProductTypeServiceImpl extends ServiceImpl<ProductTypeMapper, Produ
|
|||
return baseMapper.getSimpleListByLanguage(batchNumber,language);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductTypeSimpleVO> searchSimpleList(QuotationProductTypeSearchRequest request,String language) {
|
||||
return baseMapper.searchSimpleList(request,language);
|
||||
}
|
||||
|
||||
private void delete(Integer typeId){
|
||||
ProductType info=getById(typeId);
|
||||
removeById(typeId);
|
||||
|
|
|
|||
|
|
@ -113,4 +113,30 @@
|
|||
</if>
|
||||
ORDER BY pm.batch_number
|
||||
</select>
|
||||
|
||||
<select id="searchForQuotation1" resultType="com.nflg.mobilebroken.common.pojo.vo.QuotationProductModelSearchVO">
|
||||
SELECT pm.*,EXISTS(SELECT 1 FROM quotation_model_discount WHERE discount_status=1 AND model_id=pm.batch_number) AS 'hasDiscount'
|
||||
FROM product_model pm
|
||||
WHERE pm.state=1 AND pm.`enable`=1
|
||||
<if test="request.typeNumber!=null">
|
||||
AND pm.type_number = #{request.typeNumber}
|
||||
</if>
|
||||
<if test="request.no!=null and request.no!=''">
|
||||
AND pm.`no` like concat('%', #{request.no}, '%')
|
||||
</if>
|
||||
ORDER BY pm.sort,pm.id DESC
|
||||
</select>
|
||||
|
||||
<select id="getInfoForQuotation" resultType="com.nflg.mobilebroken.common.pojo.vo.QuotationProductModelInfoVO">
|
||||
SELECT dit.`value` as 'moduleName',psi.`name` as 'seriesName',pti.`name` as 'typeName',pm.`no`,pm.image,pmii.`desc`,pmii.feature
|
||||
FROM product_model pm
|
||||
LEFT JOIN dictionary_item_translate dit ON dit.dictionary_item_id=pm.module_id AND dit.language_code=#{language}
|
||||
INNER JOIN product_series ps ON pm.series_number=ps.batch_number AND ps.`enable`=1 AND ps.state=1
|
||||
LEFT JOIN product_series_info psi ON psi.series_id=ps.id AND psi.language_code=#{language}
|
||||
INNER JOIN product_type pt ON pm.type_number=pt.batch_number AND pt.`enable`=1 AND pt.state=1
|
||||
LEFT JOIN product_type_info pti ON pti.type_id=pt.id AND pti.language_code=#{language}
|
||||
LEFT JOIN product_model_intro pmi ON pmi.model_id=pm.id
|
||||
LEFT JOIN product_model_intro_item pmii ON pmii.model_intro_id=pmi.id AND pmii.language_code=#{language}
|
||||
WHERE pm.id=#{id}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -101,4 +101,23 @@
|
|||
where enable=1 and state=1 and series_number=#{seriesNumber}
|
||||
order by seriesName, sort
|
||||
</select>
|
||||
|
||||
<select id="searchSimpleList" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductTypeSimpleVO">
|
||||
SELECT di.name as 'moduleName',psi.name as 'seriesName',pti.name,pti.image,pt.batch_number
|
||||
FROM product_type pt
|
||||
INNER JOIN product_type_info pti ON pt.id = pti.type_id AND pti.language_code = #{language}
|
||||
left join product_series ps on pt.series_number = ps.batch_number and ps.state =1 and ps.enable=1
|
||||
left join product_series_info psi on psi.series_id=ps.id and psi.language_code = #{language}
|
||||
left join dictionary_item di on pt.module_id = di.id
|
||||
left join dictionary_item_translate dit on di.id = dit.dictionary_item_id and dit.language_code = #{language}
|
||||
WHERE pt.state = 1
|
||||
AND pt.`enable` = 1
|
||||
<if test="request.moduleId != null">
|
||||
AND pt.module_id = #{request.moduleId}
|
||||
</if>
|
||||
<if test="request.seriesNumber != null">
|
||||
AND pt.series_number = #{request.seriesNumber}
|
||||
</if>
|
||||
ORDER BY pt.sort,pt.id DESC
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue