feat: 产品中心
This commit is contained in:
parent
55e63b36e6
commit
73d46a1eac
|
|
@ -1,6 +1,7 @@
|
|||
package com.nflg.mobilebroken.admin.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.nflg.mobilebroken.common.constant.PublishState;
|
||||
import com.nflg.mobilebroken.common.constant.STATE;
|
||||
|
|
@ -11,6 +12,7 @@ import com.nflg.mobilebroken.common.pojo.dto.ProductModelParamsExcelDTO;
|
|||
import com.nflg.mobilebroken.common.pojo.request.*;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.*;
|
||||
import com.nflg.mobilebroken.common.util.EecExcelUtil;
|
||||
import com.nflg.mobilebroken.common.util.PageUtil;
|
||||
import com.nflg.mobilebroken.common.util.VUtils;
|
||||
import com.nflg.mobilebroken.repository.entity.*;
|
||||
import com.nflg.mobilebroken.repository.service.*;
|
||||
|
|
@ -21,6 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
|
@ -273,6 +276,24 @@ public class ProductModelController extends ControllerBase{
|
|||
return ApiResult.success(request.getModelParamsId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备技术参数指标
|
||||
* @param request 请求参数
|
||||
* @return 机型参数id
|
||||
*/
|
||||
@PostMapping("/deleteParamsIndexName")
|
||||
public ApiResult<Integer> deleteParamsIndexName(@Valid @RequestBody ParamsIndexNameDeleteRequest request) {
|
||||
ProductModelParams info = productModelParamsService.getById(request.getModelParamsId());
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(info)).throwMessage("无效的数据");
|
||||
if (Objects.equals(info.getState(), PublishState.Published.getState())) {
|
||||
Integer oldId = request.getModelParamsId();
|
||||
request.setModelParamsId(productModelParamsService.add(info.getModelId()));
|
||||
productModelParamsService.copyItems(oldId, request.getModelParamsId());
|
||||
}
|
||||
productModelParamsItemService.deleteIndexName(request);
|
||||
return ApiResult.success(request.getModelParamsId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加设备技术参数项
|
||||
* @param request 请求参数
|
||||
|
|
@ -596,7 +617,7 @@ public class ProductModelController extends ControllerBase{
|
|||
* @param request 请求参数
|
||||
*/
|
||||
@PostMapping("/addFile")
|
||||
public ApiResult<Void> addFile(@Valid @RequestBody ProductModelFileAddRequest request){
|
||||
public ApiResult<Void> addFile(@Valid @RequestBody @NotEmpty ProductModelFileAddRequest request){
|
||||
productModelFileService.add(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
|
@ -646,17 +667,41 @@ public class ProductModelController extends ControllerBase{
|
|||
* @param request 请求参数
|
||||
*/
|
||||
@PostMapping("/getFileList")
|
||||
public ApiResult<PageData<ProductModelFile>> getFileList(@Valid @RequestBody ProductModelImageSearchRequest request){
|
||||
return ApiResult.success(productModelFileService.getList(request));
|
||||
public ApiResult<PageData<ProductModelFileVO>> getFileList(@Valid @RequestBody ProductModelImageSearchRequest request){
|
||||
return ApiResult.success(PageUtil.convert(productModelFileService.getList(request), d -> {
|
||||
ProductModelFileVO vo=Convert.convert(ProductModelFileVO.class, d);
|
||||
vo.setLanguages(Convert.toList(ProductModelFileItemAddRequest.class,productModelFileService.getLanguages(vo.getId())));
|
||||
return vo;
|
||||
}));
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 获取资料详情
|
||||
// * @param modelFileId 视频ID
|
||||
// */
|
||||
// @GetMapping("/getFileInfo")
|
||||
// public ApiResult<ProductModelFileInfoVO> getFileInfo(@RequestParam Integer modelFileId){
|
||||
// return ApiResult.success(productModelFileService.getInfo(modelFileId));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取机型资料默认文件
|
||||
* @param modelId 机型ID
|
||||
* @return 配置信息
|
||||
*/
|
||||
@GetMapping("/getFileDefaultCondig")
|
||||
public ApiResult<List<FileDefaultConfigVO>> getFileDefaultCondig(@Valid @RequestParam @NotNull Integer modelId){
|
||||
return ApiResult.success(productModelFileService.getDefaultConfig(modelId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取资料详情
|
||||
* @param modelFileId 视频ID
|
||||
* 设置机型资料默认文件
|
||||
* @param request 配置信息
|
||||
*/
|
||||
@GetMapping("/getFileInfo")
|
||||
public ApiResult<ProductModelFileInfoVO> getFileInfo(@RequestParam Integer modelFileId){
|
||||
return ApiResult.success(productModelFileService.getInfo(modelFileId));
|
||||
@PostMapping("/setFileDefaultCondig")
|
||||
public ApiResult<Void> setFileDefaultCondig(@Valid @RequestBody FileDefaultConfigRequest request){
|
||||
productModelFileService.setFileDefaultCondig(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.nflg.mobilebroken.common.pojo.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
public class FileDefaultConfigItemRequest {
|
||||
|
||||
/**
|
||||
* 语言编码
|
||||
*/
|
||||
@NotBlank
|
||||
private String languageCode;
|
||||
|
||||
/**
|
||||
* 文件项ID
|
||||
*/
|
||||
private Integer fileItemId;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.nflg.mobilebroken.common.pojo.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class FileDefaultConfigRequest {
|
||||
|
||||
/**
|
||||
* 机型ID
|
||||
*/
|
||||
@NotNull
|
||||
private Integer modelId;
|
||||
|
||||
/**
|
||||
* 配置项
|
||||
*/
|
||||
@NotEmpty
|
||||
private List<FileDefaultConfigItemRequest> items;
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.nflg.mobilebroken.common.pojo.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class ParamsIndexNameDeleteRequest {
|
||||
|
||||
/**
|
||||
* 机型参数id
|
||||
*/
|
||||
@NotNull
|
||||
private Integer modelParamsId;
|
||||
|
||||
/**
|
||||
* 语言代码
|
||||
*/
|
||||
@NotBlank
|
||||
private String languageCode;
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*/
|
||||
@NotBlank
|
||||
private String indexName;
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.nflg.mobilebroken.common.pojo.request;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
|
@ -21,13 +22,32 @@ public class ProductModelFileAddRequest {
|
|||
@NotBlank
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
@NotBlank
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
private Integer size;
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 多语言数据
|
||||
*/
|
||||
private List<ProductModelFileItemAddRequest> items;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 项
|
||||
*/
|
||||
private List<ProductFileAddRequest> items;
|
||||
public String getType() {
|
||||
return "." + FilenameUtils.getExtension(name);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.nflg.mobilebroken.common.pojo.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ProductModelFileItemAddRequest {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 语言编码
|
||||
*/
|
||||
private String languageCode;
|
||||
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
private String name;
|
||||
}
|
||||
|
|
@ -3,10 +3,16 @@ package com.nflg.mobilebroken.common.pojo.request;
|
|||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ProductModelFileUpdateRequest extends ProductModelFileAddRequest{
|
||||
public class ProductModelFileUpdateRequest{
|
||||
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 多语言数据
|
||||
*/
|
||||
private List<ProductModelFileItemAddRequest> items;
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.nflg.mobilebroken.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class FileDefaultConfigItemVO {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 是否是当前的选择项
|
||||
*/
|
||||
private Boolean selected;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.nflg.mobilebroken.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class FileDefaultConfigVO {
|
||||
|
||||
/**
|
||||
* 语言编码
|
||||
*/
|
||||
private String languageCode;
|
||||
|
||||
/**
|
||||
* 语言名称
|
||||
*/
|
||||
private String languageName;
|
||||
|
||||
/**
|
||||
* 语言项
|
||||
*/
|
||||
private List<FileDefaultConfigItemVO> items;
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
package com.nflg.mobilebroken.common.pojo.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.nflg.mobilebroken.common.pojo.request.ProductModelFileItemAddRequest;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ProductModelFileVO {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 产品机型id
|
||||
*/
|
||||
private Integer modelId;
|
||||
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 文件后缀
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 下载地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 文件大小,单位KB
|
||||
*/
|
||||
private Integer size;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 是否显示在列表
|
||||
*/
|
||||
private Boolean showInList;
|
||||
|
||||
/**
|
||||
* 发布状态,0:未发布;1-已发布,2-已废弃
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 发布人
|
||||
*/
|
||||
private String publishBy;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 适用语种
|
||||
*/
|
||||
private List<ProductModelFileItemAddRequest> languages;
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ public class ProductModelVO {
|
|||
private List<ProductModelParamVO> params;
|
||||
|
||||
/**
|
||||
* 文件列表
|
||||
* 文件
|
||||
*/
|
||||
private List<ProductFileVO> files;
|
||||
private ProductFileVO file;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@ package com.nflg.mobilebroken.repository.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 产品中心-产品机型-文件
|
||||
|
|
@ -38,6 +39,21 @@ public class ProductModelFile implements Serializable {
|
|||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 文件后缀
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 下载地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 文件大小,单位KB
|
||||
*/
|
||||
private Integer size;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,11 +3,12 @@ package com.nflg.mobilebroken.repository.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 产品中心-产品机型-文件
|
||||
|
|
@ -27,6 +28,11 @@ public class ProductModelFileItem implements Serializable {
|
|||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 产品机型id
|
||||
*/
|
||||
private Integer modelId;
|
||||
|
||||
/**
|
||||
* 产品机型id
|
||||
*/
|
||||
|
|
@ -43,17 +49,7 @@ public class ProductModelFileItem implements Serializable {
|
|||
private String name;
|
||||
|
||||
/**
|
||||
* 文件后缀
|
||||
* 是否显示在列表
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 下载地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 文件大小,单位KB
|
||||
*/
|
||||
private Integer size;
|
||||
private Boolean showInList;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
import com.nflg.mobilebroken.common.pojo.vo.ProductFileVO;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductModelFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 产品中心-产品机型-文件 Mapper 接口
|
||||
|
|
@ -16,7 +14,7 @@ import java.util.List;
|
|||
*/
|
||||
public interface ProductModelFileMapper extends BaseMapper<ProductModelFile> {
|
||||
|
||||
List<ProductFileVO> getListByLanguage(Integer modelId, String language);
|
||||
ProductFileVO getListByLanguage(Integer modelId, String language);
|
||||
|
||||
void copyItems(Integer oldId, Integer newId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
package com.nflg.mobilebroken.repository.service;
|
||||
|
||||
import com.nflg.mobilebroken.common.pojo.request.ProductFileAddRequest;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductModelFileItem;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nflg.mobilebroken.common.pojo.request.FileDefaultConfigRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.ProductModelFileItemAddRequest;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductModelFileItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -16,9 +17,9 @@ import java.util.List;
|
|||
*/
|
||||
public interface IProductModelFileItemService extends IService<ProductModelFileItem> {
|
||||
|
||||
void add(Integer id, List<ProductFileAddRequest> items);
|
||||
void add(Integer modelId,Integer id, List<ProductModelFileItemAddRequest> items);
|
||||
|
||||
void update(List<ProductFileAddRequest> items);
|
||||
void update(Integer id, List<ProductModelFileItemAddRequest> items);
|
||||
|
||||
List<ProductFileAddRequest> getInfo(Integer modelFileId);
|
||||
void setFileDefaultCondig(FileDefaultConfigRequest request);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@ package com.nflg.mobilebroken.repository.service;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nflg.mobilebroken.common.pojo.request.*;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.FileDefaultConfigVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductFileVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductModelFileInfoVO;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductModelFile;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductModelFileItem;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -33,9 +35,7 @@ public interface IProductModelFileService extends IService<ProductModelFile> {
|
|||
|
||||
IPage<ProductModelFile> getList(@Valid ProductModelImageSearchRequest request);
|
||||
|
||||
ProductModelFileInfoVO getInfo(Integer modelFileId);
|
||||
|
||||
List<ProductFileVO> getListByLanguage(Integer modelId, String language);
|
||||
ProductFileVO getDefaultByLanguage(Integer modelId, String language);
|
||||
|
||||
void deleteByModel(@NotEmpty List<Integer> ids);
|
||||
|
||||
|
|
@ -44,4 +44,10 @@ public interface IProductModelFileService extends IService<ProductModelFile> {
|
|||
void saveSort(@NotEmpty List<Integer> ids);
|
||||
|
||||
void copyItems(Integer oldId, Integer newId);
|
||||
|
||||
List<ProductModelFileItem> getLanguages(Integer id);
|
||||
|
||||
List<FileDefaultConfigVO> getDefaultConfig(@Valid @NotNull Integer modelId);
|
||||
|
||||
void setFileDefaultCondig(@Valid FileDefaultConfigRequest request);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,4 +43,6 @@ public interface IProductModelParamsItemService extends IService<ProductModelPar
|
|||
void importModelParamsItem(@Valid @NotNull Integer modelParamsId, List<ProductModelParamsExcelDTO> datas);
|
||||
|
||||
void updateItem(@Valid ProductModelParamsItemUpdateRequest1 request);
|
||||
|
||||
void deleteIndexName(@Valid ParamsIndexNameDeleteRequest request);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
package com.nflg.mobilebroken.repository.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.mobilebroken.common.pojo.request.ProductFileAddRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.FileDefaultConfigRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.ProductModelFileItemAddRequest;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductModelFileItem;
|
||||
import com.nflg.mobilebroken.repository.mapper.ProductModelFileItemMapper;
|
||||
import com.nflg.mobilebroken.repository.service.IProductModelFileItemService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -25,54 +29,53 @@ public class ProductModelFileItemServiceImpl extends ServiceImpl<ProductModelFil
|
|||
|
||||
@Transactional
|
||||
@Override
|
||||
public void add(Integer id, List<ProductFileAddRequest> items) {
|
||||
public void add(Integer modelId,Integer id, List<ProductModelFileItemAddRequest> items) {
|
||||
if (CollectionUtil.isNotEmpty(items)){
|
||||
saveBatch(
|
||||
items.stream()
|
||||
.map(it -> new ProductModelFileItem()
|
||||
List<ProductModelFileItem> forAdd = new ArrayList<>();
|
||||
items.forEach(item -> {
|
||||
if (StrUtil.isNotBlank(item.getName())) {
|
||||
forAdd.add(new ProductModelFileItem()
|
||||
.setModelId(modelId)
|
||||
.setModelFileId(id)
|
||||
.setLanguageCode(it.getLanguageCode())
|
||||
.setName(it.getName())
|
||||
.setType(it.getType())
|
||||
.setUrl(it.getUrl())
|
||||
.setSize(it.getSize())
|
||||
)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
.setLanguageCode(item.getLanguageCode())
|
||||
.setName(item.getName()));
|
||||
}
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(forAdd)) {
|
||||
saveBatch(forAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void update(List<ProductFileAddRequest> items) {
|
||||
if (CollectionUtil.isNotEmpty(items)){
|
||||
updateBatchById(
|
||||
public void update(Integer id, List<ProductModelFileItemAddRequest> items) {
|
||||
remove(new LambdaQueryWrapper<ProductModelFileItem>()
|
||||
.eq(ProductModelFileItem::getModelFileId, id)
|
||||
.notIn(ProductModelFileItem::getId, items.stream().map(ProductModelFileItemAddRequest::getId).collect(Collectors.toList()))
|
||||
);
|
||||
saveOrUpdateBatch(
|
||||
items.stream()
|
||||
.map(it -> new ProductModelFileItem()
|
||||
.setId(it.getId())
|
||||
.setName(it.getName())
|
||||
.setType(it.getType())
|
||||
.setUrl(it.getUrl())
|
||||
.setSize(it.getSize())
|
||||
)
|
||||
.map(item -> new ProductModelFileItem()
|
||||
.setId(item.getId())
|
||||
.setName(item.getName())
|
||||
.setLanguageCode(item.getLanguageCode()))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public List<ProductFileAddRequest> getInfo(Integer modelFileId) {
|
||||
return lambdaQuery()
|
||||
.eq(ProductModelFileItem::getModelFileId,modelFileId)
|
||||
.list().stream()
|
||||
.map(it -> new ProductFileAddRequest()
|
||||
.setId(it.getId())
|
||||
.setLanguageCode(it.getLanguageCode())
|
||||
.setName(it.getName())
|
||||
.setType(it.getType())
|
||||
.setUrl(it.getUrl())
|
||||
.setSize(it.getSize())
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
public void setFileDefaultCondig(FileDefaultConfigRequest request) {
|
||||
lambdaUpdate()
|
||||
.set(ProductModelFileItem::getShowInList, false)
|
||||
.eq(ProductModelFileItem::getModelId, request.getModelId())
|
||||
.update();
|
||||
request.getItems().forEach(item -> {
|
||||
lambdaUpdate()
|
||||
.set(ProductModelFileItem::getShowInList, true)
|
||||
.eq(ProductModelFileItem::getId, item.getFileItemId())
|
||||
.update();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -5,14 +5,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.FileDefaultConfigItemVO;
|
||||
import com.nflg.mobilebroken.common.constant.PublishState;
|
||||
import com.nflg.mobilebroken.common.pojo.request.*;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.FileDefaultConfigVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductFileVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductModelFileInfoVO;
|
||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.VUtils;
|
||||
import com.nflg.mobilebroken.repository.entity.Language;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductModelFile;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductModelFileItem;
|
||||
import com.nflg.mobilebroken.repository.mapper.ProductModelFileMapper;
|
||||
import com.nflg.mobilebroken.repository.service.ILanguageService;
|
||||
import com.nflg.mobilebroken.repository.service.IProductModelFileItemService;
|
||||
import com.nflg.mobilebroken.repository.service.IProductModelFileService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -22,7 +26,9 @@ import javax.annotation.Resource;
|
|||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
|
@ -38,17 +44,23 @@ public class ProductModelFileServiceImpl extends ServiceImpl<ProductModelFileMap
|
|||
@Resource
|
||||
private IProductModelFileItemService productModelFileItemService;
|
||||
|
||||
@Resource
|
||||
private ILanguageService languageService;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void add(ProductModelFileAddRequest request) {
|
||||
ProductModelFile info = new ProductModelFile()
|
||||
.setModelId(request.getModelId())
|
||||
.setName(request.getName())
|
||||
.setUrl(request.getUrl())
|
||||
.setType(request.getType())
|
||||
.setSize(request.getSize())
|
||||
.setSort(request.getSort())
|
||||
.setCreateBy(AdminUserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now());
|
||||
save(info);
|
||||
productModelFileItemService.add(info.getId(), request.getItems());
|
||||
productModelFileItemService.add(request.getModelId(),info.getId(), request.getItems());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
@ -56,16 +68,10 @@ public class ProductModelFileServiceImpl extends ServiceImpl<ProductModelFileMap
|
|||
public void update(ProductModelFileUpdateRequest request) {
|
||||
ProductModelFile info=getById(request.getId());
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(info)).throwMessage("无效的数据");
|
||||
if (Objects.equals(info.getState(), PublishState.Published.getState())){
|
||||
add(request);
|
||||
}else {
|
||||
info.setSort(request.getSort());
|
||||
info.setName(request.getName());
|
||||
info.setUpdateBy(AdminUserUtil.getUserName());
|
||||
info.setUpdateTime(LocalDateTime.now());
|
||||
updateById(info);
|
||||
productModelFileItemService.update(request.getItems());
|
||||
}
|
||||
productModelFileItemService.update(info.getId(),request.getItems());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -152,18 +158,7 @@ public class ProductModelFileServiceImpl extends ServiceImpl<ProductModelFileMap
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProductModelFileInfoVO getInfo(Integer modelFileId) {
|
||||
ProductModelFile info=getById(modelFileId);
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(info)).throwMessage("无效的数据");
|
||||
return new ProductModelFileInfoVO()
|
||||
.setId(info.getId())
|
||||
.setName(info.getName())
|
||||
.setSort(info.getSort())
|
||||
.setItems(productModelFileItemService.getInfo(modelFileId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductFileVO> getListByLanguage(Integer modelId, String language) {
|
||||
public ProductFileVO getDefaultByLanguage(Integer modelId, String language) {
|
||||
return baseMapper.getListByLanguage(modelId,language);
|
||||
}
|
||||
|
||||
|
|
@ -199,4 +194,41 @@ public class ProductModelFileServiceImpl extends ServiceImpl<ProductModelFileMap
|
|||
public void copyItems(Integer oldId, Integer newId) {
|
||||
baseMapper.copyItems(oldId,newId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductModelFileItem> getLanguages(Integer id) {
|
||||
return productModelFileItemService.lambdaQuery()
|
||||
.eq(ProductModelFileItem::getModelFileId, id)
|
||||
.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileDefaultConfigVO> getDefaultConfig(Integer modelId) {
|
||||
List<Language> languages = languageService.getAllLanguages();
|
||||
List<ProductModelFileItem> list = productModelFileItemService.lambdaQuery()
|
||||
.eq(ProductModelFileItem::getModelFileId, modelId)
|
||||
.orderByAsc(ProductModelFileItem::getLanguageCode)
|
||||
.orderByDesc(ProductModelFileItem::getShowInList)
|
||||
.list();
|
||||
List<FileDefaultConfigVO> vos=new ArrayList<>();
|
||||
Map<String, List<ProductModelFileItem>> maps=list.stream().collect(Collectors.groupingBy(ProductModelFileItem::getLanguageCode));
|
||||
maps.forEach((languageCode,data)->{
|
||||
FileDefaultConfigVO vo=new FileDefaultConfigVO()
|
||||
.setLanguageCode(languageCode)
|
||||
.setLanguageName(languages.stream().filter(lang->lang.getCode().equals(languageCode)).findFirst().get().getName())
|
||||
.setItems(data.stream().map(item->new FileDefaultConfigItemVO()
|
||||
.setId(item.getId())
|
||||
.setName(item.getName())
|
||||
.setSelected(item.getShowInList()))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
vos.add(vo);
|
||||
});
|
||||
return vos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFileDefaultCondig(FileDefaultConfigRequest request) {
|
||||
productModelFileItemService.setFileDefaultCondig(request);
|
||||
}
|
||||
}
|
||||
|
|
@ -32,6 +32,7 @@ public class ProductModelHotimageServiceImpl extends ServiceImpl<ProductModelHot
|
|||
public void add(ProductModelHotImageAddRequest request) {
|
||||
save(new ProductModelHotimage()
|
||||
.setModelId(request.getModelId())
|
||||
.setImage(request.getImage())
|
||||
.setData(request.getData())
|
||||
.setCreateBy(AdminUserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
|
|
|
|||
|
|
@ -139,11 +139,11 @@ public class ProductModelParamsItemServiceImpl extends ServiceImpl<ProductModelP
|
|||
Map<String, List<ProductModelParamsItem>> maps = datas.stream().collect(Collectors.groupingBy(ProductModelParamsItem::getLanguageCode));
|
||||
List<ProductModelParamsItemVO> vos = new ArrayList<>();
|
||||
maps.forEach((languageCode, data) -> {
|
||||
ProductModelParamsItemVO vo = new ProductModelParamsItemVO()
|
||||
.setLanguageCode(languageCode);
|
||||
Map<String, List<ProductModelParamsItem>> itemMap = data.stream().collect(Collectors.groupingBy(ProductModelParamsItem::getIndexName));
|
||||
itemMap.forEach((indexName, itemData) -> {
|
||||
ProductModelParamsItemVO vo = new ProductModelParamsItemVO()
|
||||
.setLanguageCode(languageCode)
|
||||
.setItems(data.stream().map(it -> new ProductModelMainParamsItemChildrenVO()
|
||||
vo.setItems(data.stream().map(it -> new ProductModelMainParamsItemChildrenVO()
|
||||
.setIndexName(indexName)
|
||||
.setItems(itemData.stream()
|
||||
.filter(pi->StrUtil.isNotBlank(pi.getName()))
|
||||
|
|
@ -254,4 +254,12 @@ public class ProductModelParamsItemServiceImpl extends ServiceImpl<ProductModelP
|
|||
.eq(ProductModelParamsItem::getId, request.getModelParamsItemId())
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteIndexName(ParamsIndexNameDeleteRequest request) {
|
||||
remove(new LambdaQueryWrapper<ProductModelParamsItem>()
|
||||
.eq(ProductModelParamsItem::getModelParamsId, request.getModelParamsId())
|
||||
.eq(ProductModelParamsItem::getLanguageCode, request.getLanguageCode())
|
||||
.eq(ProductModelParamsItem::getIndexName, request.getIndexName()));
|
||||
}
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ public class ProductModelServiceImpl extends ServiceImpl<ProductModelMapper, Pro
|
|||
.setRecommend(item.getRecommend())
|
||||
.setImage(item.getImage())
|
||||
.setParams(productPartParamsService.getListByLanguage(item.getId(), language,main))
|
||||
.setFiles(productModelFileService.getListByLanguage(item.getId(), language)))
|
||||
.setFile(productModelFileService.getDefaultByLanguage(item.getId(), language)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
|
|
|||
|
|
@ -1,18 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nflg.mobilebroken.repository.mapper.ProductModelFileMapper">
|
||||
|
||||
<select id="getListByLanguage" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductFileVO">
|
||||
SELECT pmfi.*
|
||||
SELECT pmfi.name, pmfi.*
|
||||
FROM product_model_file pmf
|
||||
INNER JOIN product_model_file_item pmfi ON pmf.id = pmfi.model_file_id
|
||||
WHERE pmf.`enable`=1 AND pmf.state=1 AND pmf.model_id=#{modelId} AND pmfi.language_code=#{language}
|
||||
ORDER BY pmf.sort DESC
|
||||
WHERE pmf.`enable` = 1
|
||||
AND pmf.state = 1
|
||||
AND pmfi.show_in_list = 1
|
||||
AND pmf.model_id = #{modelId}
|
||||
AND pmfi.language_code = #{language}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="copyItems">
|
||||
INSERT INTO product_model_file_item(model_file_id,language_code,`name`,type,url,size)
|
||||
SELECT #{newId},language_code,`name`,type,url,size
|
||||
INSERT INTO product_model_file_item(model_id,model_file_id,language_code,`name`,show_in_list)
|
||||
SELECT model_id,#{newId},language_code,`name`,show_in_list
|
||||
FROM product_model_file_item
|
||||
WHERE model_file_id=#{oldId}
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in New Issue