Merge branch 'feature/bug-332' into develop
This commit is contained in:
commit
32c8637573
|
|
@ -166,7 +166,7 @@ public class ProductBaseController extends ControllerBase{
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
*/
|
*/
|
||||||
@PostMapping("/publishHonor")
|
@PostMapping("/publishHonor")
|
||||||
public ApiResult<Void> publishHonor(@Valid @RequestBody ProductPublishRequest request){
|
public ApiResult<Void> publishHonor(@Valid @RequestBody BatchPublishRequest request) {
|
||||||
productHonorService.publish(request);
|
productHonorService.publish(request);
|
||||||
return ApiResult.success();
|
return ApiResult.success();
|
||||||
}
|
}
|
||||||
|
|
@ -233,7 +233,7 @@ public class ProductBaseController extends ControllerBase{
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
*/
|
*/
|
||||||
@PostMapping("/publishCase")
|
@PostMapping("/publishCase")
|
||||||
public ApiResult<Void> publishCase(@Valid @RequestBody ProductPublishRequest request){
|
public ApiResult<Void> publishCase(@Valid @RequestBody BatchPublishRequest request) {
|
||||||
productCaseService.publish(request);
|
productCaseService.publish(request);
|
||||||
return ApiResult.success();
|
return ApiResult.success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,6 @@ public class ProductModelController extends ControllerBase{
|
||||||
@Resource
|
@Resource
|
||||||
private IProductModelParamsItemService productModelParamsItemService;
|
private IProductModelParamsItemService productModelParamsItemService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private IProductModelImageService productModelImageService;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private IProductModelVideoService productModelVideoService;
|
private IProductModelVideoService productModelVideoService;
|
||||||
|
|
||||||
|
|
@ -848,7 +845,7 @@ public class ProductModelController extends ControllerBase{
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
*/
|
*/
|
||||||
@PostMapping("/publishVideo")
|
@PostMapping("/publishVideo")
|
||||||
public ApiResult<Void> publishVideo(@Valid @RequestBody ProductPublishRequest request){
|
public ApiResult<Void> publishVideo(@Valid @RequestBody BatchPublishRequest request) {
|
||||||
productModelVideoService.publish(request);
|
productModelVideoService.publish(request);
|
||||||
return ApiResult.success();
|
return ApiResult.success();
|
||||||
}
|
}
|
||||||
|
|
@ -934,7 +931,7 @@ public class ProductModelController extends ControllerBase{
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
*/
|
*/
|
||||||
@PostMapping("/publishFile")
|
@PostMapping("/publishFile")
|
||||||
public ApiResult<Void> publishFile(@Valid @RequestBody ProductModelPublishRequest request) {
|
public ApiResult<Void> publishFile(@Valid @RequestBody BatchPublishRequest request) {
|
||||||
productModelFileService.publish(request);
|
productModelFileService.publish(request);
|
||||||
return ApiResult.success();
|
return ApiResult.success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
package com.nflg.mobilebroken.common.pojo.request;
|
package com.nflg.mobilebroken.common.pojo.request;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ProductModelPublishRequest {
|
@Accessors(chain = true)
|
||||||
|
public class BatchPublishRequest {
|
||||||
|
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private List<Integer> ids;
|
private List<Integer> ids;
|
||||||
|
|
@ -34,7 +34,7 @@ public interface IProductCaseService extends IService<ProductCase> {
|
||||||
|
|
||||||
void delete(@Valid BatchDeleteRequest request);
|
void delete(@Valid BatchDeleteRequest request);
|
||||||
|
|
||||||
void publish(@Valid ProductPublishRequest request);
|
void publish(@Valid BatchPublishRequest request);
|
||||||
|
|
||||||
ProductCaseInfoVO getInfo(@Valid @NotNull Integer caseId);
|
ProductCaseInfoVO getInfo(@Valid @NotNull Integer caseId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ public interface IProductHonorService extends IService<ProductHonor> {
|
||||||
|
|
||||||
List<ProductHonorVO> get(String language);
|
List<ProductHonorVO> get(String language);
|
||||||
|
|
||||||
void publish(@Valid ProductPublishRequest request);
|
void publish(@Valid BatchPublishRequest request);
|
||||||
|
|
||||||
void delete(@Valid BatchDeleteRequest request);
|
void delete(@Valid BatchDeleteRequest request);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ public interface IProductModelFileService extends IService<ProductModelFile> {
|
||||||
|
|
||||||
void delete(@Valid BatchDeleteRequest request);
|
void delete(@Valid BatchDeleteRequest request);
|
||||||
|
|
||||||
void publish(@Valid ProductModelPublishRequest request);
|
void publish(@Valid BatchPublishRequest request);
|
||||||
|
|
||||||
IPage<ProductModelFile> getList(@Valid ProductModelImageSearchRequest request);
|
IPage<ProductModelFile> getList(@Valid ProductModelImageSearchRequest request);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ public interface IProductModelImageService extends IService<ProductModelImage> {
|
||||||
|
|
||||||
void delete(@Valid BatchDeleteRequest request);
|
void delete(@Valid BatchDeleteRequest request);
|
||||||
|
|
||||||
void publish(@Valid ProductPublishRequest request);
|
void publish(@Valid BatchPublishRequest request);
|
||||||
|
|
||||||
IPage<ProductModelImage> getList(@Valid ProductModelImageSearchRequest request);
|
IPage<ProductModelImage> getList(@Valid ProductModelImageSearchRequest request);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ public interface IProductModelVideoService extends IService<ProductModelVideo> {
|
||||||
|
|
||||||
void delete(@Valid BatchDeleteRequest request);
|
void delete(@Valid BatchDeleteRequest request);
|
||||||
|
|
||||||
void publish(@Valid ProductPublishRequest request);
|
void publish(@Valid BatchPublishRequest request);
|
||||||
|
|
||||||
IPage<ProductModelVideo> getList(@Valid ProductModelImageSearchRequest request);
|
IPage<ProductModelVideo> getList(@Valid ProductModelImageSearchRequest request);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package com.nflg.mobilebroken.repository.service.impl;
|
package com.nflg.mobilebroken.repository.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
@ -27,6 +29,7 @@ import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -54,8 +57,8 @@ public class ProductCaseServiceImpl extends ServiceImpl<ProductCaseMapper, Produ
|
||||||
.setCreateTime(LocalDateTime.now());
|
.setCreateTime(LocalDateTime.now());
|
||||||
save(entity);
|
save(entity);
|
||||||
if (request.getPublish()) {
|
if (request.getPublish()) {
|
||||||
publish(new ProductPublishRequest()
|
publish(new BatchPublishRequest()
|
||||||
.setId(entity.getId())
|
.setIds(List.of(entity.getId()))
|
||||||
.setState(PublishState.Published.getState()));
|
.setState(PublishState.Published.getState()));
|
||||||
}
|
}
|
||||||
productCaseInfoService.add(entity.getId(), request.getItems());
|
productCaseInfoService.add(entity.getId(), request.getItems());
|
||||||
|
|
@ -79,8 +82,8 @@ public class ProductCaseServiceImpl extends ServiceImpl<ProductCaseMapper, Produ
|
||||||
info.setUpdateTime(LocalDateTime.now());
|
info.setUpdateTime(LocalDateTime.now());
|
||||||
updateById(info);
|
updateById(info);
|
||||||
if (request.getPublish()) {
|
if (request.getPublish()) {
|
||||||
publish(new ProductPublishRequest()
|
publish(new BatchPublishRequest()
|
||||||
.setId(info.getId())
|
.setIds(List.of(info.getId()))
|
||||||
.setState(PublishState.Published.getState()));
|
.setState(PublishState.Published.getState()));
|
||||||
}
|
}
|
||||||
productCaseInfoService.update(request.getItems());
|
productCaseInfoService.update(request.getItems());
|
||||||
|
|
@ -145,14 +148,22 @@ public class ProductCaseServiceImpl extends ServiceImpl<ProductCaseMapper, Produ
|
||||||
productCaseInfoService.delete(request.getIds());
|
productCaseInfoService.delete(request.getIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void publish(ProductPublishRequest request) {
|
public void publish(BatchPublishRequest request) {
|
||||||
ProductCase info = getById(request.getId());
|
List<ProductCase> list = listByIds(request.getIds());
|
||||||
VUtils.trueThrowBusinessError(Objects.isNull(info)).throwMessage("无效的数据");
|
List<String> names = list.stream().filter(ph -> Objects.equals(ph.getState(), request.getState())).map(ProductCase::getTitle).collect(Collectors.toList());
|
||||||
VUtils.trueThrowBusinessError(Objects.equals(info.getState(), request.getState()))
|
VUtils.trueThrowBusinessError(CollectionUtil.isNotEmpty(names))
|
||||||
.throwMessage("请勿重复操作");
|
.throwMessage("以下案例不需要设置为" + PublishState.findByValue(request.getState()).getDescription() + ":" + StrUtil.join(",", names));
|
||||||
if (Objects.equals(request.getState(), PublishState.Published.getState())) {
|
if (Objects.equals(request.getState(), PublishState.Published.getState())) {
|
||||||
VUtils.trueThrowBusinessError(!info.getEnable()).throwMessage("不能发布已禁用的数据");
|
names = list.stream().filter(ph -> !ph.getEnable()).map(ProductCase::getTitle).collect(Collectors.toList());
|
||||||
|
VUtils.trueThrowBusinessError(CollectionUtil.isNotEmpty(names)).throwMessage("以下案例被禁用不能发布:" + StrUtil.join(",", names));
|
||||||
|
}
|
||||||
|
list.forEach(it -> publish(it, request.getState()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void publish(ProductCase info, Integer state) {
|
||||||
|
if (Objects.equals(state, PublishState.Published.getState())) {
|
||||||
info.setState(PublishState.Published.getState());
|
info.setState(PublishState.Published.getState());
|
||||||
info.setPublishBy(AdminUserUtil.getUserName());
|
info.setPublishBy(AdminUserUtil.getUserName());
|
||||||
info.setPublishTime(LocalDateTime.now());
|
info.setPublishTime(LocalDateTime.now());
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.nflg.mobilebroken.repository.service.impl;
|
package com.nflg.mobilebroken.repository.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
|
@ -23,6 +24,7 @@ import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -55,8 +57,8 @@ public class ProductHonorServiceImpl extends ServiceImpl<ProductHonorMapper, Pro
|
||||||
.setCreateTime(LocalDateTime.now());
|
.setCreateTime(LocalDateTime.now());
|
||||||
save(productHonor);
|
save(productHonor);
|
||||||
if (request.getPublish()) {
|
if (request.getPublish()) {
|
||||||
publish(new ProductPublishRequest()
|
publish(new BatchPublishRequest()
|
||||||
.setId(productHonor.getId())
|
.setIds(List.of(productHonor.getId()))
|
||||||
.setState(PublishState.Published.getState()));
|
.setState(PublishState.Published.getState()));
|
||||||
}
|
}
|
||||||
productHonorInfoService.add(productHonor.getId(), request.getItems());
|
productHonorInfoService.add(productHonor.getId(), request.getItems());
|
||||||
|
|
@ -86,8 +88,8 @@ public class ProductHonorServiceImpl extends ServiceImpl<ProductHonorMapper, Pro
|
||||||
.eq(ProductHonor::getId, request.getId())
|
.eq(ProductHonor::getId, request.getId())
|
||||||
.update();
|
.update();
|
||||||
if (request.getPublish()) {
|
if (request.getPublish()) {
|
||||||
publish(new ProductPublishRequest()
|
publish(new BatchPublishRequest()
|
||||||
.setId(request.getId())
|
.setIds(List.of(request.getId()))
|
||||||
.setState(PublishState.Published.getState()));
|
.setState(PublishState.Published.getState()));
|
||||||
}
|
}
|
||||||
productHonorInfoService.update(request.getItems());
|
productHonorInfoService.update(request.getItems());
|
||||||
|
|
@ -105,14 +107,22 @@ public class ProductHonorServiceImpl extends ServiceImpl<ProductHonorMapper, Pro
|
||||||
return baseMapper.get(language);
|
return baseMapper.get(language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void publish(ProductPublishRequest request) {
|
public void publish(BatchPublishRequest request) {
|
||||||
ProductHonor info = getById(request.getId());
|
List<ProductHonor> list = listByIds(request.getIds());
|
||||||
VUtils.trueThrowBusinessError(Objects.isNull(info)).throwMessage("无效的数据");
|
List<String> names = list.stream().filter(ph -> Objects.equals(ph.getState(), request.getState())).map(ProductHonor::getTitle).collect(Collectors.toList());
|
||||||
VUtils.trueThrowBusinessError(Objects.equals(info.getState(), request.getState()))
|
VUtils.trueThrowBusinessError(CollectionUtil.isNotEmpty(names))
|
||||||
.throwMessage("请勿重复操作");
|
.throwMessage("以下荣誉不需要设置为" + PublishState.findByValue(request.getState()).getDescription() + ":" + StrUtil.join(",", names));
|
||||||
if (Objects.equals(request.getState(), PublishState.Published.getState())) {
|
if (Objects.equals(request.getState(), PublishState.Published.getState())) {
|
||||||
VUtils.trueThrowBusinessError(!info.getEnable()).throwMessage("不能发布已禁用的数据");
|
names = list.stream().filter(ph -> !ph.getEnable()).map(ProductHonor::getTitle).collect(Collectors.toList());
|
||||||
|
VUtils.trueThrowBusinessError(CollectionUtil.isNotEmpty(names)).throwMessage("以下荣誉被禁用不能发布:" + StrUtil.join(",", names));
|
||||||
|
}
|
||||||
|
list.forEach(it -> publish(it, request.getState()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void publish(ProductHonor info, Integer state) {
|
||||||
|
if (Objects.equals(state, PublishState.Published.getState())) {
|
||||||
info.setState(PublishState.Published.getState());
|
info.setState(PublishState.Published.getState());
|
||||||
info.setPublishBy(AdminUserUtil.getUserName());
|
info.setPublishBy(AdminUserUtil.getUserName());
|
||||||
info.setPublishTime(LocalDateTime.now());
|
info.setPublishTime(LocalDateTime.now());
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ public class ProductModelFileServiceImpl extends ServiceImpl<ProductModelFileMap
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void publish(ProductModelPublishRequest request) {
|
public void publish(BatchPublishRequest request) {
|
||||||
List<ProductModelFile> datas = listByIds(request.getIds());
|
List<ProductModelFile> datas = listByIds(request.getIds());
|
||||||
datas.removeIf(item -> !item.getEnable());
|
datas.removeIf(item -> !item.getEnable());
|
||||||
datas.forEach(info -> {
|
datas.forEach(info -> {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.nflg.mobilebroken.repository.service.impl;
|
package com.nflg.mobilebroken.repository.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
|
@ -25,6 +26,7 @@ import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -89,12 +91,20 @@ public class ProductModelImageServiceImpl extends ServiceImpl<ProductModelImageM
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void publish(ProductPublishRequest request) {
|
public void publish(BatchPublishRequest request) {
|
||||||
ProductModelImage info = getById(request.getId());
|
List<ProductModelImage> list = listByIds(request.getIds());
|
||||||
VUtils.trueThrowBusinessError(Objects.isNull(info)).throwMessage("无效的数据");
|
List<String> names = list.stream().filter(ph -> Objects.equals(ph.getState(), request.getState())).map(ProductModelImage::getName).collect(Collectors.toList());
|
||||||
VUtils.trueThrowBusinessError(Objects.equals(info.getState(), request.getState()))
|
VUtils.trueThrowBusinessError(CollectionUtil.isNotEmpty(names))
|
||||||
.throwMessage("请勿重复操作");
|
.throwMessage("以下图片不需要设置为" + PublishState.findByValue(request.getState()).getDescription() + ":" + StrUtil.join(",", names));
|
||||||
if (Objects.equals(request.getState(), PublishState.Published.getState())) {
|
if (Objects.equals(request.getState(), PublishState.Published.getState())) {
|
||||||
|
names = list.stream().filter(ph -> !ph.getEnable()).map(ProductModelImage::getName).collect(Collectors.toList());
|
||||||
|
VUtils.trueThrowBusinessError(CollectionUtil.isNotEmpty(names)).throwMessage("以下图片被禁用不能发布:" + StrUtil.join(",", names));
|
||||||
|
}
|
||||||
|
list.forEach(it -> publish(it, request.getState()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void publish(ProductModelImage info, Integer state) {
|
||||||
|
if (Objects.equals(state, PublishState.Published.getState())) {
|
||||||
VUtils.trueThrowBusinessError(!info.getEnable()).throwMessage("不能发布已禁用的数据");
|
VUtils.trueThrowBusinessError(!info.getEnable()).throwMessage("不能发布已禁用的数据");
|
||||||
info.setState(PublishState.Published.getState());
|
info.setState(PublishState.Published.getState());
|
||||||
info.setPublishBy(AdminUserUtil.getUserName());
|
info.setPublishBy(AdminUserUtil.getUserName());
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.nflg.mobilebroken.repository.service.impl;
|
package com.nflg.mobilebroken.repository.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
|
@ -25,6 +26,7 @@ import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -110,26 +112,33 @@ public class ProductModelVideoServiceImpl extends ServiceImpl<ProductModelVideoM
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void publish(ProductPublishRequest request) {
|
public void publish(BatchPublishRequest request) {
|
||||||
ProductModelVideo info = getById(request.getId());
|
List<ProductModelVideo> list = listByIds(request.getIds());
|
||||||
VUtils.trueThrowBusinessError(Objects.isNull(info)).throwMessage("无效的数据");
|
List<String> names = list.stream().filter(ph -> Objects.equals(ph.getState(), request.getState())).map(ProductModelVideo::getName).collect(Collectors.toList());
|
||||||
VUtils.trueThrowBusinessError(Objects.equals(info.getState(), request.getState()))
|
VUtils.trueThrowBusinessError(CollectionUtil.isNotEmpty(names))
|
||||||
.throwMessage("请勿重复操作");
|
.throwMessage("以下视频不需要设置为" + PublishState.findByValue(request.getState()).getDescription() + ":" + StrUtil.join(",", names));
|
||||||
if (Objects.equals(request.getState(), PublishState.Published.getState())) {
|
if (Objects.equals(request.getState(), PublishState.Published.getState())) {
|
||||||
VUtils.trueThrowBusinessError(!info.getEnable()).throwMessage("不能发布已禁用的数据");
|
names = list.stream().filter(ph -> !ph.getEnable()).map(ProductModelVideo::getName).collect(Collectors.toList());
|
||||||
|
VUtils.trueThrowBusinessError(CollectionUtil.isNotEmpty(names)).throwMessage("以下视频被禁用不能发布:" + StrUtil.join(",", names));
|
||||||
|
}
|
||||||
|
list.forEach(it -> publish(it, request.getState()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void publish(ProductModelVideo info, Integer state) {
|
||||||
|
if (Objects.equals(state, PublishState.Published.getState())) {
|
||||||
info.setState(PublishState.Published.getState());
|
info.setState(PublishState.Published.getState());
|
||||||
info.setPublishBy(AdminUserUtil.getUserName());
|
info.setPublishBy(AdminUserUtil.getUserName());
|
||||||
info.setPublishTime(LocalDateTime.now());
|
info.setPublishTime(LocalDateTime.now());
|
||||||
lambdaUpdate()
|
lambdaUpdate()
|
||||||
.set(ProductModelVideo::getState, PublishState.Obsolete.getState())
|
.set(ProductModelVideo::getState, PublishState.Obsolete.getState())
|
||||||
.eq(ProductModelVideo::getModelId, info.getModelId())
|
.eq(ProductModelVideo::getModelId, info.getModelId())
|
||||||
.eq(ProductModelVideo::getBatchNumber,info.getBatchNumber())
|
.eq(ProductModelVideo::getBatchNumber, info.getBatchNumber())
|
||||||
.eq(ProductModelVideo::getState, PublishState.Published.getState())
|
.eq(ProductModelVideo::getState, PublishState.Published.getState())
|
||||||
.update();
|
.update();
|
||||||
} else {
|
} else {
|
||||||
ProductModelVideo obsolete = lambdaQuery()
|
ProductModelVideo obsolete = lambdaQuery()
|
||||||
.eq(ProductModelVideo::getModelId, info.getModelId())
|
.eq(ProductModelVideo::getModelId, info.getModelId())
|
||||||
.eq(ProductModelVideo::getBatchNumber,info.getBatchNumber())
|
.eq(ProductModelVideo::getBatchNumber, info.getBatchNumber())
|
||||||
.eq(ProductModelVideo::getState, PublishState.Obsolete.getState())
|
.eq(ProductModelVideo::getState, PublishState.Obsolete.getState())
|
||||||
.orderByDesc(ProductModelVideo::getPublishTime)
|
.orderByDesc(ProductModelVideo::getPublishTime)
|
||||||
.last("Limit 1")
|
.last("Limit 1")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue