Compare commits

...

3 Commits

Author SHA1 Message Date
MichaelWin
b93e064edc 【改进】创建与修改时间 2025-12-26 23:14:08 +08:00
MichaelWin
aefb8d0c12 【改进】接口返回数据模型参数标识 2025-12-26 23:13:28 +08:00
MichaelWin
2955df71e9 【改进】排除模型无需登录接口 2025-12-26 23:12:30 +08:00
13 changed files with 105 additions and 38 deletions

View File

@@ -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) {

View File

@@ -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;
/** /**
* 修改人 * 修改人
*/ */

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -21,6 +22,7 @@ public class CommonEntity implements Serializable {
private String deleteFlag; private String deleteFlag;
/** 创建时间 */ /** 创建时间 */
@ApiModelProperty("创建时间")
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Date createTime; private Date createTime;
@@ -33,6 +35,7 @@ public class CommonEntity implements Serializable {
private String createUserName; private String createUserName;
/** 更新时间 */ /** 更新时间 */
@ApiModelProperty("更新时间")
@TableField(fill = FieldFill.UPDATE) @TableField(fill = FieldFill.UPDATE)
private Date updateTime; private Date updateTime;

View File

@@ -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();
}
}

View File

@@ -51,6 +51,8 @@ public class SaTokenConfig implements WebMvcConfigurer {
.excludePathPatterns("/error", "/error/**") .excludePathPatterns("/error", "/error/**")
// 排除校验更新接口 // 排除校验更新接口
.excludePathPatterns("app_version", "/app_version/checkUpdate") .excludePathPatterns("app_version", "/app_version/checkUpdate")
// 排除模型接口
.excludePathPatterns("/model/page", "/model/list", "/model/detail/**", "/model/category/**")
// 排除咨询接口 // 排除咨询接口
.excludePathPatterns("/contactMsg", "/contactMsg/**"); .excludePathPatterns("/contactMsg", "/contactMsg/**");
} }

View File

@@ -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;

View File

@@ -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;
} }

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
} }

View File

@@ -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;

View File

@@ -1,14 +1,21 @@
package com.corewing.app.util; package com.corewing.app.util;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date;
public class DateUtils { public class DateUtils {
// 格式化LocalDateTime为字符串 // 格式化LocalDateTime为字符串
public static String format(LocalDateTime time, String pattern) { public static String format(Date time, String pattern) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern); if (time == null || pattern == null || pattern.isEmpty()) {
return time.format(formatter); return "";
}
// 创建SimpleDateFormat实例
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
// 格式化日期为字符串
return sdf.format(time);
} }
} }

View File

@@ -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