From 4a3d096ac2bd2923b9c1dbe4bdc8a2ea7b7382be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 12 Aug 2025 17:39:16 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20bug-565=20=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E6=9C=BA=E5=9E=8B=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=EF=BC=8C?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E8=B5=84=E6=96=99=E8=BF=99=E9=87=8C=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E6=98=AF=E6=9C=89=E9=A1=BA=E5=BA=8F=E7=9A=84=EF=BC=8C?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=9C=A8=E5=90=8E=E5=8F=B0=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProductModelController.java | 7 +++--- .../pojo/request/SortSaveNewRequest.java | 23 +++++++++++++++++ .../service/IProductModelFileService.java | 2 +- .../impl/ProductModelFileServiceImpl.java | 25 ++++++------------- .../mapper/ProductModelFileMapper.xml | 1 + 5 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/SortSaveNewRequest.java diff --git a/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/ProductModelController.java b/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/ProductModelController.java index 12683ccc..1697f493 100644 --- a/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/ProductModelController.java +++ b/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/ProductModelController.java @@ -34,6 +34,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.io.InputStream; @@ -992,11 +993,11 @@ public class ProductModelController extends ControllerBase{ /** * 保存资料排序 - * @param request 请求参数 + * @param ids 排序后的id列表 */ @PostMapping("/saveFileSort") - public ApiResult saveFileSort(@Valid @RequestBody SortSaveRequest request){ - productModelFileService.saveSort(request); + public ApiResult saveFileSort(@Valid @RequestBody @NotEmpty List ids) { + productModelFileService.saveSort(ids); return ApiResult.success(); } diff --git a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/SortSaveNewRequest.java b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/SortSaveNewRequest.java new file mode 100644 index 00000000..d1b52e47 --- /dev/null +++ b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/SortSaveNewRequest.java @@ -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 SortSaveNewRequest { + + /** + * 机型id + */ + @NotNull + private Integer modelId; + + /** + * 调整后的顺序 + */ + @NotEmpty + private List ids; +} diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IProductModelFileService.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IProductModelFileService.java index e5307452..3f7108f2 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IProductModelFileService.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IProductModelFileService.java @@ -41,7 +41,7 @@ public interface IProductModelFileService extends IService { List getListForSort(Integer modelId); - void saveSort(SortSaveRequest request); + void saveSort(List ids); void copyItems(Integer oldId, Integer newId); diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileServiceImpl.java index 835e5a2a..2b93511f 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileServiceImpl.java @@ -7,8 +7,6 @@ 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.constant.PublishState; -import com.nflg.mobilebroken.common.constant.STATE; -import com.nflg.mobilebroken.common.exception.NflgException; import com.nflg.mobilebroken.common.pojo.request.*; import com.nflg.mobilebroken.common.pojo.vo.FileDefaultConfigItemVO; import com.nflg.mobilebroken.common.pojo.vo.FileDefaultConfigVO; @@ -206,22 +204,13 @@ public class ProductModelFileServiceImpl extends ServiceImpl datas = lambdaQuery() - .select(ProductModelFile::getId, ProductModelFile::getSort) - .in(ProductModelFile::getId, request.getId(), request.getPreviousId(), request.getNextId()) - .list(); - ProductModelFile current = datas.stream().filter(data -> data.getId().equals(request.getId())).findFirst().orElseThrow( - () -> new NflgException(STATE.BusinessError, "无效的数据") - ); - ProductModelFile previous = datas.stream().filter(data -> data.getId().equals(request.getPreviousId())).findFirst().orElse(null); - ProductModelFile next = datas.stream().filter(data -> data.getId().equals(request.getNextId())).findFirst().orElse(null); - if (Objects.isNull(previous)) { - current.setSort(next.getSort() / 2); - } else if (Objects.isNull(next)) { - current.setSort(previous.getSort() * 2); - } else { - current.setSort((previous.getSort() + next.getSort()) / 2); + public void saveSort(List ids) { + List datas = new ArrayList<>(); + for (int i = 0; i < ids.size(); i++) { + datas.add(new ProductModelFile() + .setId(ids.get(i)) + .setSort(i + 1) + ); } updateBatchById(datas); } diff --git a/nflg-mobilebroken-repository/src/main/resources/mapper/ProductModelFileMapper.xml b/nflg-mobilebroken-repository/src/main/resources/mapper/ProductModelFileMapper.xml index 78ecf0af..4dfe1a86 100644 --- a/nflg-mobilebroken-repository/src/main/resources/mapper/ProductModelFileMapper.xml +++ b/nflg-mobilebroken-repository/src/main/resources/mapper/ProductModelFileMapper.xml @@ -25,5 +25,6 @@ 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 From b40ceda0ebefdf7bbceec90afd702e633457e354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 12 Aug 2025 18:07:23 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20bug-564=20=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=EF=BC=8C=E7=AE=A1=E7=90=86=E7=AB=AF=EF=BC=8C?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E8=B5=84=E6=96=99=E7=AE=A1=E7=90=86=E8=BF=99?= =?UTF-8?q?=E9=87=8C=EF=BC=8C=E8=AE=BE=E7=BD=AE=E9=BB=98=E8=AE=A4=E6=96=87?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E8=AE=BE=E7=BD=AE=E9=94=99=E4=BA=86=EF=BC=8C?= =?UTF-8?q?=E6=83=B3=E5=8F=96=E6=B6=88=E5=8F=96=E6=B6=88=E4=B8=8D=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ProductModelFileItemServiceImpl.java | 11 ++++--- .../impl/ProductModelFileServiceImpl.java | 32 ++++++++----------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileItemServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileItemServiceImpl.java index 6537d7e6..a68f4b3c 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileItemServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileItemServiceImpl.java @@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -72,10 +73,12 @@ public class ProductModelFileItemServiceImpl extends ServiceImpl { - lambdaUpdate() - .set(ProductModelFileItem::getShowInList, true) - .eq(ProductModelFileItem::getId, item.getFileItemId()) - .update(); + if (Objects.nonNull(item.getFileItemId())) { + lambdaUpdate() + .set(ProductModelFileItem::getShowInList, true) + .eq(ProductModelFileItem::getId, item.getFileItemId()) + .update(); + } }); } diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileServiceImpl.java index 2b93511f..d9e342c8 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileServiceImpl.java @@ -27,7 +27,6 @@ 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; @@ -229,25 +228,20 @@ public class ProductModelFileServiceImpl extends ServiceImpl getDefaultConfig(Integer modelId) { - List languages = languageService.getAllLanguages(); -// List list = productModelFileItemService.lambdaQuery() -// .eq(ProductModelFileItem::getModelId, modelId) -// .orderByAsc(ProductModelFileItem::getLanguageCode) -// .orderByDesc(ProductModelFileItem::getShowInList) -// .list(); - List list =productModelFileItemService.getPublishedByLanguage(modelId); List vos=new ArrayList<>(); - Map> 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()) - ); + List languages = languageService.getLanguages(); + List list = productModelFileItemService.getPublishedByLanguage(modelId); + languages.forEach(language -> { + FileDefaultConfigVO vo = new FileDefaultConfigVO() + .setLanguageCode(language.getCode()) + .setLanguageName(language.getName()) + .setItems(list.stream().filter(item -> StrUtil.equals(language.getCode(), item.getLanguageCode())) + .map(item -> { + return new FileDefaultConfigItemVO() + .setId(item.getId()) + .setName(item.getName()) + .setSelected(item.getShowInList()); + }).collect(Collectors.toList())); vos.add(vo); }); return vos; From 7fd5bbb19ee5da70b6a9e548c0f954d22bfa84ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 12 Aug 2025 18:10:39 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20bug-565=20=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E6=9C=BA=E5=9E=8B=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=EF=BC=8C?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E8=B5=84=E6=96=99=E8=BF=99=E9=87=8C=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E6=98=AF=E6=9C=89=E9=A1=BA=E5=BA=8F=E7=9A=84=EF=BC=8C?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=9C=A8=E5=90=8E=E5=8F=B0=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProductModelController.java | 7 +++--- .../service/IProductModelFileService.java | 2 +- .../impl/ProductModelFileServiceImpl.java | 25 +++++++++++++------ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/ProductModelController.java b/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/ProductModelController.java index 1697f493..d8a0706c 100644 --- a/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/ProductModelController.java +++ b/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/ProductModelController.java @@ -34,7 +34,6 @@ 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.io.InputStream; @@ -993,11 +992,11 @@ public class ProductModelController extends ControllerBase{ /** * 保存资料排序 - * @param ids 排序后的id列表 + * @param request 请求参数 */ @PostMapping("/saveFileSort") - public ApiResult saveFileSort(@Valid @RequestBody @NotEmpty List ids) { - productModelFileService.saveSort(ids); + public ApiResult saveFileSort(@Valid @RequestBody SortSaveRequest request) { + productModelFileService.saveSort(request); return ApiResult.success(); } diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IProductModelFileService.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IProductModelFileService.java index 3f7108f2..e5307452 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IProductModelFileService.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IProductModelFileService.java @@ -41,7 +41,7 @@ public interface IProductModelFileService extends IService { List getListForSort(Integer modelId); - void saveSort(List ids); + void saveSort(SortSaveRequest request); void copyItems(Integer oldId, Integer newId); diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileServiceImpl.java index d9e342c8..9812e739 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/ProductModelFileServiceImpl.java @@ -7,6 +7,8 @@ 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.constant.PublishState; +import com.nflg.mobilebroken.common.constant.STATE; +import com.nflg.mobilebroken.common.exception.NflgException; import com.nflg.mobilebroken.common.pojo.request.*; import com.nflg.mobilebroken.common.pojo.vo.FileDefaultConfigItemVO; import com.nflg.mobilebroken.common.pojo.vo.FileDefaultConfigVO; @@ -203,13 +205,22 @@ public class ProductModelFileServiceImpl extends ServiceImpl ids) { - List datas = new ArrayList<>(); - for (int i = 0; i < ids.size(); i++) { - datas.add(new ProductModelFile() - .setId(ids.get(i)) - .setSort(i + 1) - ); + public void saveSort(SortSaveRequest request) { + List datas = lambdaQuery() + .select(ProductModelFile::getId, ProductModelFile::getSort) + .in(ProductModelFile::getId, request.getId(), request.getPreviousId(), request.getNextId()) + .list(); + ProductModelFile current = datas.stream().filter(data -> data.getId().equals(request.getId())).findFirst().orElseThrow( + () -> new NflgException(STATE.BusinessError, "无效的数据") + ); + ProductModelFile previous = datas.stream().filter(data -> data.getId().equals(request.getPreviousId())).findFirst().orElse(null); + ProductModelFile next = datas.stream().filter(data -> data.getId().equals(request.getNextId())).findFirst().orElse(null); + if (Objects.isNull(previous)) { + current.setSort(next.getSort() / 2); + } else if (Objects.isNull(next)) { + current.setSort(previous.getSort() * 2); + } else { + current.setSort((previous.getSort() + next.getSort()) / 2); } updateBatchById(datas); }