diff --git a/pom.xml b/pom.xml index c1ce87f..dbffe41 100644 --- a/pom.xml +++ b/pom.xml @@ -102,6 +102,12 @@ lombok true + + + com.aliyun.oss + aliyun-sdk-oss + 2.5.0 + diff --git a/src/main/java/com/quinn/controller/AboutController.java b/src/main/java/com/quinn/controller/AboutController.java index aa0ee6f..3aa0f5a 100644 --- a/src/main/java/com/quinn/controller/AboutController.java +++ b/src/main/java/com/quinn/controller/AboutController.java @@ -4,7 +4,6 @@ package com.quinn.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.quinn.pojo.About; -import com.quinn.pojo.Say; import com.quinn.service.AboutService; import com.quinn.utils.QuinnUtils; import org.springframework.stereotype.Controller; diff --git a/src/main/java/com/quinn/controller/DownloadController.java b/src/main/java/com/quinn/controller/DownloadController.java index 3a06c88..b8b6460 100644 --- a/src/main/java/com/quinn/controller/DownloadController.java +++ b/src/main/java/com/quinn/controller/DownloadController.java @@ -3,11 +3,13 @@ package com.quinn.controller; import com.quinn.mapper.DownloadMapper; import com.quinn.pojo.Download; +import com.quinn.service.DownloadService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import javax.annotation.Resource; import java.util.List; /** @@ -21,12 +23,12 @@ import java.util.List; @Controller public class DownloadController { - @Autowired - DownloadMapper downloadMapper; + @Resource + DownloadService downloadService; @GetMapping({"/download"}) public String download(Model model){ - List downloadList = downloadMapper.selectList(null); + List downloadList = downloadService.list(null); model.addAttribute("downloadList",downloadList); return "page/download"; } diff --git a/src/main/java/com/quinn/controller/LoginController.java b/src/main/java/com/quinn/controller/LoginController.java index 45de053..56fd57c 100644 --- a/src/main/java/com/quinn/controller/LoginController.java +++ b/src/main/java/com/quinn/controller/LoginController.java @@ -31,11 +31,6 @@ public class LoginController { return "index"; } - @GetMapping({"/auto"}) - public String auto(){ - return "index"; - } - @GetMapping("/toLogin") public String toLogin(){ return "login"; diff --git a/src/main/java/com/quinn/controller/SayController.java b/src/main/java/com/quinn/controller/SayController.java deleted file mode 100644 index 438c40b..0000000 --- a/src/main/java/com/quinn/controller/SayController.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.quinn.controller; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.quinn.pojo.Say; -import com.quinn.service.SayService; -import com.quinn.utils.QuinnUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; - -import java.util.List; - -@Controller -public class SayController { - - @Autowired - SayService sayService; - - @GetMapping("/say") - public String userIndexBlog(Model model){ - Page pageParam = new Page<>(1, 50); - sayService.page(pageParam,new QueryWrapper().orderByDesc("gmt_create")); - // 结果 - List sayList = pageParam.getRecords(); - model.addAttribute("sayList",sayList); - model.addAttribute("pageParam",pageParam); - - return "page/say"; - } - - @PostMapping("/say/{role}") - public String saveSay(@PathVariable("role") int role, Say say){ - // 防止请求提交 - if (role!=1){ - return "redirect:/say"; - } - - say.setId(QuinnUtils.getUuid()); - say.setGmtCreate(QuinnUtils.getTime()); - // 结果 - sayService.save(say); - return "redirect:/say"; - } - - - - -} - diff --git a/src/main/java/com/quinn/controller/SourceCategoryController.java b/src/main/java/com/quinn/controller/SourceCategoryController.java new file mode 100644 index 0000000..9d0571f --- /dev/null +++ b/src/main/java/com/quinn/controller/SourceCategoryController.java @@ -0,0 +1,21 @@ +package com.quinn.controller; + + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * 前端控制器 + *

+ * + * @author limqsh + * @since 2022-05-03 + */ +@Controller +public class SourceCategoryController { + +} + diff --git a/src/main/java/com/quinn/controller/SourceCommentController.java b/src/main/java/com/quinn/controller/SourceCommentController.java new file mode 100644 index 0000000..c5a606a --- /dev/null +++ b/src/main/java/com/quinn/controller/SourceCommentController.java @@ -0,0 +1,17 @@ +package com.quinn.controller; + + +import org.springframework.stereotype.Controller; +/** + *

+ * 前端控制器 + *

+ * + * @author limqsh + * @since 2022-05-03 + */ +@Controller +public class SourceCommentController { + +} + diff --git a/src/main/java/com/quinn/controller/SourceController.java b/src/main/java/com/quinn/controller/SourceController.java new file mode 100644 index 0000000..3c82256 --- /dev/null +++ b/src/main/java/com/quinn/controller/SourceController.java @@ -0,0 +1,83 @@ +package com.quinn.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.quinn.pojo.*; +import com.quinn.service.SourceCategoryService; +import com.quinn.service.SourceCommentService; +import com.quinn.service.SourceService; +import com.quinn.utils.UUIDGenerator; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + +/** + *

+ * 前端控制器 + *

+ * + * @author limqsh + * @since 2022-05-03 + */ +@Controller +public class SourceController { + + @Resource + SourceService sourceService; + + @Resource + SourceCategoryService sourceCategoryService; + + @Resource + SourceCommentService sourceCommentService; + + // 列表展示 + @GetMapping("/source") + public String blogList(@RequestParam String name,@RequestParam int category,Model model){ + System.out.println(name + category); + Page pageParam = new Page<>(1, 10); + QueryWrapper sourceQuery = new QueryWrapper<>(); + sourceQuery.orderByDesc("gmt_create"); + sourceService.page(pageParam,sourceQuery); + // 结果 + List sourceList = pageParam.getRecords(); + model.addAttribute("sourceList",sourceList); + model.addAttribute("pageParam",pageParam); + + // 分类信息 + List categoryList = sourceCategoryService.list(null); + model.addAttribute("categoryList",categoryList); + + return "source/list"; + } + + // 查看文件详情 + @GetMapping("/source/view/{sid}") + public String read(@PathVariable("sid") String sid, Model model){ + Source source = sourceService.getOne(new QueryWrapper().eq("id", sid)); + source.setSourceLink("no network link"); + model.addAttribute("source",source); + List commentList = sourceCommentService.list(new QueryWrapper().eq("topic_id", sid).orderByDesc("gmt_create")); + model.addAttribute("commentList",commentList); + return "source/view"; + } + + // 下载文件 + @GetMapping("/source/download/{sid}") + public void read(HttpServletResponse response, @PathVariable("sid") String sid) throws IOException { + //通知浏览器以附件形式下载 + response.setHeader("Content-Disposition", + "attachment;filename=" + UUIDGenerator.randomUUID()); + this.sourceService.downloadSource(response.getOutputStream(),sid); + } + +} + diff --git a/src/main/java/com/quinn/generator/CodeGenerator.java b/src/main/java/com/quinn/generator/CodeGenerator.java index 5027c40..8b68929 100644 --- a/src/main/java/com/quinn/generator/CodeGenerator.java +++ b/src/main/java/com/quinn/generator/CodeGenerator.java @@ -22,7 +22,7 @@ public class CodeGenerator { gc.setOutputDir(projectPath + "/src/main/java"); gc.setAuthor("limqsh"); gc.setOpen(false); //生成后是否打开资源管理器 - gc.setFileOverride(false); //重新生成时文件是否覆盖 + gc.setFileOverride(true); //重新生成时文件是否覆盖 gc.setServiceName("%sService"); //去掉Service接口的首字母I gc.setIdType(IdType.ID_WORKER_STR); //主键策略 gc.setDateType(DateType.ONLY_DATE);//定义生成的实体类中日期类型 @@ -51,7 +51,7 @@ public class CodeGenerator { // 5、策略配置 StrategyConfig strategy = new StrategyConfig(); - strategy.setInclude("qn_about");//设置要映射的表名 + strategy.setInclude("qn_source_comment");//设置要映射的表名 strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略 strategy.setTablePrefix("qn_");//设置表前缀不生成 diff --git a/src/main/java/com/quinn/mapper/SourceCategoryMapper.java b/src/main/java/com/quinn/mapper/SourceCategoryMapper.java new file mode 100644 index 0000000..45b1153 --- /dev/null +++ b/src/main/java/com/quinn/mapper/SourceCategoryMapper.java @@ -0,0 +1,16 @@ +package com.quinn.mapper; + +import com.quinn.pojo.SourceCategory; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author limqsh + * @since 2022-05-03 + */ +public interface SourceCategoryMapper extends BaseMapper { + +} diff --git a/src/main/java/com/quinn/mapper/SourceCommentMapper.java b/src/main/java/com/quinn/mapper/SourceCommentMapper.java new file mode 100644 index 0000000..ab19683 --- /dev/null +++ b/src/main/java/com/quinn/mapper/SourceCommentMapper.java @@ -0,0 +1,16 @@ +package com.quinn.mapper; + +import com.quinn.pojo.SourceComment; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author limqsh + * @since 2022-05-03 + */ +public interface SourceCommentMapper extends BaseMapper { + +} diff --git a/src/main/java/com/quinn/mapper/SayMapper.java b/src/main/java/com/quinn/mapper/SourceMapper.java similarity index 57% rename from src/main/java/com/quinn/mapper/SayMapper.java rename to src/main/java/com/quinn/mapper/SourceMapper.java index adbf7a2..e1880d0 100644 --- a/src/main/java/com/quinn/mapper/SayMapper.java +++ b/src/main/java/com/quinn/mapper/SourceMapper.java @@ -1,6 +1,6 @@ package com.quinn.mapper; -import com.quinn.pojo.Say; +import com.quinn.pojo.Source; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** @@ -9,8 +9,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; *

* * @author limqsh - * @since 2020-07-01 + * @since 2022-05-03 */ -public interface SayMapper extends BaseMapper { +public interface SourceMapper extends BaseMapper { } diff --git a/src/main/java/com/quinn/mapper/xml/SourceCategoryMapper.xml b/src/main/java/com/quinn/mapper/xml/SourceCategoryMapper.xml new file mode 100644 index 0000000..1ec1e31 --- /dev/null +++ b/src/main/java/com/quinn/mapper/xml/SourceCategoryMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/java/com/quinn/mapper/xml/SourceCommentMapper.xml b/src/main/java/com/quinn/mapper/xml/SourceCommentMapper.xml new file mode 100644 index 0000000..79168df --- /dev/null +++ b/src/main/java/com/quinn/mapper/xml/SourceCommentMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/java/com/quinn/mapper/xml/SourceMapper.xml b/src/main/java/com/quinn/mapper/xml/SourceMapper.xml new file mode 100644 index 0000000..4baf27b --- /dev/null +++ b/src/main/java/com/quinn/mapper/xml/SourceMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/java/com/quinn/pojo/Source.java b/src/main/java/com/quinn/pojo/Source.java new file mode 100644 index 0000000..a867e34 --- /dev/null +++ b/src/main/java/com/quinn/pojo/Source.java @@ -0,0 +1,68 @@ +package com.quinn.pojo; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author limqsh + * @since 2022-05-03 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("qn_source") +@ApiModel(value="Source对象", description="") +public class Source implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "资源名") + private String sourceName; + + @ApiModelProperty(value = "资源内容") + private String sourceContent; + + @ApiModelProperty(value = "关键字1") + private String keyWord1; + + @ApiModelProperty(value = "关键字2") + private String keyWord2; + + @ApiModelProperty(value = "关键字3") + private String keyWord3; + + @ApiModelProperty(value = "资源类型") + private String sourceType; + + @ApiModelProperty(value = "资源链接") + private String sourceLink; + + @ApiModelProperty(value = "类别ID") + private Integer categoryId; + + @ApiModelProperty(value = "类别名") + private String categoryName; + + @ApiModelProperty(value = "创建时间") + private Date gmtCreate; + + @ApiModelProperty(value = "修改时间") + private Date gmtUpdate; + + +} diff --git a/src/main/java/com/quinn/pojo/Say.java b/src/main/java/com/quinn/pojo/SourceCategory.java similarity index 53% rename from src/main/java/com/quinn/pojo/Say.java rename to src/main/java/com/quinn/pojo/SourceCategory.java index 03e7730..2c625c8 100644 --- a/src/main/java/com/quinn/pojo/Say.java +++ b/src/main/java/com/quinn/pojo/SourceCategory.java @@ -2,7 +2,6 @@ package com.quinn.pojo; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.IdType; -import java.util.Date; import com.baomidou.mybatisplus.annotation.TableId; import java.io.Serializable; import io.swagger.annotations.ApiModel; @@ -13,33 +12,27 @@ import lombok.experimental.Accessors; /** *

- * + * *

* * @author limqsh - * @since 2020-07-01 + * @since 2022-05-03 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) -@TableName("qn_say") -@ApiModel(value="Say对象", description="") -public class Say implements Serializable { +@TableName("qn_source_category") +@ApiModel(value="SourceCategory对象", description="") +public class SourceCategory implements Serializable { private static final long serialVersionUID = 1L; - @ApiModelProperty(value = "唯一id") - @TableId(value = "id", type = IdType.ID_WORKER_STR) - private String id; + @ApiModelProperty(value = "自增id") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; - @ApiModelProperty(value = "标题") - private String title; - - @ApiModelProperty(value = "内容") - private String content; - - @ApiModelProperty(value = "时间") - private Date gmtCreate; + @ApiModelProperty(value = "博客分类") + private String category; } diff --git a/src/main/java/com/quinn/pojo/SourceComment.java b/src/main/java/com/quinn/pojo/SourceComment.java new file mode 100644 index 0000000..b04cc88 --- /dev/null +++ b/src/main/java/com/quinn/pojo/SourceComment.java @@ -0,0 +1,60 @@ +package com.quinn.pojo; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author limqsh + * @since 2022-05-03 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("qn_source_comment") +@ApiModel(value="SourceComment对象", description="") +public class SourceComment implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "自增id") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "评论唯一id") + private String commentId; + + @ApiModelProperty(value = "1博客 2问答") + private Integer topicCategory; + + @ApiModelProperty(value = "评论主题id") + private String topicId; + + @ApiModelProperty(value = "评论者id") + private String userId; + + @ApiModelProperty(value = "评论者昵称") + private String userName; + + @ApiModelProperty(value = "评论者头像") + private String userAvatar; + + @ApiModelProperty(value = "评论内容") + private String content; + + @ApiModelProperty(value = "评论创建时间") + private Date gmtCreate; + + +} diff --git a/src/main/java/com/quinn/service/SourceCategoryService.java b/src/main/java/com/quinn/service/SourceCategoryService.java new file mode 100644 index 0000000..53b5e85 --- /dev/null +++ b/src/main/java/com/quinn/service/SourceCategoryService.java @@ -0,0 +1,16 @@ +package com.quinn.service; + +import com.quinn.pojo.SourceCategory; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author limqsh + * @since 2022-05-03 + */ +public interface SourceCategoryService extends IService { + +} diff --git a/src/main/java/com/quinn/service/SayService.java b/src/main/java/com/quinn/service/SourceCommentService.java similarity index 53% rename from src/main/java/com/quinn/service/SayService.java rename to src/main/java/com/quinn/service/SourceCommentService.java index c04e2b2..3eafd40 100644 --- a/src/main/java/com/quinn/service/SayService.java +++ b/src/main/java/com/quinn/service/SourceCommentService.java @@ -1,6 +1,6 @@ package com.quinn.service; -import com.quinn.pojo.Say; +import com.quinn.pojo.SourceComment; import com.baomidou.mybatisplus.extension.service.IService; /** @@ -9,8 +9,8 @@ import com.baomidou.mybatisplus.extension.service.IService; *

* * @author limqsh - * @since 2020-07-01 + * @since 2022-05-03 */ -public interface SayService extends IService { +public interface SourceCommentService extends IService { } diff --git a/src/main/java/com/quinn/service/SourceService.java b/src/main/java/com/quinn/service/SourceService.java new file mode 100644 index 0000000..a2b2bd2 --- /dev/null +++ b/src/main/java/com/quinn/service/SourceService.java @@ -0,0 +1,22 @@ +package com.quinn.service; + +import com.quinn.pojo.Source; +import com.baomidou.mybatisplus.extension.service.IService; + +import javax.servlet.ServletOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + *

+ * 服务类 + *

+ * + * @author limqsh + * @since 2022-05-03 + */ +public interface SourceService extends IService { + + void downloadSource(ServletOutputStream outputStream, String sid) throws IOException; + +} diff --git a/src/main/java/com/quinn/service/impl/SayServiceImpl.java b/src/main/java/com/quinn/service/impl/SayServiceImpl.java deleted file mode 100644 index 2e85bf5..0000000 --- a/src/main/java/com/quinn/service/impl/SayServiceImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.quinn.service.impl; - -import com.quinn.pojo.Say; -import com.quinn.mapper.SayMapper; -import com.quinn.service.SayService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; - -/** - *

- * 服务实现类 - *

- * - * @author limqsh - * @since 2020-07-01 - */ -@Service -public class SayServiceImpl extends ServiceImpl implements SayService { - -} diff --git a/src/main/java/com/quinn/service/impl/SourceCategoryServiceImpl.java b/src/main/java/com/quinn/service/impl/SourceCategoryServiceImpl.java new file mode 100644 index 0000000..8c3c811 --- /dev/null +++ b/src/main/java/com/quinn/service/impl/SourceCategoryServiceImpl.java @@ -0,0 +1,20 @@ +package com.quinn.service.impl; + +import com.quinn.pojo.SourceCategory; +import com.quinn.mapper.SourceCategoryMapper; +import com.quinn.service.SourceCategoryService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author limqsh + * @since 2022-05-03 + */ +@Service +public class SourceCategoryServiceImpl extends ServiceImpl implements SourceCategoryService { + +} diff --git a/src/main/java/com/quinn/service/impl/SourceCommentServiceImpl.java b/src/main/java/com/quinn/service/impl/SourceCommentServiceImpl.java new file mode 100644 index 0000000..f432faa --- /dev/null +++ b/src/main/java/com/quinn/service/impl/SourceCommentServiceImpl.java @@ -0,0 +1,20 @@ +package com.quinn.service.impl; + +import com.quinn.pojo.SourceComment; +import com.quinn.mapper.SourceCommentMapper; +import com.quinn.service.SourceCommentService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author limqsh + * @since 2022-05-03 + */ +@Service +public class SourceCommentServiceImpl extends ServiceImpl implements SourceCommentService { + +} diff --git a/src/main/java/com/quinn/service/impl/SourceServiceImpl.java b/src/main/java/com/quinn/service/impl/SourceServiceImpl.java new file mode 100644 index 0000000..6570df2 --- /dev/null +++ b/src/main/java/com/quinn/service/impl/SourceServiceImpl.java @@ -0,0 +1,52 @@ +package com.quinn.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.quinn.pojo.Source; +import com.quinn.mapper.SourceMapper; +import com.quinn.service.SourceService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.quinn.utils.OSSClientUtil; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + *

+ * 服务实现类 + *

+ * + * @author limqsh + * @since 2022-05-03 + */ +@Service +public class SourceServiceImpl extends ServiceImpl implements SourceService { + + @Resource + OSSClientUtil ossClientUtil; + + @Override + public void downloadSource(ServletOutputStream outputStream, String sid) throws IOException { + Source source = getOne(new QueryWrapper().eq("id", sid)); + String sourceLink = source.getSourceLink(); + // 读取文件内容。 + BufferedInputStream in = new BufferedInputStream(ossClientUtil.downloadFile(sourceLink)); + BufferedOutputStream out = new BufferedOutputStream(outputStream); + byte[] buffer = new byte[1024]; + int lenght = 0; + while ((lenght = in.read(buffer)) != -1) { + out.write(buffer, 0, lenght); + } + if (out != null) { + out.flush(); + out.close(); + } + if (in != null) { + in.close(); + } + } +} diff --git a/src/main/java/com/quinn/utils/OSSClientUtil.java b/src/main/java/com/quinn/utils/OSSClientUtil.java new file mode 100644 index 0000000..121223e --- /dev/null +++ b/src/main/java/com/quinn/utils/OSSClientUtil.java @@ -0,0 +1,115 @@ +package com.quinn.utils; + +import com.aliyun.oss.OSSClient; +import com.aliyun.oss.model.CannedAccessControlList; +import com.aliyun.oss.model.OSSObject; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Random; + +/** + * 阿里云 OSS文件类 + * + * @author zuojie.liang + */ +@Component +public class OSSClientUtil { + + Log log = LogFactory.getLog(OSSClientUtil.class); + /** + * 协议 + */ + @Value("${oss.protocol}") + private String protocol; + /** + * 仓库名称 + */ + @Value("${oss.name}") + private String bucketName; + /** + * 公网节点 + */ + @Value("${oss.endPoint}") + private String endpoint; + @Value("${oss.accessKeyId}") + private String accessKeyId; + /** + * API访问值 + */ + @Value("${oss.accessKeySecret}") + private String accessKeySecret; + @Value("${oss.url}") + private String url; + private OSSClient ossClient; + + public String upload(String filename, InputStream file) { + return uploadImg(file, filename); + } + + /** + * 上传图片 + * + * @param file + * @return + */ + public String uploadImg(MultipartFile file) throws IOException { + String originalFilename = file.getOriginalFilename(); + return uploadImg(file.getInputStream(), originalFilename); + } + + public String uploadImg(InputStream inputStream, String originalFilename) { + String backUrl = ""; + try { + ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret); + String substring = originalFilename.substring(originalFilename.lastIndexOf(".")).toLowerCase(); + Random random = new Random(); + String name = random.nextInt(10000) + System.currentTimeMillis() + substring; + backUrl = "imageDir/" + name; + // 上传文件 + ossClient.putObject(bucketName, backUrl, inputStream); + ossClient.setObjectAcl(bucketName, backUrl, CannedAccessControlList.PublicRead); + // 判断是否上传成功 + boolean uploadResult = ossClient.doesObjectExist(bucketName, backUrl); + + if (uploadResult) { + backUrl = getImgUrl(name); + } else { + backUrl = ""; + } + } finally { + if (ossClient != null) { + ossClient.shutdown(); + } + } + return backUrl; + } + + /** + * 获得图片路径 + * + * @param fileUrl + * @return + */ + public String getImgUrl(String fileUrl) { + if (!StringUtils.isEmpty(fileUrl)) { + String[] split = fileUrl.split("/"); + return url + "imageDir/" + split[split.length - 1]; + } + return null; + } + + public InputStream downloadFile(String objName){ + // ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。 + ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret); + OSSObject ossObject = ossClient.getObject(bucketName, objName); + return ossObject.getObjectContent(); + } + +} diff --git a/src/main/java/com/quinn/utils/UUIDGenerator.java b/src/main/java/com/quinn/utils/UUIDGenerator.java new file mode 100644 index 0000000..3d3693b --- /dev/null +++ b/src/main/java/com/quinn/utils/UUIDGenerator.java @@ -0,0 +1,28 @@ +package com.quinn.utils; + +import java.util.StringTokenizer; +import java.util.UUID; + +/** + * @title UUIDGenerator + * @description 随机生成32位UUID,格式如:a11686c39a154cf2a5238fb14cf3d097 + *
+ *
+ */ +public class UUIDGenerator { + /** + * 主键生成机制 + * @return + */ + public static String randomUUID(){ + String result=""; + UUID uuid = UUID.randomUUID(); + String temp=uuid.toString(); + StringTokenizer token=new StringTokenizer(temp,"-"); + while(token.hasMoreTokens()){ + result+=token.nextToken(); + } + return result; + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index cbb42d2..22a9875 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1,8 @@ spring.profiles.active=dev + +oss.accessKeyId=LTAIlbtS4W2Xe4OV +oss.accessKeySecret=qWMYkSfmXFtRoIv9q9OCbszcF9U7dX +oss.protocol=http +oss.name=smartvenue +oss.endPoint=http://oss-cn-beijing.aliyuncs.com +oss.url=https://smartvenue.oss-cn-beijing.aliyuncs.com/ diff --git a/src/main/resources/static/css/error.css b/src/main/resources/static/css/error.css index c9f418d..a6c5d50 100644 --- a/src/main/resources/static/css/error.css +++ b/src/main/resources/static/css/error.css @@ -299,19 +299,19 @@ div { @-webkit-keyframes zeroFour { 0% { - content: "4"; + content: "错"; } 100% { - content: "0"; + content: "误"; } } @keyframes zeroFour { 0% { - content: "4"; + content: "错"; } 100% { - content: "0"; + content: "误"; } } diff --git a/src/main/resources/static/live/js/addlive2d.js b/src/main/resources/static/live/js/addlive2d.js index 1052e14..68ddfa6 100644 --- a/src/main/resources/static/live/js/addlive2d.js +++ b/src/main/resources/static/live/js/addlive2d.js @@ -62,8 +62,8 @@ try { "mouseover": [ { "selector": ".container a[href^='http']", "text": ["要看看 {text} 么?"] }, { "selector": ".fui-home", "text": ["点击前往首页,想回到上一页可以使用浏览器的后退功能哦"] }, - { "selector": ".fui-chat", "text": ["一言一语,一颦一笑。一字一句,一颗赛艇。"] }, - { "selector": ".fui-eye", "text": ["嗯··· 要切换 看板娘 吗?"] }, + { "selector": ".fui-chat", "text": ["我们来干点 鸡汤 吧?"] }, + { "selector": ".fui-eye", "text": ["嗯··· 要切换 角色 吗?"] }, { "selector": ".fui-user", "text": ["喜欢换装 Play 吗?"] }, { "selector": ".fui-photo", "text": ["要拍张纪念照片吗?"] }, { "selector": ".fui-info-circle", "text": ["这里有关于我的信息呢"] }, @@ -124,10 +124,15 @@ try { ; live2d_settings['hitokotoAPI'] = 'hitokoto.cn'; - live2d_settings['modelId'] = 5; - live2d_settings['modelTexturesId'] = 1; + live2d_settings['homePageUrl'] = 'index'; + live2d_settings['modelId'] = 2; + live2d_settings['modelTexturesId'] = 22; live2d_settings['modelStorage'] = false; live2d_settings['canTurnToAboutPage'] = false; + live2d_settings['screenshotCaptureName']= 'quinn.png'; + live2d_settings['waifuEdgeSide'] = 'left:0'; // 看板娘贴边方向,例如 'left:0'(靠左 0px), 'right:30'(靠右 30px) + live2d_settings['waifuDraggable'] = 'unlimited'; // 拖拽样式,例如 'disable'(禁用), 'axis-x'(只能水平拖拽), 'unlimited'(自由拖拽) + live2d_settings['waifuDraggableRevert'] = true; // 松开鼠标还原拖拽位置,可选 true(真), false(假) initModel(modelJson); } }); diff --git a/src/main/resources/templates/blog/read.html b/src/main/resources/templates/blog/read.html index de2e01f..5f52c53 100644 --- a/src/main/resources/templates/blog/read.html +++ b/src/main/resources/templates/blog/read.html @@ -32,9 +32,9 @@ - - - + + + [[${blog.getViews()}]] diff --git a/src/main/resources/templates/common/header.html b/src/main/resources/templates/common/header.html index 88bb753..802ec70 100644 --- a/src/main/resources/templates/common/header.html +++ b/src/main/resources/templates/common/header.html @@ -27,10 +27,10 @@ 博客
  • - 资源库 + 热门资源
  • -
  • - 公告 +
  • + 资源库
  • 关于 diff --git a/src/main/resources/templates/error/404.html b/src/main/resources/templates/error/404.html deleted file mode 100644 index 825d92c..0000000 --- a/src/main/resources/templates/error/404.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - 404-Quinn - - - - -
    - - -
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - - diff --git a/src/main/resources/templates/error/4xx.html b/src/main/resources/templates/error/4xx.html new file mode 100644 index 0000000..47d98c2 --- /dev/null +++ b/src/main/resources/templates/error/4xx.html @@ -0,0 +1,18 @@ + + + + + + ERROR-Quinn + + + + + + + + diff --git a/src/main/resources/templates/error/5xx.html b/src/main/resources/templates/error/5xx.html index 81a3d87..47d98c2 100644 --- a/src/main/resources/templates/error/5xx.html +++ b/src/main/resources/templates/error/5xx.html @@ -3,48 +3,15 @@ - 5xx-Quinn + ERROR-Quinn
    - -
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    4
    -
    0
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    + +
    diff --git a/src/main/resources/templates/page/about.html b/src/main/resources/templates/page/about.html index a4d99b7..93ddcdb 100644 --- a/src/main/resources/templates/page/about.html +++ b/src/main/resources/templates/page/about.html @@ -13,43 +13,45 @@
    -
    diff --git a/src/main/resources/templates/page/say.html b/src/main/resources/templates/page/say.html deleted file mode 100644 index c3ab671..0000000 --- a/src/main/resources/templates/page/say.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - 公告-Quinn - - - - - - -
    - -
    - -
    - -
    -
    -
    - - -
    -
    - -
    - -
    -
    -
    - -
    -
    -
    - - -
    -
    -
      -
    • -
      -
      -

      - [[${say.getTitle()}]] - -

      -

      -
      -
    • -
    -

    ......

    -
    -
    - -
    -
    - -
    - -返回顶部 - - - - - - - - diff --git a/src/main/resources/templates/source/list.html b/src/main/resources/templates/source/list.html new file mode 100644 index 0000000..0213b22 --- /dev/null +++ b/src/main/resources/templates/source/list.html @@ -0,0 +1,82 @@ + + + + + + 资源库-Quinn + + + + + + +
    + +
    +
    +
    +
    +
    + +
    +
    +
    关键字
    +
    + +
    +
    +
    + +
    +
    +
    类别
    +
    + +
    + +
    +
    + +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + +
    #资源名资源内容资源类型去下载
    + 详情 +
    +
    +
    + +
    + +返回顶部 + + + + + + + + diff --git a/src/main/resources/templates/source/view.html b/src/main/resources/templates/source/view.html new file mode 100644 index 0000000..f4f63eb --- /dev/null +++ b/src/main/resources/templates/source/view.html @@ -0,0 +1,125 @@ + + + + + + 资源下载-Quinn + + + + + + + +
    + +
    +
    +
    + +
    +

    + +
    + +
    + + +
    + +
    + +
    + +
    +
    +
    + +
    +
    + + + + +
    + +
    + +
    +
    + +
    +
    +
    评论列表
    + +
    + +

    + + + +

    +
    +
    +
    +
    +
    +
    emmm... 这里暂时还没有评论....
    +
    +
    + +
    + + +
    + +
    + +返回顶部 + + + + + + + + + + + + + + + + + + + +