Compare commits
3 Commits
23511407ab
...
b93e064edc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b93e064edc | ||
|
|
aefb8d0c12 | ||
|
|
2955df71e9 |
@@ -1,6 +1,7 @@
|
||||
package com.corewing.app.common;
|
||||
|
||||
import com.corewing.app.util.I18nUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -16,21 +17,25 @@ public class Result<T> implements Serializable {
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
@ApiModelProperty("状态码")
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* 返回消息
|
||||
*/
|
||||
@ApiModelProperty("消息内容")
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
*/
|
||||
@ApiModelProperty("数据")
|
||||
private T data;
|
||||
|
||||
/**
|
||||
* 成功标识
|
||||
*/
|
||||
@ApiModelProperty("是否成功")
|
||||
private Boolean success;
|
||||
|
||||
public Result(Integer code, String message, T data, Boolean success) {
|
||||
|
||||
@@ -14,7 +14,7 @@ public class BaseEntity {
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
private Date createTime;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@@ -23,7 +23,7 @@ public class BaseEntity {
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -21,6 +22,7 @@ public class CommonEntity implements Serializable {
|
||||
private String deleteFlag;
|
||||
|
||||
/** 创建时间 */
|
||||
@ApiModelProperty("创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
@@ -33,6 +35,7 @@ public class CommonEntity implements Serializable {
|
||||
private String createUserName;
|
||||
|
||||
/** 更新时间 */
|
||||
@ApiModelProperty("更新时间")
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,6 +51,8 @@ public class SaTokenConfig implements WebMvcConfigurer {
|
||||
.excludePathPatterns("/error", "/error/**")
|
||||
// 排除校验更新接口
|
||||
.excludePathPatterns("app_version", "/app_version/checkUpdate")
|
||||
// 排除模型接口
|
||||
.excludePathPatterns("/model/page", "/model/list", "/model/detail/**", "/model/category/**")
|
||||
// 排除咨询接口
|
||||
.excludePathPatterns("/contactMsg", "/contactMsg/**");
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.corewing.app.common.base.CommonEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -16,38 +17,53 @@ import java.util.List;
|
||||
public class AppModel extends CommonEntity {
|
||||
|
||||
@TableId
|
||||
@ApiModelProperty("模型id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("模型标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty("模型描述")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty("分类id")
|
||||
private String categoryId;
|
||||
|
||||
@ApiModelProperty("模型封面(base64)")
|
||||
private String coverImage;
|
||||
|
||||
@ApiModelProperty("是否公开:(1公开,0私有)")
|
||||
private String isPublic;
|
||||
|
||||
@ApiModelProperty("状态:(1正常,0下架,2审核中)")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty("下载次数")
|
||||
private int downloadCount;
|
||||
|
||||
@ApiModelProperty("点赞次数")
|
||||
private int likeCount;
|
||||
|
||||
@ApiModelProperty("收藏次数")
|
||||
private int favoriteCount;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("扩展参数")
|
||||
private String extJson;
|
||||
|
||||
@ApiModelProperty("暂未使用【点击详情接口获取文件模型】")
|
||||
@TableField(exist = false)
|
||||
private List<AppModelFile> modelFile;
|
||||
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
@ApiModelProperty("分类名称")
|
||||
@TableField(exist = false)
|
||||
private String categoryTitle;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.corewing.app.common.base.CommonEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -13,16 +14,22 @@ import lombok.EqualsAndHashCode;
|
||||
public class AppModelCategory extends CommonEntity {
|
||||
|
||||
@TableId
|
||||
@ApiModelProperty("分类id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("分类名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("父级id")
|
||||
private String parentId;
|
||||
|
||||
@ApiModelProperty("排序码")
|
||||
private int sortCode;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("扩展参数")
|
||||
private String extJson;
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.corewing.app.common.base.CommonEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -13,16 +14,22 @@ import lombok.EqualsAndHashCode;
|
||||
public class AppModelDownloadLog extends CommonEntity {
|
||||
|
||||
@TableId
|
||||
@ApiModelProperty("id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("模型id")
|
||||
private String modelId;
|
||||
|
||||
@ApiModelProperty("下载ip")
|
||||
private String ipAddress;
|
||||
|
||||
@ApiModelProperty("下载备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("扩展参数")
|
||||
private String extJson;
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.corewing.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
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.TableName;
|
||||
import com.corewing.app.common.base.CommonEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -12,19 +13,26 @@ import lombok.EqualsAndHashCode;
|
||||
public class AppModelFile extends CommonEntity {
|
||||
|
||||
@TableId
|
||||
@ApiModelProperty("id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("模型id")
|
||||
private String modelId;
|
||||
|
||||
@ApiModelProperty("文件名称")
|
||||
private String fileName;
|
||||
|
||||
@ApiModelProperty("文件类型")
|
||||
private String fileType;
|
||||
|
||||
@ApiModelProperty("文件大小")
|
||||
private Long fileSize;
|
||||
|
||||
@ApiModelProperty("文件地址")
|
||||
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.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@Service
|
||||
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.setUserId(Long.valueOf(StpUtil.getLoginId().toString()));
|
||||
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 {
|
||||
// 这里可以直接使用 index 作为下标(从0开始)
|
||||
String downloadUrl = OSSUploadUtil.uploadFile(item.getInputStream(), "customModel/" + item.getOriginalFilename());
|
||||
AppModelFile modelFile = new AppModelFile();
|
||||
modelFile.setFileName(item.getOriginalFilename());
|
||||
@@ -157,10 +162,11 @@ public class AppModelServiceImpl extends ServiceImpl<AppModelMapper, AppModel> i
|
||||
modelFile.setFileSize(item.getSize());
|
||||
modelFile.setFileType(item.getContentType());
|
||||
modelFile.setModelId(appModel.getId());
|
||||
modelFile.setSortCode(index);
|
||||
modelFileService.save(modelFile);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("创建模型失败");
|
||||
throw new RuntimeException("创建模型失败,文件下标:" + index + ",文件名:" + item.getOriginalFilename());
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
package com.corewing.app.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
|
||||
public class DateUtils {
|
||||
|
||||
// 格式化LocalDateTime为字符串
|
||||
public static String format(LocalDateTime time, String pattern) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
return time.format(formatter);
|
||||
public static String format(Date time, String pattern) {
|
||||
if (time == null || pattern == null || pattern.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
// 创建SimpleDateFormat实例
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
|
||||
// 格式化日期为字符串
|
||||
return sdf.format(time);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -112,31 +112,3 @@ knife4j.setting.language=zh_cn
|
||||
knife4j.basic.enable=true
|
||||
knife4j.basic.username=corewing
|
||||
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