aidaV1.2
update the code until 25 May 2023
This commit is contained in:
@@ -188,6 +188,34 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
||||
* 将文件名解析成文件的上传路径
|
||||
*/
|
||||
public static File upload(MultipartFile file, String filePath) {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmssS");
|
||||
String suffix = getExtensionName(file.getOriginalFilename());
|
||||
String nowStr = format.format(date)+"-" ;
|
||||
try {
|
||||
String fileName = file.getOriginalFilename();
|
||||
String fileSuffix = fileName.substring(fileName.lastIndexOf("."));
|
||||
String path = filePath + fileSuffix;
|
||||
// getCanonicalFile 可解析正确各种路径
|
||||
File dest = new File(path).getCanonicalFile();
|
||||
// 检测是否存在目录
|
||||
if (!dest.getParentFile().exists()) {
|
||||
if (!dest.getParentFile().mkdirs()) {
|
||||
System.out.println("was not successful.");
|
||||
}
|
||||
}
|
||||
// 文件写入
|
||||
file.transferTo(dest);
|
||||
return dest;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 将文件名解析成文件的上传路径
|
||||
*/
|
||||
public static File upload2(MultipartFile file, String filePath) {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmssS");
|
||||
String suffix = getExtensionName(file.getOriginalFilename());
|
||||
@@ -211,6 +239,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*/
|
||||
|
||||
@@ -50,8 +50,8 @@ public final class LocalCacheUtils {
|
||||
private static LoadingCache<String, String> emailCache = CacheBuilder.newBuilder()
|
||||
//设置并发级别为5,并发级别是指可以同时写缓存的线程数
|
||||
.concurrencyLevel(10)
|
||||
//设置写缓存后3分钟过期
|
||||
.expireAfterWrite(60*3, TimeUnit.SECONDS)
|
||||
//设置写缓存后10分钟过期,防止跨洲发送慢失效问题
|
||||
.expireAfterWrite(60*30, TimeUnit.SECONDS)
|
||||
//刷新机制 每隔一定时间刷新缓存loader 只有调用get具体的操作才生效(懒加载) 不设置则不刷新
|
||||
// .refreshAfterWrite(60, TimeUnit.SECONDS)
|
||||
//设置缓存容器的初始容量为100
|
||||
|
||||
@@ -95,5 +95,11 @@ public class ElementController {
|
||||
public Response<List<PantoneVO>> getRgbByHsvBatch(@RequestBody @Valid List<GetRgbByHsvBatchDTO> rgbByHsvBatch) {
|
||||
return Response.success(panToneService.getRgbByHsvBatch(rgbByHsvBatch));
|
||||
}
|
||||
@ApiOperation(value = "刷新历史数据")
|
||||
@PostMapping("/refreshHistoryData")
|
||||
public Response<Boolean> refreshHistoryData() {
|
||||
collectionElementService.refreshHistoryData();
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.TCollectionElementRelation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* collection和element的关联表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2023-05-07
|
||||
*/
|
||||
@Mapper
|
||||
public interface TCollectionElementRelationMapper extends CommonMapper<TCollectionElementRelation> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.ai.da.mapper.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* collection和element的关联表
|
||||
* </p>
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2023-05-07
|
||||
*/
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_collection_element_relation")
|
||||
@ApiModel(value = "TCollectionElementRelation对象", description = "collection和element的关联表")
|
||||
public class TCollectionElementRelation implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("element ID")
|
||||
private Long elementId;
|
||||
|
||||
@ApiModelProperty("colletion ID class类型为COLLECTION 存 其他默认是0")
|
||||
private Long collectionId;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createDate;
|
||||
|
||||
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public class PythonService {
|
||||
PythonToJavaApiOperationTypeEnum operationType = PythonToJavaApiOperationTypeEnum.uploadOf(operateType);
|
||||
Assert.notNull(operationType, "unknown operateType " + operateType + "!");
|
||||
String path = calculateFileUrl(operationType);
|
||||
File generateFile = FileUtil.upload(file, path);
|
||||
File generateFile = FileUtil.upload2(file, path);
|
||||
|
||||
String linuxDomain = fileProperties.getLinuxDomain();
|
||||
if (!StringUtils.isEmpty(linuxDomain)) {
|
||||
@@ -1274,6 +1274,9 @@ public class PythonService {
|
||||
return null;
|
||||
}
|
||||
DesignPythonItemPrint print = CopyUtil.copyObject(printObject, DesignPythonItemPrint.class);
|
||||
if(StringUtils.isEmpty(printObject.getPath())){
|
||||
print.setPath("none");
|
||||
}
|
||||
if (StringUtils.isEmpty(clothesPath)
|
||||
|| "none".equals(clothesPath)
|
||||
|| CollectionUtils.isEmpty(printObject.getLocation())) {
|
||||
@@ -1286,6 +1289,7 @@ public class PythonService {
|
||||
location.set(0, location.get(0) * fileVO.getWidth());
|
||||
location.set(1, location.get(1) * fileVO.getHigh());
|
||||
});
|
||||
|
||||
log.info("本次print打点locations###{}###fileVO{}", locations, JSON.toJSONString(fileVO));
|
||||
return print;
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
|
||||
*/
|
||||
List<CollectionElementVO> saveColorBoard(List<CollectionColorDTO> colorBoards, Long collectionId, String timeZone);
|
||||
|
||||
|
||||
/**
|
||||
* 根据collection查询
|
||||
*
|
||||
@@ -105,6 +106,13 @@ public interface CollectionElementService extends IService<CollectionElement> {
|
||||
*/
|
||||
List<CollectionElement> getByCollectionId(Long collectionId);
|
||||
|
||||
List<CollectionElement> getByOnlyCollectionId(Long collectionId);
|
||||
|
||||
DesignLibraryModelPointVO calculateTemplatePoint(LibraryModelPoint modelPoint, Integer high, Integer width, String templateUrl);
|
||||
|
||||
/**
|
||||
* 刷新历史数据
|
||||
*/
|
||||
void refreshHistoryData() ;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
import com.ai.da.mapper.entity.TCollectionElementRelation;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* collection和element的关联表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2023-05-07
|
||||
*/
|
||||
public interface TCollectionElementRelationService extends IService<TCollectionElementRelation> {
|
||||
void deleteByCollectionId(Long collectionId);
|
||||
List<Long> getByCollectionId(Long collectionId);
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import com.ai.da.model.vo.AccountPreLoginVO;
|
||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
||||
import com.ai.da.service.AccountLoginLogService;
|
||||
import com.ai.da.service.AccountService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -61,6 +62,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
|
||||
@Override
|
||||
public AccountPreLoginVO preLogin(AccountPreLoginDTO accountDTO) {
|
||||
log.info("aida预先登入accountDTO###{}", JSON.toJSONString(accountDTO));
|
||||
Account account = getOneByUserName(accountDTO.getUserName());
|
||||
Assert.isTrue(Objects.nonNull(account),"User does not exist!");
|
||||
//用户有效期校验
|
||||
@@ -77,9 +79,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
@Transactional
|
||||
@Override
|
||||
public AccountLoginVO login(AccountLoginDTO accountLoginDTO, HttpServletRequest request) {
|
||||
Account accountExist = getOneByUserId(accountLoginDTO.getUserId());
|
||||
log.info("aida确认登入###accountLoginDTO###{}", JSON.toJSONString(accountLoginDTO));
|
||||
Account accountExist = getOneByEmail(accountLoginDTO.getEmail().trim());
|
||||
Assert.notNull(accountExist,"User does not exist!");
|
||||
Assert.isTrue(accountLoginDTO.getEmail().equals(accountExist.getUserEmail()),"Email not registered!");
|
||||
|
||||
LoginTypeEnum accountType = LoginTypeEnum.of(accountLoginDTO.getLoginType());
|
||||
if (Objects.isNull(accountType)|| accountType.equals(LoginTypeEnum.PASSWORD)) {
|
||||
@@ -101,7 +103,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
case EMAIL:
|
||||
Assert.isTrue(StringUtils.isNotBlank(accountLoginDTO.getEmail()), "Please input a email !");
|
||||
Assert.isTrue(StringUtils.isNotBlank(accountLoginDTO.getEmailVerifyCode()), "Please input the email verification code !");
|
||||
account = getOneByEmail(accountLoginDTO.getEmail());
|
||||
account = getOneByEmail(accountLoginDTO.getEmail().trim());
|
||||
if (Objects.isNull(account)) {
|
||||
throw new BusinessException("Email not registered!");
|
||||
}
|
||||
|
||||
@@ -5,25 +5,23 @@ import com.ai.da.common.config.FileProperties;
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.enums.*;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.DateUtil;
|
||||
import com.ai.da.common.utils.FileUtil;
|
||||
import com.ai.da.common.utils.MD5Utils;
|
||||
import com.ai.da.mapper.CollectionElementMapper;
|
||||
import com.ai.da.mapper.entity.*;
|
||||
import com.ai.da.mapper.entity.Collection;
|
||||
import com.ai.da.mapper.entity.CollectionElement;
|
||||
import com.ai.da.mapper.entity.Library;
|
||||
import com.ai.da.mapper.entity.LibraryModelPoint;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.python.PythonService;
|
||||
import com.ai.da.python.vo.DesignPythonItem;
|
||||
import com.ai.da.service.CollectionElementService;
|
||||
import com.ai.da.service.LibraryModelPointService;
|
||||
import com.ai.da.service.LibraryService;
|
||||
import com.ai.da.service.PanToneService;
|
||||
import com.ai.da.service.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
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.google.common.collect.Lists;
|
||||
import javafx.scene.chart.ValueAxis;
|
||||
@@ -32,6 +30,7 @@ import org.bouncycastle.LICENSE;
|
||||
import org.bouncycastle.cms.CMSAuthenticatedGenerator;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.reactive.AbstractReactiveTransactionManager;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -65,6 +64,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
private LibraryService libraryService;
|
||||
@Resource
|
||||
private LibraryModelPointService libraryModelPointService;
|
||||
@Resource
|
||||
private TCollectionElementRelationService tCollectionElementRelationService;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
@@ -477,6 +478,36 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
}
|
||||
return CopyUtil.copyList(colorElements, CollectionElementVO.class);
|
||||
}
|
||||
@Override
|
||||
public void refreshHistoryData() {
|
||||
//幂等
|
||||
if(!CollectionUtils.isEmpty(tCollectionElementRelationService.getByCollectionId(1083L))){
|
||||
return;
|
||||
}
|
||||
// 分页数据
|
||||
QueryWrapper<CollectionElement> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByAsc("id");
|
||||
PageQueryBaseVo pageQuery = new PageQueryBaseVo();
|
||||
pageQuery.setPage(1);
|
||||
pageQuery.setSize(200);
|
||||
while(true){
|
||||
IPage<CollectionElement> page = getBaseMapper().selectPage(
|
||||
new Page<>(pageQuery.getPage(), pageQuery.getSize()), queryWrapper);
|
||||
List<CollectionElement> list = page.getRecords();
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
break;
|
||||
}
|
||||
|
||||
//保存
|
||||
List<TCollectionElementRelation> relations = list.stream().map(element->
|
||||
TCollectionElementRelation.builder().elementId(element.getId())
|
||||
.collectionId(element.getCollectionId()).createDate(new Date()).build())
|
||||
.collect(Collectors.toList());
|
||||
tCollectionElementRelationService.saveBatch(relations);
|
||||
pageQuery.setPage(pageQuery.getPage()+1);
|
||||
log.info("refreshHistoryData###process###page###"+pageQuery.getPage());
|
||||
}
|
||||
}
|
||||
|
||||
private List<CollectionElement> resolveColorData(List<CollectionColorDTO> colorBoards, AuthPrincipalVo userInfo, Long collectionId, String timeZone) {
|
||||
List<CollectionElement> elements = Lists.newArrayList();
|
||||
@@ -505,6 +536,16 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
|
||||
@Override
|
||||
public List<CollectionElement> getByCollectionId(Long collectionId) {
|
||||
List<Long> elementIds = tCollectionElementRelationService.getByCollectionId(collectionId);
|
||||
if (CollectionUtils.isEmpty(elementIds)){
|
||||
return null;
|
||||
}
|
||||
QueryWrapper<CollectionElement> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("id", elementIds);
|
||||
return collectionElementMapper.selectList(queryWrapper);
|
||||
}
|
||||
@Override
|
||||
public List<CollectionElement> getByOnlyCollectionId(Long collectionId) {
|
||||
QueryWrapper<CollectionElement> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("collection_id", collectionId);
|
||||
return collectionElementMapper.selectList(queryWrapper);
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Maps;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -118,7 +119,7 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
|
||||
}else {
|
||||
String[] idName = name.split("_");
|
||||
if (idName.length >1){
|
||||
d.setId(Integer.valueOf(idName[0]));
|
||||
d.setId(StringUtil.isNullOrEmpty(idName[0]) ? null : Integer.valueOf(idName[0]));
|
||||
d.setName(idName[1]);
|
||||
d.setTcx(idName[2]);
|
||||
}
|
||||
|
||||
@@ -72,6 +72,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
private UserLikeService userLikeService;
|
||||
@Resource
|
||||
private SysFileService sysFileService;
|
||||
@Resource
|
||||
private TCollectionElementRelationService tCollectionElementRelationService;
|
||||
|
||||
// @Transactional
|
||||
@Override
|
||||
@@ -167,7 +169,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
//library转化为collection(生成)
|
||||
saveCollectionElemntsByLibrarys(elementVO,collectionId);
|
||||
//保存颜色版
|
||||
collectionElementService.saveColorBoard(designDTO.getColorBoards(),collectionId,designDTO.getTimeZone());
|
||||
List<CollectionElementVO> colorElementList = collectionElementService.saveColorBoard(designDTO.getColorBoards(),collectionId,designDTO.getTimeZone());
|
||||
//保存design
|
||||
Long designId = saveOne(designDTO,collectionId,userInfo.getId());
|
||||
//计算library
|
||||
@@ -181,9 +183,30 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
pythonService.design(pythonObjects);
|
||||
//生成library
|
||||
generateLibrary(elementVO,designDTO.getTimeZone());
|
||||
//处理关联关系,修复element覆盖得情况
|
||||
List<CollectionElement> reLationelements =collectionElementService.getByOnlyCollectionId(collectionId);
|
||||
List<Long> reLationelementIds = reLationelements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
||||
handleCollectionElementRelation(collectionId,(null == collectionIdParam) ? false :true,reLationelementIds);
|
||||
//保存designItem 和detail
|
||||
return saveDesignItemAndDetail(pythonObjects,designId,collectionId,userInfo,designDTO.getTimeZone());
|
||||
}
|
||||
private void handleCollectionElementRelation(Long collectionId ,Boolean isEdit,List<Long> elementIds ){
|
||||
if (CollectionUtils.isEmpty(elementIds) || collectionId == null){
|
||||
return;
|
||||
}
|
||||
if(isEdit){
|
||||
//删除
|
||||
tCollectionElementRelationService.deleteByCollectionId(collectionId);
|
||||
}
|
||||
//新增
|
||||
tCollectionElementRelationService.saveBatch(elementIds.stream().map(elementId ->
|
||||
TCollectionElementRelation.builder()
|
||||
.collectionId(collectionId)
|
||||
.elementId(elementId)
|
||||
.createDate(new Date())
|
||||
.build()
|
||||
).collect(Collectors.toList()));
|
||||
}
|
||||
private void generateLibrary(ValidateElementVO elementVO,String timeZone){
|
||||
List<CollectionElement> elements = Lists.newArrayList();
|
||||
if(!CollectionUtils.isEmpty(elementVO.getMoodBoardElements())){
|
||||
@@ -382,6 +405,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
List<Long> newElementIds = validateMergeElement(oldElements,designItemDetails);
|
||||
//合并,关联新的element到collection
|
||||
collectionElementService.relationCollection(newElementIds,userLikeGroup.getCollectionId());
|
||||
//处理关联关系,修复element覆盖得情况
|
||||
handleCollectionElementRelation(userLikeGroup.getCollectionId(),false,newElementIds);
|
||||
UserLike userLike = resolveUserLike(designLikeDTO.getUserGroupId(), designItem.getDesignId(),
|
||||
designLikeDTO.getDesignItemId(),designItem.getDesignUrl(),designLikeDTO.getTimeZone());
|
||||
userLikeService.save(userLike);
|
||||
@@ -398,6 +423,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
designItemService.updateLikeStatus(designLikeDTO.getDesignItemId(),(byte)1);
|
||||
return new DesignLikeVO(userGroupId,groupDetailId);
|
||||
}
|
||||
|
||||
private List<Long> validateMergeElement(List<CollectionElement> oldElements,List<DesignItemDetail> designItemDetails){
|
||||
List<DesignItemDetail> hasCollections = designItemDetails.stream()
|
||||
.filter(f->Objects.nonNull(f.getCollectionElementId()))
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.ai.da.service.impl;
|
||||
|
||||
import com.ai.da.mapper.TCollectionElementRelationMapper;
|
||||
import com.ai.da.mapper.UserLikeMapper;
|
||||
import com.ai.da.mapper.entity.TCollectionElementRelation;
|
||||
import com.ai.da.mapper.entity.UserLike;
|
||||
import com.ai.da.service.TCollectionElementRelationService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* collection和element的关联表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2023-05-07
|
||||
*/
|
||||
@Service
|
||||
public class TCollectionElementRelationServiceImpl extends ServiceImpl<TCollectionElementRelationMapper, TCollectionElementRelation> implements TCollectionElementRelationService {
|
||||
@Resource
|
||||
private TCollectionElementRelationMapper tCollectionElementRelationMapper;
|
||||
|
||||
public void deleteByCollectionId(Long collectionId) {
|
||||
QueryWrapper<TCollectionElementRelation> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("collection_id", collectionId);
|
||||
tCollectionElementRelationMapper.delete(queryWrapper);
|
||||
}
|
||||
|
||||
public List<Long> getByCollectionId(Long collectionId) {
|
||||
QueryWrapper<TCollectionElementRelation> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("collection_id", collectionId);
|
||||
List<TCollectionElementRelation> tCollectionElementRelations = tCollectionElementRelationMapper.selectList(queryWrapper);
|
||||
return CollectionUtils.isEmpty(tCollectionElementRelations) ? null :
|
||||
tCollectionElementRelations.stream().map(TCollectionElementRelation::getElementId).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user