remove unused code

This commit is contained in:
Cauchy
2023-10-16 15:16:30 +08:00
parent 08cc5c3a3d
commit e80116643c
14 changed files with 113 additions and 353 deletions

View File

@@ -1,24 +1,15 @@
package com.peanut.modules.book.controller;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.BuyOrderDetailEntity;
import com.peanut.modules.book.service.BuyOrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Map;
import com.peanut.modules.book.entity.BuyOrderEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.peanut.modules.book.entity.BuyOrderDetailEntity;
import com.peanut.modules.book.service.BuyOrderDetailService;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
/**
* 商品订单详情表
*
@@ -32,32 +23,27 @@ public class BuyOrderDetailController {
@Autowired
private BuyOrderDetailService buyOrderDetailService;
/**
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("book:buyorderdetail:list")
public R list(@RequestParam Map<String, Object> params){
public R list(@RequestParam Map<String, Object> params) {
PageUtils page = buyOrderDetailService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 查询已购买书籍
* 查询已购买书籍
*
* @param params
* @return
*/
@RequestMapping("/querybuy")
public R querybuy(@RequestParam Map<String, Object> params){
public R querybuy(@RequestParam Map<String, Object> params) {
PageUtils page = buyOrderDetailService.querybuy(params);
return R.ok().put("page", page);
}
/**
* 去重查询可打印面单
*
@@ -65,10 +51,8 @@ public class BuyOrderDetailController {
* @return
*/
@RequestMapping("/querySheetPage")
public R querySheetPage(@RequestParam Map<String, Object> params){
public R querySheetPage(@RequestParam Map<String, Object> params) {
PageUtils page = buyOrderDetailService.querySheet(params);
return R.ok().put("page", page);
}
@@ -76,9 +60,8 @@ public class BuyOrderDetailController {
* 信息
*/
@RequestMapping("/info/{allOrderId}")
public R info(@PathVariable("allOrderId") Long allOrderId){
BuyOrderDetailEntity buyOrderDetail = buyOrderDetailService.getById(allOrderId);
public R info(@PathVariable("allOrderId") Long allOrderId) {
BuyOrderDetailEntity buyOrderDetail = buyOrderDetailService.getById(allOrderId);
return R.ok().put("buyOrderDetail", buyOrderDetail);
}
@@ -86,10 +69,8 @@ public class BuyOrderDetailController {
* 保存
*/
@RequestMapping("/save")
// @RequiresPermissions("book:buyorderdetail:save")
public R save(@RequestBody BuyOrderDetailEntity buyOrderDetail){
buyOrderDetailService.save(buyOrderDetail);
public R save(@RequestBody BuyOrderDetailEntity buyOrderDetail) {
buyOrderDetailService.save(buyOrderDetail);
return R.ok();
}
@@ -97,10 +78,8 @@ public class BuyOrderDetailController {
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("book:buyorderdetail:update")
public R update(@RequestBody BuyOrderDetailEntity buyOrderDetail){
buyOrderDetailService.updateById(buyOrderDetail);
public R update(@RequestBody BuyOrderDetailEntity buyOrderDetail) {
buyOrderDetailService.updateById(buyOrderDetail);
return R.ok();
}
@@ -108,15 +87,13 @@ public class BuyOrderDetailController {
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("book:buyorderdetail:delete")
public R delete(@RequestBody Long[] allOrderIds){
buyOrderDetailService.removeByIds(Arrays.asList(allOrderIds));
public R delete(@RequestBody Long[] allOrderIds) {
buyOrderDetailService.removeByIds(Arrays.asList(allOrderIds));
return R.ok();
}
@RequestMapping("/updateOrderStatus")
public R updateOrderStatus(@RequestBody BuyOrderDetailEntity buyOrderDetail){
public R updateOrderStatus(@RequestBody BuyOrderDetailEntity buyOrderDetail) {
buyOrderDetail.setOrderStatus("2");
buyOrderDetailService.updateById(buyOrderDetail);
return R.ok();
@@ -130,7 +107,7 @@ public class BuyOrderDetailController {
* @return
*/
@RequestMapping("/batchUpdateByShippingSns")
public R batchUpdateByShippingSns(@RequestBody String[] shippingSnList){
public R batchUpdateByShippingSns(@RequestBody String[] shippingSnList) {
buyOrderDetailService.batchUpdateByShippingSns(shippingSnList);
return R.ok();
}

View File

@@ -25,7 +25,6 @@ import java.util.Map;
@RequestMapping("api/province")
public class ProvinceController {
@Autowired
private ProvinceService provinceService;
@Autowired
@@ -37,7 +36,7 @@ public class ProvinceController {
//获取地址
@RequestMapping("/getProvince")
public R getProvince(){
public R getProvince() {
//优化查询速度 目录放入redis中
@@ -46,40 +45,36 @@ public class ProvinceController {
if (StringUtils.isNotBlank(s)) {
List<Object> redisData = JSONArray.parseArray(s);
for (Object object : redisData) {
Map <String,Object> ret = (Map<String, Object>) object;//取出list里面的值转为map
Map<String, Object> ret = (Map<String, Object>) object;//取出list里面的值转为map
listData.add(ret);
}
return R.ok().put("provinceEntity",listData);
return R.ok().put("provinceEntity", listData);
}
List<ProvinceEntity> provinceEntityList = provinceService.getCity();
redisTemplate.opsForValue().set("Province", JSON.toJSONString(provinceEntityList));
return R.ok().put("provinceEntity",provinceEntityList);
return R.ok().put("provinceEntity", provinceEntityList);
}
//获取省列表
@RequestMapping("/getProvinceList")
public R getProvinceList(){
public R getProvinceList() {
List<ProvinceEntity> provinceList = provinceService.getBaseMapper().selectList(new QueryWrapper<ProvinceEntity>());
return R.ok().put("provinceList",provinceList);
return R.ok().put("provinceList", provinceList);
}
//获取市列表
@RequestMapping("/getCityList")
public R getCityList(@RequestParam("provId") Integer provId){
public R getCityList(@RequestParam("provId") Integer provId) {
List<CityEntity> prov = cityService.getBaseMapper().selectList(new QueryWrapper<CityEntity>()
.eq("prov_id", provId));
return R.ok().put("prov",prov);
return R.ok().put("prov", prov);
}
//获取区列表
@RequestMapping("/getCountyList")
public R getCountyList(@RequestParam("cityId") Integer cityId){
public R getCountyList(@RequestParam("cityId") Integer cityId) {
List<CountyEntity> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<CountyEntity>().eq("city_id", cityId));
return R.ok().put("countyList",countyList);
return R.ok().put("countyList", countyList);
}
}

View File

@@ -1,24 +1,15 @@
package com.peanut.modules.book.controller;
import java.util.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.modules.book.entity.AuthorEntity;
import com.peanut.modules.book.service.BookService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.peanut.modules.book.entity.PublisherEntity;
import com.peanut.modules.book.service.PublisherService;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.PublisherEntity;
import com.peanut.modules.book.service.BookService;
import com.peanut.modules.book.service.PublisherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* 出版商表
@@ -39,10 +30,8 @@ public class PublisherController {
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("book:publisher:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = publisherService.queryPage(params);
return R.ok().put("page", page);
}
@@ -50,7 +39,6 @@ public class PublisherController {
* 列表
*/
@RequestMapping("/publisherList")
// @RequiresPermissions("book:publisher:list")
public R publisherList(){
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>());
ArrayList<Object> list = new ArrayList<>();
@@ -60,7 +48,6 @@ public class PublisherController {
map.put("value",publisherEntitie.getPublisherName());
list.add(map);
}
return R.ok().put("list", list);
}
@@ -68,10 +55,8 @@ public class PublisherController {
* 信息
*/
@RequestMapping("/info/{id}")
// @RequiresPermissions("book:publisher:info")
public R info(@PathVariable("id") Integer id){
PublisherEntity publisher = publisherService.getById(id);
return R.ok().put("publisher", publisher);
}
@@ -80,7 +65,6 @@ public class PublisherController {
* 信息
*/
@RequestMapping("/appGetInfo/{id}/{limit}/{page}")
// @RequiresPermissions("book:author:info")
public R appGetInfo(@PathVariable("id") Integer id,
@PathVariable("limit") String limit,
@PathVariable("page") String page){
@@ -103,7 +87,6 @@ public class PublisherController {
public R save(@RequestBody PublisherEntity publisher){
publisher.setDelFlag(0);
publisherService.save(publisher);
return R.ok();
}
@@ -111,10 +94,8 @@ public class PublisherController {
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("book:publisher:update")
public R update(@RequestBody PublisherEntity publisher){
publisherService.updateById(publisher);
return R.ok();
}
@@ -122,11 +103,8 @@ public class PublisherController {
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("book:publisher:delete")
public R delete(@RequestBody Integer[] ids){
publisherService.removeByIds(Arrays.asList(ids));
return R.ok();
}
}

View File

@@ -1,23 +1,16 @@
package com.peanut.modules.book.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.SeckillProdRelationEntity;
import com.peanut.modules.book.service.SeckillProdRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.peanut.modules.book.entity.SeckillProdRelationEntity;
import com.peanut.modules.book.service.SeckillProdRelationService;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
@@ -38,7 +31,6 @@ public class SeckillProdRelationController {
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("book:seckillprodrelation:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = seckillProdRelationService.queryPage(params);
@@ -50,7 +42,6 @@ public class SeckillProdRelationController {
* 信息
*/
@RequestMapping("/info/{id}")
// @RequiresPermissions("book:seckillprodrelation:info")
public R info(@PathVariable("id") Integer id){
SeckillProdRelationEntity seckillProdRelation = seckillProdRelationService.getById(id);
@@ -61,26 +52,18 @@ public class SeckillProdRelationController {
* 保存
*/
@RequestMapping("/save")
// @RequiresPermissions("book:seckillprodrelation:save")
public R save(@RequestBody SeckillProdRelationEntity seckillProdRelation){
//判断当前场次 是否有相同商品
Integer prodId = seckillProdRelation.getProdId();
Integer promotionSeckillId = seckillProdRelation.getPromotionSeckillId();
List<SeckillProdRelationEntity> list = seckillProdRelationService.list(new QueryWrapper<SeckillProdRelationEntity>().eq("promotion_seckill_id", promotionSeckillId));
for (SeckillProdRelationEntity seckillProdRelationEntity : list) {
Integer prodId1 = seckillProdRelationEntity.getProdId();
if (prodId1 == prodId){
return R.error("商品已存在");
}
}
seckillProdRelationService.save(seckillProdRelation);
return R.ok();
}
@@ -88,7 +71,6 @@ public class SeckillProdRelationController {
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("book:seckillprodrelation:update")
public R update(@RequestBody SeckillProdRelationEntity seckillProdRelation){
seckillProdRelationService.updateById(seckillProdRelation);

View File

@@ -78,7 +78,6 @@ public class ShopProductLabelController {
return R.ok();
}
@RequestMapping("/getLabels")
public R getLabels(){
List<ShopProductLabelEntity> shopProductLabelEntities = shopProductLabelService.getBaseMapper().selectList(new QueryWrapper<ShopProductLabelEntity>()
@@ -88,8 +87,6 @@ public class ShopProductLabelController {
return R.ok().put("result",re);
}
/**
* 废除
* @param params
@@ -102,7 +99,6 @@ public class ShopProductLabelController {
}
/**
* 获取商品列表通过标签
* @return
@@ -119,12 +115,4 @@ public class ShopProductLabelController {
return R.ok().put("page",shopProductEntityPage);
}
}

View File

@@ -1,21 +1,17 @@
package com.peanut.modules.book.controller;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.ShopSeckillEntity;
import com.peanut.modules.book.service.ShopSeckillService;
import com.peanut.modules.book.to.SeckillRedisTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import com.peanut.modules.book.to.SeckillRedisTo;
import com.peanut.modules.book.vo.SeckillProdVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.peanut.modules.book.entity.ShopSeckillEntity;
import com.peanut.modules.book.service.ShopSeckillService;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
/**
* 秒杀库存表
@@ -34,10 +30,8 @@ public class ShopSeckillController {
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("book:shopseckill:list")
public R list(@RequestParam Map<String, Object> params){
public R list(@RequestParam Map<String, Object> params) {
PageUtils page = shopSeckillService.queryPage(params);
return R.ok().put("page", page);
}
@@ -46,10 +40,8 @@ public class ShopSeckillController {
* 信息
*/
@RequestMapping("/info/{seckillId}")
// @RequiresPermissions("book:shopseckill:info")
public R info(@PathVariable("seckillId") Long seckillId){
ShopSeckillEntity shopSeckill = shopSeckillService.getById(seckillId);
public R info(@PathVariable("seckillId") Long seckillId) {
ShopSeckillEntity shopSeckill = shopSeckillService.getById(seckillId);
return R.ok().put("shopSeckill", shopSeckill);
}
@@ -57,10 +49,8 @@ public class ShopSeckillController {
* 保存
*/
@RequestMapping("/save")
// @RequiresPermissions("book:shopseckill:save")
public R save(@RequestBody ShopSeckillEntity shopSeckill){
shopSeckillService.save(shopSeckill);
public R save(@RequestBody ShopSeckillEntity shopSeckill) {
shopSeckillService.save(shopSeckill);
return R.ok();
}
@@ -68,10 +58,8 @@ public class ShopSeckillController {
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("book:shopseckill:update")
public R update(@RequestBody ShopSeckillEntity shopSeckill){
shopSeckillService.updateById(shopSeckill);
public R update(@RequestBody ShopSeckillEntity shopSeckill) {
shopSeckillService.updateById(shopSeckill);
return R.ok();
}
@@ -79,28 +67,24 @@ public class ShopSeckillController {
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("book:shopseckill:delete")
public R delete(@RequestBody Long[] seckillIds){
shopSeckillService.removeByIds(Arrays.asList(seckillIds));
public R delete(@RequestBody Long[] seckillIds) {
shopSeckillService.removeByIds(Arrays.asList(seckillIds));
return R.ok();
}
@GetMapping("/getSeckillProd")
public R getSeckillProd(){
public R getSeckillProd() {
List<SeckillRedisTo> list = shopSeckillService.getCurrentSeckillProd();
return R.ok().put("list",list);
return R.ok().put("list", list);
}
@GetMapping("/kill")
public R kill(@RequestParam("killId") String killId,
@RequestParam("key") String key,
@RequestParam("num") Integer num,
@RequestParam("userId") Integer userId){
String orderId = shopSeckillService.kill(killId,key,num,userId);
return R.ok().put("orderId",orderId);
@RequestParam("userId") Integer userId) {
String orderId = shopSeckillService.kill(killId, key, num, userId);
return R.ok().put("orderId", orderId);
}

View File

@@ -32,9 +32,9 @@ public class UserBookClockController {
/**
* 计算打卡天数
*
* @param bookId
* @param userId
* @return
* @param bookId book ID
* @param userId user ID
* @return R
*/
@RequestMapping(path = "/clockInDays", method = RequestMethod.GET)
public R clockInDays(@RequestParam("bookId") Integer bookId,
@@ -67,9 +67,9 @@ public class UserBookClockController {
/**
* 用户打卡
*
* @param bookId
* @param userId
* @return
* @param bookId book ID
* @param userId user ID
* @return R
*/
@RequestMapping(path = "/clockIn", method = RequestMethod.GET)
public R clockIn(@RequestParam("bookId") Integer bookId,

View File

@@ -5,10 +5,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.BookClockEntryEntity;
import com.peanut.modules.book.entity.BookEntity;
import com.peanut.modules.book.service.BookClockEntryChatService;
import com.peanut.modules.book.service.BookClockEntryService;
import com.peanut.modules.book.service.BookService;
import com.peanut.modules.book.service.UserBookClockService;
import com.peanut.modules.book.to.PageIdDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
@@ -20,13 +18,9 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("book/clock")
public class UserClockController {
@Autowired
private UserBookClockService userBookClockService;
@Autowired
private BookClockEntryService bookClockEntryService;
@Autowired
private BookClockEntryChatService bookClockEntryChatService;
@Autowired
private BookService bookService;
/**

View File

@@ -1,13 +1,9 @@
package com.peanut.modules.book.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.book.entity.ActivityEntity;
import com.peanut.modules.book.entity.BuyOrderEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 订单表
*

View File

@@ -1,10 +1,7 @@
package com.peanut.modules.book.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.book.entity.BookCategoryEntity;
import org.apache.ibatis.annotations.Mapper;

View File

@@ -1,16 +1,13 @@
package com.peanut.modules.book.dao;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.book.entity.BookEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/**
* 图书表

View File

@@ -1,6 +1,5 @@
package com.peanut.modules.book.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.book.entity.BookForumArticlesEntity;
import org.apache.ibatis.annotations.Mapper;

View File

@@ -7,5 +7,4 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface BookListeningDao extends BaseMapper<BookListeningEntity> {
}

View File

@@ -51,10 +51,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
private BookChapterService bookChapterService;
@Autowired
ConstantPropertiesUtils constantPropertiesUtils;
@Autowired
private BookForumArticlesService bookForumArticlesService;
@Override
@@ -62,10 +58,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
//出版社
String publisherName1 = (String) params.get("publisherName");
String state = (String) params.get("state");
// String[] publisherName1split1 = publisherName1.split(",");
// String join = StringUtils.join(publisherName1split1, "','");
// 多查询语句
// String sql = "IN_SET(publisher_id, (SELECT GROUP_CONCAT(id) FROM publisher WHERE publisher_name in ('\"+ join +\"'))) = 1";
//类型
String typeC = (String) params.get("type");
//作者
@@ -102,15 +94,9 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
.eq("dict_type", voicesStatus).eq("dict_label", "processing_results"));
String chapterStatusName = chapter.getDictValue();
String contentStatusName = content.getDictValue();
String voicesStatusName = voices.getDictValue();
String[] split = type.split(",");
for (String tp : split) {
SysDictDataEntity dict = sysDictDataService.getBaseMapper().selectOne(new QueryWrapper<SysDictDataEntity>()
.eq("dict_type", tp).eq("dict_label", "book_type"));
@@ -120,13 +106,10 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
}
String authorId = book.getAuthorId();
String publisherId = book.getPublisherId();
String[] authorIds = authorId.split(",");
String[] publisherIds = publisherId.split(",");
List<String> authorList = Arrays.asList(authorIds);
List<String> publisherList = Arrays.asList(publisherIds);
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>().in("id", publisherList));
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
for (AuthorEntity authorEntity : authorEntities) {
@@ -165,77 +148,40 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
public void getChapter(Integer id) {
BookEntity bookEntity = this.baseMapper.selectById(id);
String novel = bookEntity.getNovel();
Integer bookEntityId = bookEntity.getId();
// String fileName = novel.split("/")[novel.split("/").length - 1];
String fileName = novel.replace("https://ehh-private-01.oss-cn-beijing.aliyuncs.com/", "");
Long count = (long) 0;
boolean bflag = false;
int n = 0;
String newStr = null;
String titleName = null; //旧章节
String titleName; //旧章节
String newChapterName = null;//新章节名称
String substring = null;
int indexOf = 0;
int indexOf1 = 0;
int linecount = 0;
// ArrayList<Object> chapterList = new ArrayList<>();
// ArrayList<Object> contentList = new ArrayList<>();
// 创建OSSClient实例。
OSS ossClient = new OSSClientBuilder().build(constantPropertiesUtils.END_POIND, constantPropertiesUtils.ACCESS_KEY_ID, constantPropertiesUtils.ACCESS_KEY_SECRET);
try {
// ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
OSSObject ossObject = ossClient.getObject(constantPropertiesUtils.BUCKET_NAME, fileName);
// 读取文件内容。
// System.out.println("Object content:");
BufferedReader reader = new BufferedReader(new InputStreamReader(ossObject.getObjectContent(), "UTF-8"));
while (true) {
String line = reader.readLine();
if (line == null) break;
BookChapterEntity content = new BookChapterEntity();
count++;
// 正则表达式
Pattern p = Pattern.compile("(^\\s*第)(.{1,9})[章节卷集部篇回讲](\\s{1})(.*)($\\s*)");
Matcher matcher = p.matcher(line);
Matcher matcher1 = p.matcher(line);
newStr = newStr + line;
while (matcher.find()) {
if (StringUtils.isNotBlank(newChapterName)) {
content.setChapter(newChapterName.trim());
}
titleName = matcher.group();
//章节去空
newChapterName = titleName.trim();
//获取章节
// System.out.println(newChapterName);
// content.setChapter(newChapterName);
// content.setNumber(++linecount);
// chapterList.add(newChapterName);
indexOf1 = indexOf;
// System.out.println("indexOf" + indexOf);
indexOf = newStr.indexOf(newChapterName);
// System.out.println(newChapterName + ":" + "第" + count + "行"); // 得到返回的章
if (bflag) {
bflag = false;
break;
@@ -246,7 +192,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
}
n = 1;
bflag = true;
//System.out.println(chapter);
}
@@ -258,14 +203,10 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
content.setBookId(bookEntityId);
content.setNumber(++linecount);
System.out.println(substring);
// contentList.add(substring);
System.out.println(content.toString());
bookChapterService.save(content);
}
}
}
// 数据读取完成后,获取的流必须关闭,否则会造成连接泄漏,导致请求无连接可用,程序无法正常工作。
reader.close();
@@ -273,11 +214,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
// 致请求无连接可用,程序无法正常工作。
ossObject.close();
bookEntity.setChapterStatus("2");
//
// System.out.println(chapterList);
// System.out.println(contentList);
} catch (OSSException oe) {
bookEntity.setChapterStatus("3");
System.out.println("Caught an OSSException, which means your request made it to OSS, "
@@ -310,7 +246,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
);
List<BookEntity> newBookList = page.getRecords();
for (BookEntity book : newBookList) {
String authorName = "";
String publisherName = "";
@@ -325,13 +260,10 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
}
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
String publisherId = book.getPublisherId();
String[] publisherIds = publisherId.split(",");
List<String> publisherList = Arrays.asList(publisherIds);
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>().in("id", publisherList));
for (PublisherEntity publisherEntity : publisherEntities) {
publisherName += "," + publisherEntity.getPublisherName();
}
@@ -339,8 +271,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
book.setPublisherName(publisherName);
book.setAuthorName(authorName);
}
return new PageUtils(page);
}
@@ -349,11 +279,12 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
Object id = params.get("id");
IPage<BookEntity> page = this.page(
new Query<BookEntity>().getPage(params),
new QueryWrapper<BookEntity>().eq("id",id)
new QueryWrapper<BookEntity>().eq("id", id)
);
return new PageUtils(page);
}
@Override
@Override
public PageUtils getNewBook(Map<String, Object> params) {
IPage<BookEntity> page = this.page(
@@ -371,19 +302,14 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
String[] authorIds = authorId.split(",");
List<String> authorList = Arrays.asList(authorIds);
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
for (AuthorEntity authorEntity : authorEntities) {
authorName += "," + authorEntity.getAuthorName();
}
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
String publisherId = book.getPublisherId();
String[] publisherIds = publisherId.split(",");
List<String> publisherList = Arrays.asList(publisherIds);
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>().in("id", publisherList));
for (PublisherEntity publisherEntity : publisherEntities) {
publisherName += "," + publisherEntity.getPublisherName();
}
@@ -391,8 +317,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
book.setPublisherName(publisherName);
book.setAuthorName(authorName);
}
return new PageUtils(page);
}
@@ -454,7 +378,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
System.out.println(StringUtils.isNotBlank(paragraph.getText().trim()));
//获取标题
if (paragraph.getStyleName().equals("Heading1") && StringUtils.isNotBlank(paragraph.getText().trim()))//段落样式为“标题1”的内容
// if (paragraph.getStyleName().equals("Normal") && StringUtils.isNotBlank(paragraph.getText().trim()))//段落样式为“标题1”的内容
{
num++;
@@ -472,7 +395,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
return false;
}
//todo 章节拆分 按照章节保存
@Override
public boolean getWord(Integer bookId) {
BookEntity bookEntity = this.getBaseMapper().selectById(bookId);
@@ -484,35 +406,8 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
Section section = doc.getSections().get(i);
//遍历Paragraph每个小节下有若干段落
for (int j = 0; j < section.getParagraphs().getCount() - 1; j++) {
//插入分页符到小节下若干段落
Paragraph paragraph = section.getParagraphs().get(j);
//插入分页符到第五个段落
// Paragraph paragraph = section.getParagraphs().get(4);
//获取标题
// int cj = 0;
// if (section.getParagraphs().get(j).getStyleName().equals("Heading2")) {
// cj = 2;
// }
// if (section.getParagraphs().get(j).getStyleName().equals("Heading3")) {
// cj = 3;
// }
// if (section.getParagraphs().get(j).getStyleName().equals("Heading4")) {
// cj = 4;
// }
// int cj= 0;
// if (section.getParagraphs().get(j).getStyleName().equals("Heading2")) {
//// cj = 2;
// }
// if(section.getParagraphs().get(j).getStyleName().equals(""))
if (paragraph.getStyleName().equals("Heading1") && StringUtils.isNotBlank(paragraph.getText().trim())) {
StringBuilder builder = new StringBuilder();
do {
builder.append(section.getParagraphs().get(j).getText());
@@ -543,11 +438,11 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
/**
* number章节号变小节号
* 如果上传文档为只有heading1标题则按照标题1进行拆分
* 如果上传文档的heading1标题下有heading2标题则按照标题2进行拆分
* @param bookId 图书ID
* number章节号变小节号
* 如果上传文档为只有heading1标题则按照标题1进行拆分
* 如果上传文档的heading1标题下有heading2标题则按照标题2进行拆分
*
* @param bookId 图书ID
* @return0
*/
@Override
@@ -556,29 +451,26 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
String novel = bookEntity.getNovel();
InputStream inputStream = FileDownloadUtil.getInputStream(novel);
Document doc = new Document(inputStream);
int nums = 0;
String title2Text = "";
int num1=0;
Map<String,List<String[]>> paraMap = new HashMap<>();
Map<String,String> headMap = new HashMap<>();
Map<String, List<String[]>> paraMap = new HashMap<>();
Map<String, String> headMap = new HashMap<>();
List<String> title_list = new ArrayList<>();
for (int i = 0; i < doc.getSections().getCount(); i++) {
String currentTitle = "";
Section section = doc.getSections().get(i);
for (int j = 0; j < section.getParagraphs().getCount() - 1; j++) {
Paragraph paragraph = section.getParagraphs().get(j);
if (paragraph.getStyleName().equals("Heading1") ) {
if (paragraph.getStyleName().equals("Heading1")) {
String textq = paragraph.getText();
currentTitle = textq;
title_list.add(currentTitle);
List<String[]> secondTitleList = new ArrayList<>();
paraMap.put(currentTitle,secondTitleList);
if(!section.getParagraphs().get(j+1).getStyleName().matches("Heading2")){
int head_index = j ;
paraMap.put(currentTitle, secondTitleList);
if (!section.getParagraphs().get(j + 1).getStyleName().matches("Heading2")) {
int head_index = j;
StringBuilder builder = new StringBuilder();
do {
builder.append(section.getParagraphs().get(head_index).getText());
builder.append(section.getParagraphs().get(head_index).getText());
head_index++;
//防止index超出异常发生
if (head_index >= section.getParagraphs().getCount()) {
@@ -586,14 +478,14 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
}
} while (!section.getParagraphs().get(head_index).getStyleName().equals("Heading2"));
String head_text = builder.toString();
headMap.put(currentTitle,head_text);
headMap.put(currentTitle, head_text);
}
} else if (paragraph.getStyleName().equals("Heading2") && StringUtils.isNotBlank(paragraph.getText().trim())) {
StringBuilder builder = new StringBuilder();
boolean isRun = false;
do {
if(isRun){
if (isRun) {
builder.append(section.getParagraphs().get(j).getText());
}
isRun = true;
@@ -602,57 +494,44 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
if (j >= section.getParagraphs().getCount()) {
break;
}
} while (!section.getParagraphs().get(j).getStyleName().equals("Heading2")&&!section.getParagraphs().get(j).getStyleName().equals("Heading1"));
j --;
} while (!section.getParagraphs().get(j).getStyleName().equals("Heading2") && !section.getParagraphs().get(j).getStyleName().equals("Heading1"));
j--;
String text = builder.toString();
nums++;
title2Text = paragraph.getText(); // 获取标题二的文本内容
if(null != title2Text && !"".equals(title2Text)){
String [] s = new String[]{title2Text,text};
if (null != title2Text && !"".equals(title2Text)) {
String[] s = new String[]{title2Text, text};
paraMap.get(currentTitle).add(s);
}
}
}
}
int index = 0;
for(String title: title_list){
if(null == paraMap.get(title) || paraMap.get(title).size() == 0){
index ++ ;
for (String title : title_list) {
if (null == paraMap.get(title) || paraMap.get(title).size() == 0) {
index++;
BookChapterEntity bookChapterEntity = new BookChapterEntity();
bookChapterEntity.setBookId(bookId);
bookChapterEntity.setNumber(index);
bookChapterEntity.setChapter(title);
bookChapterEntity.setSort(1);
if(null != headMap.get(title)){
if (null != headMap.get(title)) {
bookChapterEntity.setContent(headMap.get(title));
}else {
} else {
bookChapterEntity.setContent("");
}
bookChapterService.save(bookChapterEntity);
}else {
for(String[] t : paraMap.get(title)){
index ++;
} else {
for (String[] t : paraMap.get(title)) {
index++;
BookChapterEntity bookChapterEntity = new BookChapterEntity();
bookChapterEntity.setBookId(bookId);
bookChapterEntity.setSort(2);
bookChapterEntity.setNumber(index);
bookChapterEntity.setChapter(title+","+t[0]);
bookChapterEntity.setContent(t[1]);
bookChapterEntity.setChapter(title + "," + t[0]);
bookChapterEntity.setContent(t[1]);
bookChapterService.save(bookChapterEntity);
}
}
}
return false;
@@ -702,18 +581,16 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
if (!StringUtils.isEmpty(publisherName)) {
book.setPublisherName(publisherName);
}
}
return new PageUtils(page);
}
@Override
public Page<BookEntity> getUserClockBooks(Integer userId, Integer limit, Integer page) {
String exist_sql = "select 1 from user_ebook_buy where book_id = book.id and user_id = "+userId;
String exist_sql = "select 1 from user_ebook_buy where book_id = book.id and user_id = " + userId;
LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BookEntity::getClockIn,1);
wrapper.eq(BookEntity::getDelFlag,0);
wrapper.eq(BookEntity::getClockIn, 1);
wrapper.eq(BookEntity::getDelFlag, 0);
wrapper.exists(exist_sql);
Page<BookEntity> bookEntityPage = this.getBaseMapper().selectPage(new Page<BookEntity>(page, limit), wrapper);
return bookEntityPage;
@@ -722,15 +599,12 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
@Override
public Page<BookEntity> getUserClockBestBooks(Integer userId, Integer limit, Integer page) {
String exist_sql = "select 1 from user_ebook_buy where book_id = book.id and user_id = "+userId;
String exist_sql = "select 1 from user_ebook_buy where book_id = book.id and user_id = " + userId;
LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BookEntity::getClockIn,1);
wrapper.eq(BookEntity::getDelFlag,0);
wrapper.eq(BookEntity::getClockIn, 1);
wrapper.eq(BookEntity::getDelFlag, 0);
wrapper.notExists(exist_sql);
Page<BookEntity> bookEntityPage = this.getBaseMapper().selectPage(new Page<BookEntity>(page, limit), wrapper);
return bookEntityPage;
}
}
}