update 2021年11月15日17:42:32
parent
9ecb709543
commit
64a7e8bd41
|
|
@ -1,10 +1,9 @@
|
|||
package com.zhangmeng.admin.manager.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zhangmeng.admin.manager.feign.ArticleFeign;
|
||||
import com.zhangmeng.admin.manager.feign.CategoryFeign;
|
||||
import com.zhangmeng.admin.manager.feign.MailFeign;
|
||||
import com.zhangmeng.admin.manager.feign.QuartzFeign;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zhangmeng.admin.manager.feign.*;
|
||||
import com.zhangmeng.admin.manager.service.PermissionService;
|
||||
import com.zhangmeng.admin.manager.service.RoleService;
|
||||
import com.zhangmeng.admin.manager.service.SysLogService;
|
||||
|
|
@ -20,10 +19,13 @@ 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 org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
import tk.mybatis.mapper.entity.Condition;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -62,6 +64,9 @@ public class UrlRequestController extends BaseController {
|
|||
@Autowired
|
||||
private MailFeign mailFeign;
|
||||
|
||||
@Autowired
|
||||
private FictionFeign fictionFeign;
|
||||
|
||||
//跳转首页
|
||||
@GetMapping({"/login","/"})
|
||||
public ModelAndView login (){
|
||||
|
|
@ -364,4 +369,69 @@ public class UrlRequestController extends BaseController {
|
|||
}
|
||||
return this.jumpPage("admin/mail/edit");
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@GetMapping("/fiction/add")
|
||||
public ModelAndView add() {
|
||||
return this.jumpPage("admin/fiction/fiction_add");
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@GetMapping("/fiction/chapter/{id}")
|
||||
public ModelAndView chapter(Model model, @PathVariable Long id) {
|
||||
|
||||
Fiction fiction = this.fictionFeign.findById(id);
|
||||
model.addAttribute("fiction",fiction);
|
||||
List<FictionChapter> fictionChapterList = this.fictionFeign.findByFictionId(id);
|
||||
model.addAttribute("fictionChapter",fictionChapterList.get(0));
|
||||
model.addAttribute("fictionChapterList",fictionChapterList);
|
||||
return this.jumpPage("xiaoshuo/fiction_chapter");
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@GetMapping("/details/{chapter_id}")
|
||||
public ModelAndView details(Model model, @PathVariable String chapter_id){
|
||||
|
||||
String replace = chapter_id.replace(",", "");
|
||||
Long id = Long.parseLong(replace);
|
||||
List<FictionDetails> fictionDetailsList = this.fictionFeign.fictionDetailsId(id);
|
||||
if (fictionDetailsList.size() > 0){
|
||||
FictionDetails fictionDetails = fictionDetailsList.get(0);
|
||||
String content = fictionDetails.getContent();
|
||||
content = "<br> " + content;
|
||||
String replace1 = content.replace(" ", "<br><br><br> ");
|
||||
fictionDetails.setContent(replace1);
|
||||
model.addAttribute("fictionDetails",fictionDetails);
|
||||
}
|
||||
return this.jumpPage("xiaoshuo/fiction_details");
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@GetMapping("/fiction/index")
|
||||
public ModelAndView index(Model model, Integer pageNum, Integer pageSize) {
|
||||
|
||||
if (pageNum == null || pageSize == null) {
|
||||
pageNum = pageNum == null ? 1 : pageNum;
|
||||
pageSize = pageSize == null ? 10 : pageSize;
|
||||
}
|
||||
|
||||
PageHelper.startPage(pageNum, pageSize, "addTime desc");
|
||||
List<Fiction> fictionList = this.fictionFeign.findAll();
|
||||
PageInfo<Fiction> pageInfo = new PageInfo<>(fictionList);
|
||||
|
||||
if (pageInfo.getPrePage() == 0) {
|
||||
pageInfo.setPrePage(1);
|
||||
}
|
||||
if (pageInfo.getNextPage() == 0) {
|
||||
pageInfo.setNextPage(1);
|
||||
}
|
||||
|
||||
model.addAttribute("pageInfo", pageInfo);
|
||||
return this.jumpPage("xiaoshuo/index");
|
||||
}
|
||||
|
||||
@GetMapping("/fictionCollection/index")
|
||||
public ModelAndView fictionCollection_index() {
|
||||
return this.jumpPage("admin/fiction/fiction_list");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.zhangmeng.admin.manager.feign;
|
||||
|
||||
import com.zhangmeng.model.dto.system.SysConstant;
|
||||
import com.zhangmeng.model.entity.Fiction;
|
||||
import com.zhangmeng.model.entity.FictionChapter;
|
||||
import com.zhangmeng.model.entity.FictionDetails;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(SysConstant.mystyle_cloud_fiction)
|
||||
public interface FictionFeign {
|
||||
|
||||
@GetMapping(SysConstant.mystyle_cloud_fiction_prefix +"/findBy/{id}")
|
||||
Fiction findById(@PathVariable("id") Long id);
|
||||
|
||||
@GetMapping(SysConstant.mystyle_cloud_fiction_prefix + "/findByFictionId")
|
||||
List<FictionChapter> findByFictionId(@RequestParam("id") Long id);
|
||||
|
||||
@GetMapping(SysConstant.mystyle_cloud_fiction_prefix + "/fictionDetailsId")
|
||||
List<FictionDetails> fictionDetailsId(@RequestParam("id") Long id);
|
||||
|
||||
@GetMapping(SysConstant.mystyle_cloud_fiction_prefix + "/findAllToFiction")
|
||||
List<Fiction> findAll();
|
||||
|
||||
}
|
||||
|
|
@ -12,6 +12,8 @@ var file_url = "mystyle-cloud-file";
|
|||
var quartz_url = "mystyle-cloud-quartz";
|
||||
//邮件微服务
|
||||
var mail_url = "mystyle-cloud-mail";
|
||||
//小说微服务
|
||||
var fiction_url = "mystyle-cloud-fiction";
|
||||
//验证码
|
||||
var v_code = gate_way_url + "/" + admin_manager_url + "/verificationCode/generate";
|
||||
var access_token = localStorage.getItem("access_token");
|
||||
|
|
@ -126,6 +128,11 @@ var mail_save_url = gate_way_url + "/" + mail_url + "/mail/save";
|
|||
var mail_edit_url = gate_way_url + "/" + admin_manager_url + "/mail/edit" + access_token_url;
|
||||
//邮件发送
|
||||
var mail_send_url = gate_way_url + "/" + mail_url + "/mail/sendEmail";
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
//小说列表
|
||||
var fiction_list_url = gate_way_url + "/" + fiction_url + "/fiction/list";
|
||||
//小说集合列表
|
||||
var fictionCollection_list_url = gate_way_url + "/" + fiction_url + "/fictionCollection/list";
|
||||
|
||||
//页面跳转
|
||||
function postToPage(url, token) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>小说集合</title>
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/system/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/css/pear.css" />
|
||||
</head>
|
||||
<body class="pear-container">
|
||||
<div class="layui-card">
|
||||
|
|
@ -64,8 +64,9 @@
|
|||
{{layui.util.toDateString(d.addTime, 'yyyy-MM-dd HH:mm:ss')}}
|
||||
</script>
|
||||
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/admin/js/mystyle-admin.js"></script>
|
||||
<script>
|
||||
layui.use(['table', 'form', 'jquery','common','laypage'], function() {
|
||||
let table = layui.table;
|
||||
|
|
@ -108,11 +109,13 @@
|
|||
|
||||
table.render({
|
||||
elem: '#fiction-list-table',
|
||||
url: '/fictionCollection/list',
|
||||
headers: {token: localStorage.getItem("token")},
|
||||
url: fictionCollection_list_url,
|
||||
headers: {
|
||||
access_token : access_token
|
||||
},
|
||||
page: true,
|
||||
cols: cols,
|
||||
skin: 'line',
|
||||
skin: 'rows',
|
||||
toolbar: '#fiction-list-toolbar',
|
||||
defaultToolbar: [{
|
||||
title: '刷新',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
package com.zhangmeng.api.service.fiction;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
|
||||
@Api(tags = "小说集合")
|
||||
public interface FictionCollectionControllerApi {
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.zhangmeng.api.service.fiction;
|
||||
|
||||
|
||||
import com.zhangmeng.model.dto.system.SysConstant;
|
||||
import com.zhangmeng.model.entity.Fiction;
|
||||
import com.zhangmeng.model.entity.FictionChapter;
|
||||
import com.zhangmeng.model.entity.FictionDetails;
|
||||
import com.zhangmeng.model.vo.Result;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Api(tags = "小说管理")
|
||||
public interface FictionControllerApi {
|
||||
|
||||
@ApiOperation("添加小说")
|
||||
public Result save(@RequestParam @RequestBody Map<String, Object> map);
|
||||
|
||||
@ApiOperation("检查状态")
|
||||
public Result check();
|
||||
|
||||
@ApiOperation("更新小说")
|
||||
public Result update_fiction(String fictionName);
|
||||
|
||||
@ApiOperation("根据id获取")
|
||||
public Fiction getFictionById(Long id);
|
||||
|
||||
@ApiOperation("根据小说id查询章节")
|
||||
List<FictionChapter> findByFictionId(@RequestParam("id") Long id);
|
||||
|
||||
@ApiOperation("根据小说章节id查询详情")
|
||||
public List<FictionDetails> fictionDetailsId(@RequestParam("id") Long id);
|
||||
|
||||
@ApiOperation("获取全部小说")
|
||||
List<Fiction> findAll();
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>mystyle-cloud-parent</artifactId>
|
||||
<groupId>com.zhangmeng</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>mystyle-cloud-fiction</artifactId>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.zhangmeng</groupId>
|
||||
<artifactId>mystyle-cloud-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-sleuth</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.zhangmeng.fiction;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* @author zhangmeng
|
||||
* @date 2021年11月15日10:59:55
|
||||
* @version 1.0
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients
|
||||
@ComponentScan(basePackages = {"com.zhangmeng.model","com.zhangmeng.fiction","com.zhangmeng.api"})
|
||||
public class FictionApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(FictionApplication.class,args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.zhangmeng.fiction.config.feign;
|
||||
|
||||
import feign.RequestInterceptor;
|
||||
import feign.RequestTemplate;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
* 请求拦截器
|
||||
*/
|
||||
@Configuration
|
||||
public class FeignOauth2RequestInterceptor implements RequestInterceptor {
|
||||
@Override
|
||||
public void apply(RequestTemplate requestTemplate) {
|
||||
// 获取的全部请求信息
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
if (attributes != null){
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
// 获取所有的请求头信息
|
||||
Enumeration<String> headerNames = request.getHeaderNames();
|
||||
if (headerNames != null){
|
||||
while (headerNames.hasMoreElements()){
|
||||
// 获取请求头的key
|
||||
String element = headerNames.nextElement();
|
||||
// 获取请求头的value
|
||||
String value = request.getHeader(element);
|
||||
// 将请求头信息放入到请求头
|
||||
requestTemplate.header(element,value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
package com.zhangmeng.fiction.config.security;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
|
||||
import org.springframework.security.oauth2.provider.token.TokenStore;
|
||||
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
|
||||
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 转身的背影在心底里沉沦
|
||||
* @date 2021年9月14日16:45:29
|
||||
* @version 1.0
|
||||
*/
|
||||
@Configuration
|
||||
@EnableResourceServer
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)// 激活方法上的PreAuthorize注解
|
||||
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
|
||||
|
||||
// 公钥
|
||||
private static final String PUBLIC_KEY = "public.key";
|
||||
|
||||
@Autowired
|
||||
private SecurityProperty securityProperty;
|
||||
|
||||
/***
|
||||
* 定义JwtTokenStore
|
||||
* @param jwtAccessTokenConverter
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public TokenStore tokenStore(JwtAccessTokenConverter jwtAccessTokenConverter) {
|
||||
return new JwtTokenStore(jwtAccessTokenConverter);
|
||||
}
|
||||
|
||||
/***
|
||||
* 定义JJwtAccessTokenConverter
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public JwtAccessTokenConverter jwtAccessTokenConverter() {
|
||||
JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
|
||||
converter.setVerifierKey(getPubKey()); //秘钥的一部分
|
||||
return converter;
|
||||
}
|
||||
/**
|
||||
* 获取非对称加密公钥 Key
|
||||
* @return 公钥 Key
|
||||
*/
|
||||
private String getPubKey() {
|
||||
Resource resource = new ClassPathResource(PUBLIC_KEY);
|
||||
try {
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(resource.getInputStream());
|
||||
BufferedReader br = new BufferedReader(inputStreamReader);
|
||||
return br.lines().collect(Collectors.joining("\n"));
|
||||
} catch (IOException ioe) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* SpringSecurity
|
||||
* Http安全配置,对每个到达系统的http请求链接进行校验
|
||||
* @param http
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void configure(HttpSecurity http) throws Exception {
|
||||
|
||||
http.headers().frameOptions().disable();
|
||||
|
||||
// 所有请求必须认证通过
|
||||
http.authorizeRequests()
|
||||
// 跨域预检请求
|
||||
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
||||
.antMatchers(securityProperty.getOpenApi()).permitAll()
|
||||
.anyRequest().
|
||||
authenticated(); // 其他地址需要认证授权
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.zhangmeng.fiction.config.security;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author 转身的背影在心底里沉沦
|
||||
* @date 2021年9月14日16:50:47
|
||||
* @version 1.0
|
||||
* */
|
||||
@Configuration
|
||||
@ConfigurationProperties("mystyle.security")
|
||||
public class SecurityProperty {
|
||||
|
||||
/**
|
||||
* 超级管理员不认证
|
||||
* */
|
||||
private boolean superAuthOpen;
|
||||
|
||||
/**
|
||||
* 不验证权限用户名
|
||||
* */
|
||||
private String superAdmin;
|
||||
|
||||
/**
|
||||
* 记住密码标识
|
||||
* */
|
||||
private String rememberKey;
|
||||
|
||||
/**
|
||||
* 开放接口列表
|
||||
* */
|
||||
private String[] openApi;
|
||||
|
||||
/**
|
||||
* 是否允许多账号在线
|
||||
* */
|
||||
private Integer maximum = 1;
|
||||
|
||||
public boolean isSuperAuthOpen() {
|
||||
return superAuthOpen;
|
||||
}
|
||||
|
||||
public void setSuperAuthOpen(boolean superAuthOpen) {
|
||||
this.superAuthOpen = superAuthOpen;
|
||||
}
|
||||
|
||||
public String getSuperAdmin() {
|
||||
return superAdmin;
|
||||
}
|
||||
|
||||
public void setSuperAdmin(String superAdmin) {
|
||||
this.superAdmin = superAdmin;
|
||||
}
|
||||
|
||||
public String getRememberKey() {
|
||||
return rememberKey;
|
||||
}
|
||||
|
||||
public void setRememberKey(String rememberKey) {
|
||||
this.rememberKey = rememberKey;
|
||||
}
|
||||
|
||||
public String[] getOpenApi() {
|
||||
return openApi;
|
||||
}
|
||||
|
||||
public void setOpenApi(String[] openApi) {
|
||||
this.openApi = openApi;
|
||||
}
|
||||
|
||||
public Integer getMaximum() {
|
||||
return maximum;
|
||||
}
|
||||
|
||||
public void setMaximum(Integer maximum) {
|
||||
this.maximum = maximum;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
package com.zhangmeng.fiction.controller;
|
||||
|
||||
import com.zhangmeng.api.service.fiction.FictionCollectionControllerApi;
|
||||
import com.zhangmeng.fiction.service.FictionCollectionService;
|
||||
import com.zhangmeng.fiction.service.TianYuXiaoShuoJsoupService;
|
||||
import com.zhangmeng.model.base.baseController.BaseController;
|
||||
import com.zhangmeng.model.base.baseUtil.CommonUtil;
|
||||
import com.zhangmeng.model.dto.query.QueryParams;
|
||||
import com.zhangmeng.model.entity.FictionCollection;
|
||||
import com.zhangmeng.model.vo.Result;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
import tk.mybatis.mapper.entity.Condition;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/fictionCollection")
|
||||
public class FictionCollectionController extends BaseController implements FictionCollectionControllerApi {
|
||||
|
||||
@Autowired
|
||||
private FictionCollectionService fictionCollectionService;
|
||||
|
||||
@Autowired
|
||||
private TianYuXiaoShuoJsoupService tianYuXiaoShuoJsoupService;
|
||||
|
||||
@ApiOperation("爬取小说集合")
|
||||
@GetMapping("/gen")
|
||||
public Result gen() {
|
||||
Elements li = tianYuXiaoShuoJsoupService.fiction_collection();
|
||||
if (li != null) {
|
||||
for (Element element : li) {
|
||||
Elements a = element.getElementsByTag("a");
|
||||
String href = a.attr("href");
|
||||
String title = a.text();
|
||||
FictionCollection fictionCollection = new FictionCollection();
|
||||
fictionCollection.setHref(href);
|
||||
fictionCollection.setTitle(title);
|
||||
fictionCollection.setGenStatus(0);
|
||||
this.fictionCollectionService.save(fictionCollection);
|
||||
}
|
||||
}
|
||||
return this.success();
|
||||
}
|
||||
|
||||
@ApiOperation("集合列表")
|
||||
@GetMapping("/list")
|
||||
public Result list(String title, Integer pageNum, Integer pageSize) {
|
||||
Condition condition = new Condition(FictionCollection.class);
|
||||
Example.Criteria criteria = condition.createCriteria();
|
||||
if (CommonUtil.isNotNull(title)) {
|
||||
criteria.andLike("title", "%" + title + "%");
|
||||
}
|
||||
return this.fictionCollectionService.findByByConditionWithResult(new QueryParams(pageNum, pageSize, condition, "addTime desc"));
|
||||
}
|
||||
|
||||
@ApiOperation("genFiction")
|
||||
@GetMapping("/genFiction")
|
||||
public Result genFiction(String url) {
|
||||
if (url != null) {
|
||||
Condition condition = new Condition(FictionCollection.class);
|
||||
Example.Criteria criteria = condition.createCriteria();
|
||||
criteria.andEqualTo("href", url);
|
||||
List<FictionCollection> fictionCollections = this.fictionCollectionService.findByCondition(condition);
|
||||
if (fictionCollections.size() > 0) {
|
||||
FictionCollection fictionCollection = fictionCollections.get(0);
|
||||
if (fictionCollection.getGenStatus() == 0) {
|
||||
this.tianYuXiaoShuoJsoupService.gen_fiction(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.success("生成成功");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
package com.zhangmeng.fiction.controller;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zhangmeng.api.service.fiction.FictionControllerApi;
|
||||
import com.zhangmeng.fiction.service.*;
|
||||
import com.zhangmeng.model.base.baseController.BaseController;
|
||||
import com.zhangmeng.model.base.baseUtil.CommonUtil;
|
||||
import com.zhangmeng.model.dto.system.SysConstant;
|
||||
import com.zhangmeng.model.entity.Fiction;
|
||||
import com.zhangmeng.model.entity.FictionChapter;
|
||||
import com.zhangmeng.model.entity.FictionCollection;
|
||||
import com.zhangmeng.model.entity.FictionDetails;
|
||||
import com.zhangmeng.model.vo.Result;
|
||||
import com.zhangmeng.model.vo.StatusCode;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
import tk.mybatis.mapper.entity.Condition;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/fiction")
|
||||
public class FictionController extends BaseController implements FictionControllerApi {
|
||||
|
||||
@Autowired
|
||||
private FictionService fictionService;
|
||||
|
||||
@Autowired
|
||||
private FictionCollectionService fictionCollectionService;
|
||||
|
||||
@Autowired
|
||||
private FictionChapterService fictionChapterService;
|
||||
|
||||
@Autowired
|
||||
private FictionDetailsService fictionDetailsService;
|
||||
|
||||
@Autowired
|
||||
private TianYuXiaoShuoJsoupService tianYuXiaoShuoJsoupService;
|
||||
|
||||
@Override
|
||||
@PostMapping("/save")
|
||||
public Result save(@RequestParam @RequestBody Map<String, Object> map) {
|
||||
|
||||
FictionCollection fictionCollection = CommonUtil.map2Obj(map, FictionCollection.class);
|
||||
fictionCollection.setAddTime(new Date());
|
||||
fictionCollection.setDeleteStatus(false);
|
||||
fictionCollection.setUpdateTime(new Date());
|
||||
fictionCollection.setGenStatus(0);
|
||||
List<FictionCollection> collections = this.fictionCollectionService.findByObj(fictionCollection);
|
||||
if (collections.size() > 0) {
|
||||
this.fictionCollectionService.update(fictionCollection);
|
||||
}
|
||||
this.fictionCollectionService.save(fictionCollection);
|
||||
return this.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("/check")
|
||||
public Result check() {
|
||||
List<FictionCollection> all = this.fictionCollectionService.findAll();
|
||||
if (all.size() > 0) {
|
||||
for (FictionCollection fictionCollection : all) {
|
||||
String bookName = fictionCollection.getTitle();
|
||||
Fiction fiction = this.fictionService.finbByBookName(bookName);
|
||||
if (fiction != null) {
|
||||
fictionCollection.setUpdateTime(new Date());
|
||||
fictionCollection.setGenStatus(1);
|
||||
this.fictionCollectionService.update(fictionCollection);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("/fictionName")
|
||||
public Result update_fiction(String fictionName) {
|
||||
//查询小说
|
||||
Fiction fiction = this.fictionService.finbByBookName(fictionName);
|
||||
if (fiction != null) {
|
||||
String links = fiction.getLinks();
|
||||
//获取该小说的最新章节
|
||||
this.tianYuXiaoShuoJsoupService.update_fiction(links);
|
||||
}
|
||||
return new Result(true, StatusCode.OK, "更新成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("/findBy/{id}")
|
||||
public Fiction getFictionById(@PathVariable("id") Long id) {
|
||||
return this.fictionService.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("/findByFictionId")
|
||||
public List<FictionChapter> findByFictionId(@RequestParam("id") Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("/fictionDetailsId")
|
||||
public List<FictionDetails> fictionDetailsId(@RequestParam("id") Long id) {
|
||||
Condition condition = new Condition(FictionDetails.class);
|
||||
Example.Criteria criteria = condition.createCriteria();
|
||||
if (CommonUtil.isNotNull(id)) {
|
||||
criteria.andEqualTo("fiction_chapter_id", id);
|
||||
}
|
||||
return this.fictionDetailsService.findByCondition(condition);
|
||||
}
|
||||
|
||||
@GetMapping("/findAllToFiction")
|
||||
public List<Fiction> findAll() {
|
||||
return this.fictionService.findAll();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.zhangmeng.fiction.dao;
|
||||
|
||||
import com.zhangmeng.model.base.baseDao.AbstractBaseMapper;
|
||||
import com.zhangmeng.model.entity.FictionChapter;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface FictionChapterDao extends AbstractBaseMapper<FictionChapter> {
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.zhangmeng.fiction.dao;
|
||||
|
||||
import com.zhangmeng.model.base.baseDao.AbstractBaseMapper;
|
||||
import com.zhangmeng.model.entity.FictionCollection;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface FictionCollectionDao extends AbstractBaseMapper<FictionCollection> {
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.zhangmeng.fiction.dao;
|
||||
|
||||
import com.zhangmeng.model.base.baseDao.AbstractBaseMapper;
|
||||
import com.zhangmeng.model.entity.Fiction;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface FictionDao extends AbstractBaseMapper<Fiction> {
|
||||
|
||||
|
||||
@Select("select * from fiction obj where obj.bookName = #{bookName}")
|
||||
Fiction finbByBookName(String bookName);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.zhangmeng.fiction.dao;
|
||||
|
||||
|
||||
import com.zhangmeng.model.base.baseDao.AbstractBaseMapper;
|
||||
import com.zhangmeng.model.entity.FictionDetails;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface FictionDetailsDao extends AbstractBaseMapper<FictionDetails> {
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.zhangmeng.fiction.service;
|
||||
|
||||
|
||||
import com.zhangmeng.model.base.baseService.BaseService;
|
||||
import com.zhangmeng.model.entity.FictionChapter;
|
||||
|
||||
public interface FictionChapterService extends BaseService<FictionChapter> {
|
||||
FictionChapter findByChapterName(String title);
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.zhangmeng.fiction.service;
|
||||
|
||||
|
||||
import com.zhangmeng.model.base.baseService.BaseService;
|
||||
import com.zhangmeng.model.entity.FictionCollection;
|
||||
|
||||
public interface FictionCollectionService extends BaseService<FictionCollection> {
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.zhangmeng.fiction.service;
|
||||
|
||||
import com.zhangmeng.model.base.baseService.BaseService;
|
||||
import com.zhangmeng.model.entity.FictionDetails;
|
||||
|
||||
public interface FictionDetailsService extends BaseService<FictionDetails> {
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.zhangmeng.fiction.service;
|
||||
|
||||
import com.zhangmeng.model.base.baseService.BaseService;
|
||||
import com.zhangmeng.model.entity.Fiction;
|
||||
|
||||
public interface FictionService extends BaseService<Fiction> {
|
||||
|
||||
Fiction finbByBookName(String bookName);
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.zhangmeng.fiction.service;
|
||||
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
public interface TianYuXiaoShuoJsoupService {
|
||||
void gen_fiction(String url);
|
||||
|
||||
Elements fiction_collection();
|
||||
|
||||
public void update_fiction(String url);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.zhangmeng.fiction.service.impl;
|
||||
|
||||
|
||||
import com.zhangmeng.fiction.service.FictionChapterService;
|
||||
import com.zhangmeng.model.base.baseService.impl.AbstractBaseServiceImpl;
|
||||
import com.zhangmeng.model.entity.FictionChapter;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tk.mybatis.mapper.entity.Condition;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class FictionChapterServiceImpl extends AbstractBaseServiceImpl<FictionChapter> implements FictionChapterService {
|
||||
@Override
|
||||
public FictionChapter findByChapterName(String title) {
|
||||
|
||||
Condition condition = new Condition(FictionChapter.class);
|
||||
Example.Criteria criteria = condition.createCriteria();
|
||||
criteria.andEqualTo("title",title);
|
||||
List<FictionChapter> fictionChapters = this.findByCondition(condition);
|
||||
if (fictionChapters.size() > 0){
|
||||
return fictionChapters.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.zhangmeng.fiction.service.impl;
|
||||
|
||||
import com.zhangmeng.fiction.service.FictionCollectionService;
|
||||
import com.zhangmeng.model.base.baseService.impl.AbstractBaseServiceImpl;
|
||||
import com.zhangmeng.model.entity.FictionCollection;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class FictionCollectionServiceImpl extends AbstractBaseServiceImpl<FictionCollection> implements FictionCollectionService {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.zhangmeng.fiction.service.impl;
|
||||
|
||||
|
||||
import com.zhangmeng.fiction.service.FictionDetailsService;
|
||||
import com.zhangmeng.model.base.baseService.impl.AbstractBaseServiceImpl;
|
||||
import com.zhangmeng.model.entity.FictionDetails;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class FictionDetailsServiceImpl extends AbstractBaseServiceImpl<FictionDetails> implements FictionDetailsService {
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.zhangmeng.fiction.service.impl;
|
||||
|
||||
import com.zhangmeng.fiction.dao.FictionDao;
|
||||
import com.zhangmeng.fiction.service.FictionService;
|
||||
import com.zhangmeng.model.base.baseService.impl.AbstractBaseServiceImpl;
|
||||
import com.zhangmeng.model.entity.Fiction;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class FictionServiceImpl extends AbstractBaseServiceImpl<Fiction> implements FictionService {
|
||||
|
||||
@Autowired
|
||||
private FictionDao fictionDao;
|
||||
|
||||
@Override
|
||||
public Fiction finbByBookName(String bookName) {
|
||||
return this.fictionDao.finbByBookName(bookName);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
package com.zhangmeng.fiction.service.impl;
|
||||
|
||||
import com.zhangmeng.fiction.service.FictionChapterService;
|
||||
import com.zhangmeng.fiction.service.FictionDetailsService;
|
||||
import com.zhangmeng.fiction.service.FictionService;
|
||||
import com.zhangmeng.fiction.service.TianYuXiaoShuoJsoupService;
|
||||
import com.zhangmeng.model.base.baseUtil.JsoupUtil;
|
||||
import com.zhangmeng.model.entity.Fiction;
|
||||
import com.zhangmeng.model.entity.FictionChapter;
|
||||
import com.zhangmeng.model.entity.FictionDetails;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class TianYuXiaoShuoJsoupImpl implements TianYuXiaoShuoJsoupService {
|
||||
|
||||
private String domain = "https://www.tycqxs.com";//域名
|
||||
|
||||
@Autowired
|
||||
private FictionService fictionService;
|
||||
|
||||
@Autowired
|
||||
private FictionChapterService fictionChapterService;
|
||||
|
||||
@Autowired
|
||||
private FictionDetailsService fictionDetailsService;
|
||||
|
||||
public Elements fiction_collection() {
|
||||
try {
|
||||
String url = domain + "/xiaoshuodaquan/";
|
||||
Document document = JsoupUtil.sendGet(url, 5000);
|
||||
Element body = document.body();
|
||||
Element main = body.getElementById("main");
|
||||
return main.getElementsByTag("li");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//更新小说
|
||||
public void update_fiction(String url){
|
||||
try {
|
||||
Document document = JsoupUtil.sendGet(url, 5000);
|
||||
Element body = document.body();
|
||||
Element box_con_1 = body.getElementsByClass("box_con").get(0);
|
||||
Element maininfo = box_con_1.getElementById("maininfo");
|
||||
//小说名称
|
||||
String bookname = maininfo.getElementById("info").getElementsByTag("h1").text();
|
||||
|
||||
//小说简介
|
||||
String intro = maininfo.getElementById("intro").getElementsByTag("p").text();
|
||||
|
||||
//小说作者
|
||||
String author = getUserName(maininfo.getElementById("info").getElementsByTag("p").get(0).text());
|
||||
|
||||
Element sidebar = box_con_1.getElementById("sidebar");
|
||||
Element fmimg = sidebar.getElementById("fmimg");
|
||||
//小说图片
|
||||
String image_path = fmimg.getElementsByTag("img").attr("src");
|
||||
|
||||
Fiction fiction = this.fictionService.finbByBookName(bookname);
|
||||
if (fiction != null){
|
||||
//章节
|
||||
Element box_con = body.getElementsByClass("box_con").get(1);
|
||||
Elements elements = box_con.getElementById("list").getElementsByTag("dd");
|
||||
if (elements.size() > 0) {
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
if (i >= 9) {
|
||||
String title = elements.get(i).text();
|
||||
String href = domain + elements.get(i).getElementsByTag("a").attr("href");
|
||||
|
||||
//根据章节名称查询
|
||||
FictionChapter fictionChapter = this.fictionChapterService.findByChapterName(title);
|
||||
if (fictionChapter == null){
|
||||
//生成目录
|
||||
fictionChapter = new FictionChapter();
|
||||
fictionChapter.setFiction_id(fiction.getId());
|
||||
fictionChapter.setHref(href);
|
||||
fictionChapter.setTitle(title);
|
||||
this.fictionChapterService.save(fictionChapter);
|
||||
//生成内容
|
||||
genContent(href,fiction,fictionChapter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void gen_fiction(String url) {
|
||||
try {
|
||||
Fiction fiction = new Fiction();
|
||||
Document document = JsoupUtil.sendGet(url, 5000);
|
||||
Element body = document.body();
|
||||
Element box_con_1 = body.getElementsByClass("box_con").get(0);
|
||||
Element maininfo = box_con_1.getElementById("maininfo");
|
||||
//小说名称
|
||||
String bookname = maininfo.getElementById("info").getElementsByTag("h1").text();
|
||||
fiction.setBookName(bookname);
|
||||
//小说简介
|
||||
String intro = maininfo.getElementById("intro").getElementsByTag("p").text();
|
||||
fiction.setIntro(intro);
|
||||
//小说作者
|
||||
String author = getUserName(maininfo.getElementById("info").getElementsByTag("p").get(0).text());
|
||||
fiction.setAuthor(author);
|
||||
Element sidebar = box_con_1.getElementById("sidebar");
|
||||
Element fmimg = sidebar.getElementById("fmimg");
|
||||
//小说图片
|
||||
String image_path = fmimg.getElementsByTag("img").attr("src");
|
||||
fiction.setMain_image_path(image_path);
|
||||
this.fictionService.save(fiction);
|
||||
//章节
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
Element box_con = body.getElementsByClass("box_con").get(1);
|
||||
Elements elements = box_con.getElementById("list").getElementsByTag("dd");
|
||||
if (elements.size() > 0) {
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
if (i >= 9) {
|
||||
String title = elements.get(i).text();
|
||||
String href = domain + elements.get(i).getElementsByTag("a").attr("href");
|
||||
//生成目录
|
||||
FictionChapter fictionChapter = new FictionChapter();
|
||||
fictionChapter.setFiction_id(fiction.getId());
|
||||
fictionChapter.setHref(href);
|
||||
fictionChapter.setTitle(title);
|
||||
this.fictionChapterService.save(fictionChapter);
|
||||
//生成内容
|
||||
genContent(href,fiction,fictionChapter);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void genContent(String href,Fiction fiction ,FictionChapter fictionChapter) {
|
||||
try {
|
||||
Document document = JsoupUtil.sendGet(href, 5000);
|
||||
String content = document.body().getElementById("content").text();
|
||||
FictionDetails fictionDetails = new FictionDetails();
|
||||
fictionDetails.setContent(content);
|
||||
fictionDetails.setFiction_chapter_id(fictionChapter.getId());
|
||||
fictionDetails.setFiction_id(fiction.getId());
|
||||
fictionDetails.setHref(href);
|
||||
fictionDetails.setIntro(fiction.getIntro());
|
||||
fictionDetails.setTitle(fictionChapter.getTitle());
|
||||
fictionDetails.setBookName(fiction.getBookName());
|
||||
this.fictionDetailsService.save(fictionDetails);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private String getUserName(String str) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
char[] chars = str.toCharArray();
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
if (i >= 4) {
|
||||
stringBuilder.append(chars[i]);
|
||||
}
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
server:
|
||||
port: 31009
|
||||
spring:
|
||||
application:
|
||||
name: mystyle-cloud-fiction
|
||||
datasource:
|
||||
username: root
|
||||
password: root
|
||||
url: jdbc:mysql://127.0.0.1:3306/mystyle-blog?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
jpa:
|
||||
database: mysql
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
naming:
|
||||
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
|
||||
show-sql: true
|
||||
properties:
|
||||
hibernate:
|
||||
dialect: org.hibernate.dialect.MySQL5Dialect
|
||||
zipkin:
|
||||
sender:
|
||||
type: web
|
||||
base-url: http://localhost:9411/
|
||||
service:
|
||||
name: mystyle-cloud-fiction
|
||||
sleuth:
|
||||
sampler:
|
||||
probability: 1
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 4GB
|
||||
max-request-size: 4GB
|
||||
mybatis:
|
||||
type-aliases-package: com.zhangmeng.model.entity
|
||||
configuration:
|
||||
mapUnderscoreToCamelCase: true
|
||||
default-enum-type-handler: org.apache.ibatis.type.EnumOrdinalTypeHandler
|
||||
mapper:
|
||||
style: normal
|
||||
enum-as-simple-type: true
|
||||
identity: MYSQL
|
||||
check-example-entity-class: true
|
||||
mystyle:
|
||||
security:
|
||||
open-api:
|
||||
#swagger-ui.html
|
||||
- /swagger-ui.html
|
||||
- /swagger-ui/**
|
||||
- /swagger-resources/**
|
||||
- /v2/api-docs
|
||||
- /v3/api-docs
|
||||
- /doc.html
|
||||
- /webjars/**
|
||||
#
|
||||
- /upload/decoToken
|
||||
|
|
@ -0,0 +1 @@
|
|||
-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAizuj0fBV2+dj4lM3G6efKYvC2czd07BqmzV++E2yBguVks3XWvsW8qlzmG+t1XBCnRFDI/t1Ddc/Jsnlfy4YzRN8otb/Xn6Yz9ACFvZIPGx/q0cqcrgVaR9rSQiSzsGTgUGHNJk8r3A4w9PSSB552Z9s6p5TsWK5ezlfgg+2ANKn1eJ6R/hzajS/B1bTAqYcl9ddo7prneoeAN5LjlMhc2e0cSVgQt8ALP+4x/bTMnDkMjG6R8lnDAxE27B2ZPaLOIOjkUMK+9mZa4RNBoCDG6J/fwPD1NUoVRCbyr/TVaS4EzyhfNK1QW3BlZ0NLSI/SFD3eryKaFQdacJHS31neQIDAQAB-----END PUBLIC KEY-----
|
||||
|
|
@ -70,5 +70,11 @@ spring:
|
|||
uri: lb://mystyle-cloud-mail
|
||||
predicates:
|
||||
- Path=/mystyle-cloud-mail/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
- id: mystyle-cloud-fiction
|
||||
uri: lb://mystyle-cloud-fiction
|
||||
predicates:
|
||||
- Path=/mystyle-cloud-fiction/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
|
|
@ -14,4 +14,8 @@ public class SysConstant {
|
|||
public static final String mystyle_cloud_quartz = "mystyle-cloud-quartz";
|
||||
|
||||
public static final String mystyle_cloud_mail = "mystyle-cloud-mail";
|
||||
|
||||
public static final String mystyle_cloud_fiction= "mystyle-cloud-fiction";
|
||||
|
||||
public static final String mystyle_cloud_fiction_prefix = "/fiction";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package com.zhangmeng.model.entity;
|
||||
|
||||
import com.zhangmeng.model.base.baseEntity.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 小说信息
|
||||
*
|
||||
* @author zhengmeng
|
||||
* @version 1.0
|
||||
* @date 2021年1月7日11:38:42
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = "fiction")
|
||||
public class Fiction extends BaseEntity<Long> {
|
||||
|
||||
private String bookName;
|
||||
|
||||
private String author;//作者
|
||||
|
||||
private String main_image_path;//主图
|
||||
|
||||
@Column(columnDefinition = "longtext")
|
||||
private String intro;//简介 章节 FictionChapter
|
||||
|
||||
private String links;//链接
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.zhangmeng.model.entity;
|
||||
|
||||
import com.zhangmeng.model.base.baseEntity.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 小说信息
|
||||
*
|
||||
* @author zhengmeng
|
||||
* @version 1.0
|
||||
* @date 2021年1月7日11:38:42
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = "fiction_chapter")
|
||||
public class FictionChapter extends BaseEntity<Long> {
|
||||
|
||||
private String title;//章节名称
|
||||
|
||||
private String href;//链接地址
|
||||
|
||||
private Long fiction_id;//小说id
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.zhangmeng.model.entity;
|
||||
|
||||
|
||||
import com.zhangmeng.model.base.baseEntity.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 小说集合
|
||||
*
|
||||
* @author zhengmeng
|
||||
* @version 1.0
|
||||
* @date 2021年1月7日11:38:42
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = "fiction_collection")
|
||||
public class FictionCollection extends BaseEntity<Long> {
|
||||
|
||||
private String title;
|
||||
|
||||
private String href;
|
||||
|
||||
private Integer genStatus; //0 未生成 1 已生成
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.zhangmeng.model.entity;
|
||||
|
||||
import com.zhangmeng.model.base.baseEntity.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 小说信息
|
||||
*
|
||||
* @author zhengmeng
|
||||
* @version 1.0
|
||||
* @date 2021年1月7日11:38:42
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = "fiction_details")
|
||||
public class FictionDetails extends BaseEntity<Long> {
|
||||
|
||||
private String bookName;//小说名称
|
||||
|
||||
private String title;//章节名称
|
||||
|
||||
private String href;//链接地址
|
||||
|
||||
private Long fiction_id;//小说id
|
||||
|
||||
private Long fiction_chapter_id;//小说章节的id
|
||||
|
||||
@Column(columnDefinition = "longtext")
|
||||
private String intro;//简介
|
||||
|
||||
@Column(columnDefinition = "longtext")
|
||||
private String content;//小说内容
|
||||
}
|
||||
Loading…
Reference in New Issue