package cc.mrbird.febs.mall.service.impl;
|
|
import cc.mrbird.febs.common.entity.FebsResponse;
|
import cc.mrbird.febs.common.entity.QueryRequest;
|
import cc.mrbird.febs.common.enumerates.StateUpDownEnum;
|
import cc.mrbird.febs.mall.dto.clothes.AdminClothesTypeInfoDto;
|
import cc.mrbird.febs.mall.entity.*;
|
import cc.mrbird.febs.mall.mapper.*;
|
import cc.mrbird.febs.mall.service.ClothesTypeService;
|
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.StrUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import lombok.RequiredArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Set;
|
import java.util.stream.Collectors;
|
|
@Slf4j
|
@Service
|
@RequiredArgsConstructor
|
@Transactional
|
public class ClothesTypeServiceImpl extends ServiceImpl<ClothesTypeMapper, ClothesType> implements ClothesTypeService {
|
|
private final ClothesTypeMapper clothesTypeMapper;
|
private final ClothesSizeMapper clothesSizeMapper ;
|
private final ClothesPatternMapper clothesPatternMapper;
|
private final ClothesLocationMapper clothesLocationMapper;
|
private final ClothesClothMapper clothesClothMapper;
|
private final ClothesArtMapper clothesArtMapper;
|
private final ClothesTypeArtMapper clothesTypeArtMapper;
|
private final ClothesTypeSizeMapper clothesTypeSizeMapper;
|
private final ClothesTypeClothMapper clothesTypeClothMapper;
|
private final ClothesTypePatternMapper clothesTypePatternMapper;
|
private final ClothesTypeLocationMapper clothesTypeLocationMapper;
|
|
@Override
|
public IPage<ClothesType> adminTypeList(ClothesType dto, QueryRequest request) {
|
Page<ClothesType> page = new Page<>(request.getPageNum(), request.getPageSize());
|
LambdaQueryWrapper<ClothesType> clothesTypeLambdaQueryWrapper = Wrappers.lambdaQuery(ClothesType.class);
|
Page<ClothesType> clothesTypePage = clothesTypeMapper.selectPage(page, clothesTypeLambdaQueryWrapper);
|
return clothesTypePage;
|
}
|
|
@Override
|
public FebsResponse typeAdd(ClothesType dto) {
|
ClothesType clothesType = new ClothesType();
|
clothesType.setName(dto.getName());
|
clothesType.setOrderNum(dto.getOrderNum());
|
clothesType.setImage(dto.getImage());
|
clothesType.setImageFront(dto.getImageFront());
|
clothesType.setImageBack(dto.getImageBack());
|
clothesType.setContent(dto.getContent());
|
clothesTypeMapper.insert(clothesType);
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public FebsResponse typeUpdate(ClothesType dto) {
|
Long id = dto.getId();
|
ClothesType clothesType = clothesTypeMapper.selectById(id);
|
if (ObjectUtil.isNotNull(clothesType)) {
|
clothesTypeMapper.update(null,
|
Wrappers.lambdaUpdate(ClothesType.class)
|
.eq(ClothesType::getId, id)
|
.set(ClothesType::getName, dto.getName())
|
.set(ClothesType::getOrderNum, dto.getOrderNum())
|
.set(ClothesType::getImage, dto.getImage())
|
.set(ClothesType::getImageFront, dto.getImageFront())
|
.set(ClothesType::getImageBack, dto.getImageBack())
|
.set(ClothesType::getContent, dto.getContent())
|
);
|
}
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public FebsResponse changeState(Long id, Integer type, Integer state) {
|
ClothesType clothesType = clothesTypeMapper.selectById(id);
|
if(ObjectUtil.isNotEmpty(clothesType)){
|
switch (type) {
|
case 1:
|
clothesType.setState( state);
|
break;
|
case 2:
|
clothesType.setClothState(state);
|
break;
|
case 3:
|
clothesType.setArtState(state);
|
break;
|
case 4:
|
clothesType.setPatternState(state);
|
break;
|
case 5:
|
clothesType.setLocationState(state);
|
break;
|
case 6:
|
clothesType.setSizeState(state);
|
break;
|
default:
|
break;
|
}
|
clothesTypeMapper.updateById(clothesType);
|
}
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public IPage<ClothesSize> adminSizeList(ClothesSize dto, QueryRequest request) {
|
Page<ClothesSize> page = new Page<>(request.getPageNum(), request.getPageSize());
|
LambdaQueryWrapper<ClothesSize> clothesSizeLambdaQueryWrapper = Wrappers.lambdaQuery(ClothesSize.class);
|
Page<ClothesSize> clothesSizePage = clothesSizeMapper.selectPage(page, clothesSizeLambdaQueryWrapper);
|
return clothesSizePage;
|
}
|
|
@Override
|
public FebsResponse sizeAdd(ClothesSize dto) {
|
ClothesSize clothesSize = new ClothesSize();
|
clothesSize.setName(dto.getName());
|
clothesSize.setOrderNum(dto.getOrderNum());
|
clothesSize.setPrice(dto.getPrice());
|
clothesSize.setType(dto.getType());
|
clothesSize.setImage(dto.getImage());
|
clothesSize.setContent(dto.getContent());
|
clothesSizeMapper.insert(clothesSize);
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public FebsResponse sizeUpdate(ClothesSize dto) {
|
Long id = dto.getId();
|
ClothesSize clothesSize = clothesSizeMapper.selectById(id);
|
if (ObjectUtil.isNotNull(clothesSize)) {
|
clothesSizeMapper.update(null,
|
Wrappers.lambdaUpdate(ClothesSize.class)
|
.eq(ClothesSize::getId, id)
|
.set(ClothesSize::getName, dto.getName())
|
.set(ClothesSize::getCode, dto.getCode())
|
.set(ClothesSize::getOrderNum, dto.getOrderNum())
|
.set(ClothesSize::getPrice, dto.getPrice())
|
.set(ClothesSize::getType, dto.getType())
|
.set(ClothesSize::getImage, dto.getImage())
|
.set(ClothesSize::getContent, dto.getContent())
|
);
|
}
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public IPage<ClothesPattern> adminPatternList(ClothesPattern dto, QueryRequest request) {
|
Page<ClothesPattern> page = new Page<>(request.getPageNum(), request.getPageSize());
|
LambdaQueryWrapper<ClothesPattern> clothesPatternLambdaQueryWrapper = Wrappers.lambdaQuery(ClothesPattern.class);
|
Page<ClothesPattern> clothesPatternPage = clothesPatternMapper.selectPage(page, clothesPatternLambdaQueryWrapper);
|
return clothesPatternPage;
|
}
|
|
@Override
|
public FebsResponse patternAdd(ClothesPattern dto) {
|
ClothesPattern clothesPattern = new ClothesPattern();
|
clothesPattern.setName(dto.getName());
|
clothesPattern.setCode(dto.getCode());
|
clothesPattern.setType(dto.getType());
|
clothesPattern.setPrice(dto.getPrice());
|
clothesPattern.setOrderNum(dto.getOrderNum());
|
clothesPattern.setImage(dto.getImage());
|
clothesPattern.setContent(dto.getContent());
|
clothesPatternMapper.insert(clothesPattern);
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public FebsResponse patternUpdate(ClothesPattern dto) {
|
Long id = dto.getId();
|
ClothesPattern clothesPattern = clothesPatternMapper.selectById(id);
|
if (ObjectUtil.isNotNull(clothesPattern)) {
|
clothesPatternMapper.update(null,
|
Wrappers.lambdaUpdate(ClothesPattern.class)
|
.eq(ClothesPattern::getId, id)
|
.set(ClothesPattern::getName, dto.getName())
|
.set(ClothesPattern::getCode, dto.getCode())
|
.set(ClothesPattern::getImage, dto.getImage())
|
.set(ClothesPattern::getContent, dto.getContent())
|
.set(ClothesPattern::getOrderNum, dto.getOrderNum())
|
.set(ClothesPattern::getPrice, dto.getPrice())
|
.set(ClothesPattern::getType, dto.getType())
|
);
|
}
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public IPage<ClothesLocation> adminLocationList(ClothesLocation dto, QueryRequest request) {
|
Page<ClothesLocation> page = new Page<>(request.getPageNum(), request.getPageSize());
|
LambdaQueryWrapper<ClothesLocation> queryWrapper = Wrappers.lambdaQuery(ClothesLocation.class);
|
Page<ClothesLocation> pages = clothesLocationMapper.selectPage(page, queryWrapper);
|
return pages;
|
}
|
|
@Override
|
public FebsResponse locationAdd(ClothesLocation dto) {
|
ClothesLocation clothesLocation = new ClothesLocation();
|
clothesLocation.setName(dto.getName());
|
clothesLocation.setCode(dto.getCode());
|
clothesLocation.setImage(dto.getImage());
|
clothesLocation.setContent(dto.getContent());
|
clothesLocation.setPrice(dto.getPrice());
|
clothesLocation.setOrderNum(dto.getOrderNum());
|
clothesLocationMapper.insert(clothesLocation);
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public FebsResponse locationUpdate(ClothesLocation dto) {
|
Long id = dto.getId();
|
ClothesLocation clothesLocation = clothesLocationMapper.selectById(id);
|
if (ObjectUtil.isNotNull(clothesLocation)) {
|
clothesLocationMapper.update(null,
|
Wrappers.lambdaUpdate(ClothesLocation.class)
|
.eq(ClothesLocation::getId, id)
|
.set(ClothesLocation::getName, dto.getName())
|
.set(ClothesLocation::getCode, dto.getCode())
|
.set(ClothesLocation::getOrderNum, dto.getOrderNum())
|
.set(ClothesLocation::getPrice, dto.getPrice())
|
.set(ClothesLocation::getImage, dto.getImage())
|
.set(ClothesLocation::getContent, dto.getContent())
|
);
|
}
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public IPage<ClothesCloth> adminClothList(ClothesCloth dto, QueryRequest request) {
|
Page<ClothesCloth> page = new Page<>(request.getPageNum(), request.getPageSize());
|
LambdaQueryWrapper<ClothesCloth> queryWrapper = Wrappers.lambdaQuery(ClothesCloth.class);
|
Page<ClothesCloth> pages = clothesClothMapper.selectPage(page, queryWrapper);
|
return pages;
|
}
|
|
@Override
|
public FebsResponse clothAdd(ClothesCloth dto) {
|
ClothesCloth clothesCloth = new ClothesCloth();
|
clothesCloth.setName(dto.getName());
|
clothesCloth.setCode(dto.getCode());
|
clothesCloth.setImage(dto.getImage());
|
clothesCloth.setContent(dto.getContent());
|
clothesCloth.setPrice(dto.getPrice());
|
clothesCloth.setOrderNum(dto.getOrderNum());
|
clothesClothMapper.insert(clothesCloth);
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public FebsResponse clothUpdate(ClothesCloth dto) {
|
Long id = dto.getId();
|
ClothesCloth clothesCloth = clothesClothMapper.selectById(id);
|
if (ObjectUtil.isNotNull(clothesCloth)) {
|
clothesClothMapper.update(null,
|
Wrappers.lambdaUpdate(ClothesCloth.class)
|
.eq(ClothesCloth::getId, id)
|
.set(ClothesCloth::getName, dto.getName())
|
.set(ClothesCloth::getCode, dto.getCode())
|
.set(ClothesCloth::getOrderNum, dto.getOrderNum())
|
.set(ClothesCloth::getPrice, dto.getPrice())
|
.set(ClothesCloth::getImage, dto.getImage())
|
.set(ClothesCloth::getContent, dto.getContent())
|
);
|
}
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public IPage<ClothesArt> adminArtList(ClothesArt dto, QueryRequest request) {
|
Page<ClothesArt> page = new Page<>(request.getPageNum(), request.getPageSize());
|
LambdaQueryWrapper<ClothesArt> queryWrapper = Wrappers.lambdaQuery(ClothesArt.class);
|
Page<ClothesArt> pages = clothesArtMapper.selectPage(page, queryWrapper);
|
return pages;
|
}
|
|
@Override
|
public FebsResponse artAdd(ClothesArt dto) {
|
ClothesArt clothesArt = new ClothesArt();
|
clothesArt.setName(dto.getName());
|
clothesArt.setCode(dto.getCode());
|
clothesArt.setImage(dto.getImage());
|
clothesArt.setContent(dto.getContent());
|
clothesArt.setPrice(dto.getPrice());
|
clothesArt.setOrderNum(dto.getOrderNum());
|
clothesArtMapper.insert(clothesArt);
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public FebsResponse artUpdate(ClothesArt dto) {
|
Long id = dto.getId();
|
ClothesArt clothesArt = clothesArtMapper.selectById(id);
|
if (ObjectUtil.isNotNull(clothesArt)) {
|
clothesArtMapper.update(null,
|
Wrappers.lambdaUpdate(ClothesArt.class)
|
.eq(ClothesArt::getId, id)
|
.set(ClothesArt::getName, dto.getName())
|
.set(ClothesArt::getCode, dto.getCode())
|
.set(ClothesArt::getOrderNum, dto.getOrderNum())
|
.set(ClothesArt::getPrice, dto.getPrice())
|
.set(ClothesArt::getImage, dto.getImage())
|
.set(ClothesArt::getContent, dto.getContent())
|
);
|
}
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public FebsResponse artSet(AdminClothesTypeInfoDto dto) {
|
Long typeId = dto.getTypeId();
|
List<Long> chooseIds = dto.getChooseIds();
|
ClothesType clothesType = clothesTypeMapper.selectById(typeId);
|
if (ObjectUtil.isNotEmpty(clothesType)) {
|
LambdaQueryWrapper<ClothesTypeArt> queryWrapper = new LambdaQueryWrapper<>();
|
queryWrapper.eq(ClothesTypeArt::getTypeId,typeId);
|
clothesTypeArtMapper.delete(queryWrapper);
|
if(CollUtil.isNotEmpty(chooseIds)){
|
for (Long chooseId : chooseIds){
|
ClothesTypeArt entity = new ClothesTypeArt();
|
entity.setTypeId(typeId);
|
entity.setArtId(chooseId);
|
clothesTypeArtMapper.insert(entity);
|
}
|
}
|
}
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public FebsResponse sizeSet(AdminClothesTypeInfoDto dto) {
|
Long typeId = dto.getTypeId();
|
List<Long> chooseIds = dto.getChooseIds();
|
ClothesType clothesType = clothesTypeMapper.selectById(typeId);
|
if (ObjectUtil.isNotEmpty(clothesType)) {
|
LambdaQueryWrapper<ClothesTypeSize> queryWrapper = new LambdaQueryWrapper<>();
|
queryWrapper.eq(ClothesTypeSize::getTypeId,typeId);
|
clothesTypeSizeMapper.delete(queryWrapper);
|
if(CollUtil.isNotEmpty(chooseIds)){
|
for (Long chooseId : chooseIds){
|
ClothesTypeSize entity = new ClothesTypeSize();
|
entity.setTypeId(typeId);
|
entity.setSizeId(chooseId);
|
clothesTypeSizeMapper.insert(entity);
|
}
|
}
|
}
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public FebsResponse clothSet(AdminClothesTypeInfoDto dto) {
|
Long typeId = dto.getTypeId();
|
List<Long> chooseIds = dto.getChooseIds();
|
ClothesType clothesType = clothesTypeMapper.selectById(typeId);
|
if (ObjectUtil.isNotEmpty(clothesType)) {
|
LambdaQueryWrapper<ClothesTypeCloth> queryWrapper = new LambdaQueryWrapper<>();
|
queryWrapper.eq(ClothesTypeCloth::getTypeId,typeId);
|
clothesTypeClothMapper.delete(queryWrapper);
|
if(CollUtil.isNotEmpty(chooseIds)){
|
for (Long chooseId : chooseIds){
|
ClothesTypeCloth entity = new ClothesTypeCloth();
|
entity.setTypeId(typeId);
|
entity.setClothId(chooseId);
|
clothesTypeClothMapper.insert(entity);
|
}
|
}
|
}
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public FebsResponse patternSet(AdminClothesTypeInfoDto dto) {
|
Long typeId = dto.getTypeId();
|
List<Long> chooseIds = dto.getChooseIds();
|
ClothesType clothesType = clothesTypeMapper.selectById(typeId);
|
if (ObjectUtil.isNotEmpty(clothesType)) {
|
LambdaQueryWrapper<ClothesTypePattern> queryWrapper = new LambdaQueryWrapper<>();
|
queryWrapper.eq(ClothesTypePattern::getTypeId,typeId);
|
clothesTypePatternMapper.delete(queryWrapper);
|
if(CollUtil.isNotEmpty(chooseIds)){
|
for (Long chooseId : chooseIds){
|
ClothesTypePattern entity = new ClothesTypePattern();
|
entity.setTypeId(typeId);
|
entity.setPatternId(chooseId);
|
clothesTypePatternMapper.insert(entity);
|
}
|
}
|
}
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public FebsResponse locationSet(AdminClothesTypeInfoDto dto) {
|
Long typeId = dto.getTypeId();
|
List<Long> chooseIds = dto.getChooseIds();
|
ClothesType clothesType = clothesTypeMapper.selectById(typeId);
|
if (ObjectUtil.isNotEmpty(clothesType)) {
|
LambdaQueryWrapper<ClothesTypeLocation> queryWrapper = new LambdaQueryWrapper<>();
|
queryWrapper.eq(ClothesTypeLocation::getTypeId,typeId);
|
clothesTypeLocationMapper.delete(queryWrapper);
|
if(CollUtil.isNotEmpty(chooseIds)){
|
for (Long chooseId : chooseIds){
|
ClothesTypeLocation entity = new ClothesTypeLocation();
|
entity.setTypeId(typeId);
|
entity.setLocationId(chooseId);
|
clothesTypeLocationMapper.insert(entity);
|
}
|
}
|
}
|
return new FebsResponse().success().message("操作成功");
|
}
|
}
|