【改进】接口返回数据模型参数标识
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.corewing.app.common;
|
package com.corewing.app.common;
|
||||||
|
|
||||||
import com.corewing.app.util.I18nUtil;
|
import com.corewing.app.util.I18nUtil;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -16,21 +17,25 @@ public class Result<T> implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 状态码
|
* 状态码
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty("状态码")
|
||||||
private Integer code;
|
private Integer code;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回消息
|
* 返回消息
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty("消息内容")
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回数据
|
* 返回数据
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty("数据")
|
||||||
private T data;
|
private T data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 成功标识
|
* 成功标识
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty("是否成功")
|
||||||
private Boolean success;
|
private Boolean success;
|
||||||
|
|
||||||
public Result(Integer code, String message, T data, Boolean success) {
|
public Result(Integer code, String message, T data, Boolean success) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class BaseEntity {
|
|||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private LocalDateTime createTime;
|
private Date createTime;
|
||||||
/**
|
/**
|
||||||
* 创建人
|
* 创建人
|
||||||
*/
|
*/
|
||||||
@@ -23,7 +23,7 @@ public class BaseEntity {
|
|||||||
* 修改时间
|
* 修改时间
|
||||||
*/
|
*/
|
||||||
@TableField(fill = FieldFill.UPDATE)
|
@TableField(fill = FieldFill.UPDATE)
|
||||||
private LocalDateTime updateTime;
|
private Date updateTime;
|
||||||
/**
|
/**
|
||||||
* 修改人
|
* 修改人
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.corewing.app.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
|
import springfox.documentation.builders.PathSelectors;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.service.Contact;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableSwagger2WebMvc
|
||||||
|
public class Knife4jConfiguration {
|
||||||
|
|
||||||
|
@Bean(value = "defaultApi")
|
||||||
|
public Docket defaultApi() {
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.apiInfo(new ApiInfoBuilder()
|
||||||
|
.title("CoreWing APP APIs")
|
||||||
|
.description("CoreWing APP APIs")
|
||||||
|
.contact(new Contact("CoreWing", "www.corewing.com", "main@corewing.com"))
|
||||||
|
.version("1.0")
|
||||||
|
.build())
|
||||||
|
//分组名称
|
||||||
|
.groupName("1.1.0版本")
|
||||||
|
.select()
|
||||||
|
//这里指定Controller扫描包路径
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("com.corewing.app.modules.app"))
|
||||||
|
.paths(PathSelectors.any())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.corewing.app.common.base.CommonEntity;
|
import com.corewing.app.common.base.CommonEntity;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@@ -16,38 +17,53 @@ import java.util.List;
|
|||||||
public class AppModel extends CommonEntity {
|
public class AppModel extends CommonEntity {
|
||||||
|
|
||||||
@TableId
|
@TableId
|
||||||
|
@ApiModelProperty("模型id")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户id")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
@ApiModelProperty("模型标题")
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
|
@ApiModelProperty("模型描述")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
@ApiModelProperty("分类id")
|
||||||
private String categoryId;
|
private String categoryId;
|
||||||
|
|
||||||
|
@ApiModelProperty("模型封面(base64)")
|
||||||
private String coverImage;
|
private String coverImage;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否公开:(1公开,0私有)")
|
||||||
private String isPublic;
|
private String isPublic;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态:(1正常,0下架,2审核中)")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
@ApiModelProperty("下载次数")
|
||||||
private int downloadCount;
|
private int downloadCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("点赞次数")
|
||||||
private int likeCount;
|
private int likeCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("收藏次数")
|
||||||
private int favoriteCount;
|
private int favoriteCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
@ApiModelProperty("扩展参数")
|
||||||
private String extJson;
|
private String extJson;
|
||||||
|
|
||||||
|
@ApiModelProperty("暂未使用【点击详情接口获取文件模型】")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private List<AppModelFile> modelFile;
|
private List<AppModelFile> modelFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分类名称
|
* 分类名称
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty("分类名称")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String categoryTitle;
|
private String categoryTitle;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.corewing.app.common.base.CommonEntity;
|
import com.corewing.app.common.base.CommonEntity;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@@ -13,16 +14,22 @@ import lombok.EqualsAndHashCode;
|
|||||||
public class AppModelCategory extends CommonEntity {
|
public class AppModelCategory extends CommonEntity {
|
||||||
|
|
||||||
@TableId
|
@TableId
|
||||||
|
@ApiModelProperty("分类id")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty("分类名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("父级id")
|
||||||
private String parentId;
|
private String parentId;
|
||||||
|
|
||||||
|
@ApiModelProperty("排序码")
|
||||||
private int sortCode;
|
private int sortCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
@ApiModelProperty("扩展参数")
|
||||||
private String extJson;
|
private String extJson;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.corewing.app.common.base.CommonEntity;
|
import com.corewing.app.common.base.CommonEntity;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@@ -13,16 +14,22 @@ import lombok.EqualsAndHashCode;
|
|||||||
public class AppModelDownloadLog extends CommonEntity {
|
public class AppModelDownloadLog extends CommonEntity {
|
||||||
|
|
||||||
@TableId
|
@TableId
|
||||||
|
@ApiModelProperty("id")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户id")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
@ApiModelProperty("模型id")
|
||||||
private String modelId;
|
private String modelId;
|
||||||
|
|
||||||
|
@ApiModelProperty("下载ip")
|
||||||
private String ipAddress;
|
private String ipAddress;
|
||||||
|
|
||||||
|
@ApiModelProperty("下载备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
@ApiModelProperty("扩展参数")
|
||||||
private String extJson;
|
private String extJson;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.corewing.app.entity;
|
package com.corewing.app.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.corewing.app.common.base.CommonEntity;
|
import com.corewing.app.common.base.CommonEntity;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.corewing.app.entity;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.corewing.app.common.base.CommonEntity;
|
import com.corewing.app.common.base.CommonEntity;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@@ -12,19 +13,26 @@ import lombok.EqualsAndHashCode;
|
|||||||
public class AppModelFile extends CommonEntity {
|
public class AppModelFile extends CommonEntity {
|
||||||
|
|
||||||
@TableId
|
@TableId
|
||||||
|
@ApiModelProperty("id")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty("模型id")
|
||||||
private String modelId;
|
private String modelId;
|
||||||
|
|
||||||
|
@ApiModelProperty("文件名称")
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
|
||||||
|
@ApiModelProperty("文件类型")
|
||||||
private String fileType;
|
private String fileType;
|
||||||
|
|
||||||
|
@ApiModelProperty("文件大小")
|
||||||
private Long fileSize;
|
private Long fileSize;
|
||||||
|
|
||||||
|
@ApiModelProperty("文件地址")
|
||||||
private String fileUrl;
|
private String fileUrl;
|
||||||
|
|
||||||
private String sortCode;
|
@ApiModelProperty("文件排序")
|
||||||
|
private int sortCode;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,12 @@ import com.corewing.app.util.OSSUploadUtil;
|
|||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class AppModelServiceImpl extends ServiceImpl<AppModelMapper, AppModel> implements AppModelService {
|
public class AppModelServiceImpl extends ServiceImpl<AppModelMapper, AppModel> implements AppModelService {
|
||||||
@@ -146,10 +148,13 @@ public class AppModelServiceImpl extends ServiceImpl<AppModelMapper, AppModel> i
|
|||||||
appModel.setStatus("1");
|
appModel.setStatus("1");
|
||||||
appModel.setUserId(Long.valueOf(StpUtil.getLoginId().toString()));
|
appModel.setUserId(Long.valueOf(StpUtil.getLoginId().toString()));
|
||||||
this.save(appModel);
|
this.save(appModel);
|
||||||
|
// 获取文件列表
|
||||||
|
List<MultipartFile> files = modelCreateRequest.getFiles();
|
||||||
// 上传文件
|
// 上传文件
|
||||||
modelCreateRequest.getFiles().forEach(item -> {
|
IntStream.range(0, files.size()).forEach(index -> {
|
||||||
|
MultipartFile item = files.get(index); // 通过索引获取文件
|
||||||
try {
|
try {
|
||||||
|
// 这里可以直接使用 index 作为下标(从0开始)
|
||||||
String downloadUrl = OSSUploadUtil.uploadFile(item.getInputStream(), "customModel/" + item.getOriginalFilename());
|
String downloadUrl = OSSUploadUtil.uploadFile(item.getInputStream(), "customModel/" + item.getOriginalFilename());
|
||||||
AppModelFile modelFile = new AppModelFile();
|
AppModelFile modelFile = new AppModelFile();
|
||||||
modelFile.setFileName(item.getOriginalFilename());
|
modelFile.setFileName(item.getOriginalFilename());
|
||||||
@@ -157,10 +162,11 @@ public class AppModelServiceImpl extends ServiceImpl<AppModelMapper, AppModel> i
|
|||||||
modelFile.setFileSize(item.getSize());
|
modelFile.setFileSize(item.getSize());
|
||||||
modelFile.setFileType(item.getContentType());
|
modelFile.setFileType(item.getContentType());
|
||||||
modelFile.setModelId(appModel.getId());
|
modelFile.setModelId(appModel.getId());
|
||||||
|
modelFile.setSortCode(index);
|
||||||
modelFileService.save(modelFile);
|
modelFileService.save(modelFile);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("创建模型失败");
|
throw new RuntimeException("创建模型失败,文件下标:" + index + ",文件名:" + item.getOriginalFilename());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -112,31 +112,3 @@ knife4j.setting.language=zh_cn
|
|||||||
knife4j.basic.enable=true
|
knife4j.basic.enable=true
|
||||||
knife4j.basic.username=corewing
|
knife4j.basic.username=corewing
|
||||||
knife4j.basic.password=Aaa123..
|
knife4j.basic.password=Aaa123..
|
||||||
# ===================== Knife4j OpenAPI 全局文档配置 =====================
|
|
||||||
# 文档标题
|
|
||||||
knife4j.openapi.title=CoreWing APP API
|
|
||||||
# 文档描述(支持Markdown,换行用\n,特殊符号保留)
|
|
||||||
|
|
||||||
knife4j.openapi.description=
|
|
||||||
# 作者邮箱
|
|
||||||
knife4j.openapi.email=
|
|
||||||
# 联系人
|
|
||||||
knife4j.openapi.concat=
|
|
||||||
# 文档官网地址
|
|
||||||
knife4j.openapi.url=
|
|
||||||
# 文档版本
|
|
||||||
knife4j.openapi.version=v1.0
|
|
||||||
# 许可证
|
|
||||||
knife4j.openapi.license=
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ===================== Knife4j 分组配置 =====================
|
|
||||||
# 分组名称
|
|
||||||
knife4j.openapi.group.test1.group-name=APP接口
|
|
||||||
# 接口扫描规则:package(按包扫描)、path(按路径匹配)、api(按注解匹配)
|
|
||||||
knife4j.openapi.group.test1.api-rule=package
|
|
||||||
# 按包扫描的资源(数组,用[索引]标识多个包)
|
|
||||||
knife4j.openapi.group.test1.api-rule-resources[0]=com.corewing.app.modules.app
|
|
||||||
# 若有多个包,继续添加索引
|
|
||||||
# knife4j.openapi.group.test1.api-rule-resources[1]=com.knife4j.demo.new4
|
|
||||||
|
|||||||
Reference in New Issue
Block a user