Compare commits

...

26 Commits

Author SHA1 Message Date
8d3ce53dba build(pom): v3.5.4发布 2021-06-01 23:14:35 +08:00
d32d9d8410 perf(html): 模版更新 2021-06-01 23:13:18 +08:00
05ae012e05 fix(yml): Public Key Retrieval is not allowed 2021-06-01 23:03:15 +08:00
b60a0c9b40 perf(监控): 设置druid监控信息登陆后查看 2021-06-01 22:49:23 +08:00
3efaf8ce5f perf(评论): 优化评论显示 2021-06-01 22:01:05 +08:00
ebc4210774 fix(章节更新): xss 2021-06-01 21:44:18 +08:00
655ec90906 fix(data submit): Xss攻击 2021-06-01 20:58:06 +08:00
f28dd867ef v3.5.3发布 2021-05-28 20:32:08 +08:00
8e6842a495 模版更新 2021-05-28 20:08:45 +08:00
928cb2417f 小说详情页优化 2021-05-28 20:04:52 +08:00
625694ba1e Merge branch 'release_3.5.3' into develop_xxy 2021-05-28 11:54:24 +08:00
d6c0337c09 首页SEO优化 2021-05-28 11:51:11 +08:00
689efc0807 style(novel-common/bean): ResultBean更新
代码格式化,去除多余分号
2021-05-16 10:54:25 +08:00
4540c3781e 模版更新 2021-05-16 09:49:35 +08:00
9d2c453bb0 图片上传流程优化 2021-05-16 09:47:23 +08:00
xxy
9de47ce697 update README.md. 2021-04-25 07:39:56 +08:00
c79974ff77 3.5.2发布 2021-04-24 10:46:59 +08:00
fb0098aef8 作家后台新增作品封片图片修改功能 2021-04-24 10:38:55 +08:00
419d7a971b 优化首页显示(修改周推小说数量) 2021-02-11 18:03:27 +08:00
83eda2a44d 模版更新 2021-02-11 12:25:04 +08:00
3182029bdd 文件压缩 2021-02-11 10:26:48 +08:00
19d4a9960d 使用图片懒加载优化首页加载速度 2021-02-11 09:36:03 +08:00
2603150b33 作家专区的跳转方式改为新标签页跳转 2021-02-11 08:31:27 +08:00
f5e440390b 修改404页面自动跳转首页的时间 2021-02-11 08:27:11 +08:00
91e525ec8e v3.5.1发布 2021-02-05 00:39:25 +08:00
83afb9e6e2 新增内置爬虫源i笔趣阁 2021-02-05 00:17:19 +08:00
153 changed files with 1572 additions and 27189 deletions

View File

@ -262,7 +262,7 @@ novel-plus -- 父工程
**喜欢此项目的可以给我的GitHub和Gitee加个Star支持一下 **
#### 其他安装教程
#### 其他安装教程如果链接打不开可关注公众号获取
##### version>=3.5.0版本

View File

@ -1836,4 +1836,6 @@ INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4900, 1, 235);
INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4888, 1, 234);
delete from sys_menu where menu_id = 202;
delete from sys_menu where menu_id = 202;
INSERT INTO crawl_source(`id`, `source_name`, `crawl_rule`, `source_status`, `create_time`, `update_time`) VALUES (16, 'i笔趣阁', '{\"bookListUrl\":\"http://m.ibiquge.net/xclass/{catId}/{page}.html\",\"catIdRule\":{\"catId1\":\"1\",\"catId2\":\"2\",\"catId3\":\"3\",\"catId4\":\"4\",\"catId5\":\"6\",\"catId6\":\"5\",\"catId7\":\"7\"},\"bookIdPatten\":\"href=\\\"/(\\\\d+_\\\\d+)/\\\"\",\"pagePatten\":\"value=\\\"(\\\\d+)/\\\\d+\\\"\",\"totalPagePatten\":\"value=\\\"\\\\d+/(\\\\d+)\\\"\",\"bookDetailUrl\":\"http://m.ibiquge.net/{bookId}/\",\"bookNamePatten\":\"<span class=\\\"title\\\">([^/]+)</span>\",\"authorNamePatten\":\"<a href=\\\"/author/\\\\d+/\\\">([^/]+)</a>\",\"picUrlPatten\":\"<img src=\\\"([^>]+)\\\"\\\\s+onerror=\\\"this.src=\",\"picUrlPrefix\":\"http://m.ibiquge.net\",\"statusPatten\":\">状态:([^/]+)</li>\",\"bookStatusRule\":{\"连载\":0,\"完结\":1},\"visitCountPatten\":\">点击:(\\\\d+)</li>\",\"descStart\":\"<p class=\\\"review\\\">\",\"descEnd\":\"</p>\",\"bookIndexUrl\":\"http://www.ibiquge.net/{bookId}/\",\"bookIndexStart\":\"正文</dt>\",\"indexIdPatten\":\"<a\\\\s+style=\\\"\\\"\\\\s+href=\\\"/\\\\d+_\\\\d+/(\\\\d+)\\\\.html\\\">[^/]+</a>\",\"indexNamePatten\":\"<a\\\\s+style=\\\"\\\"\\\\s+href=\\\"/\\\\d+_\\\\d+/\\\\d+\\\\.html\\\">([^/]+)</a>\",\"bookContentUrl\":\"http://www.ibiquge.net/{bookId}/{indexId}.html\",\"contentStart\":\"</p>\",\"contentEnd\":\"<div align=\\\"center\\\">\"}', 0, '2021-02-04 21:31:23', '2021-02-04 21:31:23');

View File

@ -5,7 +5,7 @@
<groupId>com.java2nb</groupId>
<artifactId>novel-admin</artifactId>
<version>3.5.0</version>
<version>3.5.4</version>
<packaging>jar</packaging>
<name>novel-admin</name>

View File

@ -75,7 +75,6 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/img/**", "anon");
filterChainDefinitionMap.put("/docs/**", "anon");
filterChainDefinitionMap.put("/layuimini/**", "anon");
filterChainDefinitionMap.put("/druid/**", "anon");
filterChainDefinitionMap.put("/upload/**", "anon");
filterChainDefinitionMap.put("/files/**", "anon");
filterChainDefinitionMap.put("/logout", "logout");

View File

@ -1,19 +1,17 @@
package com.java2nb.novel.controller;
import com.java2nb.common.utils.DateUtils;
import com.java2nb.common.utils.PageBean;
import com.java2nb.common.utils.Query;
import com.java2nb.common.utils.R;
import com.java2nb.novel.domain.AuthorCodeDO;
import com.java2nb.novel.service.*;
import com.java2nb.test.service.OrderService;
import io.swagger.annotations.ApiOperation;
import com.java2nb.novel.service.AuthorService;
import com.java2nb.novel.service.BookService;
import com.java2nb.novel.service.PayService;
import com.java2nb.novel.service.UserService;
import lombok.SneakyThrows;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.SimpleDateFormat;
import java.util.Date;

View File

@ -1,135 +0,0 @@
package com.java2nb.test.controller;
import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import io.swagger.annotations.ApiOperation;
import com.java2nb.test.domain.OrderDO;
import com.java2nb.test.service.OrderService;
import com.java2nb.common.utils.PageBean;
import com.java2nb.common.utils.Query;
import com.java2nb.common.utils.R;
/**
* 付呗-订单信息表
*
* @author xiongxy
* @email 1179705413@qq.com
* @date 2019-11-25 11:57:16
*/
@Controller
@RequestMapping("/test/order")
public class OrderController {
@Autowired
private OrderService orderService;
@GetMapping()
@RequiresPermissions("test:order:order")
String Order() {
return "test/order/order";
}
@ApiOperation(value = "获取付呗-订单信息表列表", notes = "获取付呗-订单信息表列表")
@ResponseBody
@GetMapping("/list")
@RequiresPermissions("test:order:order")
public R list(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
List<OrderDO> orderList = orderService.list(query);
int total = orderService.count(query);
PageBean pageBean = new PageBean(orderList, total);
return R.ok().put("data", pageBean);
}
@ApiOperation(value = "新增付呗-订单信息表页面", notes = "新增付呗-订单信息表页面")
@GetMapping("/add")
@RequiresPermissions("test:order:add")
String add() {
return "test/order/add";
}
@ApiOperation(value = "修改付呗-订单信息表页面", notes = "修改付呗-订单信息表页面")
@GetMapping("/edit/{id}")
@RequiresPermissions("test:order:edit")
String edit(@PathVariable("id") Long id, Model model) {
OrderDO order = orderService.get(id);
model.addAttribute("order", order);
return "test/order/edit";
}
@ApiOperation(value = "查看付呗-订单信息表页面", notes = "查看付呗-订单信息表页面")
@GetMapping("/detail/{id}")
@RequiresPermissions("test:order:detail")
String detail(@PathVariable("id") Long id, Model model) {
OrderDO order = orderService.get(id);
model.addAttribute("order", order);
return "test/order/detail";
}
/**
* 保存
*/
@ApiOperation(value = "新增付呗-订单信息表", notes = "新增付呗-订单信息表")
@ResponseBody
@PostMapping("/save")
@RequiresPermissions("test:order:add")
public R save( OrderDO order) {
if (orderService.save(order) > 0) {
return R.ok();
}
return R.error();
}
/**
* 修改
*/
@ApiOperation(value = "修改付呗-订单信息表", notes = "修改付呗-订单信息表")
@ResponseBody
@RequestMapping("/update")
@RequiresPermissions("test:order:edit")
public R update( OrderDO order) {
orderService.update(order);
return R.ok();
}
/**
* 删除
*/
@ApiOperation(value = "删除付呗-订单信息表", notes = "删除付呗-订单信息表")
@PostMapping("/remove")
@ResponseBody
@RequiresPermissions("test:order:remove")
public R remove( Long id) {
if (orderService.remove(id) > 0) {
return R.ok();
}
return R.error();
}
/**
* 删除
*/
@ApiOperation(value = "批量删除付呗-订单信息表", notes = "批量删除付呗-订单信息表")
@PostMapping("/batchRemove")
@ResponseBody
@RequiresPermissions("test:order:batchRemove")
public R remove(@RequestParam("ids[]") Long[] ids) {
orderService.batchRemove(ids);
return R.ok();
}
}

View File

@ -1,32 +0,0 @@
package com.java2nb.test.dao;
import com.java2nb.test.domain.OrderDO;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
/**
* 付呗-订单信息表
* @author xiongxy
* @email 1179705413@qq.com
* @date 2019-11-25 11:57:16
*/
@Mapper
public interface OrderDao {
OrderDO get(Long id);
List<OrderDO> list(Map<String,Object> map);
int count(Map<String,Object> map);
int save(OrderDO order);
int update(OrderDO order);
int remove(Long id);
int batchRemove(Long[] ids);
}

View File

@ -1,475 +0,0 @@
package com.java2nb.test.domain;
import java.io.Serializable;
import java.math.BigDecimal;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.java2nb.common.jsonserializer.LongToStringSerializer;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 付呗-订单信息表
*
* @author xiongxy
* @email 1179705413@qq.com
* @date 2019-11-25 11:57:16
*/
public class OrderDO implements Serializable {
private static final long serialVersionUID = 1L;
//主键
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
//所以通过序列化成字符串来解决
@JsonSerialize(using = LongToStringSerializer.class)
private Long id;
//付呗商户号
private String fbMerchantCode;
//第三方商户的订单号
private String merchantOrderSn;
//付呗订单号
private String orderSn;
//平台方订单号
private String platformOrderNo;
//商户单号
private String tradeNo;
//订单状态1未支付2支付成功3支付失败4支付取消
private Integer orderState;
//蜂鸟优惠卷抵扣
private Double fnCoupon;
//红包抵扣
private BigDecimal redPacket;
//实收金额(元)
private BigDecimal totalFee;
//订单金额
private BigDecimal orderPrice;
//手续费(元)
private BigDecimal fee;
//对商品或交易的描述
private String body;
//附加数据
private String attach;
//付呗系统的门店id
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
//所以通过序列化成字符串来解决
@JsonSerialize(using = LongToStringSerializer.class)
private Long storeId;
//付呗系统的收银员id
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
//所以通过序列化成字符串来解决
@JsonSerialize(using = LongToStringSerializer.class)
private Long cashierId;
//设备终端号
private String deviceNo;
//微信顾客支付授权的“open_id”或者支付宝顾客的“buyer_user_id”
private String userId;
//支付宝顾客的账号
private String userLogonId;
//交易成功的时间
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date payTime;
//支付通道:1微信、2支付宝、3银联
private Integer payChannel;
//免充值代金券金额(元)
private BigDecimal noCashCouponFee;
//预充值代金券金额(元)
private BigDecimal cashCouponFee;
//顾客实际支付金额(元)
private BigDecimal cashFee;
//签名
private String sign;
//其它选项
private String options;
//创建时间
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
//推送时间
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date pushTime;
//推送IP
private String pushIp;
//商户id
private BigDecimal mchtId;
//QR编号
private String sn;
/**
* 设置:主键
*/
public void setId(Long id) {
this.id = id;
}
/**
* 获取:主键
*/
public Long getId() {
return id;
}
/**
* 设置:付呗商户号
*/
public void setFbMerchantCode(String fbMerchantCode) {
this.fbMerchantCode = fbMerchantCode;
}
/**
* 获取:付呗商户号
*/
public String getFbMerchantCode() {
return fbMerchantCode;
}
/**
* 设置:第三方商户的订单号
*/
public void setMerchantOrderSn(String merchantOrderSn) {
this.merchantOrderSn = merchantOrderSn;
}
/**
* 获取:第三方商户的订单号
*/
public String getMerchantOrderSn() {
return merchantOrderSn;
}
/**
* 设置:付呗订单号
*/
public void setOrderSn(String orderSn) {
this.orderSn = orderSn;
}
/**
* 获取:付呗订单号
*/
public String getOrderSn() {
return orderSn;
}
/**
* 设置:平台方订单号
*/
public void setPlatformOrderNo(String platformOrderNo) {
this.platformOrderNo = platformOrderNo;
}
/**
* 获取:平台方订单号
*/
public String getPlatformOrderNo() {
return platformOrderNo;
}
/**
* 设置:商户单号
*/
public void setTradeNo(String tradeNo) {
this.tradeNo = tradeNo;
}
/**
* 获取:商户单号
*/
public String getTradeNo() {
return tradeNo;
}
/**
* 设置订单状态1未支付2支付成功3支付失败4支付取消
*/
public void setOrderState(Integer orderState) {
this.orderState = orderState;
}
/**
* 获取订单状态1未支付2支付成功3支付失败4支付取消
*/
public Integer getOrderState() {
return orderState;
}
/**
* 设置:蜂鸟优惠卷抵扣
*/
public void setFnCoupon(Double fnCoupon) {
this.fnCoupon = fnCoupon;
}
/**
* 获取:蜂鸟优惠卷抵扣
*/
public Double getFnCoupon() {
return fnCoupon;
}
/**
* 设置:红包抵扣
*/
public void setRedPacket(BigDecimal redPacket) {
this.redPacket = redPacket;
}
/**
* 获取:红包抵扣
*/
public BigDecimal getRedPacket() {
return redPacket;
}
/**
* 设置:实收金额(元)
*/
public void setTotalFee(BigDecimal totalFee) {
this.totalFee = totalFee;
}
/**
* 获取:实收金额(元)
*/
public BigDecimal getTotalFee() {
return totalFee;
}
/**
* 设置:订单金额
*/
public void setOrderPrice(BigDecimal orderPrice) {
this.orderPrice = orderPrice;
}
/**
* 获取:订单金额
*/
public BigDecimal getOrderPrice() {
return orderPrice;
}
/**
* 设置:手续费(元)
*/
public void setFee(BigDecimal fee) {
this.fee = fee;
}
/**
* 获取:手续费(元)
*/
public BigDecimal getFee() {
return fee;
}
/**
* 设置:对商品或交易的描述
*/
public void setBody(String body) {
this.body = body;
}
/**
* 获取:对商品或交易的描述
*/
public String getBody() {
return body;
}
/**
* 设置:附加数据
*/
public void setAttach(String attach) {
this.attach = attach;
}
/**
* 获取:附加数据
*/
public String getAttach() {
return attach;
}
/**
* 设置付呗系统的门店id
*/
public void setStoreId(Long storeId) {
this.storeId = storeId;
}
/**
* 获取付呗系统的门店id
*/
public Long getStoreId() {
return storeId;
}
/**
* 设置付呗系统的收银员id
*/
public void setCashierId(Long cashierId) {
this.cashierId = cashierId;
}
/**
* 获取付呗系统的收银员id
*/
public Long getCashierId() {
return cashierId;
}
/**
* 设置:设备终端号
*/
public void setDeviceNo(String deviceNo) {
this.deviceNo = deviceNo;
}
/**
* 获取:设备终端号
*/
public String getDeviceNo() {
return deviceNo;
}
/**
* 设置微信顾客支付授权的“open_id”或者支付宝顾客的“buyer_user_id”
*/
public void setUserId(String userId) {
this.userId = userId;
}
/**
* 获取微信顾客支付授权的“open_id”或者支付宝顾客的“buyer_user_id”
*/
public String getUserId() {
return userId;
}
/**
* 设置:支付宝顾客的账号
*/
public void setUserLogonId(String userLogonId) {
this.userLogonId = userLogonId;
}
/**
* 获取:支付宝顾客的账号
*/
public String getUserLogonId() {
return userLogonId;
}
/**
* 设置:交易成功的时间
*/
public void setPayTime(Date payTime) {
this.payTime = payTime;
}
/**
* 获取:交易成功的时间
*/
public Date getPayTime() {
return payTime;
}
/**
* 设置:支付通道:1微信、2支付宝、3银联
*/
public void setPayChannel(Integer payChannel) {
this.payChannel = payChannel;
}
/**
* 获取:支付通道:1微信、2支付宝、3银联
*/
public Integer getPayChannel() {
return payChannel;
}
/**
* 设置:免充值代金券金额(元)
*/
public void setNoCashCouponFee(BigDecimal noCashCouponFee) {
this.noCashCouponFee = noCashCouponFee;
}
/**
* 获取:免充值代金券金额(元)
*/
public BigDecimal getNoCashCouponFee() {
return noCashCouponFee;
}
/**
* 设置:预充值代金券金额(元)
*/
public void setCashCouponFee(BigDecimal cashCouponFee) {
this.cashCouponFee = cashCouponFee;
}
/**
* 获取:预充值代金券金额(元)
*/
public BigDecimal getCashCouponFee() {
return cashCouponFee;
}
/**
* 设置:顾客实际支付金额(元)
*/
public void setCashFee(BigDecimal cashFee) {
this.cashFee = cashFee;
}
/**
* 获取:顾客实际支付金额(元)
*/
public BigDecimal getCashFee() {
return cashFee;
}
/**
* 设置:签名
*/
public void setSign(String sign) {
this.sign = sign;
}
/**
* 获取:签名
*/
public String getSign() {
return sign;
}
/**
* 设置:其它选项
*/
public void setOptions(String options) {
this.options = options;
}
/**
* 获取:其它选项
*/
public String getOptions() {
return options;
}
/**
* 设置:创建时间
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 获取:创建时间
*/
public Date getCreateTime() {
return createTime;
}
/**
* 设置:推送时间
*/
public void setPushTime(Date pushTime) {
this.pushTime = pushTime;
}
/**
* 获取:推送时间
*/
public Date getPushTime() {
return pushTime;
}
/**
* 设置推送IP
*/
public void setPushIp(String pushIp) {
this.pushIp = pushIp;
}
/**
* 获取推送IP
*/
public String getPushIp() {
return pushIp;
}
/**
* 设置商户id
*/
public void setMchtId(BigDecimal mchtId) {
this.mchtId = mchtId;
}
/**
* 获取商户id
*/
public BigDecimal getMchtId() {
return mchtId;
}
/**
* 设置QR编号
*/
public void setSn(String sn) {
this.sn = sn;
}
/**
* 获取QR编号
*/
public String getSn() {
return sn;
}
}

View File

@ -1,30 +0,0 @@
package com.java2nb.test.service;
import com.java2nb.test.domain.OrderDO;
import java.util.List;
import java.util.Map;
/**
* 付呗-订单信息表
*
* @author xiongxy
* @email 1179705413@qq.com
* @date 2019-11-25 11:57:16
*/
public interface OrderService {
OrderDO get(Long id);
List<OrderDO> list(Map<String, Object> map);
int count(Map<String, Object> map);
int save(OrderDO order);
int update(OrderDO order);
int remove(Long id);
int batchRemove(Long[] ids);
}

View File

@ -1,55 +0,0 @@
package com.java2nb.test.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import com.java2nb.test.dao.OrderDao;
import com.java2nb.test.domain.OrderDO;
import com.java2nb.test.service.OrderService;
@Service
public class OrderServiceImpl implements OrderService {
@Autowired
private OrderDao orderDao;
@Override
public OrderDO get(Long id){
return orderDao.get(id);
}
@Override
public List<OrderDO> list(Map<String, Object> map){
return orderDao.list(map);
}
@Override
public int count(Map<String, Object> map){
return orderDao.count(map);
}
@Override
public int save(OrderDO order){
return orderDao.save(order);
}
@Override
public int update(OrderDO order){
return orderDao.update(order);
}
@Override
public int remove(Long id){
return orderDao.remove(id);
}
@Override
public int batchRemove(Long[] ids){
return orderDao.batchRemove(ids);
}
}

View File

@ -10,7 +10,7 @@ spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: test123456
#password:

View File

@ -10,7 +10,7 @@ spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: test123456
#password:

View File

@ -1,283 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.java2nb.test.dao.OrderDao">
<select id="get" resultType="com.java2nb.test.domain.OrderDO">
select `id`,`fb_merchant_code`,`merchant_order_sn`,`order_sn`,`platform_order_no`,`trade_no`,`order_state`,`fn_coupon`,`red_packet`,`total_fee`,`order_price`,`fee`,`body`,`attach`,`store_id`,`cashier_id`,`device_no`,`user_id`,`user_logon_id`,`pay_time`,`pay_channel`,`no_cash_coupon_fee`,`cash_coupon_fee`,`cash_fee`,`sign`,`options`,`create_time`,`push_time`,`push_ip`,`mcht_id`,`sn` from fb_order where id = #{value}
</select>
<select id="list" resultType="com.java2nb.test.domain.OrderDO">
select `id`,`fb_merchant_code`,`merchant_order_sn`,`order_sn`,`platform_order_no`,`trade_no`,`order_state`,`fn_coupon`,`red_packet`,`total_fee`,`order_price`,`fee`,`body`,`attach`,`store_id`,`cashier_id`,`device_no`,`user_id`,`user_logon_id`,`pay_time`,`pay_channel`,`no_cash_coupon_fee`,`cash_coupon_fee`,`cash_fee`,`sign`,`options`,`create_time`,`push_time`,`push_ip`,`mcht_id`,`sn` from fb_order
<where>
<if test="id != null and id != ''"> and id = #{id} </if>
<if test="fbMerchantCode != null and fbMerchantCode != ''"> and fb_merchant_code = #{fbMerchantCode} </if>
<if test="merchantOrderSn != null and merchantOrderSn != ''"> and merchant_order_sn = #{merchantOrderSn} </if>
<if test="orderSn != null and orderSn != ''"> and order_sn = #{orderSn} </if>
<if test="platformOrderNo != null and platformOrderNo != ''"> and platform_order_no = #{platformOrderNo} </if>
<if test="tradeNo != null and tradeNo != ''"> and trade_no = #{tradeNo} </if>
<if test="orderState != null and orderState != ''"> and order_state = #{orderState} </if>
<if test="fnCoupon != null and fnCoupon != ''"> and fn_coupon = #{fnCoupon} </if>
<if test="redPacket != null and redPacket != ''"> and red_packet = #{redPacket} </if>
<if test="totalFee != null and totalFee != ''"> and total_fee = #{totalFee} </if>
<if test="orderPrice != null and orderPrice != ''"> and order_price = #{orderPrice} </if>
<if test="fee != null and fee != ''"> and fee = #{fee} </if>
<if test="body != null and body != ''"> and body = #{body} </if>
<if test="attach != null and attach != ''"> and attach = #{attach} </if>
<if test="storeId != null and storeId != ''"> and store_id = #{storeId} </if>
<if test="cashierId != null and cashierId != ''"> and cashier_id = #{cashierId} </if>
<if test="deviceNo != null and deviceNo != ''"> and device_no = #{deviceNo} </if>
<if test="userId != null and userId != ''"> and user_id = #{userId} </if>
<if test="userLogonId != null and userLogonId != ''"> and user_logon_id = #{userLogonId} </if>
<if test="payTime != null and payTime != ''"> and pay_time = #{payTime} </if>
<if test="payChannel != null and payChannel != ''"> and pay_channel = #{payChannel} </if>
<if test="noCashCouponFee != null and noCashCouponFee != ''"> and no_cash_coupon_fee = #{noCashCouponFee} </if>
<if test="cashCouponFee != null and cashCouponFee != ''"> and cash_coupon_fee = #{cashCouponFee} </if>
<if test="cashFee != null and cashFee != ''"> and cash_fee = #{cashFee} </if>
<if test="sign != null and sign != ''"> and sign = #{sign} </if>
<if test="options != null and options != ''"> and options = #{options} </if>
<if test="createTime != null and createTime != ''"> and create_time = #{createTime} </if>
<if test="pushTime != null and pushTime != ''"> and push_time = #{pushTime} </if>
<if test="pushIp != null and pushIp != ''"> and push_ip = #{pushIp} </if>
<if test="mchtId != null and mchtId != ''"> and mcht_id = #{mchtId} </if>
<if test="sn != null and sn != ''"> and sn = #{sn} </if>
</where>
<choose>
<when test="sort != null and sort.trim() != ''">
order by ${sort} ${order}
</when>
<otherwise>
order by id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="count" resultType="int">
select count(*) from fb_order
<where>
<if test="id != null and id != ''"> and id = #{id} </if>
<if test="fbMerchantCode != null and fbMerchantCode != ''"> and fb_merchant_code = #{fbMerchantCode} </if>
<if test="merchantOrderSn != null and merchantOrderSn != ''"> and merchant_order_sn = #{merchantOrderSn} </if>
<if test="orderSn != null and orderSn != ''"> and order_sn = #{orderSn} </if>
<if test="platformOrderNo != null and platformOrderNo != ''"> and platform_order_no = #{platformOrderNo} </if>
<if test="tradeNo != null and tradeNo != ''"> and trade_no = #{tradeNo} </if>
<if test="orderState != null and orderState != ''"> and order_state = #{orderState} </if>
<if test="fnCoupon != null and fnCoupon != ''"> and fn_coupon = #{fnCoupon} </if>
<if test="redPacket != null and redPacket != ''"> and red_packet = #{redPacket} </if>
<if test="totalFee != null and totalFee != ''"> and total_fee = #{totalFee} </if>
<if test="orderPrice != null and orderPrice != ''"> and order_price = #{orderPrice} </if>
<if test="fee != null and fee != ''"> and fee = #{fee} </if>
<if test="body != null and body != ''"> and body = #{body} </if>
<if test="attach != null and attach != ''"> and attach = #{attach} </if>
<if test="storeId != null and storeId != ''"> and store_id = #{storeId} </if>
<if test="cashierId != null and cashierId != ''"> and cashier_id = #{cashierId} </if>
<if test="deviceNo != null and deviceNo != ''"> and device_no = #{deviceNo} </if>
<if test="userId != null and userId != ''"> and user_id = #{userId} </if>
<if test="userLogonId != null and userLogonId != ''"> and user_logon_id = #{userLogonId} </if>
<if test="payTime != null and payTime != ''"> and pay_time = #{payTime} </if>
<if test="payChannel != null and payChannel != ''"> and pay_channel = #{payChannel} </if>
<if test="noCashCouponFee != null and noCashCouponFee != ''"> and no_cash_coupon_fee = #{noCashCouponFee} </if>
<if test="cashCouponFee != null and cashCouponFee != ''"> and cash_coupon_fee = #{cashCouponFee} </if>
<if test="cashFee != null and cashFee != ''"> and cash_fee = #{cashFee} </if>
<if test="sign != null and sign != ''"> and sign = #{sign} </if>
<if test="options != null and options != ''"> and options = #{options} </if>
<if test="createTime != null and createTime != ''"> and create_time = #{createTime} </if>
<if test="pushTime != null and pushTime != ''"> and push_time = #{pushTime} </if>
<if test="pushIp != null and pushIp != ''"> and push_ip = #{pushIp} </if>
<if test="mchtId != null and mchtId != ''"> and mcht_id = #{mchtId} </if>
<if test="sn != null and sn != ''"> and sn = #{sn} </if>
</where>
</select>
<insert id="save" parameterType="com.java2nb.test.domain.OrderDO" useGeneratedKeys="true" keyProperty="id">
insert into fb_order
(
`fb_merchant_code`,
`merchant_order_sn`,
`order_sn`,
`platform_order_no`,
`trade_no`,
`order_state`,
`fn_coupon`,
`red_packet`,
`total_fee`,
`order_price`,
`fee`,
`body`,
`attach`,
`store_id`,
`cashier_id`,
`device_no`,
`user_id`,
`user_logon_id`,
`pay_time`,
`pay_channel`,
`no_cash_coupon_fee`,
`cash_coupon_fee`,
`cash_fee`,
`sign`,
`options`,
`create_time`,
`push_time`,
`push_ip`,
`mcht_id`,
`sn`
)
values
(
#{fbMerchantCode},
#{merchantOrderSn},
#{orderSn},
#{platformOrderNo},
#{tradeNo},
#{orderState},
#{fnCoupon},
#{redPacket},
#{totalFee},
#{orderPrice},
#{fee},
#{body},
#{attach},
#{storeId},
#{cashierId},
#{deviceNo},
#{userId},
#{userLogonId},
#{payTime},
#{payChannel},
#{noCashCouponFee},
#{cashCouponFee},
#{cashFee},
#{sign},
#{options},
#{createTime},
#{pushTime},
#{pushIp},
#{mchtId},
#{sn}
)
</insert>
<insert id="saveSelective" parameterType="com.java2nb.test.domain.OrderDO" useGeneratedKeys="true" keyProperty="id">
insert into fb_order
(
<if test="id != null"> `id`, </if>
<if test="fbMerchantCode != null"> `fb_merchant_code`, </if>
<if test="merchantOrderSn != null"> `merchant_order_sn`, </if>
<if test="orderSn != null"> `order_sn`, </if>
<if test="platformOrderNo != null"> `platform_order_no`, </if>
<if test="tradeNo != null"> `trade_no`, </if>
<if test="orderState != null"> `order_state`, </if>
<if test="fnCoupon != null"> `fn_coupon`, </if>
<if test="redPacket != null"> `red_packet`, </if>
<if test="totalFee != null"> `total_fee`, </if>
<if test="orderPrice != null"> `order_price`, </if>
<if test="fee != null"> `fee`, </if>
<if test="body != null"> `body`, </if>
<if test="attach != null"> `attach`, </if>
<if test="storeId != null"> `store_id`, </if>
<if test="cashierId != null"> `cashier_id`, </if>
<if test="deviceNo != null"> `device_no`, </if>
<if test="userId != null"> `user_id`, </if>
<if test="userLogonId != null"> `user_logon_id`, </if>
<if test="payTime != null"> `pay_time`, </if>
<if test="payChannel != null"> `pay_channel`, </if>
<if test="noCashCouponFee != null"> `no_cash_coupon_fee`, </if>
<if test="cashCouponFee != null"> `cash_coupon_fee`, </if>
<if test="cashFee != null"> `cash_fee`, </if>
<if test="sign != null"> `sign`, </if>
<if test="options != null"> `options`, </if>
<if test="createTime != null"> `create_time`, </if>
<if test="pushTime != null"> `push_time`, </if>
<if test="pushIp != null"> `push_ip`, </if>
<if test="mchtId != null"> `mcht_id`, </if>
<if test="sn != null"> `sn` </if>
)
values
(
<if test="id != null"> #{id}, </if>
<if test="fbMerchantCode != null"> #{fbMerchantCode}, </if>
<if test="merchantOrderSn != null"> #{merchantOrderSn}, </if>
<if test="orderSn != null"> #{orderSn}, </if>
<if test="platformOrderNo != null"> #{platformOrderNo}, </if>
<if test="tradeNo != null"> #{tradeNo}, </if>
<if test="orderState != null"> #{orderState}, </if>
<if test="fnCoupon != null"> #{fnCoupon}, </if>
<if test="redPacket != null"> #{redPacket}, </if>
<if test="totalFee != null"> #{totalFee}, </if>
<if test="orderPrice != null"> #{orderPrice}, </if>
<if test="fee != null"> #{fee}, </if>
<if test="body != null"> #{body}, </if>
<if test="attach != null"> #{attach}, </if>
<if test="storeId != null"> #{storeId}, </if>
<if test="cashierId != null"> #{cashierId}, </if>
<if test="deviceNo != null"> #{deviceNo}, </if>
<if test="userId != null"> #{userId}, </if>
<if test="userLogonId != null"> #{userLogonId}, </if>
<if test="payTime != null"> #{payTime}, </if>
<if test="payChannel != null"> #{payChannel}, </if>
<if test="noCashCouponFee != null"> #{noCashCouponFee}, </if>
<if test="cashCouponFee != null"> #{cashCouponFee}, </if>
<if test="cashFee != null"> #{cashFee}, </if>
<if test="sign != null"> #{sign}, </if>
<if test="options != null"> #{options}, </if>
<if test="createTime != null"> #{createTime}, </if>
<if test="pushTime != null"> #{pushTime}, </if>
<if test="pushIp != null"> #{pushIp}, </if>
<if test="mchtId != null"> #{mchtId}, </if>
<if test="sn != null"> #{sn} </if>
)
</insert>
<update id="update" parameterType="com.java2nb.test.domain.OrderDO">
update fb_order
<set>
<if test="fbMerchantCode != null">`fb_merchant_code` = #{fbMerchantCode}, </if>
<if test="merchantOrderSn != null">`merchant_order_sn` = #{merchantOrderSn}, </if>
<if test="orderSn != null">`order_sn` = #{orderSn}, </if>
<if test="platformOrderNo != null">`platform_order_no` = #{platformOrderNo}, </if>
<if test="tradeNo != null">`trade_no` = #{tradeNo}, </if>
<if test="orderState != null">`order_state` = #{orderState}, </if>
<if test="fnCoupon != null">`fn_coupon` = #{fnCoupon}, </if>
<if test="redPacket != null">`red_packet` = #{redPacket}, </if>
<if test="totalFee != null">`total_fee` = #{totalFee}, </if>
<if test="orderPrice != null">`order_price` = #{orderPrice}, </if>
<if test="fee != null">`fee` = #{fee}, </if>
<if test="body != null">`body` = #{body}, </if>
<if test="attach != null">`attach` = #{attach}, </if>
<if test="storeId != null">`store_id` = #{storeId}, </if>
<if test="cashierId != null">`cashier_id` = #{cashierId}, </if>
<if test="deviceNo != null">`device_no` = #{deviceNo}, </if>
<if test="userId != null">`user_id` = #{userId}, </if>
<if test="userLogonId != null">`user_logon_id` = #{userLogonId}, </if>
<if test="payTime != null">`pay_time` = #{payTime}, </if>
<if test="payChannel != null">`pay_channel` = #{payChannel}, </if>
<if test="noCashCouponFee != null">`no_cash_coupon_fee` = #{noCashCouponFee}, </if>
<if test="cashCouponFee != null">`cash_coupon_fee` = #{cashCouponFee}, </if>
<if test="cashFee != null">`cash_fee` = #{cashFee}, </if>
<if test="sign != null">`sign` = #{sign}, </if>
<if test="options != null">`options` = #{options}, </if>
<if test="createTime != null">`create_time` = #{createTime}, </if>
<if test="pushTime != null">`push_time` = #{pushTime}, </if>
<if test="pushIp != null">`push_ip` = #{pushIp}, </if>
<if test="mchtId != null">`mcht_id` = #{mchtId}, </if>
<if test="sn != null">`sn` = #{sn}</if>
</set>
where id = #{id}
</update>
<delete id="remove">
delete from fb_order where id = #{value}
</delete>
<delete id="batchRemove">
delete from fb_order where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -1,18 +0,0 @@
-- 菜单SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('1', '付呗-订单信息表', 'test/order', 'test:order:order', '1', 'fa', '6');
-- 按钮父菜单ID
set @parentId = @@identity;
-- 菜单对应按钮SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '查看', null, 'test:order:detail', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '新增', null, 'test:order:add', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '修改', null, 'test:order:edit', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, 'test:order:remove', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '批量删除', null, 'test:order:batchRemove', '2', null, '6';

View File

@ -1,25 +0,0 @@
package com.java2nb.testDemo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.RestController;
@RestController()
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestDemo {
@Autowired
RedisTemplate redisTemplate;
@Test
public void test() {
redisTemplate.opsForValue().set("a", "b");
System.out.println(redisTemplate.opsForValue().get("a"));
}
;
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>novel</artifactId>
<groupId>com.java2nb</groupId>
<version>3.5.1</version>
<version>3.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -8,8 +8,9 @@ import java.io.Serializable;
/**
* 自定义响应结构
* @author 11797
*
* @param <T>
* @author 11797
*/
@Data
public class ResultBean<T> implements Serializable {
@ -19,20 +20,20 @@ public class ResultBean<T> implements Serializable {
/**
* 响应消息
* */
*/
private String msg = ResponseStatus.OK.getMsg();
/**
* 响应中的数据
* */
*/
private T data;
private ResultBean() {
}
private ResultBean(ResponseStatus ResponseStatus) {
this.code = ResponseStatus.getCode();;
this.msg = ResponseStatus.getMsg();
private ResultBean(ResponseStatus responseStatus) {
this.code = responseStatus.getCode();
this.msg = responseStatus.getMsg();
}
private ResultBean(T data) {
@ -40,34 +41,33 @@ public class ResultBean<T> implements Serializable {
}
/**
* 业务处理成功,无数据返回
* */
public static ResultBean ok() {
return new ResultBean();
*/
public static ResultBean<Void> ok() {
return new ResultBean<>();
}
/**
* 业务处理成功,有数据返回
* */
public static <T> ResultBean ok(T data) {
return new ResultBean(data);
*/
public static <T> ResultBean<T> ok(T data) {
return new ResultBean<>(data);
}
/**
* 业务处理失败
* */
public static ResultBean fail(ResponseStatus ResponseStatus) {
return new ResultBean(ResponseStatus);
*/
public static ResultBean<Void> fail(ResponseStatus responseStatus) {
return new ResultBean<>(responseStatus);
}
/**
* 系统错误
* */
public static ResultBean error() {
return new ResultBean(ResponseStatus.ERROR);
*/
public static ResultBean<Void> error() {
return new ResultBean<>(ResponseStatus.ERROR);
}
}

View File

@ -68,6 +68,12 @@ public enum ResponseStatus {
* */
ES_SEARCH_FAIL(9001,"搜索引擎查询错误!"),
/**
* 文件相关错误
* */
FILE_DIR_MAKE_FAIL(10001,"目录创建失败"),
FILE_NOT_IMAGE(10002,"请上传图片类型的文件"),
FILE_SIZE_LIMIT(10003,"文件大小超出限制"),
/**
* 其他通用错误

View File

@ -1,6 +1,7 @@
package com.java2nb.novel.core.utils;
import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.Charsets;
import org.apache.http.client.utils.DateUtils;
@ -11,6 +12,7 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.Date;
import java.util.Objects;
@ -19,13 +21,14 @@ import java.util.Objects;
* 文件操作工具类
* @author 11797
*/
@UtilityClass
@Slf4j
public class FileUtil {
/**
* 网络图片转本地
* */
public static String network2Local(String picSrc,String picSavePath,String visitPrefix) {
public String network2Local(String picSrc,String picSavePath,String visitPrefix) {
InputStream input = null;
OutputStream out = null;
try {
@ -82,5 +85,21 @@ public class FileUtil {
}
/**
* 判断文件是否为图片
* @param file 需要判断的文件
* @return true:是图片false:不是图片
* */
@SneakyThrows
public boolean isImage(File file){
BufferedImage bi = ImageIO.read(file);
return bi != null;
}
}

View File

@ -11,6 +11,11 @@ spring:
generator:
write-numbers-as-strings: true
#上传文件的最大值1M
servlet:
multipart:
max-file-size: 1048576
#缓存类型ehcache(默认)redis
cache:
type: ehcache
@ -26,3 +31,5 @@ logging:
config: classpath:logback-boot.xml

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>novel</artifactId>
<groupId>com.java2nb</groupId>
<version>3.5.1</version>
<version>3.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>novel</artifactId>
<groupId>com.java2nb</groupId>
<version>3.5.1</version>
<version>3.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -160,6 +160,17 @@ public class AuthorController extends BaseController{
return ResultBean.ok();
}
/**
* 修改小说封面
*/
@PostMapping("updateBookPic")
public ResultBean updateBookPic(@RequestParam("bookId") Long bookId,@RequestParam("bookPic") String bookPic,HttpServletRequest request) {
Author author = checkAuthor(request);
bookService.updateBookPic(bookId,bookPic, author.getId());
return ResultBean.ok();
}
/**
* 作家日收入统计数据分页列表查询
* */

View File

@ -2,28 +2,23 @@ package com.java2nb.novel.controller;
import com.java2nb.novel.core.bean.ResultBean;
import com.java2nb.novel.core.cache.CacheService;
import com.java2nb.novel.core.enums.ResponseStatus;
import com.java2nb.novel.core.exception.BusinessException;
import com.java2nb.novel.core.utils.Constants;
import com.java2nb.novel.core.utils.FileUtil;
import com.java2nb.novel.core.utils.RandomValidateCodeUtil;
import com.java2nb.novel.core.utils.RestTemplateUtil;
import com.java2nb.novel.core.utils.UUIDUtil;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.Charsets;
import org.apache.http.client.utils.DateUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.*;
import java.util.Date;
import java.util.Objects;
@ -63,29 +58,35 @@ public class FileController {
}
/**
* 文件上传
* 图片上传
* @return
*/
@SneakyThrows
@ResponseBody
@PostMapping("/upload")
ResultBean upload(@RequestParam("file") MultipartFile file) {
@PostMapping("/picUpload")
ResultBean<String> upload(@RequestParam("file") MultipartFile file) {
Date currentDate = new Date();
try {
String savePath =
Constants.LOCAL_PIC_PREFIX + DateUtils.formatDate(currentDate, "yyyy") + "/" +
DateUtils.formatDate(currentDate, "MM") + "/" +
DateUtils.formatDate(currentDate, "dd") ;
String oriName = file.getOriginalFilename();
String saveFileName = UUIDUtil.getUUID32() + oriName.substring(oriName.lastIndexOf("."));
File saveFile = new File( picSavePath + savePath, saveFileName);
if (!saveFile.getParentFile().exists()) {
saveFile.getParentFile().mkdirs();
String savePath =
Constants.LOCAL_PIC_PREFIX + DateUtils.formatDate(currentDate, "yyyy") + "/" +
DateUtils.formatDate(currentDate, "MM") + "/" +
DateUtils.formatDate(currentDate, "dd");
String oriName = file.getOriginalFilename();
assert oriName != null;
String saveFileName = UUIDUtil.getUUID32() + oriName.substring(oriName.lastIndexOf("."));
File saveFile = new File(picSavePath + savePath, saveFileName);
if (!saveFile.getParentFile().exists()) {
boolean isSuccess = saveFile.getParentFile().mkdirs();
if(!isSuccess){
throw new BusinessException(ResponseStatus.FILE_DIR_MAKE_FAIL);
}
file.transferTo(saveFile);
return ResultBean.ok(savePath+"/"+saveFileName);
} catch (Exception e) {
log.error(e.getMessage(), e);
return ResultBean.error();
}
file.transferTo(saveFile);
if(!FileUtil.isImage(saveFile)){
//上传的文件不是图片
saveFile.delete();
throw new BusinessException(ResponseStatus.FILE_NOT_IMAGE);
};
return ResultBean.ok(savePath + "/" + saveFileName);
}

View File

@ -55,7 +55,7 @@ public class NovelFilter implements Filter {
userMark = UUIDUtil.getUUID32();
CookieUtil.setCookie(resp,Constants.USER_CLIENT_MARK_KEY,userMark);
}
ThreadLocalUtil.setCientId(userMark);
ThreadLocalUtil.setClientId(userMark);
//根据浏览器类型选择前端模板
String to = req.getParameter("to");
CacheService cacheService = SpringUtil.getBean(CacheService.class);

View File

@ -0,0 +1,20 @@
package com.java2nb.novel.core.serialize;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
public class CommentUserNameSerialize extends JsonSerializer<String> {
@Override
public void serialize(String s, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
if(StringUtils.isNotBlank(s)){
jsonGenerator.writeString(s.substring(0, 4) + "****" + s.substring(s.length() - 3));
}
}
}

View File

@ -29,7 +29,7 @@ public class Constants {
/**
* 首页设置的小说数量
* */
public static final int INDEX_BOOK_SETTING_NUM = 32;
public static final int INDEX_BOOK_SETTING_NUM = 31;
/**
* 累积的最大点击量

View File

@ -41,7 +41,7 @@ public class ThreadLocalUtil {
/**
* 设置当前访问线程的客户端ID
* */
public static void setCientId(String id){
public static void setClientId(String id){
clientId.set(id);
}

View File

@ -14,11 +14,6 @@ import java.util.List;
*/
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
/**
* 假如有有html 代码是自己传来的 需要设定对应的name 不过滤
*/
private static final List<String> noFilterNames = Arrays.asList("content");
/**
* @param request
*/
@ -29,7 +24,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
@Override
public String[] getParameterValues(String name) {
String[] values = super.getParameterValues(name);
if (!noFilterNames.contains(name) && values != null) {
if (values != null) {
int length = values.length;
String[] escapseValues = new String[length];
for (int i = 0; i < length; i++) {

View File

@ -1,6 +1,7 @@
package com.java2nb.novel.page;
import com.java2nb.novel.controller.BaseController;
import com.java2nb.novel.core.bean.PageBean;
import com.java2nb.novel.core.bean.UserDetails;
import com.java2nb.novel.core.utils.ThreadLocalUtil;
import com.java2nb.novel.entity.*;
@ -8,6 +9,7 @@ import com.java2nb.novel.service.AuthorService;
import com.java2nb.novel.service.BookService;
import com.java2nb.novel.service.NewsService;
import com.java2nb.novel.service.UserService;
import com.java2nb.novel.vo.BookCommentVO;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
@ -77,7 +79,8 @@ public class PageController extends BaseController {
* 首页
*/
@RequestMapping(path = {"/", "/index", "/index.html"})
public String index() {
public String index(Model model) {
model.addAttribute("bookMap", bookService.listBookSettingVO());
return ThreadLocalUtil.getTemplateDir() + "index";
}
@ -105,13 +108,42 @@ public class PageController extends BaseController {
@SneakyThrows
@RequestMapping("/book/{bookId}.html")
public String bookDetail(@PathVariable("bookId") Long bookId, Model model) {
Book book = bookService.queryBookDetail(bookId);
model.addAttribute("book", book);
if (book.getLastIndexId() != null) {
//查询首章目录ID
Long firstBookIndexId = bookService.queryFirstBookIndexId(bookId);
model.addAttribute("firstBookIndexId", firstBookIndexId);
}
//加载小说基本信息线程
CompletableFuture<Book> bookCompletableFuture = CompletableFuture.supplyAsync(() -> {
//查询书籍
Book book = bookService.queryBookDetail(bookId);
log.debug("加载小说基本信息线程结束");
return book;
}, threadPoolExecutor);
//加载小说评论列表线程
CompletableFuture<PageBean<BookCommentVO>> bookCommentPageBeanCompletableFuture = CompletableFuture.supplyAsync(() -> {
PageBean<BookCommentVO> bookCommentVOPageBean = bookService.listCommentByPage(null, bookId, 1, 5);
log.debug("加载小说评论列表线程结束");
return bookCommentVOPageBean;
}, threadPoolExecutor);
//加载小说首章信息线程,该线程在加载小说基本信息线程执行完毕后才执行
CompletableFuture<Long> firstBookIndexIdCompletableFuture = bookCompletableFuture.thenApplyAsync((book) -> {
if (book.getLastIndexId() != null) {
//查询首章目录ID
Long firstBookIndexId = bookService.queryFirstBookIndexId(bookId);
log.debug("加载小说基本信息线程结束");
return firstBookIndexId;
}
return null;
}, threadPoolExecutor);
//加载随机推荐小说线程,该线程在加载小说基本信息线程执行完毕后才执行
CompletableFuture<List<Book>> recBookCompletableFuture = bookCompletableFuture.thenApplyAsync((book) -> {
List<Book> books = bookService.listRecBookByCatId(book.getCatId());
log.debug("加载随机推荐小说线程结束");
return books;
}, threadPoolExecutor);
model.addAttribute("book", bookCompletableFuture.get());
model.addAttribute("firstBookIndexId", firstBookIndexIdCompletableFuture.get());
model.addAttribute("recBooks", recBookCompletableFuture.get());
model.addAttribute("bookCommentPageBean", bookCommentPageBeanCompletableFuture.get());
return ThreadLocalUtil.getTemplateDir() + "book/book_detail";
}
@ -135,8 +167,6 @@ public class PageController extends BaseController {
@SneakyThrows
@RequestMapping("/book/{bookId}/{bookIndexId}.html")
public String indexList(@PathVariable("bookId") Long bookId, @PathVariable("bookIndexId") Long bookIndexId, HttpServletRequest request, Model model) {
//加载小说基本信息线程
CompletableFuture<Book> bookCompletableFuture = CompletableFuture.supplyAsync(() -> {
//查询书籍

View File

@ -279,4 +279,12 @@ public interface BookService {
* @param authorId
*/
void updateBookContent( Long indexId, String indexName, String content, Long authorId);
/**
* 修改小说封面
* @param bookId
* @param bookPic
* @param authorId
*/
void updateBookPic(Long bookId, String bookPic, Long authorId);
}

View File

@ -126,9 +126,9 @@ public class BookServiceImpl implements BookService {
type = 0;
} else if (i < 14) {
type = 1;
} else if (i < 20) {
} else if (i < 19) {
type = 2;
} else if (i < 26) {
} else if (i < 25) {
type = 3;
} else {
type = 4;
@ -830,5 +830,18 @@ public class BookServiceImpl implements BookService {
}
}
@Override
public void updateBookPic(Long bookId, String bookPic, Long authorId) {
bookMapper.update(update(book)
.set(picUrl)
.equalTo(bookPic)
.set(updateTime)
.equalTo(new Date())
.where(id, isEqualTo(bookId))
.and(BookDynamicSqlSupport.authorId, isEqualTo(authorId))
.build()
.render(RenderingStrategies.MYBATIS3));
}
}

View File

@ -1,6 +1,8 @@
package com.java2nb.novel.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.java2nb.novel.core.serialize.CommentUserNameSerialize;
import com.java2nb.novel.entity.BookComment;
import lombok.Data;
@ -13,6 +15,7 @@ import java.util.Date;
@Data
public class BookCommentVO extends BookComment {
@JsonSerialize(using = CommentUserNameSerialize.class)
private String createUserName;
private String createUserPhoto;

View File

@ -48,7 +48,7 @@ xss:
# 排除链接多个用逗号分隔
excludes: /system/notice/*
# 匹配链接 多个用逗号分隔
urlPatterns: /book/addBookComment,/user/addFeedBack,/author/addBook,/author/addBookContent,/author/register.html
urlPatterns: /book/addBookComment,/user/addFeedBack,/author/addBook,/author/addBookContent,/author/updateBookContent,/author/register.html
author:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -124,4 +124,36 @@ String.prototype.isNickName = function () {
function logout() {
$.cookie('Authorization', null,{ path: '/' });
location.reload();
}
}
function isImg(str) {
return !str.search("[.]+(jpg|jpeg|swf|gif|png|JPG|JPEG|SWF|GIF|PNG)$");
}
//校验图片上传
function checkPicUpload(file){
if(!isImg(file.value.substr(file.value.lastIndexOf(".")))){
layer.alert('只能上传图片格式的文件');
return false;
}
var fileSize = 0;
var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
if (isIE && !file.files) {
var filePath = file.value;
var fileSystem = new ActiveXObject("Scripting.FileSystemfileect");
var file = fileSystem.GetFile (filePath);
fileSize = file.Size;
}else {
fileSize = file.files[0].size;
}
fileSize=Math.round(fileSize/1024*100)/100; //单位为KB
if(fileSize>=1024){
layer.alert('上传的图片大小不能超过1M');
return false;
}
return true;
}

View File

@ -0,0 +1,180 @@
/*!
* Lazy Load - JavaScript plugin for lazy loading images
*
* Copyright (c) 2007-2019 Mika Tuupola
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Project home:
* https://appelsiini.net/projects/lazyload
*
* Version: 2.0.0-rc.2
*
*/
(function (root, factory) {
if (typeof exports === "object") {
module.exports = factory(root);
} else if (typeof define === "function" && define.amd) {
define([], factory);
} else {
root.LazyLoad = factory(root);
}
}) (typeof global !== "undefined" ? global : this.window || this.global, function (root) {
"use strict";
if (typeof define === "function" && define.amd){
root = window;
}
const defaults = {
src: "data-src",
srcset: "data-srcset",
selector: ".lazyload",
root: null,
rootMargin: "0px",
threshold: 0
};
/**
* Merge two or more objects. Returns a new object.
* @private
* @param {Boolean} deep If true, do a deep (or recursive) merge [optional]
* @param {Object} objects The objects to merge together
* @returns {Object} Merged values of defaults and options
*/
const extend = function () {
let extended = {};
let deep = false;
let i = 0;
let length = arguments.length;
/* Check if a deep merge */
if (Object.prototype.toString.call(arguments[0]) === "[object Boolean]") {
deep = arguments[0];
i++;
}
/* Merge the object into the extended object */
let merge = function (obj) {
for (let prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
/* If deep merge and property is an object, merge properties */
if (deep && Object.prototype.toString.call(obj[prop]) === "[object Object]") {
extended[prop] = extend(true, extended[prop], obj[prop]);
} else {
extended[prop] = obj[prop];
}
}
}
};
/* Loop through each object and conduct a merge */
for (; i < length; i++) {
let obj = arguments[i];
merge(obj);
}
return extended;
};
function LazyLoad(images, options) {
this.settings = extend(defaults, options || {});
this.images = images || document.querySelectorAll(this.settings.selector);
this.observer = null;
this.init();
}
LazyLoad.prototype = {
init: function() {
/* Without observers load everything and bail out early. */
if (!root.IntersectionObserver) {
this.loadImages();
return;
}
let self = this;
let observerConfig = {
root: this.settings.root,
rootMargin: this.settings.rootMargin,
threshold: [this.settings.threshold]
};
this.observer = new IntersectionObserver(function(entries) {
Array.prototype.forEach.call(entries, function (entry) {
if (entry.isIntersecting) {
self.observer.unobserve(entry.target);
let src = entry.target.getAttribute(self.settings.src);
let srcset = entry.target.getAttribute(self.settings.srcset);
if ("img" === entry.target.tagName.toLowerCase()) {
if (src) {
entry.target.src = src;
}
if (srcset) {
entry.target.srcset = srcset;
}
} else {
entry.target.style.backgroundImage = "url(" + src + ")";
}
}
});
}, observerConfig);
Array.prototype.forEach.call(this.images, function (image) {
self.observer.observe(image);
});
},
loadAndDestroy: function () {
if (!this.settings) { return; }
this.loadImages();
this.destroy();
},
loadImages: function () {
if (!this.settings) { return; }
let self = this;
Array.prototype.forEach.call(this.images, function (image) {
let src = image.getAttribute(self.settings.src);
let srcset = image.getAttribute(self.settings.srcset);
if ("img" === image.tagName.toLowerCase()) {
if (src) {
image.src = src;
}
if (srcset) {
image.srcset = srcset;
}
} else {
image.style.backgroundImage = "url('" + src + "')";
}
});
},
destroy: function () {
if (!this.settings) { return; }
this.observer.disconnect();
this.settings = null;
}
};
root.lazyload = function(images, options) {
return new LazyLoad(images, options);
};
if (root.jQuery) {
const $ = root.jQuery;
$.fn.lazyload = function (options) {
options = options || {};
options.attribute = options.attribute || "data-src";
new LazyLoad($.makeArray(this), options);
return this;
};
}
return LazyLoad;
});

View File

@ -3,16 +3,6 @@ var UserPay = {
czPayPalData: [[20, "10000屋币"], [50, "25000屋币"], [100, "50000屋币"], [80, "全站包年阅读"]],
sendPay: function () {
$("#payform").submit();
},
GetPayState: function (payId) {
$.post("/api/book.aspx", { act: "getpaystatus", pid: payId }, function (data, textStatus) {
if (data == "1") {
location.href = '/pay/wx_return.aspx?out_trade_no=sc'+payId;
}
else {
setTimeout("UserPay.GetPayState("+payId+")",3000);
}
}, "html");
}
}
@ -46,20 +36,6 @@ $(function () {
$("#ulZFWXXJ").show();
}
var postUrl = "";
switch (type)
{
case "1":
postUrl = "sendalipay.aspx";
break;
case "2":
postUrl = "sendwxpaynowqr.aspx";
break;
case "3":
postUrl = "sendpaypal.aspx";
break;
}
$("#payform").attr("action", postUrl);
})
$("#ulZFWX li").click(function () {

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

View File

@ -1,270 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
<meta name="generator" content="Aspose.Words for .NET 15.1.0.0"/>
<title>RestTemplate中文乱码问题源码分析与解决</title></head>
<body>
<div><p style="font-size:18pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_499-1566046872517"></a><a
style="color:#003884" href="http://www.zinglizingli.xyz"><span
style="background-color:#ffffff; color:#003884; font-family:'Times New Roman'; font-size:18pt; font-weight:bold; text-decoration:underline">RestTemplate中文乱码问题源码分析与解决</span></a>
</p>
<p style="font-size:18pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_668-1566076102707"></a><span
style="background-color:#ffffff; color:#393939; font-family:'Times New Roman'; font-size:18pt; font-weight:bold">---  请求响应数据乱码源码原理分析</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_359-1566070296357"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_090-1566070299368"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="margin:0pt"><a name="_374-1566070299635"></a><span
style="background-color:#ffffff; color:#df402a; font-family:微软雅黑; font-size:15pt; font-weight:bold">============================原理===================</span>
</p>
<p style="margin:0pt"><a name="_115-1566075419335"></a><span
style="color:#7b5ba1; font-family:SimSun; font-size:11pt; font-style:italic">//默认方式:</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_398-1566075426884"></a><span
style="color:#7b5ba1; font-family:SimSun; font-size:11pt; font-style:italic">//RestTemplate restTemplate = new RestTemplate();</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_535-1566075426884"></a><span
style="color:#7b5ba1; font-family:SimSun; font-size:11pt; font-style:italic">// 当返回的response-header的content-type属性有charset值时</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_832-1566075426884"></a><span
style="color:#7b5ba1; font-family:SimSun; font-size:11pt; font-style:italic">// restTemplate的 StringHttpMessageConverter会读取该charset值并使用该值进行</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_044-1566081046911"></a><span
style="color:#7b5ba1; font-family:SimSun; font-size:11pt; font-style:italic">//IO流 = 》字符串的转换,否则则使用默认的字符集</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_025-1566075590776"></a><span
style="color:#7b5ba1; font-family:SimSun; font-size:11pt; font-style:italic">// </span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_437-1566081514760"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_917-1566081515252"></a><span
style="color:#7b5ba1; font-family:SimSun; font-size:11pt; font-style:italic">通过源码可以发现restTemplate底层默认使用了</span><span
style="background-color:#ff0000; color:#ffffff; font-family:SimSun; font-size:11pt">HttpURLConnection</span><span
style="background-color:#ffffff; color:#7b5ba1; font-family:SimSun; font-size:11pt">可以支持其他多种http客户端,如httpclientokhttp等通过</span><span
style="background-color:#ffffff; color:#df402a; font-family:SimSun; font-size:11pt">工厂方法模式</span><span
style="background-color:#ffffff; color:#7b5ba1; font-family:SimSun; font-size:11pt">创建请求</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_345-1566082269458"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_991-1566082211397"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.001.png" width="553" height="144" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_880-1566082349718"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_793-1566082349718"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.002.png" width="553" height="345" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_565-1566082347503"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_974-1566082347716"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_859-1566082347902"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_055-1566082348093"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_542-1566081537855"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.003.png" width="553" height="277" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_721-1566075426884"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_131-1566077535593"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:0pt"><span
style="font:7.0pt 'Times New Roman'">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><a
name="_460-1566077535917"></a><span
style="color:#df402a; font-family:SimSun; font-size:11pt; font-style:italic">restTemplate调用excute方法</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_598-1566077659788"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.004.png" width="553" height="271" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:0pt"><span
style="font:7.0pt 'Times New Roman'">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><a
name="_383-1566077653687"></a><span
style="color:#df402a; font-family:SimSun; font-size:11pt; font-style:italic">restTemplate调用了doExecute方法</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_000-1566077736808"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.005.png" width="553" height="236" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:0pt"><span
style="font:7.0pt 'Times New Roman'">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><a
name="_340-1566077732786"></a><span
style="color:#df402a; font-family:SimSun; font-size:11pt; font-style:italic">执行请求调用</span><span
style="background-color:#ffffff; color:#df402a; font-family:SimSun; font-size:11pt">ResponseExtractor </span><span
style="color:#df402a; font-family:SimSun; font-size:11pt; font-style:italic">responseExtractor.extractData()对相应结果进行数据提取</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_150-1566078107678"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.006.png" width="553" height="382" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:0pt"><span
style="font:7.0pt 'Times New Roman'">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><a
name="_593-1566078099144"></a><span
style="color:#df402a; font-family:SimSun; font-size:11pt; font-style:italic">调用</span><span
style="color:#df402a; font-family:'Times New Roman'; font-size:11pt">HttpMessageConverterExtractor </span><span
style="color:#df402a; font-family:SimSun; font-size:11pt; font-style:italic">this.delegate.extractData()执行抽取数据的操作</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_666-1566078333273"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.007.png" width="553" height="285" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:0pt"><span
style="font:7.0pt 'Times New Roman'">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><a
name="_657-1566078289591"></a><span
style="color:#df402a; font-family:SimSun; font-size:11pt; font-style:italic">获取response-header的content-type</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_561-1566078994408"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.008.png" width="553" height="316" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_699-1566078994408"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_240-1566078897012"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.009.png" width="553" height="303" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:0pt"><span
style="font:7.0pt 'Times New Roman'">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><a
name="_090-1566078895423"></a><span
style="color:#df402a; font-family:SimSun; font-size:11pt; font-style:italic">判断消息转换器对应的支持媒体类型supportMediaType是否包含该content-type</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_470-1566079766383"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.010.png" width="553" height="275" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:0pt"><span
style="font:7.0pt 'Times New Roman'">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><a
name="_142-1566079701403"></a><span
style="color:#df402a; font-family:SimSun; font-size:11pt; font-style:italic">调用第一个包含该content-type的</span><span
style="background-color:#ffffff; color:#df402a; font-family:SimSun; font-size:11pt">GenericHttpMessageConverter转换数据读取数据</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_247-1566080661650"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.011.png" width="553" height="247" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_813-1566080714156"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_896-1566080714156"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.012.png" width="553" height="308" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:0pt"><span
style="font:7.0pt 'Times New Roman'">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><a
name="_223-1566080677140"></a><span style="color:#df402a; font-family:'Times New Roman'; font-size:11pt">读取数据的时候会再一次获取</span><span
style="color:#df402a; font-family:SimSun; font-size:11pt; font-style:italic">response-header的content-type</span><span
style="color:#df402a; font-family:'Times New Roman'; font-size:11pt">的字符集</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:21pt"><a name="_092-1566080909997"></a><span
style="color:#df402a; font-family:'Times New Roman'; font-size:11pt">如果该字符集存在则使用该字符集进行 IO流 =字符串 转换</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_512-1566080804579"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.013.png" width="553" height="294" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_470-1566080966519"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_225-1566080966519"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.014.png" width="553" height="307" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_627-1566078282891"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_729-1566075429719"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_937-1566081177561"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="margin:0pt"><a name="_699-1566081177711"></a><span
style="color:#df402a; font-family:微软雅黑; font-size:15pt; font-weight:bold">案例</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_026-1566075429891"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_059-1566071031255"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.015.png" width="553" height="251" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:42pt"><a name="_176-1566070330576"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:42pt"><a name="_530-1566072661453"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_299-1566072723246"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.016.png" width="367" height="101" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:42pt"><a name="_671-1566072721602"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:12pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:42pt"><a name="_075-1566072855176"></a><span
style="color:#df402a; font-family:'Times New Roman'; font-size:12pt; font-weight:bold">响应头中并没有content-type的header照理说浏览器应该不知道服务端返回的输入流编码如果和浏览器默认的编码不匹配应该会出现乱码但是现在浏览器有编码自动识别功能所以上面的代码没有加content-type的Header也没有问题</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:42pt"><a name="_245-1566072658054"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt; text-indent:42pt"><a name="_872-1566072191117"></a><span
style="font-family:'Times New Roman'; font-size:11pt">          </span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_972-1566072692409"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.017.png" width="439" height="462" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_066-1566072088274"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_580-1566075732276"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_942-1566075732559"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="margin:0pt"><a name="_150-1566075732802"></a><span
style="color:#df402a; font-family:微软雅黑; font-size:15pt; font-weight:bold">实际上下面的做法更规范</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_139-1566072089816"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.018.png" width="553" height="188" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="margin:0pt"><a name="_337-1566070344498"></a><span
style="color:#df402a; font-family:微软雅黑; font-size:15pt; font-weight:bold">源码</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_773-1566073175445"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.019.png" width="553" height="366" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_074-1566085375320"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_689-1566085375320"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.020.png" width="553" height="222" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_837-1566085044019"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_120-1566085034872"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.021.png" width="553" height="127" alt="clipboard.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="margin:0pt"><a name="_080-1566073168924"></a><span style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span>
</p>
<p style="margin:0pt"><a name="_415-1566085038805"></a><span style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span>
</p>
<p style="margin:0pt"><a name="_122-1566085039048"></a><span
style="background-color:#ffffff; color:#df402a; font-family:微软雅黑; font-size:15pt; font-weight:bold">============================原理=====================</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_073-1566070331260"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_256-1566070331284"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_812-1566070331308"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_451-1566070331332"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_130-1566070331359"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_999-1566070331383"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_029-1566070331405"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_074-1566070331428"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_078-1566046874710"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_579-1566047010084"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.022.png" width="553" height="1"
alt="初探RestTemplate--解决中文乱码问题 - mryang125的博客 - CSDN博客.jpg"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_666-1566047010084"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p></div>
</body>
</html>

View File

@ -1,280 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
<meta name="generator" content="Aspose.Words for .NET 15.1.0.0"/>
<title>服务器跨域处理</title></head>
<body>
<div><p style="margin:0pt"><a name="_073-1565689474241"></a><span
style="font-family:微软雅黑; font-size:15pt; font-weight:bold"><a href="http://m.zinglizingli.xyz">跨域处理</a></span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_011-1565689506880"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_400-1565689507090"></a><span
style="font-family:'Times New Roman'; font-size:11pt">跨域是什么浏览器从一个域名的网页去请求另一个域名的资源时域名端口 协议任一不同都是跨域 我们是采用前后端分离开发的也是前后端分离部署的必然会存在跨域问题 怎么解决跨域很简单只需要在controller类上添加注解 @CrossOrigin 即可这个注解其实是CORS的实现 </span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_460-1565689522680"></a><span
style="font-family:'Times New Roman'; font-size:11pt">CORS(Cross-Origin Resource Sharing, 跨源资源共享)是W3C出的一个标准其思 想是使用自定义的HTTP头部让浏览器与服务器进行沟通从而决定请求或响应是应该成 还是应该失败因此要想实现CORS进行跨域需要服务器进行一些设置同时前端也需要做一些配置和分析本文简单的对服务端的配置和前端的一些设置进行分析</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_845-1565689480275"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_065-1565689480471"></a><span
style="font-family:'Times New Roman'; font-size:11pt">1</span><span
style="color:#df402a; font-family:'Times New Roman'; font-size:11pt">在controller类上添加注解 @CrossOrigin表示Controller上的所以方法允许跨域在方法上添加注解 @CrossOrigin表示该方法允许跨域</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_231-1565689931759"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_436-1565689932017"></a><span
style="font-family:'Times New Roman'; font-size:11pt">@Target({ ElementType.METHOD, ElementType.TYPE })</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_134-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">@Retention(RetentionPolicy.RUNTIME)</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_249-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">@Documented</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_993-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">public @interface CrossOrigin {</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_860-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_082-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    String[] DEFAULT_ORIGINS = { "*" };</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_340-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_077-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    String[] DEFAULT_ALLOWED_HEADERS = { "*" };</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_080-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_672-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    boolean DEFAULT_ALLOW_CREDENTIALS = true;</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_262-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_435-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    long DEFAULT_MAX_AGE = 1800;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_682-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_040-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_925-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    /**</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_940-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     * 同origins属性一样</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_047-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     */</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_939-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    @AliasFor("origins")</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_774-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    String[] value() default {};</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_570-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_575-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    /**</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_114-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     * 所有支持域的集合,例如"http://domain1.com"。</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_373-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     * &lt;p&gt;这些值都显示在请求头中的Access-Control-Allow-Origin</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_316-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     * "*"代表所有域的请求都支持</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_011-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     * &lt;p&gt;如果没有定义,所有请求的域都支持</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_880-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     * @see #value</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_783-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     */</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_681-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    @AliasFor("value")</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_042-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    String[] origins() default {};</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_140-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_747-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    /**</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_226-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     * 允许请求头中的header默认都支持</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_485-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     */</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_047-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    String[] allowedHeaders() default {};</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_052-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_280-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    /**</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_742-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     * 响应头中允许访问的header默认为空</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_186-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     */</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_068-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    String[] exposedHeaders() default {};</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_680-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_547-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    /**</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_089-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     * 请求支持的方法,例如"{RequestMethod.GET, RequestMethod.POST}"}。</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_880-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     * 默认支持RequestMapping中设置的方法</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_922-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     */</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_840-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    RequestMethod[] methods() default {};</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_090-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_066-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    /**</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_985-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     * 是否允许cookie随请求发送使用时必须指定具体的域</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_972-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     */</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_119-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    String allowCredentials() default "";</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_127-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_478-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    /**</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_580-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     * 预请求的结果的有效期默认30分钟</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_510-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">     */</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_534-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">    long maxAge() default -1;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_743-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_586-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">}</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_052-1565689932796"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_129-1565689558428"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_873-1565689558663"></a><span
style="font-family:'Times New Roman'; font-size:11pt">2</span><span
style="color:#df402a; font-family:'Times New Roman'; font-size:11pt">配置 CorsFilter(全局配置)</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_025-1565690417616"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_510-1565690417783"></a><span
style="background-color:#ffffff; color:#808000; font-family:SimSun; font-size:11pt">@Configuration</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_314-1565690418407"></a><span
style="background-color:#ffffff; color:#000080; font-family:SimSun; font-size:11pt; font-weight:bold">public class </span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">GlobalCorsConfig {</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_117-1565690418407"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_834-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">    </span><span
style="background-color:#ffffff; color:#808000; font-family:SimSun; font-size:11pt">@Bean</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_074-1565690418407"></a><span
style="background-color:#ffffff; color:#808000; font-family:SimSun; font-size:11pt">    </span><span
style="background-color:#ffffff; color:#000080; font-family:SimSun; font-size:11pt; font-weight:bold">public </span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">CorsFilter corsFilter() {</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_037-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        </span><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">//1.添加CORS配置信息</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_231-1565690418407"></a><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">        </span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">CorsConfiguration config = </span><span
style="background-color:#ffffff; color:#000080; font-family:SimSun; font-size:11pt; font-weight:bold">new </span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">CorsConfiguration();</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_560-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        </span><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">//1) 允许的域,不要写*否则cookie就无法使用了</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_937-1565690418407"></a><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">        </span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">config.addAllowedOrigin(</span><span
style="background-color:#ffffff; color:#008000; font-family:SimSun; font-size:11pt; font-weight:bold">"http://manage.shop.com"</span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">);</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_288-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        config.addAllowedOrigin(</span><span
style="background-color:#ffffff; color:#008000; font-family:SimSun; font-size:11pt; font-weight:bold">"http://www.shop.com"</span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">);</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_712-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        </span><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">//2) 是否发送Cookie信息</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_250-1565690418407"></a><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">        </span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">config.setAllowCredentials(</span><span
style="background-color:#ffffff; color:#000080; font-family:SimSun; font-size:11pt; font-weight:bold">true</span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">);</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_149-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        </span><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">//3) 允许的请求方式</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_028-1565690418407"></a><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">        </span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">config.addAllowedMethod(</span><span
style="background-color:#ffffff; color:#008000; font-family:SimSun; font-size:11pt; font-weight:bold">"OPTIONS"</span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">);</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_040-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        config.addAllowedMethod(</span><span
style="background-color:#ffffff; color:#008000; font-family:SimSun; font-size:11pt; font-weight:bold">"HEAD"</span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">);</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_940-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        config.addAllowedMethod(</span><span
style="background-color:#ffffff; color:#008000; font-family:SimSun; font-size:11pt; font-weight:bold">"GET"</span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">);</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_487-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        config.addAllowedMethod(</span><span
style="background-color:#ffffff; color:#008000; font-family:SimSun; font-size:11pt; font-weight:bold">"PUT"</span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">);</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_065-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        config.addAllowedMethod(</span><span
style="background-color:#ffffff; color:#008000; font-family:SimSun; font-size:11pt; font-weight:bold">"POST"</span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">);</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_034-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        config.addAllowedMethod(</span><span
style="background-color:#ffffff; color:#008000; font-family:SimSun; font-size:11pt; font-weight:bold">"DELETE"</span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">);</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_286-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        config.addAllowedMethod(</span><span
style="background-color:#ffffff; color:#008000; font-family:SimSun; font-size:11pt; font-weight:bold">"PATCH"</span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">);</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_584-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        </span><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">// 4允许的头信息</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_339-1565690418407"></a><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">        </span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">config.addAllowedHeader(</span><span
style="background-color:#ffffff; color:#008000; font-family:SimSun; font-size:11pt; font-weight:bold">"*"</span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">);</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_440-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        </span><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">// 5) 有效时长</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_023-1565690418407"></a><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">//        config.setMaxAge(3600L);</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_025-1565690418407"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_612-1565690418407"></a><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">        //2.添加映射路径,我们拦截一切请求</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_816-1565690418407"></a><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">        </span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">UrlBasedCorsConfigurationSource configSource = </span><span
style="background-color:#ffffff; color:#000080; font-family:SimSun; font-size:11pt; font-weight:bold">new </span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">UrlBasedCorsConfigurationSource();</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_520-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        configSource.registerCorsConfiguration(</span><span
style="background-color:#ffffff; color:#008000; font-family:SimSun; font-size:11pt; font-weight:bold">"/**"</span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">, config);</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_929-1565690418407"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_591-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">        </span><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">//3.返回新的CorsFilter.</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_259-1565690418407"></a><span
style="background-color:#ffffff; color:#808080; font-family:SimSun; font-size:11pt; font-style:italic">        </span><span
style="background-color:#ffffff; color:#000080; font-family:SimSun; font-size:11pt; font-weight:bold">return new </span><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">CorsFilter(configSource);</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_877-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">    }</span></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_415-1565690418407"></a><span
style="background-color:#ffffff; font-family:SimSun; font-size:11pt">}</span></p></div>
</body>
</html>

View File

@ -1,243 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
<meta name="generator" content="Aspose.Words for .NET 15.1.0.0"/>
<title>对分布式事务的理解</title></head>
<body>
<div><p style="font-size:18pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_848-1565404932800"></a><a
style="color:#000000" href="http://www.zinglizingli.xyz"><span
style="background-color:#ffffff; font-family:Verdana; font-size:18pt">对分布式事务及两阶段提交和三阶段提交的理解</span></a></p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_635-1565404934953"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="margin:0pt 0pt 10pt"><a name="_338-1565404935257"></a><span
style="background-color:#ffffff; color:#008000; font-family:Verdana; font-size:16pt; font-weight:bold">分布式数据一致性</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_989-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">在分布式系统中为了保证数据的高可用通常会将数据保留多个副本(replica)这些副本会放置在不同的物理的机器上</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_565-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt; font-weight:bold">1.什么是数据一致性</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_151-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">在数据有多份副本的情况下如果网络服务器或者软件出现故障会导致部分副本写入成功部分副本写入失败这就造成各个副本之间的数据不一致数据内容冲突</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_436-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">造成事实上的数据不一致</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_810-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt; font-weight:bold">2.CAP定理</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_066-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">CAP理论认为在分布式的环境下设计和部署系统时有3个核心的需求</span>
</p>
<p style="font-size:12pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_928-1565405011043"></a><span
style="background-color:#ffffff; color:#800000; font-family:Verdana; font-size:12pt; font-weight:bold">ConsistencyAvailability和Partition Tolerance即CAP</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_842-1565405011043"></a><span
style="font-family:'Times New Roman'; font-size:11pt">&#xa0;</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_811-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">Consistency一致性这个和数据库ACID的一致性类似但这里关注的所有数据节点上的数据一致性和正确性而数据库的ACID关注的是在在一个事务内对数据的一些约束系统在执行过某项操作后仍然处于一致的状态在分布式系统中更新操作执行成功后所有的用户都应该读取到最新值</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_016-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">Availability可用性每一个操作总是能够在一定时间内返回结果需要注意一定时间返回结果一定时间是指系统结果必须在给定时间内返回返回结果是指系统返回操作成功或失败的结果</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_115-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">Partition Tolerance分区容忍性是否可以对数据进行分区这是考虑到性能和可伸缩性</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_237-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt; font-weight:bold">3.数据一致性模型</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_943-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">一些分布式系统通过复制数据来提高系统的可靠性和容错性并且将数据的不同的副本存放在不同的机器</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_047-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">强一致性</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_172-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">当更新操作完成之后任何多个后续进程或者线程的访问都会返回最新的更新过的值这种是对用户最友好的就是用户上一次写什么下一次就保证能读到什么根据 CAP 理论这种实现需要牺牲可用性</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_182-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">弱一致性</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_317-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">系统并不保证续进程或者线程的访问都会返回最新的更新过的值用户读到某一操作对系统特定数据的更新需要一段时间我们称这段时间为不一致性窗口系统在数据写入成功之后不承诺立即可以读到最新写入的值也不会具体的承诺多久之后可以读到</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_443-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">最终一致性</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_483-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">是弱一致性的一种特例系统保证在没有后续更新的前提下系统最终返回上一次更新操作的值在没有故障发生的前提下不一致窗口的时间主要受通信延迟系统负载和复制副本的个数影响DNS 是一个典型的最终一致性系统</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_856-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">&#xa0;</span></p>
<p style="margin:0pt 0pt 10pt"><a name="_788-1565405011043"></a><span
style="background-color:#ffffff; color:#008000; font-family:Verdana; font-size:16pt; font-weight:bold">典型的分布式事务实例</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_082-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">跨行转账问题是一个典型的分布式事务用户A向B的一个转账1000要进行A的余额-1000B的余额+1000显然必须保证这两个操作的事务性</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_085-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">类似的还有电商系统中当有用户下单后除了在订单表插入记还要在商品表更新库存等特别是随着微服务架构的流行分布式事务的场景更变得更普遍</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_090-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">&#xa0;</span></p>
<p style="margin:0pt 0pt 10pt"><a name="_157-1565405011043"></a><span
style="background-color:#ffffff; color:#008000; font-family:Verdana; font-size:16pt; font-weight:bold">两阶段提交协议</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_571-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">两阶段提交协议是协调所有分布式原子事务参与者并决定提交或取消回滚的分布式算法</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_016-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt; font-weight:bold">1.协议参与者</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_050-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">在两阶段提交协议中系统一般包含两类机器或节点一类为协调者coordinator通常一个系统中只有一个另一类为事务参与者participantscohorts或workers一般包含多个在数据存储系统中可以理解为数据副本的个数协议中假设每个节点都会记录写前日志write-ahead log并持久性存储即使节点发生故障日志也不会丢失协议中同时假设节点不会发生永久性故障而且任意两个节点都可以互相通信</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_760-1565405011043"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.023.png" width="553" height="358" alt="61-160357634.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_560-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt; font-weight:bold">2.两个阶段的执行</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_474-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">1.请求阶段commit-request phase或称表决阶段voting phase</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_786-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">在请求阶段协调者将通知事务参与者准备提交或取消事务然后进入表决过程</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_710-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">在表决过程中参与者将告知协调者自己的决策同意事务参与者本地作业执行成功或取消本地作业执行故障</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_125-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">2.提交阶段commit phase</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_067-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">在该阶段协调者将基于第一个阶段的投票结果进行决策提交或取消</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_981-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">当且仅当所有的参与者同意提交事务协调者才通知所有的参与者提交事务否则协调者将通知所有的参与者取消事务</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_532-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">参与者在接收到协调者发来的消息后将执行响应的操作</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_080-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt; font-weight:bold">3两阶段提交的缺点</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_646-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">1.同步阻塞问题执行过程中所有参与节点都是事务阻塞型的</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_014-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">当参与者占有公共资源时其他第三方节点访问公共资源不得不处于阻塞状态</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_488-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">2.单点故障由于协调者的重要性一旦协调者发生故障</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_765-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">参与者会一直阻塞下去尤其在第二阶段协调者发生故障那么所有的参与者还都处于锁定事务资源的状态中而无法继续完成事务操作如果是协调者挂掉可以重新选举一个协调者但是无法解决因为协调者宕机导致的参与者处于阻塞状态的问题</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_010-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">3.数据不一致在二阶段提交的阶段二中当协调者向参与者发送commit请求之后发生了局部网络异常或者在发送commit请求过程中协调者发生了故障这回导致只有一部分参与者接受到了commit请求</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_785-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">而在这部分参与者接到commit请求之后就会执行commit操作但是其他部分未接到commit请求的机器则无法执行事务提交于是整个分布式系统便出现了数据部一致性的现象</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt; font-weight:bold">4两阶段提交无法解决的问题</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_450-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">当协调者出错同时参与者也出错时两阶段无法保证事务执行的完整性</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_279-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">考虑协调者再发出commit消息之后宕机而唯一接收到这条消息的参与者同时也宕机了</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_793-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">那么即使协调者通过选举协议产生了新的协调者这条事务的状态也是不确定的没人知道事务是否被已经提交</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_037-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">&#xa0;</span></p>
<p style="margin:0pt 0pt 10pt"><a name="_052-1565405011043"></a><span
style="background-color:#ffffff; color:#008000; font-family:Verdana; font-size:16pt; font-weight:bold">三阶段提交协议</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_420-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">三阶段提交协议在协调者和参与者中都引入超时机制并且把两阶段提交协议的第一个阶段拆分成了两步询问然后再锁资源最后真正提交</span>
</p>
<p style="font-size:11pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_180-1565405011043"></a><img
src="9a4a540e-1759-4268-90fa-7fb652c3604a.024.png" width="553" height="479" alt="92-920273519.png"
style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline"/>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_743-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt; font-weight:bold">1三个阶段的执行</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_294-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">1.CanCommit阶段</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_945-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">3PC的CanCommit阶段其实和2PC的准备阶段很像</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_981-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">协调者向参与者发送commit请求参与者如果可以提交就返回Yes响应否则返回No响应</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_220-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">2.PreCommit阶段</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_740-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">Coordinator根据Cohort的反应情况来决定是否可以继续事务的PreCommit操作</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_866-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">根据响应情况有以下两种可能</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_992-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">A.假如Coordinator从所有的Cohort获得的反馈都是Yes响应那么就会进行事务的预执行</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_627-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">发送预提交请求Coordinator向Cohort发送PreCommit请求并进入Prepared阶段</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_214-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">事务预提交Cohort接收到PreCommit请求后会执行事务操作并将undo和redo信息记录到事务日志中</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_012-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">响应反馈如果Cohort成功的执行了事务操作则返回ACK响应同时开始等待最终指令</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_068-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">B.假如有任何一个Cohort向Coordinator发送了No响应或者等待超时之后Coordinator都没有接到Cohort的响应那么就中断事务</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_646-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">发送中断请求Coordinator向所有Cohort发送abort请求</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_143-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">中断事务Cohort收到来自Coordinator的abort请求之后或超时之后仍未收到Cohort的请求执行事务的中断</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_223-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">3.DoCommit阶段</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_678-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">该阶段进行真正的事务提交也可以分为以下两种情况:</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_532-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">执行提交</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_431-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">A.发送提交请求Coordinator接收到Cohort发送的ACK响应那么他将从预提交状态进入到提交状态并向所有Cohort发送doCommit请求</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_533-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">B.事务提交Cohort接收到doCommit请求之后执行正式的事务提交并在完成事务提交之后释放所有事务资源</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_010-1565405011043"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">C.响应反馈事务提交完之后向Coordinator发送ACK响应</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_145-1565405011044"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">D.完成事务Coordinator接收到所有Cohort的ACK响应之后完成事务</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_084-1565405011044"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">中断事务</span></p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_752-1565405011044"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">Coordinator没有接收到Cohort发送的ACK响应可能是接受者发送的不是ACK响应也可能响应超时那么就会执行中断事务</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_841-1565405011044"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt; font-weight:bold">2三阶段提交协议和两阶段提交协议的不同</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_499-1565405011044"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">对于协调者(Coordinator)和参与者(Cohort)都设置了超时机制在2PC中只有协调者拥有超时机制即如果在一定时间内没有收到cohort的消息则默认失败</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_629-1565405011044"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">在2PC的准备阶段和提交阶段之间插入预提交阶段使3PC拥有CanCommitPreCommitDoCommit三个阶段</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_049-1565405011044"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">PreCommit是一个缓冲保证了在最后提交阶段之前各参与节点的状态是一致的</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_674-1565405011044"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt; font-weight:bold">2三阶段提交协议的缺点</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_085-1565405011044"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">如果进入PreCommit后Coordinator发出的是abort请求假设只有一个Cohort收到并进行了abort操作</span>
</p>
<p style="font-size:10pt; line-height:115%; margin:0pt 0pt 10pt"><a name="_298-1565405011044"></a><span
style="background-color:#ffffff; font-family:Verdana; font-size:10pt">而其他对于系统状态未知的Cohort会根据3PC选择继续Commit此时系统状态发生不一致性</span>
</p></div>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -6,7 +6,7 @@
<script>
setTimeout(function () {
location.href = '/';
},3000)
},1000)
</script>
</head>

View File

@ -43,17 +43,6 @@
<div class="userBox cf">
<form method="post" action="./register.html" id="form2">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKLTIzNjMxNDQxNw9kFgJmD2QWAmYPFgIeBFRleHQFqAE8YSBocmVmPSIvc2VhcmNoLmFzcHg/c2VhcmNoS2V5PeWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqyIgdGFyZ2V0PSJfYmxhbmsiPuWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqzwvYT5kZOquoASBvnvPbc/TYIQiLhSPJ8GKnYQrmk7jGhb5AC5Q">
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="23AA6834">
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="/wEdAAVece19BIZ9HiByRfHz3pfnqKSXUE1UN51mNFrIuw38c3Y2+Mc6SrnAqio3oCKbxYZZ1lS+gZUZKpbsAea8j7ASAv40DHFcQ/NE7tJUnABeyQ3d9sFDIcFCYNqlVtprfLoh4JFy0U+R/CcMuyAiWTz7">
</div>
<div class="user_l">
<div></div>
<h3>小说基本信息填写</h3>
@ -142,29 +131,32 @@
<script src="/layui/layui.all.js" type="text/javascript"></script>
<script src="/javascript/header.js" type="text/javascript"></script>
<script src="/javascript/user.js" type="text/javascript"></script>
<script src="/javascript/common.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
function picChange() {
var file = $("#file0").val(); //文件名称
if (file != "") {
$.ajaxFileUpload({
url : "/file/upload", //用于文件上传的服务器端请求地址
secureuri : false, //是否需要安全协议一般设置为false
fileElementId : "file0", //文件上传域的ID
dataType : "json", //返回值类型 一般设置为json
type : "post",
success : function(data) { //服务器成功响应处理函数
if (data.code == 200) {
$("#picImage").attr("src", data.data);
$("#picUrl").val(data.data);
}else {
layer.alert('图片上传失败');
if(checkPicUpload($("#file0")[0])) {
$.ajaxFileUpload({
url: "/file/picUpload", //用于文件上传的服务器端请求地址
secureuri: false, //是否需要安全协议一般设置为false
fileElementId: "file0", //文件上传域的ID
dataType: "json", //返回值类型 一般设置为json
type: "post",
success: function (data) { //服务器成功响应处理函数
if (data.code == 200) {
$("#picImage").attr("src", data.data);
$("#picUrl").val(data.data);
} else {
layer.alert(data.msg);
}
}
}
});
});
}
} else {
alert("请选择上传文件");
}

View File

@ -40,17 +40,6 @@
<div class="userBox cf">
<form method="post" action="./register.html" id="form2">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKLTIzNjMxNDQxNw9kFgJmD2QWAmYPFgIeBFRleHQFqAE8YSBocmVmPSIvc2VhcmNoLmFzcHg/c2VhcmNoS2V5PeWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqyIgdGFyZ2V0PSJfYmxhbmsiPuWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqzwvYT5kZOquoASBvnvPbc/TYIQiLhSPJ8GKnYQrmk7jGhb5AC5Q">
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="23AA6834">
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="/wEdAAVece19BIZ9HiByRfHz3pfnqKSXUE1UN51mNFrIuw38c3Y2+Mc6SrnAqio3oCKbxYZZ1lS+gZUZKpbsAea8j7ASAv40DHFcQ/NE7tJUnABeyQ3d9sFDIcFCYNqlVtprfLoh4JFy0U+R/CcMuyAiWTz7">
</div>
<div class="user_l">
<div></div>
<h3>小说章节内容填写</h3>

View File

@ -38,17 +38,6 @@
<div class="userBox cf">
<form method="post" action="./register.html" id="form2">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKLTIzNjMxNDQxNw9kFgJmD2QWAmYPFgIeBFRleHQFqAE8YSBocmVmPSIvc2VhcmNoLmFzcHg/c2VhcmNoS2V5PeWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqyIgdGFyZ2V0PSJfYmxhbmsiPuWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqzwvYT5kZOquoASBvnvPbc/TYIQiLhSPJ8GKnYQrmk7jGhb5AC5Q">
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="23AA6834">
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="/wEdAAVece19BIZ9HiByRfHz3pfnqKSXUE1UN51mNFrIuw38c3Y2+Mc6SrnAqio3oCKbxYZZ1lS+gZUZKpbsAea8j7ASAv40DHFcQ/NE7tJUnABeyQ3d9sFDIcFCYNqlVtprfLoh4JFy0U+R/CcMuyAiWTz7">
</div>
<div class="user_l">
<div></div>
<h3>小说章节内容填写</h3>

View File

@ -133,10 +133,12 @@
</body>
<script src="/javascript/jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="/javascript/ajaxfileupload.js" type="text/javascript"></script>
<script src="/layui/layui.all.js" type="text/javascript"></script>
<script src="/javascript/header.js" type="text/javascript"></script>
<script src="/javascript/user.js" type="text/javascript"></script>
<script src="/javascript/date.js" type="text/javascript"></script>
<script src="/javascript/common.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
search(1, 5);
@ -162,7 +164,12 @@
" ["+(i+1)+"]\n" +
" </td>\n" +*/
" <td class=\"goread\">\n" +
" <td style=\"position: relative\" class=\"goread\">\n" +
"<input class=\"opacity\" onchange=\"picChange('"+book.id+"')\"\n" +
" type=\"file\" id=\"file0\" name=\"file\"\n" +
" title=\"点击上传图片\"\n" +
" style=\"z-index: 100;cursor: pointer;left: 30px; top: 0px; width: 60px; height: 80px; opacity: 0; position: absolute; \"\n" +
" />" +
"<img width='50' height='70' src='"+book.picUrl+"'/><br/>" +
" "+book.bookName+"</td>\n" +
@ -269,6 +276,58 @@
}
function picChange(bookId) {
var file = $("#file0").val(); //文件名称
if (file != "") {
if(checkPicUpload($("#file0")[0])) {
$.ajaxFileUpload({
url: "/file/picUpload", //用于文件上传的服务器端请求地址
secureuri: false, //是否需要安全协议一般设置为false
fileElementId: "file0", //文件上传域的ID
dataType: "json", //返回值类型 一般设置为json
type: "post",
success: function (data) { //服务器成功响应处理函数
if (data.code == 200) {
$.ajax({
type: "POST",
url: "/author/updateBookPic",
data: {'bookId': bookId, 'bookPic': data.data},
dataType: "json",
success: function (data) {
if (data.code == 200) {
location.reload();
} else {
lock = false;
layer.alert(data.msg);
}
},
error: function () {
lock = false;
layer.alert('网络异常');
}
})
} else {
layer.alert(data.msg);
}
}
});
}
} else {
alert("请选择上传文件!");
}
}
</script>
</html>

View File

@ -33,15 +33,6 @@
<body style="background-color: #444;">
<div style="width: 800px; margin-left: auto; margin-right: auto; margin-top: 150px;">
<form method="post" action="/author/register.html" id="form1" onsubmit="return $(this).form(&quot;validate&quot;);">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTcyNTY0MjQ5NGRk++It0MqlJDSbyu54vkeAbEa5OUhkaoZyC53OelRtDeg=" />
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="799CC77D" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAkIOs3R4B2+v3nSsFBLSe3g1MEpq666rzQ7jjzhNwecX7wsg773N8DhSUPLdYYjtuwvQ8kN6tkIkhd/68qh+xm6RWIUm/02TrSmncT3Z6CDZUrw+Qm6bt8NGm9h/X+a2xTq1sAiXqGUGwYVZVK+kL9fPOaW1pQztoQA36D1w/+bXZEqukB3SRMoY9NENNgXVe/neqc7kNqcr4JW0Rj8Hcw3qispLYQVy/s36rQl1WiEaw==" />
</div>
<div id="main">
<table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic" style="line-height:40px;">
<tr>

View File

@ -106,15 +106,6 @@
<div id="showBooking" class="orderBox">
<h3>此章为VIP章节需要订阅后才能继续阅读</h3>
<form method="post" action="./2052117.html?bid=302&amp;cid=2052117" id="Form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTI5NzI4MTkzMQ9kFgRmD2QWAmYPFgIeBFRleHQFqAE8YSBocmVmPSIvc2VhcmNoLmFzcHg/c2VhcmNoS2V5PeWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqyIgdGFyZ2V0PSJfYmxhbmsiPuWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqzwvYT5kAgEPZBYIZg8WAh8ABQnkupHmg7PlrrlkAgEPFgIfAAUEMTE0NmQCAg8WAh8ABREyMDIwLzEvNyAxMDoxOTo1MWQCBA9kFgICAQ9kFg5mDxYCHwAFBDExNDZkAgEPFgIfAAUBNmQCAg8WAh8ABQEwZAIDDxYCHwAFATBkAgQPFgIeB1Zpc2libGVnZAIFDxYCHwFnZAIGDxYCHwFoZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAQUOY2J4QXV0b0Jvb2tpbmfqQ909Hciz2aB+AfEr2lQsyt0OxDFr478jb+bXR8kVYA==">
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="0F20AF34">
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAX4WEeZOhVYVmRzc9paH9JSy/08L4LdXX0bnEtd0tA2crFh4MPja1O/9L0Y0B5Q7Mkw2OnJlkYmOh3/iyqfPkkn99UiP/cCDJ38/2cPKg8P57VHEmkKJr8/tJbwExBtkfhGxxoA1kMIQUaw59BH5iPe">
</div>
<ul class="order_list">
<li>价格:<span class="red" th:text="${bookIndex.bookPrice}+'屋币(1元=100屋币)'"></span></li>
<li id="panelPay" class="btns"><a class="btn_red" href="javascript:buyBookIndex()" >购买</a></li>

View File

@ -86,20 +86,21 @@
<div class="bookComment">
<div class="book_tit">
<div class="fl">
<h3>作品评论区</h3><span id="bookCommentTotal">(0条)</span>
<h3>作品评论区</h3><span id="bookCommentTotal" th:text="'('+${bookCommentPageBean.total}+')'"></span>
</div>
<a class="fr" href="#txtComment">发表评论</a>
</div>
<div class="no_comment" id="noCommentPanel" style="display: none;">
<div class="no_comment" id="noCommentPanel" th:style="${bookCommentPageBean.total > 0}? 'display:none'" >
<img src="/images/no_comment.png" alt=""/>
<span class="block">暂无评论</span>
</div>
<div class="commentBar" id="commentPanel">
<div class="commentBar" id="commentPanel" th:style="${bookCommentPageBean.total == 0}? 'display:none'">
<div th:each="comment: ${bookCommentPageBean.list}" class="comment_list cf"><div class="user_heads fl" vals="389"><img th:src="${comment.createUserPhoto}?${comment.createUserPhoto}:'/images/man.png'" class="user_head" alt=""><span class="user_level1" style="display: none;">见习</span></div><ul class="pl_bar fr"> <li class="name" th:text="${#strings.substring(comment.createUserName,0,4)}+'****'+${#strings.substring(comment.createUserName,#strings.length(comment.createUserName)-3,#strings.length(comment.createUserName))}"></li><li class="dec" th:utext="${comment.commentContent}"></li><li class="other cf"><span class="time fl" th:text="${#calendars.format(comment.createTime, 'yyyy-MM-dd HH:mm:ss')}"></span><span class="fr"><a href="javascript:void(0);" onclick="javascript:BookDetail.AddAgreeTotal(77,this);" class="zan" style="display: none;">赞<i class="num">(0)</i></a></span></li> </ul> </div>
</div>
<!--无评论时此处隐藏-->
<div class="more_bar" id="moreCommentPanel">
<div class="more_bar" id="moreCommentPanel" th:style="${bookCommentPageBean.total == 0}? 'display:none'">
<a th:href="'/book/comment-'+${book.id}+'.html'">查看全部评论&gt;</a>
</div>
@ -171,7 +172,19 @@
</div>
<div class="tj_bar">
<ul id="recBookList">
<li th:each="book : ${recBooks}">
<div class="book_intro">
<div class="cover">
<a th:href="'/book/'+${book.id}+'.html'"><img th:src="${book.picUrl}" th:alt="${book.bookName}"></a>
</div>
<div class="dec">
<a class="book_name" th:href="'/book/'+${book.id}+'.html'" th:text="${book.bookName}"></a>
<a class="txt" th:href="'/book/'+${book.id}+'.html'" th:utext="${book.bookDesc}">
</a>
</div>
</div>
</li>
</ul>
</div>
@ -250,56 +263,7 @@
}
})
//加载评价列表
loadCommentList();
function loadCommentList(){
$.ajax({
type: "get",
url: "/book/listCommentByPage",
data: {'bookId': $("#bookId").val()},
dataType: "json",
success: function (data) {
if (data.code == 200) {
var commentList = data.data.list;
if (commentList.length > 0) {
$("#bookCommentTotal").html("("+data.data.total+"条)");
var commentListHtml = "";
for (var i = 0; i < commentList.length; i++) {
var comment = commentList[i];
commentListHtml += ("<div class=\"comment_list cf\">" +
"<div class=\"user_heads fl\" vals=\"389\">" +
"<img src=\""+(comment.createUserPhoto ? comment.createUserPhoto : '/images/man.png')+"\" class=\"user_head\" alt=\"\">" +
"<span class=\"user_level1\" style=\"display: none;\">见习</span></div>" +
"<ul class=\"pl_bar fr\">\t\t\t<li class=\"name\">"+(comment.createUserName.substr(0, 4) + "****" + comment.createUserName.substr(comment.createUserName.length - 3, 3))+"</li><li class=\"dec\">" +
comment.commentContent+
"</li><li class=\"other cf\">" +
"<span class=\"time fl\">"+comment.createTime+"</span>" +
"<span class=\"fr\"><a href=\"javascript:void(0);\" onclick=\"javascript:BookDetail.AddAgreeTotal(77,this);\" class=\"zan\" style=\"display: none;\">赞<i class=\"num\">(0)</i></a>" +
"</span></li>\t\t</ul>\t</div>");
}
$("#commentPanel").html(commentListHtml);
$("#noCommentPanel").hide();
$("#commentPanel").show();
$("#moreCommentPanel").show();
} else {
$("#commentPanel").hide();
$("#moreCommentPanel").hide();
$("#noCommentPanel").show();
}
} else {
layer.alert(data.msg);
}
},
error: function () {
layer.alert('网络异常');
}
})
}
@ -332,49 +296,58 @@
});
var bookCatId = $("#bookCatId").val();
//查询同类推荐
$.ajax({
type: "get",
url: "/book/listRecBookByCatId",
data: {'catId': bookCatId},
dataType: "json",
success: function (data) {
if (data.code == 200) {
var recBookList = data.data;
var recBookListHtml = "";
for (var i = 0; i < recBookList.length; i++) {
var recBook = recBookList[i];
recBookListHtml += ("<li>\n" +
" <div class=\"book_intro\">\n" +
" <div class=\"cover\">\n" +
" <a href=\"/book/" + recBook.id + ".html\" ><img src=\"" + recBook.picUrl + "\" alt=\"" + recBook.bookName + "\" /></a>\n" +
" </div>\n" +
" <div class=\"dec\">\n" +
" <a class=\"book_name\" href=\"/book/" + recBook.id + ".html\" >" + recBook.bookName + "</a>\n" +
" <a class=\"txt\" href=\"/book/" + recBook.id + ".html\" >\n" + recBook.bookDesc +
" </a>\n" +
" </div>\n" +
" </div>\n" +
" </li>");
}
$("#recBookList").html(recBookListHtml);
} else {
layer.alert(data.msg);
}
},
error: function () {
layer.alert('网络异常');
}
})
$.post("/book/addVisitCount", {"bookId": bookId}, function () {
});
function loadCommentList(){
$.ajax({
type: "get",
url: "/book/listCommentByPage",
data: {'bookId': $("#bookId").val()},
dataType: "json",
success: function (data) {
if (data.code == 200) {
var commentList = data.data.list;
if (commentList.length > 0) {
$("#bookCommentTotal").html("("+data.data.total+"条)");
var commentListHtml = "";
for (var i = 0; i < commentList.length; i++) {
var comment = commentList[i];
commentListHtml += ("<div class=\"comment_list cf\">" +
"<div class=\"user_heads fl\" vals=\"389\">" +
"<img src=\""+(comment.createUserPhoto ? comment.createUserPhoto : '/images/man.png')+"\" class=\"user_head\" alt=\"\">" +
"<span class=\"user_level1\" style=\"display: none;\">见习</span></div>" +
"<ul class=\"pl_bar fr\">\t\t\t<li class=\"name\">"+(comment.createUserName)+"</li><li class=\"dec\">" +
comment.commentContent+
"</li><li class=\"other cf\">" +
"<span class=\"time fl\">"+comment.createTime+"</span>" +
"<span class=\"fr\"><a href=\"javascript:void(0);\" onclick=\"javascript:BookDetail.AddAgreeTotal(77,this);\" class=\"zan\" style=\"display: none;\">赞<i class=\"num\">(0)</i></a>" +
"</span></li>\t\t</ul>\t</div>");
}
$("#commentPanel").html(commentListHtml);
$("#noCommentPanel").hide();
$("#commentPanel").show();
$("#moreCommentPanel").show();
} else {
$("#commentPanel").hide();
$("#moreCommentPanel").hide();
$("#noCommentPanel").show();
}
} else {
layer.alert(data.msg);
}
},
error: function () {
layer.alert('网络异常');
}
})
}
</script>
</body>
</html>

View File

@ -43,7 +43,7 @@
<li th:class="${navType}==1?'on':''"><a href="/book/bookclass.html">全部作品</a></li>
<li th:class="${navType}==2?'on':''"><a href="/book/book_ranking.html">排行榜</a></li>
<li class=""><a href="/pay/index.html">充值</a></li>
<li><a href="/author/index.html">作家专区</a></li>
<li><a href="/author/index.html" target="_blank">作家专区</a></li>
</ul>
</div>

View File

@ -21,18 +21,29 @@
<div class="channelWrap channelBanner cf">
<div class="leftBox">
<div class="sliderContent">
<dl class="scBigImg" id="carouseBig">
<dl class="scBigImg" id="carouseBig" th:if="${bookMap['0']}" >
<dd th:each="book,iterStat : ${bookMap['0']}" th:class="${iterStat.first}? 'on'"><a th:href="'/book/'+${book.bookId}+'.html'">
<img th:src="${book.picUrl}" th:alt="${book.bookName}"/></a></dd>
</dl>
<div class="scSmallImg" id="carouseSmall">
<ul>
<div class="scSmallImg" id="carouseSmall" >
<ul th:if="${bookMap['0']}">
<li th:each="book,iterStat : ${bookMap['0']}" th:class="${iterStat.first}? 'on'">
<img th:src="${book.picUrl}" th:alt="${book.bookName}"/></li>
</ul>
</div>
</div>
<div class="hot_articles">
<dl class="hot_recommend" id="topBooks1">
<dl class="hot_recommend" id="topBooks1" th:if="${bookMap['1']} and ${#lists.size(bookMap['1']) > 0}">
<dt><a th:href="'/book/'+${bookMap['1'][0].bookId}+'.html'" th:text="${bookMap['1'][0].bookName}"></a></dt>
<dd th:if="${#lists.size(bookMap['1']) > 1}"><a th:href="'/book/'+${bookMap['1'][1].bookId}+'.html'" th:text="${bookMap['1'][1].bookName}"></a><a th:if="${#lists.size(bookMap['1']) > 2}" th:href="'/book/'+${bookMap['1'][1].bookId}+'.html'" th:text="${bookMap['1'][1].bookName}"></a></dd>
<dd th:if="${#lists.size(bookMap['1']) > 3}"><a th:href="'/book/'+${bookMap['1'][3].bookId}+'.html'" th:text="${bookMap['1'][3].bookName}"></a><a th:if="${#lists.size(bookMap['1']) > 4}" th:href="'/book/'+${bookMap['1'][4].bookId}+'.html'" th:text="${bookMap['1'][4].bookName}"></a></dd>
</dl>
<dl class="hot_recommend" id="topBooks2">
<dl class="hot_recommend" id="topBooks2" th:if="${bookMap['1']} and ${#lists.size(bookMap['1']) > 5}">
<dt><a th:href="'/book/'+${bookMap['1'][5].bookId}+'.html'" th:text="${bookMap['1'][5].bookName}"></a></dt>
<dd th:if="${#lists.size(bookMap['1']) > 6}"><a th:href="'/book/'+${bookMap['1'][6].bookId}+'.html'" th:text="${bookMap['1'][6].bookName}"></a><a th:if="${#lists.size(bookMap['1']) > 7}" th:href="'/book/'+${bookMap['1'][7].bookId}+'.html'" th:text="${bookMap['1'][7].bookName}"></a></dd>
<dd th:if="${#lists.size(bookMap['1']) > 8}"><a th:href="'/book/'+${bookMap['1'][8].bookId}+'.html'" th:text="${bookMap['1'][8].bookName}"></a><a th:if="${#lists.size(bookMap['1']) > 9}" th:href="'/book/'+${bookMap['1'][9].bookId}+'.html'" th:text="${bookMap['1'][9].bookName}"></a></dd>
</dl>
<dl class="hot_notice" id="indexNews">
</dl>
@ -43,7 +54,15 @@
<h3>本周强推</h3>
</div>
<div class="rightList">
<ul id="currentWeek">
<ul id="currentWeek" th:if="${bookMap['2']}">
<li th:each="book,iterStat : ${bookMap['2']}" th:class="${iterStat.first}? 'on num1': (${iterStat.index < 3}? 'num'+${iterStat.index+1})">
<div class="book_name"><i th:text="${iterStat.index+1}"></i><a class="name" th:href="'/book/'+${book.bookId}+'.html'" th:text="${book.bookName}"></a></div>
<div class="book_intro">
<div class="cover"><a th:href="'/book/'+${book.bookId}+'.html'"><img th:src="${book.picUrl}" th:alt="${book.bookName}"></a>
</div>
<a class="txt" th:href="'/book/'+${book.bookId}+'.html'" th:utext="${book.bookDesc}"></a>
</div>
</li>
</ul>
</div>
</div>
@ -54,9 +73,18 @@
<div class="title">
<h2 class="on">热门推荐</h2>
</div>
<div class="picRecommend cf" id="hotRecBooks">
<div class="picRecommend cf" id="hotRecBooks" th:if="${bookMap['3']}">
<div class="itemsList" th:each="book : ${bookMap['3']}">
<a class="items_img" th:href="'/book/'+${book.bookId}+'.html'">
<img class="lazyload" src="/images/default.gif" th:data-src="${book.picUrl}" th:alt="${book.bookName}">
</a>
<div class="items_txt">
<h4><a th:href="'/book/'+${book.bookId}+'.html'" th:text="${book.bookName}"></a></h4>
<p class="author"><a href="javascript:void(0)" th:text="'作者'+${book.authorName}"></a></p>
<p class="intro"><a th:href="'/book/'+${book.bookId}+'.html'" th:utext="${book.bookDesc}"></a>
</p>
</div>
</div>
</div>
</div>
@ -80,9 +108,18 @@
<div class="title">
<h2>精品推荐</h2>
</div>
<div class="picRecommend cf" id="classicBooks">
<div class="picRecommend cf" id="classicBooks" th:if="${bookMap['4']}">
<div class="itemsList" th:each="book : ${bookMap['4']}">
<a class="items_img" th:href="'/book/'+${book.bookId}+'.html'">
<img class="lazyload" src="/images/default.gif" th:data-src="${book.picUrl}" th:alt="${book.bookName}">
</a>
<div class="items_txt">
<h4><a th:href="'/book/'+${book.bookId}+'.html'" th:text="${book.bookName}"></a></h4>
<p class="author"><a href="javascript:void(0)" th:text="'作者'+${book.authorName}"></a></p>
<p class="intro"><a th:href="'/book/'+${book.bookId}+'.html'" th:utext="${book.bookDesc}"></a>
</p>
</div>
</div>
</div>
</div>
@ -141,7 +178,7 @@
</div>
</div>
<div class="friend_link" >
<div class="friend_link">
<div class="box_center cf" id="friendLink">
<span>友情链接:</span>
</div>
@ -153,182 +190,46 @@
</body>
<div th:replace="common/js :: js"></div>
<script src="/javascript/lazyload.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(function () {
//加载首页书籍设置数据
$.ajax({
type: "get",
url: "/book/listBookSetting",
data: {},
dataType: "json",
success: function (data) {
if (data.code == 200) {
var $div = $('.scBigImg dl');//放置大图容器
var $nav = $('.scSmallImg li');//放置缩略图容器
var num = -1;
var open;
//轮播图设置
var carouselBooks = data.data[0];
var carouseBigHtml = "";
var carouseSmallHtml = "";
for (var i = 0; i < carouselBooks.length; i++) {
var carouselBook = carouselBooks[i];
var classHtml = "";
if (i == 0) {
classHtml = "on";
}
carouseBigHtml += ("<dd class=\"" + classHtml + "\"><a href=\"/book/"+carouselBook.bookId+".html\">" +
"<img src=\"" + carouselBook.picUrl + "\" alt=\"" + carouselBook.bookName + "\"/></a></dd>");
function changeKv() {
if (num >= $nav.length - 1) {
num = 0;
} else {
num++;
}
$nav.eq(num).trigger('mouseenter');
open = setTimeout(changeKv, 3000);
}
carouseSmallHtml += " <li class=\"" + classHtml + "\">" +
"<img src=\"" + carouselBook.picUrl + "\" alt=\"" + carouselBook.bookName + "\"/></li>";
}
$("#carouseBig").html(carouseBigHtml);
$("#carouseSmall").html(carouseSmallHtml);
var $div = $('.scBigImg dl');//放置大图容器
var $nav = $('.scSmallImg li');//放置缩略图容器
var num = -1;
var open;
function changeKv() {
if (num >= $nav.length - 1) {
num = 0;
} else {
num++;
}
$nav.eq(num).trigger('mouseenter');
open = setTimeout(changeKv, 3000);
}
changeKv();
$nav.each(function (index) {
$(this).off('mouseenter').on('mouseenter', function () {
clearTimeout(open);
$(this).addClass('on').siblings().removeClass('on');
$('.scBigImg dd').eq(index).addClass('on').siblings().removeClass('on');
$('.scSmallImg').off('mouseleave').on('mouseleave', function () {
num = index;
setTimeout(function () {
changeKv();
$nav.each(function (index) {
$(this).off('mouseenter').on('mouseenter', function () {
clearTimeout(open);
}, 3000)
})
});
});
$div.each(function () {
$(this).off('mouseenter').on('mouseenter', function () {
clearTimeout(open);
});
});
$(this).addClass('on').siblings().removeClass('on');
$('.scBigImg dd').eq(index).addClass('on').siblings().removeClass('on');
$('.scSmallImg').off('mouseleave').on('mouseleave', function () {
num = index;
setTimeout(function () {
changeKv();
}, 3000)
})
});
});
$div.each(function (index) {
$(this).off('mouseenter').on('mouseenter', function () {
clearTimeout(open);
});
});
//顶部小说栏设置
var topBooks = data.data[1];
var topBooks1Html = "";
var topBooks2Html = "";
for (var i = 0; i < topBooks.length; i++) {
var toBook = topBooks[i];
if (i < 5) {
if (i == 0) {
topBooks1Html += "<dt>";
} else if (i % 2 == 1) {
topBooks1Html += "<dd>";
}
topBooks1Html += ("<a href=\"book/"+toBook.bookId+".html\">" + toBook.bookName + "</a>");
if (i == 0) {
topBooks1Html += "</dt>";
} else if (i % 2 == 0) {
topBooks1Html += "</dd>";
}
} else {
if (i == 5) {
topBooks2Html += "<dt>";
} else if (i % 2 == 0) {
topBooks2Html += "<dd>";
}
topBooks2Html += ("<a href=\"book/"+toBook.bookId+".html\">" + toBook.bookName + "</a>");
if (i == 5) {
topBooks2Html += "</dt>";
} else if (i % 2 == 1) {
topBooks2Html += "</dd>";
}
}
}
$("#topBooks1").html(topBooks1Html);
$("#topBooks2").html(topBooks2Html);
//本周强推
var rightListBooks = data.data[2];
var rightListBooksHtml = "";
for (var i = 0; i < rightListBooks.length; i++) {
var rightListBook = rightListBooks[i];
var classHtml = "";
if (i == 0) {
classHtml = "on";
}
if (i < 3) {
classHtml += (" num" + (i + 1));
}
rightListBooksHtml += ("<li class=\"" + classHtml + "\">\n" +
" <div class=\"book_name\"><i>" + (i + 1) + "</i><a class=\"name\" href=\"/book/"+rightListBook.bookId+".html\">" + rightListBook.bookName + "</a></div>\n" +
" <div class=\"book_intro\">\n" +
" <div class=\"cover\"><a href=\"/book/"+rightListBook.bookId+".html\"><img\n" +
" src=\"" + rightListBook.picUrl + "\" alt=\"" + rightListBook.bookName + "\"/></a>\n" +
" </div>\n" +
" <a class=\"txt\" href=\"/book/"+rightListBook.bookId+".html\">" + rightListBook.bookDesc + "</a>\n" +
" </div>\n" +
" </li>");
}
$("#currentWeek").html(rightListBooksHtml);
//热门推荐
var hotRecBooks = data.data[3];
var hotRecBooksHtml = "";
for (var i = 0; i < hotRecBooks.length; i++) {
var hotRecBook = hotRecBooks[i];
hotRecBooksHtml += (" <div class=\"itemsList\">\n" +
" <a class=\"items_img\" href=\"/book/"+hotRecBook.bookId+".html\">\n" +
" <img src=\"" + hotRecBook.picUrl + "\" alt=\"" + hotRecBook.bookName + "\"/>\n" +
" </a>\n" +
" <div class=\"items_txt\">\n" +
" <h4><a href=\"/book/"+hotRecBook.bookId+".html\">" + hotRecBook.bookName + "</a></h4>\n" +
" <p class=\"author\"><a href=\"javascript:void(0)\">作者:" + hotRecBook.authorName + "</a></p>\n" +
" <p class=\"intro\"><a href=\"/book/"+hotRecBook.bookId+".html\">" + hotRecBook.bookDesc + "</a>\n" +
" </p>\n" +
" </div>\n" +
" </div>");
}
$("#hotRecBooks").html(hotRecBooksHtml);
//精品推荐
var classicBooks = data.data[4];
var classicBooksHtml = "";
for (var i = 0; i < classicBooks.length; i++) {
var classicBook = classicBooks[i];
classicBooksHtml += (" <div class=\"itemsList\">\n" +
" <a class=\"items_img\" href=\"/book/"+classicBook.bookId+".html\">\n" +
" <img src=\"" + classicBook.picUrl + "\" alt=\"" + classicBook.bookName + "\"/>\n" +
" </a>\n" +
" <div class=\"items_txt\">\n" +
" <h4><a href=\"/book/"+classicBook.bookId+".html\">" + classicBook.bookName + "</a></h4>\n" +
" <p class=\"author\"><a href=\"javascript:void(0)\">作者:" + classicBook.authorName + "</a></p>\n" +
" <p class=\"intro\"><a href=\"/book/"+classicBook.bookId+".html\">" + classicBook.bookDesc + "</a>\n" +
" </p>\n" +
" </div>\n" +
" </div>");
}
$("#classicBooks").html(classicBooksHtml);
} else {
layer.alert(data.msg);
}
},
error: function () {
layer.alert('网络异常');
}
})
lazyload();
$(function () {
//首页新闻查询
$.ajax({
type: "get",
@ -342,7 +243,7 @@
for (var i = 0; i < indexNewsList.length; i++) {
var indexNews = indexNewsList[i];
indexNewsHtml += ("<dd style=\"text-align:left;\"><span>[" + indexNews.catName + "]</span><a\n" +
" href=\"/about/newsInfo-"+indexNews.id+".html\">" + indexNews.title + "</a>\n" +
" href=\"/about/newsInfo-" + indexNews.id + ".html\">" + indexNews.title + "</a>\n" +
" </dd>");
}
$("#indexNews").html(indexNewsHtml);
@ -368,24 +269,25 @@
var clickRankBooks = data.data;
var clickRankBooksHtml = "";
for (var i = 0; i < clickRankBooks.length; i++) {
var clickRankBook = clickRankBooks[i];
var classHtml = "";
var imageHtml = "";
if (i == 0) {
classHtml = "on";
imageHtml = "<img src=\"" + clickRankBook.picUrl + "\" alt=\"" + clickRankBook.bookName + "\"/>";
}
if (i < 3) {
classHtml += (" num" + (i + 1));
}
var clickRankBook = clickRankBooks[i];
clickRankBooksHtml += ("<li class=\"" + classHtml + "\">\n" +
" <div class=\"book_name\">\n" +
" <i>" + (i + 1) + "</i><a class=\"name\" href=\"/book/"+clickRankBook.id+".html\">" + clickRankBook.bookName + "</a>\n" +
" <i>" + (i + 1) + "</i><a class=\"name\" href=\"/book/" + clickRankBook.id + ".html\">" + clickRankBook.bookName + "</a>\n" +
" </div>\n" +
" <div class=\"book_intro\">\n" +
" <div class=\"cover\">\n" +
" <a href=\"book/"+clickRankBook.id+".html\"><img src=\"" + clickRankBook.picUrl + "\"\n" +
" alt=\"" + clickRankBook.bookName + "\"/></a>\n" +
" <a href=\"book/" + clickRankBook.id + ".html\">"+ imageHtml +"</a>\n" +
" </div>\n" +
" <a class=\"txt\" href=\"/book/"+clickRankBook.id+".html\">" + clickRankBook.bookDesc + "</a>\n" +
" <a class=\"txt\" href=\"/book/" + clickRankBook.id + ".html\">" + clickRankBook.bookDesc + "</a>\n" +
" </div>\n" +
"\n" +
" </li>");
@ -411,25 +313,25 @@
var newRankBooks = data.data;
var newRankBooksHtml = "";
for (var i = 0; i < newRankBooks.length; i++) {
var newRankBook = newRankBooks[i];
var classHtml = "";
var imageHtml = "";
if (i == 0) {
classHtml = "on";
imageHtml = "<img src=\"" + newRankBook.picUrl + "\" alt=\"" + newRankBook.bookName + "\"/>";
}
if (i < 3) {
classHtml += (" num" + (i + 1));
}
var newRankBook = newRankBooks[i];
newRankBooksHtml += ("<li class=\"" + classHtml + "\">\n" +
" <div class=\"book_name\">\n" +
" <i>" + (i + 1) + "</i><a class=\"name\" href=\"/book/"+newRankBook.id+".html\">" + newRankBook.bookName + "</a>\n" +
" <i>" + (i + 1) + "</i><a class=\"name\" href=\"/book/" + newRankBook.id + ".html\">" + newRankBook.bookName + "</a>\n" +
" </div>\n" +
" <div class=\"book_intro\">\n" +
" <div class=\"cover\">\n" +
" <a href=\"book/"+newRankBook.id+".html\"><img\n" +
" src=\"" + newRankBook.picUrl + "\"\n" +
" alt=\"" + newRankBook.bookName + "\"/></a>\n" +
" <a href=\"book/" + newRankBook.id + ".html\">" + imageHtml + "</a>\n" +
" </div>\n" +
" <a class=\"txt\" href=\"/book/"+newRankBook.id+".html\">" + newRankBook.bookDesc + "</a>\n" +
" <a class=\"txt\" href=\"/book/" + newRankBook.id + ".html\">" + newRankBook.bookDesc + "</a>\n" +
" </div>\n" +
"\n" +
" </li>");
@ -456,34 +358,34 @@
var updateRankBookHtml = "";
var updateRankBookHtml2 = "";
for (var i = 0; i < updateRankBooks.length; i++) {
var updateRankBook = updateRankBooks[i];
var classHtml = "";
var imageHtml = "";
if (i == 0) {
classHtml = "on";
imageHtml = "<img\ src=\"" + updateRankBook.picUrl + "\" alt=\"" + updateRankBook.bookName + "\"/>";
}
if (i < 3) {
classHtml += (" num" + (i + 1));
}
var updateRankBook = updateRankBooks[i];
if (i < 10) {
updateRankBookHtml += ("<li class=\"" + classHtml + "\">\n" +
" <div class=\"book_name\">\n" +
" <i>" + (i + 1) + "</i><a class=\"name\" href=\"/book/"+updateRankBook.id+".html\">" + updateRankBook.bookName + "</a>\n" +
" <i>" + (i + 1) + "</i><a class=\"name\" href=\"/book/" + updateRankBook.id + ".html\">" + updateRankBook.bookName + "</a>\n" +
" </div>\n" +
" <div class=\"book_intro\">\n" +
" <div class=\"cover\">\n" +
" <a href=\"book/"+updateRankBook.id+".html\"><img\n" +
" src=\"" + updateRankBook.picUrl + "\"\n" +
" alt=\"" + updateRankBook.bookName + "\"/></a>\n" +
" <a href=\"book/" + updateRankBook.id + ".html\">" + imageHtml + "</a>\n" +
" </div>\n" +
" <a class=\"txt\" href=\"/book/"+updateRankBook.id+".html\">" + updateRankBook.bookDesc + "</a>\n" +
" <a class=\"txt\" href=\"/book/" + updateRankBook.id + ".html\">" + updateRankBook.bookDesc + "</a>\n" +
" </div>\n" +
"\n" +
" </li>");
}
updateRankBookHtml2 += ("<tr>\n" +
" <td class=\"style\"><a href=\"book/bookclass.html?c="+updateRankBook.catId+"\">[" + updateRankBook.catName + "]</a></td>\n" +
" <td class=\"name\"><a href=\"/book/"+updateRankBook.id+".html\">" + updateRankBook.bookName + "</a></td>\n" +
" <td class=\"chapter\"><a href=\"/book/"+updateRankBook.id+".html\">" + updateRankBook.lastIndexName + "</a>\n" +
" <td class=\"style\"><a href=\"book/bookclass.html?c=" + updateRankBook.catId + "\">[" + updateRankBook.catName + "]</a></td>\n" +
" <td class=\"name\"><a href=\"/book/" + updateRankBook.id + ".html\">" + updateRankBook.bookName + "</a></td>\n" +
" <td class=\"chapter\"><a href=\"/book/" + updateRankBook.id + ".html\">" + updateRankBook.lastIndexName + "</a>\n" +
" <i class=\"\"></i>\n" +
" </td>\n" +
" <td class=\"author\"><a href=\"javascript:void(0)\">" + updateRankBook.authorName + "</a></td>\n" +
@ -514,7 +416,7 @@
var friendLinkHtml = "";
for (var i = 0; i < friendLinkList.length; i++) {
var friendLink = friendLinkList[i];
friendLinkHtml += ("<a target='_blank' href=\""+friendLink.linkUrl+"\">"+friendLink.linkName+"</a>");
friendLinkHtml += ("<a target='_blank' href=\"" + friendLink.linkUrl + "\">" + friendLink.linkName + "</a>");
}
$("#friendLink").append(friendLinkHtml);
} else {

View File

@ -49,7 +49,7 @@
<!-- 你的HTML代码 -->
<a name="top"></a>
<ul class="layui-nav app" lay-filter="" style="display:none;padding:0 10px;text-align: center">
<ul class="layui-nav app" lay-filter="" style="display:none;padding:0 10px;text-align: center">
<li class="layui-nav-item"><a>分类</a>
<dl class="layui-nav-child">
<dd><a href="/book/book_ranking.html?catId=1&sort=last_index_update_time">玄幻小说</a></dd>
@ -145,46 +145,48 @@
</blockquote>
<div class="layui-container" style="padding: 0px">
<div class="layui-container" style="padding: 0px">
<div class="layui-row" style="text-align: center" id="currentWeek">
</div>
<div class="layui-row" style="text-align: center" id="currentWeek" th:if="${bookMap['4']}">
<span th:each="book,iterStat : ${bookMap['4']}" th:if="${iterStat.index<3}">
<a th:href="'/book/'+${book.bookId}+'.html'">
<div style="padding: 1%" class="layui-col-xs4 layui-col-sm4 layui-col-md4 layui-col-lg4">
<img style=" width:100px; height:125px; max-width:100%; max-height:100%;"
th:src="${book.picUrl}">
<br>
<span th:text="${#strings.length(book.bookName) > 5}? (${#strings.substring(book.bookName,0,5)}+'...'): ${book.bookName} "></span>
</div>
</a>
</span>
</div>
</div>
</div>
<div class="layui-colla-item">
<blockquote class="layui-elem-quote" style="text-align: left;font-size: 16px">
热门推荐
</blockquote>
<div class="layui-container">
<div class="layui-row" id="hotRecBooks">
<div class="layui-container">
<div class="layui-row" id="hotRecBooks" th:if="${bookMap['3']}">
<div th:each="book,iterStat : ${bookMap['3']}" th:if="${iterStat.index<6}" style="margin-bottom: 5px" class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
<a th:href="'/book/'+${book.bookId}+'.html'">
<div class="layui-col-xs5 layui-col-sm4 layui-col-md4 layui-col-lg4">
<img style=" width:100px; height:125px;" th:src="${book.picUrl}">
<!--<div th:each="hotBook : ${hotBooks}" style="margin-top: 1%"
class="layui-col-xs12 layui-col-sm6 layui-col-md6 layui-col-lg6">
<a th:href="'/book/'+${hotBook.id}+'.html'">
<div class="layui-col-xs5 layui-col-sm3 layui-col-md3 layui-col-lg3">
<img style=" width:100px; height:125px;"
th:src="${hotBook.picUrl}"/>
</div>
<div class="layui-col-xs7 layui-col-sm6 layui-col-md7 layui-col-lg7"
style="float: left;padding-right: 10px">
<div><b th:text="${hotBook.bookName}"></b></div>
<div class="layui-col-xs8 layui-col-sm9 layui-col-md10 layui-col-lg10"
th:text="'作者'+ ${hotBook.author}"></div>
<div class="layui-col-xs3 layui-col-sm2 layui-col-md1 layui-col-lg1" style="text-align: right;">
<b><i style="color: red"
th:text="${hotBook.score} + '分'"></i></b></div>
</div>
<div class="layui-elip layui-col-xs12 layui-col-sm9 layui-col-md10 layui-col-lg10 layui-col-sm9 layui-col-md10 layui-col-lg10"
th:text="${hotBook.bookDesc}">
</div>
<div class="layui-col-xs5 layui-col-sm6 layui-col-md6 layui-col-lg6">
<ul>
<li style="padding-bottom: 2px" class="line-limit-length" th:text="${book.bookName}"></li>
<li style="padding-bottom: 2px;color: #a6a6a6" th:text="'作者'+${book.authorName}"></li>
<li style="color: #a6a6a6;width: 180px;height:60px;overflow: hidden" th:utext="${book.bookDesc}"> </li></ul>
</div>
<div style="font-style: italic;color: red" class="layui-col-xs2 layui-col-sm2 layui-col-md2 layui-col-lg2"></div>
</a>
</div>-->
</div>
</div>
</div>
@ -209,7 +211,6 @@
<div class="layui-row" id="updateRankBooks">
</div>
</div>
@ -227,87 +228,6 @@
<script>
//加载首页书籍设置数据
$.ajax({
type: "get",
url: "/book/listBookSetting",
data: {},
dataType: "json",
success: function (data) {
if (data.code == 200) {
//精品推荐
var rightListBooks = data.data[4];
var rightListBooksHtml = "";
for (var i = 0; i < 3; i++) {
var rightListBook = rightListBooks[i];
var classHtml = "";
if (i == 0) {
classHtml = "on";
}
if (i < 3) {
classHtml += (" num" + (i + 1));
}
rightListBooksHtml += (" <span>\n" +
" <a href=\"/book/"+rightListBook.bookId+".html\">\n" +
" <div style=\"padding: 1%\" class=\"layui-col-xs4 layui-col-sm4 layui-col-md4 layui-col-lg4\">\n" +
" <img style=\" width:100px; height:125px; max-width:100%; max-height:100%;\"\n" +
" src=\""+rightListBook.picUrl+"\"/>\n" +
"\n" +
" <br/>\n" +
" <span >"+(rightListBook.bookName.length>5?(rightListBook.bookName.substr(0,5)+'...'):rightListBook.bookName)+"</span>\n" +
"\n" +
" </div>\n" +
" </a>\n" +
" </span>");
}
$("#currentWeek").html(rightListBooksHtml);
//热门推荐
var hotRecBooks = data.data[3];
var hotRecBooksHtml = "";
for (var i = 0; i < 6; i++) {
var hotRecBook = hotRecBooks[i];
if(hotRecBook.bookDesc){
hotRecBook.bookDesc = hotRecBook.bookDesc.replace(/<[^>]+>/g,"").replace(/\s+/g,"");
}
//手机浏览器不支持String.replaceAll()方法
hotRecBooksHtml += ("<div style=\"margin-bottom: 5px\" class=\"layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4\">\n" +
" <a href=\"/book/"+hotRecBook.bookId+".html\">\n" +
" <div class=\"layui-col-xs5 layui-col-sm4 layui-col-md4 layui-col-lg4\" >\n" +
" <img style=\" width:100px; height:125px;\"\n" +
" src=\""+hotRecBook.picUrl+"\"/>\n" +
"\n" +
" </div>\n" +
" <div class=\"layui-col-xs5 layui-col-sm6 layui-col-md6 layui-col-lg6\">\n" +
" <ul>\n" +
" <li style='padding-bottom: 2px' class=\"line-limit-length\" >"+hotRecBook.bookName+"</li>\n" +
" <li style='padding-bottom: 2px;color: #a6a6a6'>作者:"+hotRecBook.authorName+"</li>\n" +
" <li style=\"color: #a6a6a6;width: 180px;height:60px;overflow: hidden\">"+hotRecBook.bookDesc +
" </ul>\n" +
" </div>\n" +
" <div style=\"font-style: italic;color: red\"\n" +
" class=\"layui-col-xs2 layui-col-sm2 layui-col-md2 layui-col-lg2\"></div>\n" +
" </a>\n" +
" </div>");
}
$("#hotRecBooks").html(hotRecBooksHtml);
} else {
layer.alert(data.msg);
}
},
error: function () {
layer.alert('网络异常');
}
})
//更新榜单查询
@ -323,26 +243,24 @@
for (var i = 0; i < 10; i++) {
var updateRankBook = updateRankBooks[i];
if(updateRankBook.bookDesc){
updateRankBook.bookDesc = updateRankBook.bookDesc.replace(/<[^>]+>/g,"").replace(/\s+/g,"");
if (updateRankBook.bookDesc) {
updateRankBook.bookDesc = updateRankBook.bookDesc.replace(/<[^>]+>/g, "").replace(/\s+/g, "");
}
updateRankBookHtml += ("<div style=\"padding-bottom: 30px\"\n" +
" class=\"layui-col-xs12 layui-col-sm6 layui-col-md6 layui-col-lg6\">\n" +
"\n" +
" <a href=\"/book/"+updateRankBook.id+".html\">\n" +
" <div class=\"line-limit-length layui-col-xs8 layui-col-sm6 layui-col-md6 layui-col-lg6\"><span '>"+(i+1)+"."+updateRankBook.bookName+"</span> - <span class=\"layui-elip\" style='color: #a6a6a6;'>"+updateRankBook.authorName+"</span>\n" +
" </div>\n" +
" <div class=\"layui-col-sm3 layui-col-md3 layui-col-lg3\"\n" +
" style=\"color: #FF5722;float: right;margin-right:5px\"><i>"+updateRankBook.lastIndexUpdateTime+"</i></div>\n" +
"\n" +
" <div style=\"clear: both\"></div>\n" +
" <div style=\"color: #a6a6a6;padding-left: 5px;padding-top: 5px\"\n" +
" class=\"layui-elip layui-col-md11 layui-col-sm11 layui-col-lg11\">简介:  "+updateRankBook.bookDesc+"" +
" </div></a>\n" +
" </div>");
updateRankBookHtml += ("<div style=\"padding-bottom: 30px\"\n" +
" class=\"layui-col-xs12 layui-col-sm6 layui-col-md6 layui-col-lg6\">\n" +
"\n" +
" <a href=\"/book/" + updateRankBook.id + ".html\">\n" +
" <div class=\"line-limit-length layui-col-xs8 layui-col-sm6 layui-col-md6 layui-col-lg6\"><span '>" + (i + 1) + "." + updateRankBook.bookName + "</span> - <span class=\"layui-elip\" style='color: #a6a6a6;'>" + updateRankBook.authorName + "</span>\n" +
" </div>\n" +
" <div class=\"layui-col-sm3 layui-col-md3 layui-col-lg3\"\n" +
" style=\"color: #FF5722;float: right;margin-right:5px\"><i>" + updateRankBook.lastIndexUpdateTime + "</i></div>\n" +
"\n" +
" <div style=\"clear: both\"></div>\n" +
" <div style=\"color: #a6a6a6;padding-left: 5px;padding-top: 5px\"\n" +
" class=\"layui-elip layui-col-md11 layui-col-sm11 layui-col-lg11\">简介:  " + updateRankBook.bookDesc + "" +
" </div></a>\n" +
" </div>");
}
@ -359,7 +277,6 @@
})
function moreNewBooks(event) {
window.location.href = "/book/book_ranking.html?sortBy=last_index_update_time";
}

View File

@ -22,9 +22,6 @@
<div class="fl">
充值账号:<span class="user_name" id="my_name"></span>余额:<em class="red" id="accountBalance">0</em>屋币<!--<em class="red">+0</em>代金券-->
</div>
<!--<div class="fr">
<a class="btn_gray" href="/user/pay_record.aspx" target="_blank">充值记录</a><a class="btn_gray" href="/user/my_order.aspx" target="_blank">消费记录</a>
</div>-->
</div>
<div class="payCon">
<h5>选择充值方式</h5>

View File

@ -23,18 +23,6 @@
<form method="post" action="/" id="Form1"
onsubmit="javascript:return checkForm();">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKLTI0NTcxNzYzNQ9kFgJmD2QWAmYPFgIeBFRleHQFqAE8YSBocmVmPSIvc2VhcmNoLmFzcHg/c2VhcmNoS2V5PeWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqyIgdGFyZ2V0PSJfYmxhbmsiPuWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqzwvYT5kZOKmHcn3Hx3hiIXMcMpQUjAD9MIGLnq1zjEfYvQaVwy3"/>
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR"
value="EC00F135"/>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="/wEdAAOgvD0TAZWHlMabubpkV5BnBh62Mb2K7OVw5a48s/sFVJZYgDymPir0Zp4mFYzbkIhNun0nyr9cDo847Ee31BA4NS8zv4PJDmcEpjfg+YdsoQ=="/>
</div>
<ul class="reg_list">
<li>
<textarea name="txtDescription" rows="2" cols="20" id="txtDescription"

View File

@ -17,15 +17,6 @@
<div class="userBox cf">
<div class="user_l">
<form method="post" action="./login.html" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJLTU4MDE1Nzc3D2QWAmYPZBYCZg8WAh4EVGV4dAWoATxhIGhyZWY9Ii9zZWFyY2guYXNweD9zZWFyY2hLZXk95Za75a6J6Zuv77yM54uE5rO977yM54G15byC77yM5YmN5LiW5LuK55Sf77yM5Yal546L6ay85aSrIiB0YXJnZXQ9Il9ibGFuayI+5Za75a6J6Zuv77yM54uE5rO977yM54G15byC77yM5YmN5LiW5LuK55Sf77yM5Yal546L6ay85aSrPC9hPmRke+U5PV/m7ho155TiR+flEgGjh+T6z8Hjoa5q62rCUFg=" />
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="C93BE1AE" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAXkRxK+hbBn9D6bVAXo8t/4qKSXUE1UN51mNFrIuw38c3Y2+Mc6SrnAqio3oCKbxYainihG6d/Xh3PZm3b5AoMQ2xnvcKe7Apj/DdmzfeCXoTjAjITeRewsBR3AmjdQ75+yP5bUUcdUUiZlMKONJDef" />
</div>
<h3 th:text="'登陆'+${application.website.name}"></h3>
<ul class="log_list">
<li><span id="LabErr"></span></li>

View File

@ -16,17 +16,6 @@
<div class="main box_center cf">
<div class="userBox cf">
<form method="post" action="./register.html" id="form2">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKLTIzNjMxNDQxNw9kFgJmD2QWAmYPFgIeBFRleHQFqAE8YSBocmVmPSIvc2VhcmNoLmFzcHg/c2VhcmNoS2V5PeWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqyIgdGFyZ2V0PSJfYmxhbmsiPuWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqzwvYT5kZOquoASBvnvPbc/TYIQiLhSPJ8GKnYQrmk7jGhb5AC5Q"/>
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="23AA6834"/>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="/wEdAAVece19BIZ9HiByRfHz3pfnqKSXUE1UN51mNFrIuw38c3Y2+Mc6SrnAqio3oCKbxYZZ1lS+gZUZKpbsAea8j7ASAv40DHFcQ/NE7tJUnABeyQ3d9sFDIcFCYNqlVtprfLoh4JFy0U+R/CcMuyAiWTz7"/>
</div>
<div class="user_l">
<h3 th:text="'注册'+${application.website.name}+'小说账号'"></h3>
<ul class="log_list">

View File

@ -25,17 +25,6 @@
<div class="my_r">
<div class="my_info cf">
<div class="my_info_txt">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKMTI5MzkzMzQyMw9kFgJmD2QWAmYPFgIeBFRleHQFqAE8YSBocmVmPSIvc2VhcmNoLmFzcHg/c2VhcmNoS2V5PeWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqyIgdGFyZ2V0PSJfYmxhbmsiPuWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqzwvYT5kZLj1Uo6akAHRsP9HH/tJWCPmjwlzm9tv02sZRfbbCnBA"/>
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="6C876674"/>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="/wEdAAO8SPdUDpH0Q7nHjeqbvI7ld2C+OxfjpZOniBJbql7XdnRgTJ25FWigbeFr84Vgoxdi/cg2vS37N0KER6F1nyr1wKHztnXmDR5zls+9dCeAZg=="/>
</div>
<ul class="mytab_list">
<li><i class="tit">我的昵称</i><input name="txtNiceName" type="text" value="15171695474"
maxlength="20" id="txtNiceName" class="s_input"

View File

@ -24,15 +24,6 @@
<div class="my_r">
<div class="my_info cf">
<div class="my_info_txt">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE5NTM3Mjc0MTkPZBYEZg9kFgJmDxYCHgRUZXh0BagBPGEgaHJlZj0iL3NlYXJjaC5hc3B4P3NlYXJjaEtleT3llrvlronpm6/vvIzni4Tms73vvIzngbXlvILvvIzliY3kuJbku4rnlJ/vvIzlhqXnjovprLzlpKsiIHRhcmdldD0iX2JsYW5rIj7llrvlronpm6/vvIzni4Tms73vvIzngbXlvILvvIzliY3kuJbku4rnlJ/vvIzlhqXnjovprLzlpKs8L2E+ZAICD2QWAgIJDw8WAh8ABSHkuKTmrKHovpPlhaXnmoTmlrDlr4bnoIHkuI3ljLnphY1kZGRhp36YOW0VXvnzag3X7ggb4GZjGR2iOhc3esYV+gLQoA==" />
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="65B8FACB" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAX/+YBS+s4SAkXd5M3/Ah/txr1QWsMVpxihbk+u9oMvC/bi8V6FV2PI0iftNhvgoqk7nMhcHLH9bj8jEonVtSua9n7/EOPGKgFySK9U6TwmXfgmt+UwsLWDkQL9tHgrPR3yuBzIgg7/7BXfGNHKEmhv" />
</div>
<ul class="mytab_list">
<li><i class="tit">我的密码</i><input name="oldPass" type="password" id="txtOldPass" class="s_input" placeholder="请输入原密码" /></li>
<li><i class="tit">&nbsp;</i><input name="txtNewPass1" type="password" id="txtNewPass1" class="s_input" placeholder="请输入新密码" /></li>

View File

@ -24,15 +24,6 @@
<div class="my_r">
<div class="my_info cf">
<div class="my_info_txt">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTkyODgwMDQwMA9kFgJmD2QWAmYPFgIeBFRleHQFqAE8YSBocmVmPSIvc2VhcmNoLmFzcHg/c2VhcmNoS2V5PeWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqyIgdGFyZ2V0PSJfYmxhbmsiPuWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqzwvYT5kZMZ5uDacrADq981tXsiwhce7e3YhhhJ5JQQTUHxIrSut" />
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="5DBBC1A2" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAIB0+ZH6KYdr1mTvok41QcAdGBMnbkVaKBt4WvzhWCjFyKLzSsxk3yjFX2xXrDnmlabnJvU11tPMoHIge4rg3hW" />
</div>
<ul class="mytab_list">
<li><i class="tit">我的性别</i>
<label><input type="radio" name="sex" value="0" />&nbsp;男生</label>

View File

@ -96,45 +96,48 @@
var file = $("#file0").val(); //文件名称
if (file != "") {
$.ajaxFileUpload({
url : "/file/upload", //用于文件上传的服务器端请求地址
secureuri : false, //是否需要安全协议一般设置为false
fileElementId : "file0", //文件上传域的ID
dataType : "json", //返回值类型 一般设置为json
type : "post",
success : function(data) { //服务器成功响应处理函数
if (data.code == 200) {
if(checkPicUpload($("#file0")[0])) {
$.ajax({
type: "POST",
url: "/user/updateUserInfo",
data: {'userPhoto':data.data},
dataType: "json",
success: function (data) {
if (data.code == 200) {
window.location.href = '/user/setup.html';
$.ajaxFileUpload({
url: "/file/picUpload", //用于文件上传的服务器端请求地址
secureuri: false, //是否需要安全协议一般设置为false
fileElementId: "file0", //文件上传域的ID
dataType: "json", //返回值类型 一般设置为json
type: "post",
success: function (data) { //服务器成功响应处理函数
if (data.code == 200) {
} else if (data.code == 1001) {
//未登录
location.href = '/user/login.html?originUrl=' + decodeURIComponent(location.href);
$.ajax({
type: "POST",
url: "/user/updateUserInfo",
data: {'userPhoto': data.data},
dataType: "json",
success: function (data) {
if (data.code == 200) {
window.location.href = '/user/setup.html';
} else {
layer.alert(data.msg);
} else if (data.code == 1001) {
//未登录
location.href = '/user/login.html?originUrl=' + decodeURIComponent(location.href);
} else {
layer.alert(data.msg);
}
},
error: function () {
layer.alert('网络异常');
}
})
},
error: function () {
layer.alert('网络异常');
}
})
} else {
layer.alert(data.msg);
}
}else {
layer.alert('图片上传失败');
}
}
});
});
}
} else {
alert("请选择上传文件!");
}

View File

@ -5,7 +5,7 @@
<groupId>com.java2nb</groupId>
<artifactId>novel</artifactId>
<version>3.5.1</version>
<version>3.5.4</version>
<modules>
<module>novel-common</module>
<module>novel-front</module>

View File

@ -6,7 +6,7 @@
<script>
setTimeout(function () {
location.href = '/';
},3000)
},1000)
</script>
</head>

View File

@ -43,17 +43,6 @@
<div class="userBox cf">
<form method="post" action="./register.html" id="form2">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKLTIzNjMxNDQxNw9kFgJmD2QWAmYPFgIeBFRleHQFqAE8YSBocmVmPSIvc2VhcmNoLmFzcHg/c2VhcmNoS2V5PeWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqyIgdGFyZ2V0PSJfYmxhbmsiPuWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqzwvYT5kZOquoASBvnvPbc/TYIQiLhSPJ8GKnYQrmk7jGhb5AC5Q">
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="23AA6834">
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="/wEdAAVece19BIZ9HiByRfHz3pfnqKSXUE1UN51mNFrIuw38c3Y2+Mc6SrnAqio3oCKbxYZZ1lS+gZUZKpbsAea8j7ASAv40DHFcQ/NE7tJUnABeyQ3d9sFDIcFCYNqlVtprfLoh4JFy0U+R/CcMuyAiWTz7">
</div>
<div class="user_l">
<div></div>
<h3>小说基本信息填写</h3>
@ -142,29 +131,32 @@
<script src="/layui/layui.all.js" type="text/javascript"></script>
<script src="/javascript/header.js" type="text/javascript"></script>
<script src="/javascript/user.js" type="text/javascript"></script>
<script src="/javascript/common.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
function picChange() {
var file = $("#file0").val(); //文件名称
if (file != "") {
$.ajaxFileUpload({
url : "/file/upload", //用于文件上传的服务器端请求地址
secureuri : false, //是否需要安全协议一般设置为false
fileElementId : "file0", //文件上传域的ID
dataType : "json", //返回值类型 一般设置为json
type : "post",
success : function(data) { //服务器成功响应处理函数
if (data.code == 200) {
$("#picImage").attr("src", data.data);
$("#picUrl").val(data.data);
}else {
layer.alert('图片上传失败');
if(checkPicUpload($("#file0")[0])) {
$.ajaxFileUpload({
url: "/file/picUpload", //用于文件上传的服务器端请求地址
secureuri: false, //是否需要安全协议一般设置为false
fileElementId: "file0", //文件上传域的ID
dataType: "json", //返回值类型 一般设置为json
type: "post",
success: function (data) { //服务器成功响应处理函数
if (data.code == 200) {
$("#picImage").attr("src", data.data);
$("#picUrl").val(data.data);
} else {
layer.alert(data.msg);
}
}
}
});
});
}
} else {
alert("请选择上传文件");
}

View File

@ -40,17 +40,6 @@
<div class="userBox cf">
<form method="post" action="./register.html" id="form2">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKLTIzNjMxNDQxNw9kFgJmD2QWAmYPFgIeBFRleHQFqAE8YSBocmVmPSIvc2VhcmNoLmFzcHg/c2VhcmNoS2V5PeWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqyIgdGFyZ2V0PSJfYmxhbmsiPuWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqzwvYT5kZOquoASBvnvPbc/TYIQiLhSPJ8GKnYQrmk7jGhb5AC5Q">
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="23AA6834">
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="/wEdAAVece19BIZ9HiByRfHz3pfnqKSXUE1UN51mNFrIuw38c3Y2+Mc6SrnAqio3oCKbxYZZ1lS+gZUZKpbsAea8j7ASAv40DHFcQ/NE7tJUnABeyQ3d9sFDIcFCYNqlVtprfLoh4JFy0U+R/CcMuyAiWTz7">
</div>
<div class="user_l">
<div></div>
<h3>小说章节内容填写</h3>

View File

@ -38,17 +38,6 @@
<div class="userBox cf">
<form method="post" action="./register.html" id="form2">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKLTIzNjMxNDQxNw9kFgJmD2QWAmYPFgIeBFRleHQFqAE8YSBocmVmPSIvc2VhcmNoLmFzcHg/c2VhcmNoS2V5PeWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqyIgdGFyZ2V0PSJfYmxhbmsiPuWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqzwvYT5kZOquoASBvnvPbc/TYIQiLhSPJ8GKnYQrmk7jGhb5AC5Q">
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="23AA6834">
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="/wEdAAVece19BIZ9HiByRfHz3pfnqKSXUE1UN51mNFrIuw38c3Y2+Mc6SrnAqio3oCKbxYZZ1lS+gZUZKpbsAea8j7ASAv40DHFcQ/NE7tJUnABeyQ3d9sFDIcFCYNqlVtprfLoh4JFy0U+R/CcMuyAiWTz7">
</div>
<div class="user_l">
<div></div>
<h3>小说章节内容填写</h3>

View File

@ -133,10 +133,12 @@
</body>
<script src="/javascript/jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="/javascript/ajaxfileupload.js" type="text/javascript"></script>
<script src="/layui/layui.all.js" type="text/javascript"></script>
<script src="/javascript/header.js" type="text/javascript"></script>
<script src="/javascript/user.js" type="text/javascript"></script>
<script src="/javascript/date.js" type="text/javascript"></script>
<script src="/javascript/common.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
search(1, 5);
@ -162,7 +164,12 @@
" ["+(i+1)+"]\n" +
" </td>\n" +*/
" <td class=\"goread\">\n" +
" <td style=\"position: relative\" class=\"goread\">\n" +
"<input class=\"opacity\" onchange=\"picChange('"+book.id+"')\"\n" +
" type=\"file\" id=\"file0\" name=\"file\"\n" +
" title=\"点击上传图片\"\n" +
" style=\"z-index: 100;cursor: pointer;left: 30px; top: 0px; width: 60px; height: 80px; opacity: 0; position: absolute; \"\n" +
" />" +
"<img width='50' height='70' src='"+book.picUrl+"'/><br/>" +
" "+book.bookName+"</td>\n" +
@ -269,6 +276,58 @@
}
function picChange(bookId) {
var file = $("#file0").val(); //文件名称
if (file != "") {
if(checkPicUpload($("#file0")[0])) {
$.ajaxFileUpload({
url: "/file/picUpload", //用于文件上传的服务器端请求地址
secureuri: false, //是否需要安全协议一般设置为false
fileElementId: "file0", //文件上传域的ID
dataType: "json", //返回值类型 一般设置为json
type: "post",
success: function (data) { //服务器成功响应处理函数
if (data.code == 200) {
$.ajax({
type: "POST",
url: "/author/updateBookPic",
data: {'bookId': bookId, 'bookPic': data.data},
dataType: "json",
success: function (data) {
if (data.code == 200) {
location.reload();
} else {
lock = false;
layer.alert(data.msg);
}
},
error: function () {
lock = false;
layer.alert('网络异常');
}
})
} else {
layer.alert(data.msg);
}
}
});
}
} else {
alert("请选择上传文件!");
}
}
</script>
</html>

View File

@ -33,15 +33,6 @@
<body style="background-color: #444;">
<div style="width: 800px; margin-left: auto; margin-right: auto; margin-top: 150px;">
<form method="post" action="/author/register.html" id="form1" onsubmit="return $(this).form(&quot;validate&quot;);">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTcyNTY0MjQ5NGRk++It0MqlJDSbyu54vkeAbEa5OUhkaoZyC53OelRtDeg=" />
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="799CC77D" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAkIOs3R4B2+v3nSsFBLSe3g1MEpq666rzQ7jjzhNwecX7wsg773N8DhSUPLdYYjtuwvQ8kN6tkIkhd/68qh+xm6RWIUm/02TrSmncT3Z6CDZUrw+Qm6bt8NGm9h/X+a2xTq1sAiXqGUGwYVZVK+kL9fPOaW1pQztoQA36D1w/+bXZEqukB3SRMoY9NENNgXVe/neqc7kNqcr4JW0Rj8Hcw3qispLYQVy/s36rQl1WiEaw==" />
</div>
<div id="main">
<table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic" style="line-height:40px;">
<tr>

Some files were not shown because too many files have changed in this diff Show More