业务层修改,属性组前台数据获取

day-06
Saisai Liu 2024-03-04 15:52:54 +08:00
parent bdbfc8ed3a
commit a7adac6613
9 changed files with 77 additions and 0 deletions

View File

@ -74,6 +74,10 @@
<artifactId>aliyun-sdk-oss</artifactId> <artifactId>aliyun-sdk-oss</artifactId>
<version>3.12.0</version> <version>3.12.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-security</artifactId>
</dependency>
</dependencies> </dependencies>

View File

@ -2,8 +2,10 @@ package com.muyu.file.controller;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.file.FileUtils; import com.muyu.common.core.utils.file.FileUtils;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.file.service.ISysFileService; import com.muyu.file.service.ISysFileService;
import com.muyu.common.system.domain.SysFile; import com.muyu.common.system.domain.SysFile;
import com.muyu.file.utils.OSSCloudClient;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -11,6 +13,10 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/** /**
* *
* *
@ -40,4 +46,28 @@ public class SysFileController {
return Result.error(e.getMessage()); return Result.error(e.getMessage());
} }
} }
@PostMapping("imagesUpload")
public Result<SysFile> imagesUpload(MultipartFile file) {
OSSCloudClient client = OSSCloudClient.getInstance();
SysFile sysFile = new SysFile();
try {
String filePath = client.uploadFile(file.getName(), SecurityUtils.getUsername(), "D:\\muyu\\images");
System.out.println(filePath);
System.out.println(client.fileExist(filePath));
String format = new SimpleDateFormat("/yyyyMMdd/").format(new Date());
List<String> list = client.listFiles(format);
sysFile.setName(file.getName());
sysFile.setUrl(filePath);
for(String s : list) {
System.out.println(s);
client.deleteFile(s);
}
client.deleteFile("https://zhaohy-bucket.oss-cn-guangzhou.aliyuncs.com/static/images/1/"+format);
}catch (Exception e){
log.warn("文件上传异常{【】}",e.getMessage());
return Result.error(e.getMessage());
}
return Result.success(sysFile);
}
} }

View File

@ -39,6 +39,7 @@ public class AttributeGroup extends BaseEntity
private List<Attribute> attributeList; private List<Attribute> attributeList;
private List<Long> checkedAttributeIds; private List<Long> checkedAttributeIds;
private List<Long> asAttributeIds;
/** 状态 */ /** 状态 */
@Excel(name = "状态") @Excel(name = "状态")

View File

@ -60,4 +60,6 @@ public interface AsAttributeGroupMapper extends BaseMapper<AsAttributeGroup>
* @return * @return
*/ */
public int deleteAsAttributeGroupByIds(Long[] ids); public int deleteAsAttributeGroupByIds(Long[] ids);
public int deleteAsAttributeGroupByGroupId(Long id);
} }

View File

@ -60,4 +60,6 @@ public interface IAsAttributeGroupService extends IService<AsAttributeGroup>
* @return * @return
*/ */
public int deleteAsAttributeGroupById(Long id); public int deleteAsAttributeGroupById(Long id);
public int deleteAsAttributeGroupByGroupId(Long id);
} }

View File

@ -0,0 +1,22 @@
{
"name": null,
"remark": null,
"rules": [
{
"rule": null,
"values": []
}
]
}
{
"id": 1,
"ruleName": "ceshi",
"ruleAttr": [
"rule": {
"ruleName": "aa",
"ruleValue": []
}
]
}

View File

@ -96,4 +96,9 @@ public class AsAttributeGroupServiceImpl extends ServiceImpl<AsAttributeGroupMap
{ {
return asAttributeGroupMapper.deleteAsAttributeGroupById(id); return asAttributeGroupMapper.deleteAsAttributeGroupById(id);
} }
@Override
public int deleteAsAttributeGroupByGroupId(Long id) {
return asAttributeGroupMapper.deleteAsAttributeGroupByGroupId(id);
}
} }

View File

@ -54,13 +54,16 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
private void setAttributeList(AttributeGroup group) { private void setAttributeList(AttributeGroup group) {
List<Attribute> attributeLongs = new ArrayList<>(); List<Attribute> attributeLongs = new ArrayList<>();
List<Long> longs = new ArrayList<>(); List<Long> longs = new ArrayList<>();
List<Long> asIds = new ArrayList<>();
List<AsAttributeGroup> asAttributeGroups = asAttributeGroupService.selectAsAttributeGroupList(AsAttributeGroup.builder() List<AsAttributeGroup> asAttributeGroups = asAttributeGroupService.selectAsAttributeGroupList(AsAttributeGroup.builder()
.groupId(group.getId()) .groupId(group.getId())
.build()); .build());
asAttributeGroups.forEach(asAttributeGroup -> attributeLongs.add(attributeService.selectAttributeById(asAttributeGroup.getAttributeId()))); asAttributeGroups.forEach(asAttributeGroup -> attributeLongs.add(attributeService.selectAttributeById(asAttributeGroup.getAttributeId())));
asAttributeGroups.forEach(asAttributeGroup -> longs.add(attributeService.selectAttributeById(asAttributeGroup.getAttributeId()).getId())); asAttributeGroups.forEach(asAttributeGroup -> longs.add(attributeService.selectAttributeById(asAttributeGroup.getAttributeId()).getId()));
asAttributeGroups.forEach(asAttributeGroup -> asIds.add(asAttributeGroup.getId()));
group.setAttributeList(attributeLongs); group.setAttributeList(attributeLongs);
group.setCheckedAttributeIds(longs); group.setCheckedAttributeIds(longs);
group.setAsAttributeIds(asIds);
} }
@ -108,13 +111,18 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
@Override @Override
public int updateAttributeGroup(AttributeGroupReq attributeGroupReq) { public int updateAttributeGroup(AttributeGroupReq attributeGroupReq) {
AttributeGroup attributeGroup = AttributeGroupReq.updateBuilder(attributeGroupReq); AttributeGroup attributeGroup = AttributeGroupReq.updateBuilder(attributeGroupReq);
this.setAttributeList(attributeGroup);
int i = attributeGroupMapper.updateAttributeGroup(attributeGroup); int i = attributeGroupMapper.updateAttributeGroup(attributeGroup);
List<AsAttributeGroup> asAttributeGroups = List<AsAttributeGroup> asAttributeGroups =
attributeGroupReq.getCheckedAttributeIds().stream() attributeGroupReq.getCheckedAttributeIds().stream()
.map(attributeId -> AsAttributeGroup .map(attributeId -> AsAttributeGroup
.saveBuilder(attributeGroup.getId(), attributeId)) .saveBuilder(attributeGroup.getId(), attributeId))
.toList(); .toList();
asAttributeGroupService.removeBatchByIds(attributeGroup.getAsAttributeIds());
// asAttributeGroupService.deleteAsAttributeGroupByIds(attributeGroup.getAsAttributeIds());
asAttributeGroupService.saveBatch(asAttributeGroups); asAttributeGroupService.saveBatch(asAttributeGroups);
// asAttributeGroupService.saveOrUpdateBatch(asAttributeGroups);
// asAttributeGroups.forEach(asAttributeGroup -> asAttributeGroupService.updateAsAttributeGroup(asAttributeGroup)); // asAttributeGroups.forEach(asAttributeGroup -> asAttributeGroupService.updateAsAttributeGroup(asAttributeGroup));
return asAttributeGroups.size(); return asAttributeGroups.size();
} }

View File

@ -80,4 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
<delete id="deleteAsAttributeGroupByGroupId">
delete from as_attribute_group where group_id = #{id}
</delete>
</mapper> </mapper>