Commit 8522c7f6 authored by xiaoyao's avatar xiaoyao

fix

parent d9266b2d
......@@ -55,6 +55,60 @@ public class CategoryVo implements Serializable {
*/
private String publisher;
/**
* 王朝
*/
private String dynasty;
/**
* 品种代码
*/
private String serialNo;
/**
* 分类
*/
private String categoryPath;
/**
* 扩展名称
*/
private String extendName;
/**
* 直径 (mm * 100)
*/
private Integer diameter;
/**
* 厚度 (mm * 100)
*/
private Integer thickness;
/**
*重量 (g * 100)
*/
private Integer weight;
public Boolean getLeaf() {
return isLeaf;
}
public void setLeaf(Boolean leaf) {
isLeaf = leaf;
}
/**
* 是否叶子节点
*/
private Boolean isLeaf;
/**
* 当前所有人(传承链这块还要重新设计,暂时只存当前拥有人)
*/
private String owner;
/**
* 面值
*/
......@@ -70,6 +124,11 @@ public class CategoryVo implements Serializable {
*/
private String material;
/**
* 详细图片
*/
private String images;
/**
* 子类目
......@@ -85,23 +144,23 @@ public class CategoryVo implements Serializable {
this.pid = category.getPid();
this.desc = category.getDesc();
this.level = category.getLevel();
this.isLeaf = category.getIsLeaf();
if (!StringUtils.isEmpty(category.getExtra())) {
Map<String, Object> extraData = (Map<String, Object>) JSONUtils.parse(category.getExtra());
if (null != extraData.get("publishTime")) {
this.publishTime = extraData.get("publishTime").toString();
}
if (null != extraData.get("publisher")) {
this.publisher = extraData.get("publisher").toString();
}
if (null != extraData.get("exiQuantity")) {
this.exiQuantity = extraData.get("exiQuantity").toString();
}
if (null != extraData.get("parValue")) {
this.parValue = extraData.get("parValue").toString();
}
if (null != extraData.get("material")) {
this.material = extraData.get("material").toString();
}
this.publishTime = extractExtra(extraData, "publishTime");
this.publisher = extractExtra(extraData, "publisher");
this.exiQuantity = extractExtra(extraData, "exiQuantity");
this.parValue = extractExtra(extraData, "parValue");
this.material = extractExtra(extraData, "material");
this.images = extractExtra(extraData, "images");
this.dynasty = extractExtra(extraData, "dynasty");
this.diameter = extractExtraInt(extraData, "diameter");
this.thickness = extractExtraInt(extraData, "thickness");
this.weight = extractExtraInt(extraData, "weight");
this.owner = extractExtra(extraData, "owner");
this.extendName = extractExtra(extraData, "extendName");
this.serialNo = extractExtra(extraData, "serialNo");
}
}
......@@ -201,6 +260,92 @@ public class CategoryVo implements Serializable {
this.material = material;
}
public String getImages() {
return images;
}
public void setImages(String images) {
this.images = images;
}
public String getDynasty() {
return dynasty;
}
public void setDynasty(String dynasty) {
this.dynasty = dynasty;
}
public String getSerialNo() {
return serialNo;
}
public void setSerialNo(String serialNo) {
this.serialNo = serialNo;
}
public String getCategoryPath() {
return categoryPath;
}
public void setCategoryPath(String categoryPath) {
this.categoryPath = categoryPath;
}
public String getExtendName() {
return extendName;
}
public void setExtendName(String extendName) {
this.extendName = extendName;
}
public Integer getDiameter() {
return diameter;
}
public void setDiameter(Integer diameter) {
this.diameter = diameter;
}
public Integer getThickness() {
return thickness;
}
public void setThickness(Integer thickness) {
this.thickness = thickness;
}
public Integer getWeight() {
return weight;
}
public void setWeight(Integer weight) {
this.weight = weight;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
private String extractExtra(Map<String, Object> extraData, String key) {
if (null != extraData.get(key)) {
return extraData.get(key).toString();
}
return "";
}
private Integer extractExtraInt(Map<String, Object> extraData, String key) {
if (null != extraData.get(key)) {
return Integer.valueOf(extraData.get(key).toString());
}
return null;
}
public Category toDo() {
Category category = new Category();
category.setId(this.id);
......@@ -220,6 +365,14 @@ public class CategoryVo implements Serializable {
extraObj.put("parValue", this.parValue);
extraObj.put("exiQuantity", this.exiQuantity);
extraObj.put("material", this.material);
extraObj.put("images", this.images);
extraObj.put("owner", this.owner);
extraObj.put("diameter", this.diameter);
extraObj.put("dynasty", this.dynasty);
extraObj.put("extendName", this.extendName);
extraObj.put("serialNo", this.serialNo);
extraObj.put("thickness", this.thickness);
extraObj.put("weight", this.weight);
return JSONUtils.toJSONString(extraObj);
}
}
......@@ -97,6 +97,23 @@ public class AdminCategoryController {
return ResponseUtil.ok(data);
}
@RequiresPermissions("admin:category:tree")
@RequiresPermissionsDesc(menu = { "商场管理", "类目管理" }, button = "查询")
@GetMapping("/getSubCategory")
public Object getSubCategory(@NotNull Integer id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 查询根据类目ID查询子类目");
List<CategoryVo> categoryVoList = new ArrayList<>();
List<Category> categoryList = categoryService.queryByPid(id);
for (Category c : categoryList) {
categoryVoList.add(new CategoryVo(c));
}
Map<String, Object> data = new HashMap<>();
data.put("categoryList", categoryVoList);
data.put("categoryPath", categoryService.getCategoryPath(id));
logger.info("【请求结束】查询根据类目ID查询子类目 : {}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
@RequiresPermissions("admin:category:create")
......
package com.wwdz.ch.core.storage;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.util.stream.Stream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.model.ObjectMetadata;
import com.qcloud.cos.model.PutObjectRequest;
import com.qcloud.cos.model.PutObjectResult;
import com.qcloud.cos.region.Region;
/**
* 腾讯对象存储服务
*/
public class TencentStorage implements Storage {
private final Log logger = LogFactory.getLog(TencentStorage.class);
private String secretId;
private String secretKey;
private String region;
private String bucketName;
private COSClient cosClient;
public String getSecretId() {
return secretId;
}
public void setSecretId(String secretId) {
this.secretId = secretId;
}
public String getSecretKey() {
return secretKey;
}
public void setSecretKey(String secretKey) {
this.secretKey = secretKey;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getBucketName() {
return bucketName;
}
public void setBucketName(String bucketName) {
this.bucketName = bucketName;
}
private COSClient getCOSClient() {
if (cosClient == null) {
// 1 初始化用户身份信息(secretId, secretKey)
COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
// 2 设置bucket的区域, COS地域的简称请参照
// https://cloud.tencent.com/document/product/436/6224
ClientConfig clientConfig = new ClientConfig(new Region(region));
cosClient = new COSClient(cred, clientConfig);
}
return cosClient;
}
private String getBaseUrl() {
return "https://" + bucketName + ".cos-website." + region + ".myqcloud.com/";
}
@Override
public void store(InputStream inputStream, long contentLength, String contentType, String keyName) {
try {
// 简单文件上传, 最大支持 5 GB, 适用于小文件上传, 建议 20M以下的文件使用该接口
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setContentLength(contentLength);
objectMetadata.setContentType(contentType);
// 对象键(Key)是对象在存储桶中的唯一标识。例如,在对象的访问域名
// `bucket1-1250000000.cos.ap-guangzhou.myqcloud.com/doc1/pic1.jpg` 中,对象键为
// doc1/pic1.jpg, 详情参考
// [对象键](https://cloud.tencent.com/document/product/436/13324)
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, keyName, inputStream, objectMetadata);
PutObjectResult putObjectResult = getCOSClient().putObject(putObjectRequest);
logger.info("腾讯云存储结果:" + putObjectResult.getRequestId());
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Override
public Stream<Path> loadAll() {
return null;
}
@Override
public Path load(String keyName) {
return null;
}
@Override
public Resource loadAsResource(String keyName) {
try {
URL url = new URL(getBaseUrl() + keyName);
Resource resource = new UrlResource(url);
if (resource.exists() || resource.isReadable()) {
return resource;
} else {
return null;
}
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
}
}
@Override
public void delete(String keyName) {
try {
getCOSClient().deleteObject(bucketName, keyName);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public String generateUrl(String keyName) {
return getBaseUrl() + keyName;
}
}
......@@ -57,17 +57,6 @@ public class StorageAutoConfiguration {
return aliyunStorage;
}
@Bean
public TencentStorage tencentStorage() {
TencentStorage tencentStorage = new TencentStorage();
StorageProperties.Tencent tencent = this.properties.getTencent();
tencentStorage.setSecretId(tencent.getSecretId());
tencentStorage.setSecretKey(tencent.getSecretKey());
tencentStorage.setBucketName(tencent.getBucketName());
tencentStorage.setRegion(tencent.getRegion());
return tencentStorage;
}
@Bean
public QiniuStorage qiniuStorage() {
QiniuStorage qiniuStorage = new QiniuStorage();
......
......@@ -8,10 +8,13 @@ import com.wwdz.ch.db.domain.CategoryExample;
import com.wwdz.ch.db.domain.DtsCategory;
import com.wwdz.ch.db.domain.DtsCategoryExample;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Service
......@@ -86,4 +89,18 @@ public class CategoryService {
return categoryMapper.getMaxCagtegoryLevel();
}
public List<String> getCategoryPath(Integer id) {
if (0 == id) {
return Collections.EMPTY_LIST;
}
Category category = categoryMapper.selectByPrimaryKey(id);
List<String> pathList = new ArrayList<>();
while (null != category && category.getId() != 0) {
pathList.add(category.getName());
category = categoryMapper.selectByPrimaryKey(category.getPid());
}
Collections.reverse(pathList);
return pathList;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment