feat(repository): 完善删除功能
This commit is contained in:
parent
41100bdcf5
commit
b3c625ce72
|
|
@ -1,4 +1,7 @@
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
@ -19,4 +22,12 @@ public class TTest {
|
||||||
public void test2() {
|
public void test2() {
|
||||||
System.out.println("【" + " 打 撒sfc dffd发多少分多少 分多少分的d f ".replaceAll("\\s+", "") + "】");
|
System.out.println("【" + " 打 撒sfc dffd发多少分多少 分多少分的d f ".replaceAll("\\s+", "") + "】");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test4() {
|
||||||
|
PasswordEncoder PASSWORDENCODER = new BCryptPasswordEncoder();
|
||||||
|
String password = PASSWORDENCODER.encode("Nflg0331");
|
||||||
|
System.out.println(password);
|
||||||
|
Assertions.assertTrue(PASSWORDENCODER.matches("Nflg0331", password), "密码不正确");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,6 +4,7 @@ import com.nflg.mobilebroken.common.pojo.request.ProductModelImageItemAddRequest
|
||||||
import com.nflg.mobilebroken.repository.entity.ProductModelImageItem;
|
import com.nflg.mobilebroken.repository.entity.ProductModelImageItem;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -21,4 +22,6 @@ public interface IProductModelImageItemService extends IService<ProductModelImag
|
||||||
void update(List<ProductModelImageItemAddRequest> items);
|
void update(List<ProductModelImageItemAddRequest> items);
|
||||||
|
|
||||||
List<ProductModelImageItemAddRequest> getInfo(Integer modelImagesId);
|
List<ProductModelImageItemAddRequest> getInfo(Integer modelImagesId);
|
||||||
|
|
||||||
|
void removeByImageIds(List<Integer> ids);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface IProductModelIntroItemService extends IService<ProductModelIntroItem> {
|
public interface IProductModelIntroItemService extends IService<ProductModelIntroItem> {
|
||||||
|
|
||||||
void add(Integer id, @NotEmpty List<ProductModelIntroItemAddRequest> items);
|
void add(Integer id, List<ProductModelIntroItemAddRequest> items);
|
||||||
|
|
||||||
void update(List<ProductModelIntroItemAddRequest> items);
|
void update(List<ProductModelIntroItemAddRequest> items);
|
||||||
|
|
||||||
|
void deleteByIntroIds(List<Integer> ids);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,6 @@ public interface IProductModelVideoItemService extends IService<ProductModelVide
|
||||||
void update(List<ProductModelVideoItemAddRequest> items);
|
void update(List<ProductModelVideoItemAddRequest> items);
|
||||||
|
|
||||||
List<ProductModelVideoItemAddRequest> getInfo(Integer modelVideoId);
|
List<ProductModelVideoItemAddRequest> getInfo(Integer modelVideoId);
|
||||||
|
|
||||||
|
void removeByVideoIds(List<Integer> itemIds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -18,6 +19,7 @@ import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
import com.nflg.mobilebroken.repository.entity.Language;
|
import com.nflg.mobilebroken.repository.entity.Language;
|
||||||
import com.nflg.mobilebroken.repository.entity.ProductModelFile;
|
import com.nflg.mobilebroken.repository.entity.ProductModelFile;
|
||||||
import com.nflg.mobilebroken.repository.entity.ProductModelFileItem;
|
import com.nflg.mobilebroken.repository.entity.ProductModelFileItem;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.ProductModelIntro;
|
||||||
import com.nflg.mobilebroken.repository.mapper.ProductModelFileMapper;
|
import com.nflg.mobilebroken.repository.mapper.ProductModelFileMapper;
|
||||||
import com.nflg.mobilebroken.repository.service.ILanguageService;
|
import com.nflg.mobilebroken.repository.service.ILanguageService;
|
||||||
import com.nflg.mobilebroken.repository.service.IProductModelFileItemService;
|
import com.nflg.mobilebroken.repository.service.IProductModelFileItemService;
|
||||||
|
|
@ -190,9 +192,20 @@ public class ProductModelFileServiceImpl extends ServiceImpl<ProductModelFileMap
|
||||||
return baseMapper.getDefaultByLanguage(modelId, language);
|
return baseMapper.getDefaultByLanguage(modelId, language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void deleteByModel(List<Integer> ids) {
|
public void deleteByModel(List<Integer> ids) {
|
||||||
remove(new LambdaQueryWrapper<ProductModelFile>().in(ProductModelFile::getModelId, ids));
|
List<Integer> itemIds = lambdaQuery()
|
||||||
|
.eq(ProductModelFile::getModelId, ids)
|
||||||
|
.select(ProductModelFile::getId)
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.map(ProductModelFile::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollectionUtil.isNotEmpty(itemIds)) {
|
||||||
|
productModelFileItemService.removeByFileIds(itemIds);
|
||||||
|
}
|
||||||
|
removeByIds(itemIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -69,4 +69,11 @@ public class ProductModelImageItemServiceImpl extends ServiceImpl<ProductModelIm
|
||||||
)
|
)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeByImageIds(List<Integer> ids) {
|
||||||
|
lambdaUpdate()
|
||||||
|
.in(ProductModelImageItem::getModelImagesId, ids)
|
||||||
|
.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import com.nflg.mobilebroken.common.pojo.vo.ProductImageVO;
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.ProductModelImagesInfoVO;
|
import com.nflg.mobilebroken.common.pojo.vo.ProductModelImagesInfoVO;
|
||||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||||
import com.nflg.mobilebroken.common.util.VUtils;
|
import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.ProductModelFile;
|
||||||
import com.nflg.mobilebroken.repository.entity.ProductModelImage;
|
import com.nflg.mobilebroken.repository.entity.ProductModelImage;
|
||||||
import com.nflg.mobilebroken.repository.mapper.ProductModelImageMapper;
|
import com.nflg.mobilebroken.repository.mapper.ProductModelImageMapper;
|
||||||
import com.nflg.mobilebroken.repository.service.IProductModelImageItemService;
|
import com.nflg.mobilebroken.repository.service.IProductModelImageItemService;
|
||||||
|
|
@ -76,6 +77,7 @@ public class ProductModelImageServiceImpl extends ServiceImpl<ProductModelImageM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void delete(BatchDeleteRequest request) {
|
public void delete(BatchDeleteRequest request) {
|
||||||
VUtils.trueThrowBusinessError(lambdaQuery()
|
VUtils.trueThrowBusinessError(lambdaQuery()
|
||||||
|
|
@ -88,6 +90,7 @@ public class ProductModelImageServiceImpl extends ServiceImpl<ProductModelImageM
|
||||||
.ne(ProductModelImage::getCreateBy, AdminUserUtil.getUserName())
|
.ne(ProductModelImage::getCreateBy, AdminUserUtil.getUserName())
|
||||||
.exists()).throwMessage("不能删除其他人创建的数据");
|
.exists()).throwMessage("不能删除其他人创建的数据");
|
||||||
removeByIds(request.getIds());
|
removeByIds(request.getIds());
|
||||||
|
productModelImageItemService.removeByImageIds(request.getIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -183,9 +186,20 @@ public class ProductModelImageServiceImpl extends ServiceImpl<ProductModelImageM
|
||||||
return baseMapper.getListByLanguage(modelId,language);
|
return baseMapper.getListByLanguage(modelId,language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void deleteByModel(List<Integer> ids) {
|
public void deleteByModel(List<Integer> ids) {
|
||||||
remove(new LambdaQueryWrapper<ProductModelImage>().in(ProductModelImage::getModelId, ids));
|
List<Integer> itemIds = lambdaQuery()
|
||||||
|
.eq(ProductModelImage::getModelId, ids)
|
||||||
|
.select(ProductModelImage::getId)
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.map(ProductModelImage::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollectionUtil.isNotEmpty(itemIds)) {
|
||||||
|
productModelImageItemService.removeByImageIds(itemIds);
|
||||||
|
}
|
||||||
|
removeByIds(itemIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -52,4 +52,11 @@ public class ProductModelIntroItemServiceImpl extends ServiceImpl<ProductModelIn
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByIntroIds(List<Integer> ids) {
|
||||||
|
lambdaUpdate()
|
||||||
|
.in(ProductModelIntroItem::getModelIntroId, ids)
|
||||||
|
.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
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;
|
||||||
|
|
@ -10,6 +11,7 @@ import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||||
import com.nflg.mobilebroken.common.util.VUtils;
|
import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
import com.nflg.mobilebroken.repository.entity.ProductModelIntro;
|
import com.nflg.mobilebroken.repository.entity.ProductModelIntro;
|
||||||
import com.nflg.mobilebroken.repository.entity.ProductModelIntroItem;
|
import com.nflg.mobilebroken.repository.entity.ProductModelIntroItem;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.ProductModelParams;
|
||||||
import com.nflg.mobilebroken.repository.mapper.ProductModelIntroMapper;
|
import com.nflg.mobilebroken.repository.mapper.ProductModelIntroMapper;
|
||||||
import com.nflg.mobilebroken.repository.service.IProductModelIntroItemService;
|
import com.nflg.mobilebroken.repository.service.IProductModelIntroItemService;
|
||||||
import com.nflg.mobilebroken.repository.service.IProductModelIntroService;
|
import com.nflg.mobilebroken.repository.service.IProductModelIntroService;
|
||||||
|
|
@ -20,6 +22,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>
|
||||||
|
|
@ -63,6 +66,7 @@ public class ProductModelIntroServiceImpl extends ServiceImpl<ProductModelIntroM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void delete(BatchDeleteRequest request) {
|
public void delete(BatchDeleteRequest request) {
|
||||||
VUtils.trueThrowBusinessError(lambdaQuery()
|
VUtils.trueThrowBusinessError(lambdaQuery()
|
||||||
|
|
@ -75,6 +79,7 @@ public class ProductModelIntroServiceImpl extends ServiceImpl<ProductModelIntroM
|
||||||
.ne(ProductModelIntro::getCreateBy, AdminUserUtil.getUserName())
|
.ne(ProductModelIntro::getCreateBy, AdminUserUtil.getUserName())
|
||||||
.exists()).throwMessage("不能删除其他人创建的数据");
|
.exists()).throwMessage("不能删除其他人创建的数据");
|
||||||
removeByIds(request.getIds());
|
removeByIds(request.getIds());
|
||||||
|
productModelIntroItemService.deleteByIntroIds(request.getIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -132,9 +137,20 @@ public class ProductModelIntroServiceImpl extends ServiceImpl<ProductModelIntroM
|
||||||
baseMapper.copyItems(oldId, newId);
|
baseMapper.copyItems(oldId, newId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void deleteByModel(List<Integer> ids) {
|
public void deleteByModel(List<Integer> ids) {
|
||||||
remove(new LambdaQueryWrapper<ProductModelIntro>().in(ProductModelIntro::getModelId, ids));
|
List<Integer> itemIds = lambdaQuery()
|
||||||
|
.eq(ProductModelIntro::getModelId, ids)
|
||||||
|
.select(ProductModelIntro::getId)
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.map(ProductModelIntro::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollectionUtil.isNotEmpty(itemIds)) {
|
||||||
|
productModelIntroItemService.deleteByIntroIds(itemIds);
|
||||||
|
}
|
||||||
|
removeByIds(itemIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -144,9 +144,20 @@ public class ProductModelParamsServiceImpl extends ServiceImpl<ProductModelParam
|
||||||
return baseMapper.getAllListByLanguage(modelId, language);
|
return baseMapper.getAllListByLanguage(modelId, language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void deleteByModel(List<Integer> ids) {
|
public void deleteByModel(List<Integer> ids) {
|
||||||
remove(new LambdaQueryWrapper<ProductModelParams>().in(ProductModelParams::getModelId, ids));
|
List<Integer> itemIds=lambdaQuery()
|
||||||
|
.eq(ProductModelParams::getModelId, ids)
|
||||||
|
.select(ProductModelParams::getId)
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.map(ProductModelParams::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollectionUtil.isNotEmpty(itemIds)){
|
||||||
|
productModelParamsItemService.deleteByParamsIds(itemIds);
|
||||||
|
}
|
||||||
|
removeByIds(itemIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -75,4 +75,11 @@ public class ProductModelVideoItemServiceImpl extends ServiceImpl<ProductModelVi
|
||||||
)
|
)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeByVideoIds(List<Integer> itemIds) {
|
||||||
|
lambdaUpdate()
|
||||||
|
.in(ProductModelVideoItem::getModelVideoId, itemIds)
|
||||||
|
.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import com.nflg.mobilebroken.common.pojo.vo.ProductModelVideoInfoVO;
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.ProductVideoVO;
|
import com.nflg.mobilebroken.common.pojo.vo.ProductVideoVO;
|
||||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||||
import com.nflg.mobilebroken.common.util.VUtils;
|
import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.ProductModelImage;
|
||||||
import com.nflg.mobilebroken.repository.entity.ProductModelVideo;
|
import com.nflg.mobilebroken.repository.entity.ProductModelVideo;
|
||||||
import com.nflg.mobilebroken.repository.mapper.ProductModelVideoMapper;
|
import com.nflg.mobilebroken.repository.mapper.ProductModelVideoMapper;
|
||||||
import com.nflg.mobilebroken.repository.service.IProductModelVideoItemService;
|
import com.nflg.mobilebroken.repository.service.IProductModelVideoItemService;
|
||||||
|
|
@ -97,6 +98,7 @@ public class ProductModelVideoServiceImpl extends ServiceImpl<ProductModelVideoM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void delete(BatchDeleteRequest request) {
|
public void delete(BatchDeleteRequest request) {
|
||||||
VUtils.trueThrowBusinessError(lambdaQuery()
|
VUtils.trueThrowBusinessError(lambdaQuery()
|
||||||
|
|
@ -109,6 +111,7 @@ public class ProductModelVideoServiceImpl extends ServiceImpl<ProductModelVideoM
|
||||||
.ne(ProductModelVideo::getCreateBy, AdminUserUtil.getUserName())
|
.ne(ProductModelVideo::getCreateBy, AdminUserUtil.getUserName())
|
||||||
.exists()).throwMessage("不能删除其他人创建的数据");
|
.exists()).throwMessage("不能删除其他人创建的数据");
|
||||||
removeByIds(request.getIds());
|
removeByIds(request.getIds());
|
||||||
|
productModelVideoItemService.removeByVideoIds(request.getIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -183,9 +186,20 @@ public class ProductModelVideoServiceImpl extends ServiceImpl<ProductModelVideoM
|
||||||
return baseMapper.getListByLanguage(modelId,language);
|
return baseMapper.getListByLanguage(modelId,language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void deleteByModel(List<Integer> ids) {
|
public void deleteByModel(List<Integer> ids) {
|
||||||
remove(new LambdaQueryWrapper<ProductModelVideo>().in(ProductModelVideo::getModelId, ids));
|
List<Integer> itemIds = lambdaQuery()
|
||||||
|
.eq(ProductModelVideo::getModelId, ids)
|
||||||
|
.select(ProductModelVideo::getId)
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.map(ProductModelVideo::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollectionUtil.isNotEmpty(itemIds)) {
|
||||||
|
productModelVideoItemService.removeByVideoIds(itemIds);
|
||||||
|
}
|
||||||
|
removeByIds(itemIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue