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; 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.Arrays;
import java.util.Map; 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 @Autowired
private BuyOrderDetailService buyOrderDetailService; private BuyOrderDetailService buyOrderDetailService;
/** /**
* 列表 * 列表
*/ */
@RequestMapping("/list") @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); PageUtils page = buyOrderDetailService.queryPage(params);
return R.ok().put("page", page); return R.ok().put("page", page);
} }
/** /**
* 查询已购买书籍 * 查询已购买书籍
*
* @param params * @param params
* @return * @return
*/ */
@RequestMapping("/querybuy") @RequestMapping("/querybuy")
public R querybuy(@RequestParam Map<String, Object> params) { public R querybuy(@RequestParam Map<String, Object> params) {
PageUtils page = buyOrderDetailService.querybuy(params); PageUtils page = buyOrderDetailService.querybuy(params);
return R.ok().put("page", page); return R.ok().put("page", page);
} }
/** /**
* 去重查询可打印面单 * 去重查询可打印面单
* *
@@ -66,9 +52,7 @@ public class BuyOrderDetailController {
*/ */
@RequestMapping("/querySheetPage") @RequestMapping("/querySheetPage")
public R querySheetPage(@RequestParam Map<String, Object> params) { public R querySheetPage(@RequestParam Map<String, Object> params) {
PageUtils page = buyOrderDetailService.querySheet(params); PageUtils page = buyOrderDetailService.querySheet(params);
return R.ok().put("page", page); return R.ok().put("page", page);
} }
@@ -78,7 +62,6 @@ public class BuyOrderDetailController {
@RequestMapping("/info/{allOrderId}") @RequestMapping("/info/{allOrderId}")
public R info(@PathVariable("allOrderId") Long allOrderId) { public R info(@PathVariable("allOrderId") Long allOrderId) {
BuyOrderDetailEntity buyOrderDetail = buyOrderDetailService.getById(allOrderId); BuyOrderDetailEntity buyOrderDetail = buyOrderDetailService.getById(allOrderId);
return R.ok().put("buyOrderDetail", buyOrderDetail); return R.ok().put("buyOrderDetail", buyOrderDetail);
} }
@@ -86,10 +69,8 @@ public class BuyOrderDetailController {
* 保存 * 保存
*/ */
@RequestMapping("/save") @RequestMapping("/save")
// @RequiresPermissions("book:buyorderdetail:save")
public R save(@RequestBody BuyOrderDetailEntity buyOrderDetail) { public R save(@RequestBody BuyOrderDetailEntity buyOrderDetail) {
buyOrderDetailService.save(buyOrderDetail); buyOrderDetailService.save(buyOrderDetail);
return R.ok(); return R.ok();
} }
@@ -97,10 +78,8 @@ public class BuyOrderDetailController {
* 修改 * 修改
*/ */
@RequestMapping("/update") @RequestMapping("/update")
// @RequiresPermissions("book:buyorderdetail:update")
public R update(@RequestBody BuyOrderDetailEntity buyOrderDetail) { public R update(@RequestBody BuyOrderDetailEntity buyOrderDetail) {
buyOrderDetailService.updateById(buyOrderDetail); buyOrderDetailService.updateById(buyOrderDetail);
return R.ok(); return R.ok();
} }
@@ -108,10 +87,8 @@ public class BuyOrderDetailController {
* 删除 * 删除
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
// @RequiresPermissions("book:buyorderdetail:delete")
public R delete(@RequestBody Long[] allOrderIds) { public R delete(@RequestBody Long[] allOrderIds) {
buyOrderDetailService.removeByIds(Arrays.asList(allOrderIds)); buyOrderDetailService.removeByIds(Arrays.asList(allOrderIds));
return R.ok(); return R.ok();
} }

View File

@@ -25,7 +25,6 @@ import java.util.Map;
@RequestMapping("api/province") @RequestMapping("api/province")
public class ProvinceController { public class ProvinceController {
@Autowired @Autowired
private ProvinceService provinceService; private ProvinceService provinceService;
@Autowired @Autowired
@@ -76,10 +75,6 @@ public class ProvinceController {
@RequestMapping("/getCountyList") @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)); 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; package com.peanut.modules.book.controller;
import java.util.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.PageUtils;
import com.peanut.common.utils.R; 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") @RequestMapping("/list")
// @RequiresPermissions("book:publisher:list")
public R list(@RequestParam Map<String, Object> params){ public R list(@RequestParam Map<String, Object> params){
PageUtils page = publisherService.queryPage(params); PageUtils page = publisherService.queryPage(params);
return R.ok().put("page", page); return R.ok().put("page", page);
} }
@@ -50,7 +39,6 @@ public class PublisherController {
* 列表 * 列表
*/ */
@RequestMapping("/publisherList") @RequestMapping("/publisherList")
// @RequiresPermissions("book:publisher:list")
public R publisherList(){ public R publisherList(){
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>()); List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>());
ArrayList<Object> list = new ArrayList<>(); ArrayList<Object> list = new ArrayList<>();
@@ -60,7 +48,6 @@ public class PublisherController {
map.put("value",publisherEntitie.getPublisherName()); map.put("value",publisherEntitie.getPublisherName());
list.add(map); list.add(map);
} }
return R.ok().put("list", list); return R.ok().put("list", list);
} }
@@ -68,10 +55,8 @@ public class PublisherController {
* 信息 * 信息
*/ */
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
// @RequiresPermissions("book:publisher:info")
public R info(@PathVariable("id") Integer id){ public R info(@PathVariable("id") Integer id){
PublisherEntity publisher = publisherService.getById(id); PublisherEntity publisher = publisherService.getById(id);
return R.ok().put("publisher", publisher); return R.ok().put("publisher", publisher);
} }
@@ -80,7 +65,6 @@ public class PublisherController {
* 信息 * 信息
*/ */
@RequestMapping("/appGetInfo/{id}/{limit}/{page}") @RequestMapping("/appGetInfo/{id}/{limit}/{page}")
// @RequiresPermissions("book:author:info")
public R appGetInfo(@PathVariable("id") Integer id, public R appGetInfo(@PathVariable("id") Integer id,
@PathVariable("limit") String limit, @PathVariable("limit") String limit,
@PathVariable("page") String page){ @PathVariable("page") String page){
@@ -103,7 +87,6 @@ public class PublisherController {
public R save(@RequestBody PublisherEntity publisher){ public R save(@RequestBody PublisherEntity publisher){
publisher.setDelFlag(0); publisher.setDelFlag(0);
publisherService.save(publisher); publisherService.save(publisher);
return R.ok(); return R.ok();
} }
@@ -111,10 +94,8 @@ public class PublisherController {
* 修改 * 修改
*/ */
@RequestMapping("/update") @RequestMapping("/update")
// @RequiresPermissions("book:publisher:update")
public R update(@RequestBody PublisherEntity publisher){ public R update(@RequestBody PublisherEntity publisher){
publisherService.updateById(publisher); publisherService.updateById(publisher);
return R.ok(); return R.ok();
} }
@@ -122,11 +103,8 @@ public class PublisherController {
* 删除 * 删除
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
// @RequiresPermissions("book:publisher:delete")
public R delete(@RequestBody Integer[] ids){ public R delete(@RequestBody Integer[] ids){
publisherService.removeByIds(Arrays.asList(ids)); publisherService.removeByIds(Arrays.asList(ids));
return R.ok(); return R.ok();
} }
} }

View File

@@ -1,23 +1,16 @@
package com.peanut.modules.book.controller; 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.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; 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") @RequestMapping("/list")
// @RequiresPermissions("book:seckillprodrelation:list")
public R list(@RequestParam Map<String, Object> params){ public R list(@RequestParam Map<String, Object> params){
PageUtils page = seckillProdRelationService.queryPage(params); PageUtils page = seckillProdRelationService.queryPage(params);
@@ -50,7 +42,6 @@ public class SeckillProdRelationController {
* 信息 * 信息
*/ */
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
// @RequiresPermissions("book:seckillprodrelation:info")
public R info(@PathVariable("id") Integer id){ public R info(@PathVariable("id") Integer id){
SeckillProdRelationEntity seckillProdRelation = seckillProdRelationService.getById(id); SeckillProdRelationEntity seckillProdRelation = seckillProdRelationService.getById(id);
@@ -61,26 +52,18 @@ public class SeckillProdRelationController {
* 保存 * 保存
*/ */
@RequestMapping("/save") @RequestMapping("/save")
// @RequiresPermissions("book:seckillprodrelation:save")
public R save(@RequestBody SeckillProdRelationEntity seckillProdRelation){ public R save(@RequestBody SeckillProdRelationEntity seckillProdRelation){
//判断当前场次 是否有相同商品 //判断当前场次 是否有相同商品
Integer prodId = seckillProdRelation.getProdId(); Integer prodId = seckillProdRelation.getProdId();
Integer promotionSeckillId = seckillProdRelation.getPromotionSeckillId(); Integer promotionSeckillId = seckillProdRelation.getPromotionSeckillId();
List<SeckillProdRelationEntity> list = seckillProdRelationService.list(new QueryWrapper<SeckillProdRelationEntity>().eq("promotion_seckill_id", promotionSeckillId)); List<SeckillProdRelationEntity> list = seckillProdRelationService.list(new QueryWrapper<SeckillProdRelationEntity>().eq("promotion_seckill_id", promotionSeckillId));
for (SeckillProdRelationEntity seckillProdRelationEntity : list) { for (SeckillProdRelationEntity seckillProdRelationEntity : list) {
Integer prodId1 = seckillProdRelationEntity.getProdId(); Integer prodId1 = seckillProdRelationEntity.getProdId();
if (prodId1 == prodId){ if (prodId1 == prodId){
return R.error("商品已存在"); return R.error("商品已存在");
} }
} }
seckillProdRelationService.save(seckillProdRelation); seckillProdRelationService.save(seckillProdRelation);
return R.ok(); return R.ok();
} }
@@ -88,7 +71,6 @@ public class SeckillProdRelationController {
* 修改 * 修改
*/ */
@RequestMapping("/update") @RequestMapping("/update")
// @RequiresPermissions("book:seckillprodrelation:update")
public R update(@RequestBody SeckillProdRelationEntity seckillProdRelation){ public R update(@RequestBody SeckillProdRelationEntity seckillProdRelation){
seckillProdRelationService.updateById(seckillProdRelation); seckillProdRelationService.updateById(seckillProdRelation);

View File

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

View File

@@ -1,21 +1,17 @@
package com.peanut.modules.book.controller; 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.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; 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") @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); PageUtils page = shopSeckillService.queryPage(params);
return R.ok().put("page", page); return R.ok().put("page", page);
} }
@@ -46,10 +40,8 @@ public class ShopSeckillController {
* 信息 * 信息
*/ */
@RequestMapping("/info/{seckillId}") @RequestMapping("/info/{seckillId}")
// @RequiresPermissions("book:shopseckill:info")
public R info(@PathVariable("seckillId") Long seckillId) { public R info(@PathVariable("seckillId") Long seckillId) {
ShopSeckillEntity shopSeckill = shopSeckillService.getById(seckillId); ShopSeckillEntity shopSeckill = shopSeckillService.getById(seckillId);
return R.ok().put("shopSeckill", shopSeckill); return R.ok().put("shopSeckill", shopSeckill);
} }
@@ -57,10 +49,8 @@ public class ShopSeckillController {
* 保存 * 保存
*/ */
@RequestMapping("/save") @RequestMapping("/save")
// @RequiresPermissions("book:shopseckill:save")
public R save(@RequestBody ShopSeckillEntity shopSeckill) { public R save(@RequestBody ShopSeckillEntity shopSeckill) {
shopSeckillService.save(shopSeckill); shopSeckillService.save(shopSeckill);
return R.ok(); return R.ok();
} }
@@ -68,10 +58,8 @@ public class ShopSeckillController {
* 修改 * 修改
*/ */
@RequestMapping("/update") @RequestMapping("/update")
// @RequiresPermissions("book:shopseckill:update")
public R update(@RequestBody ShopSeckillEntity shopSeckill) { public R update(@RequestBody ShopSeckillEntity shopSeckill) {
shopSeckillService.updateById(shopSeckill); shopSeckillService.updateById(shopSeckill);
return R.ok(); return R.ok();
} }
@@ -79,17 +67,14 @@ public class ShopSeckillController {
* 删除 * 删除
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
// @RequiresPermissions("book:shopseckill:delete")
public R delete(@RequestBody Long[] seckillIds) { public R delete(@RequestBody Long[] seckillIds) {
shopSeckillService.removeByIds(Arrays.asList(seckillIds)); shopSeckillService.removeByIds(Arrays.asList(seckillIds));
return R.ok(); return R.ok();
} }
@GetMapping("/getSeckillProd") @GetMapping("/getSeckillProd")
public R getSeckillProd() { public R getSeckillProd() {
List<SeckillRedisTo> list = shopSeckillService.getCurrentSeckillProd(); List<SeckillRedisTo> list = shopSeckillService.getCurrentSeckillProd();
return R.ok().put("list", list); return R.ok().put("list", list);
} }
@@ -99,7 +84,6 @@ public class ShopSeckillController {
@RequestParam("num") Integer num, @RequestParam("num") Integer num,
@RequestParam("userId") Integer userId) { @RequestParam("userId") Integer userId) {
String orderId = shopSeckillService.kill(killId, key, num, userId); String orderId = shopSeckillService.kill(killId, key, num, userId);
return R.ok().put("orderId", orderId); return R.ok().put("orderId", orderId);
} }

View File

@@ -32,9 +32,9 @@ public class UserBookClockController {
/** /**
* 计算打卡天数 * 计算打卡天数
* *
* @param bookId * @param bookId book ID
* @param userId * @param userId user ID
* @return * @return R
*/ */
@RequestMapping(path = "/clockInDays", method = RequestMethod.GET) @RequestMapping(path = "/clockInDays", method = RequestMethod.GET)
public R clockInDays(@RequestParam("bookId") Integer bookId, public R clockInDays(@RequestParam("bookId") Integer bookId,
@@ -67,9 +67,9 @@ public class UserBookClockController {
/** /**
* 用户打卡 * 用户打卡
* *
* @param bookId * @param bookId book ID
* @param userId * @param userId user ID
* @return * @return R
*/ */
@RequestMapping(path = "/clockIn", method = RequestMethod.GET) @RequestMapping(path = "/clockIn", method = RequestMethod.GET)
public R clockIn(@RequestParam("bookId") Integer bookId, 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.common.utils.R;
import com.peanut.modules.book.entity.BookClockEntryEntity; import com.peanut.modules.book.entity.BookClockEntryEntity;
import com.peanut.modules.book.entity.BookEntity; 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.BookClockEntryService;
import com.peanut.modules.book.service.BookService; import com.peanut.modules.book.service.BookService;
import com.peanut.modules.book.service.UserBookClockService;
import com.peanut.modules.book.to.PageIdDto; import com.peanut.modules.book.to.PageIdDto;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@@ -20,13 +18,9 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("book/clock") @RequestMapping("book/clock")
public class UserClockController { public class UserClockController {
@Autowired
private UserBookClockService userBookClockService;
@Autowired @Autowired
private BookClockEntryService bookClockEntryService; private BookClockEntryService bookClockEntryService;
@Autowired @Autowired
private BookClockEntryChatService bookClockEntryChatService;
@Autowired
private BookService bookService; private BookService bookService;
/** /**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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