670 lines
23 KiB
Java
670 lines
23 KiB
Java
package com.peanut.modules.book.controller;
|
||
import java.util.*;
|
||
import java.util.concurrent.ExecutorService;
|
||
import java.util.concurrent.Executors;
|
||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||
import com.peanut.common.utils.ReadProvinceUtil;
|
||
import com.peanut.modules.book.dao.BookDao;
|
||
import com.peanut.modules.book.entity.*;
|
||
import com.peanut.modules.book.service.*;
|
||
import com.peanut.modules.book.vo.BookIndexVo;
|
||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||
import org.springframework.web.bind.annotation.*;
|
||
import com.peanut.common.utils.PageUtils;
|
||
import com.peanut.common.utils.R;
|
||
/**
|
||
* 图书表
|
||
*
|
||
* @author yl
|
||
* @email yl328572838@163.com
|
||
* @date 2022-08-04 15:36:59
|
||
*/
|
||
@RestController
|
||
@RequestMapping("book/book")
|
||
public class BookController {
|
||
@Autowired
|
||
private BookService bookService;
|
||
@Autowired
|
||
private BookChapterService bookChapterService;
|
||
@Autowired
|
||
private StringRedisTemplate redisTemplate;
|
||
@Autowired
|
||
private AuthorService authorService;
|
||
@Autowired
|
||
private PublisherService publisherService;
|
||
@Autowired
|
||
private BookShelfService bookShelfService;
|
||
@Autowired
|
||
private BookReadRateService bookReadRateService;
|
||
@Autowired
|
||
private MyUserService myUserService;
|
||
@Autowired
|
||
private ProvinceService provinceService;
|
||
@Autowired
|
||
private CityService cityService;
|
||
@Autowired
|
||
private CountyService countyService;
|
||
@Autowired
|
||
private UserEbookBuyService userEbookBuyService;
|
||
@Autowired
|
||
private BookDao bookDao;
|
||
final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);
|
||
|
||
/**
|
||
* 列表
|
||
*/
|
||
@RequestMapping("/list")
|
||
public R list(@RequestParam Map<String, Object> params) {
|
||
PageUtils page = bookService.queryPage(params);
|
||
|
||
return R.ok().put("page", page);
|
||
}
|
||
|
||
|
||
/**
|
||
* 列表
|
||
*/
|
||
@RequestMapping("/listbooks")
|
||
public R listbooks(@RequestParam Map<String, Object> params) {
|
||
PageUtils page = bookService.queryPagebooks(params);
|
||
|
||
return R.ok().put("page", page);
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 信息
|
||
*/
|
||
@RequestMapping("/info/{id}")
|
||
// @RequiresPermissions("book:book:info")
|
||
public R info(@PathVariable("id") Integer id) {
|
||
BookEntity book = bookService.getById(id);
|
||
|
||
return R.ok().put("book", book);
|
||
}
|
||
|
||
|
||
/**
|
||
* 信息
|
||
*/
|
||
@RequestMapping("/appinfo/{id}/{userId}")
|
||
// @RequiresPermissions("book:book:info")
|
||
public R appinfo(@PathVariable("id") Integer id,
|
||
@PathVariable("userId") Integer userId) {
|
||
|
||
|
||
BookEntity book = bookService.getById(id);
|
||
|
||
book.setIsBuy(true);
|
||
|
||
|
||
boolean b = myUserService.bookAuthen(id, userId);
|
||
if (!b) {
|
||
// 无权限
|
||
book.setIsBuy(false);
|
||
}
|
||
//书籍详情返回,购买状态,免费章节数
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
String authorName = "";
|
||
String publisherName = "";
|
||
String authorId = book.getAuthorId();
|
||
|
||
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();
|
||
}
|
||
publisherName = publisherName.startsWith(",") ? publisherName.substring(1) : publisherName;
|
||
|
||
//查询书籍阅读进度
|
||
|
||
BookReadRateEntity bookReadRateEntity = bookReadRateService.getBaseMapper().selectOne(new QueryWrapper<BookReadRateEntity>()
|
||
.eq("book_id", id)
|
||
.eq("user_id", userId)
|
||
);
|
||
if (bookReadRateEntity != null) {
|
||
|
||
Integer chapterId = bookReadRateEntity.getChapterId();
|
||
String chapterName = bookReadRateEntity.getChapterName();
|
||
book.setChapterName(chapterName);
|
||
book.setChapterId(chapterId);
|
||
// 查询 书籍 章节 number
|
||
BookChapterEntity bookChapterEntity = bookChapterService.getById(chapterId);
|
||
if (bookChapterEntity != null) {
|
||
Integer number = bookChapterEntity.getNumber();
|
||
book.setChapterNum(number);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
//查询书籍是否加入书架
|
||
Integer integer = bookShelfService.getBaseMapper().selectCount(new QueryWrapper<BookShelfEntity>()
|
||
.eq("book_id", id)
|
||
.eq("user_id", userId));
|
||
|
||
boolean flag = false;
|
||
|
||
if (integer > 0) {
|
||
flag = true;
|
||
}
|
||
|
||
book.setAuthorName(authorName);
|
||
book.setPublisherName(publisherName);
|
||
book.setFlag(flag);
|
||
return R.ok().put("book", book);
|
||
}
|
||
|
||
/**
|
||
* 保存
|
||
*/
|
||
@RequestMapping("/save")
|
||
|
||
public R save(@RequestBody BookEntity book) {
|
||
bookService.save(book);
|
||
|
||
return R.ok();
|
||
}
|
||
|
||
/**
|
||
* 获取用户未拥有的可听图书
|
||
* @return
|
||
*/
|
||
@RequestMapping("/getUserNobuyBooks")
|
||
public R getUserNobuyBooks(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){
|
||
List<UserEbookBuyEntity> bookids = userEbookBuyService.getBaseMapper().selectList(new QueryWrapper<UserEbookBuyEntity>()
|
||
.select("book_id").eq("user_id", userId));
|
||
List bids = new ArrayList();
|
||
for (UserEbookBuyEntity b :bookids){
|
||
bids.add(b.getBookId());
|
||
}
|
||
// Integer start = (page-1)*limit;
|
||
QueryWrapper<BookEntity> wrapper = new QueryWrapper<>();
|
||
wrapper.eq("can_listen",1);
|
||
wrapper.notIn("id",bids);
|
||
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<BookEntity>(page, limit), wrapper);
|
||
// Integer start = (page-1)*limit;
|
||
// QueryWrapper<BookEntity> wrapper = new QueryWrapper<>();
|
||
// wrapper.eq("t.can_listen",1);
|
||
// wrapper.notIn("t1.Book_id",bids);
|
||
// List<BookEntity> bookEntities = bookDao.queryUserListenBooksNobuy(wrapper,start,limit);
|
||
// Integer count = bookDao.queryUserListenBooksNobuyCount(wrapper);
|
||
|
||
|
||
return R.ok().put("page",bookEntityPage);
|
||
}
|
||
|
||
/**
|
||
* 修改
|
||
*/
|
||
@RequestMapping("/update")
|
||
|
||
public R update(@RequestBody BookEntity book) {
|
||
bookService.updateById(book);
|
||
|
||
return R.ok();
|
||
}
|
||
|
||
/**
|
||
* 删除
|
||
*/
|
||
@RequestMapping("/delete")
|
||
|
||
public R delete(@RequestBody Integer[] ids) {
|
||
bookService.removeByIds(Arrays.asList(ids));
|
||
|
||
return R.ok();
|
||
}
|
||
|
||
/**
|
||
* 常规章节拆分
|
||
*/
|
||
@RequestMapping("/getChapter")
|
||
public R getChapter(@RequestParam("id") Integer id) {
|
||
|
||
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
|
||
singleThreadExecutor.execute(new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
// bookService.getWordChapter(id);
|
||
// bookService.getChapter(id);
|
||
// bookService.getWord(id);
|
||
bookService.getWordSection(id);
|
||
}
|
||
});
|
||
|
||
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
|
||
bookEntity.setChapterStatus("2");
|
||
bookService.updateById(bookEntity);
|
||
|
||
return R.ok();
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 章节拆分 2.0
|
||
*/
|
||
@RequestMapping("/getWord")
|
||
public R getWord(@RequestParam("id") Integer id) {
|
||
|
||
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
|
||
singleThreadExecutor.execute(new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
//2.0
|
||
bookService.getWord(id);
|
||
|
||
|
||
|
||
}
|
||
});
|
||
|
||
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
|
||
bookEntity.setChapterStatus("2");
|
||
bookService.updateById(bookEntity);
|
||
|
||
return R.ok();
|
||
}
|
||
|
||
|
||
|
||
|
||
/**
|
||
* 章节拆分 3.0小节
|
||
*/
|
||
@RequestMapping("/WordSection")
|
||
public R getWordSection(@RequestParam("id") Integer id) {
|
||
|
||
// List<BookChapterEntity> kid = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>().eq("book_id", id));
|
||
// if (kid != null) {
|
||
// for (BookChapterEntity bookChapterEntity : kid) {
|
||
// // 调用删除方法进行删除
|
||
// Integer id1 = bookChapterEntity.getId();
|
||
// System.out.println("===========id1=="+id1);
|
||
//// bookChapterService.removeById(id1);
|
||
// }
|
||
//
|
||
//
|
||
// }
|
||
|
||
|
||
|
||
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
|
||
singleThreadExecutor.execute(new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
|
||
|
||
|
||
//3.0 大小章拆分
|
||
bookService.getWordSection(id);
|
||
// bookService.getChapter(id);
|
||
}
|
||
});
|
||
|
||
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
|
||
bookEntity.setChapterStatus("2");
|
||
bookService.updateById(bookEntity);
|
||
return R.ok();
|
||
|
||
}
|
||
|
||
/**
|
||
* app 获取电子书目录
|
||
*/
|
||
@RequestMapping("/getBookCatalogue")
|
||
public R getBookCatalogue(@RequestParam("bookid") Integer id,
|
||
@RequestParam("userid") Integer userid) {
|
||
|
||
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
|
||
if (bookEntity.getImages()==null) {
|
||
return R.error("电子书目录为空");
|
||
}
|
||
String images = bookEntity.getImages() ;
|
||
|
||
Integer freeChapterCount = bookEntity.getFreeChapterCount();
|
||
UserEbookBuyEntity userEbookBuyEntity1 = userEbookBuyService.getBaseMapper().selectOne(new QueryWrapper<UserEbookBuyEntity>().eq("book_id", id).eq("user_id", userid));
|
||
|
||
List<BookChapterEntity> bookChapterEntities = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>().eq("book_id", id));
|
||
List<HashMap<Object, Object>> chapterList = new ArrayList<>();
|
||
for (BookChapterEntity bookEntitys : bookChapterEntities) {
|
||
HashMap<Object, Object> map = new HashMap<>();
|
||
map.put("bookid",id);
|
||
map.put("number", bookEntitys.getNumber());
|
||
map.put("chapterId", bookEntitys.getId());
|
||
map.put("chapterName", bookEntitys.getChapter());
|
||
//freeChapterCount
|
||
|
||
map.put("images",images);
|
||
chapterList.add(map);
|
||
}
|
||
//true免费 ,false付费
|
||
if (userEbookBuyEntity1!=null) {
|
||
return R.ok().put("BookCatalogue", chapterList).put("buy",true);
|
||
}
|
||
return R.ok().put("BookCatalogue", chapterList).put("buy",false).put("freeChapterCount",freeChapterCount);
|
||
}
|
||
|
||
|
||
/**
|
||
* app 电子书目录
|
||
*/
|
||
@RequestMapping("/getCatalogue")
|
||
public R getCatalogue(@RequestParam("bookid") Integer id
|
||
) {
|
||
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
|
||
if (bookEntity == null) {
|
||
return R.error("当前图书不存在或已删除");
|
||
}
|
||
String images = bookEntity.getImages() ;
|
||
Integer number=null;
|
||
List<BookChapterEntity> bookChapterEntities = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>().eq("book_id", id));
|
||
List<HashMap<Object, Object>> chapterList = new ArrayList<>();
|
||
for (BookChapterEntity bookEntitys : bookChapterEntities) {
|
||
number = bookEntitys.getNumber();
|
||
HashMap<Object, Object> map = new HashMap<>();
|
||
map.put("bookid",id);
|
||
map.put("number", bookEntitys.getNumber());
|
||
map.put("chapterId", bookEntitys.getId());
|
||
map.put("chapterName", bookEntitys.getChapter());
|
||
//freeChapterCount
|
||
|
||
map.put("images",images);
|
||
chapterList.add(map);
|
||
}
|
||
if (number==null) {
|
||
return R.error("当前电子书目录为空");
|
||
}else{
|
||
return R.ok().put("BookCatalogue",chapterList);
|
||
|
||
|
||
}
|
||
|
||
}
|
||
//书籍详情返回,购买状态,免费章节数
|
||
|
||
/**
|
||
* app 获取免费章节数
|
||
*/
|
||
@RequestMapping("/getfreeChapter")
|
||
public R getfreeChapter(@RequestParam("bookid") Integer id
|
||
) {
|
||
|
||
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
|
||
if (bookEntity == null) {
|
||
return R.error("当前图书不存在或已删除");
|
||
}
|
||
Integer freeChapterCount = bookEntity.getFreeChapterCount();
|
||
if (freeChapterCount == null) {
|
||
return R.error("当前电子书目录为空");
|
||
} else {
|
||
|
||
|
||
return R.ok().put("freeChapterCount", freeChapterCount);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* 对外图标列表
|
||
*/
|
||
@RequestMapping("/listForWebsite")
|
||
// @RequiresPermissions("book:book:list")
|
||
public R listForWebsite(@RequestParam Map<String, Object> params) {
|
||
PageUtils page = bookService.queryPage(params);
|
||
|
||
return R.ok().put("page", page);
|
||
}
|
||
|
||
|
||
/**
|
||
* app首页数据
|
||
*/
|
||
@RequestMapping("/bookIndex")
|
||
// @RequiresPermissions("book:book:list")
|
||
public R bookIndex() {
|
||
|
||
HashMap<Object, Object> map = new HashMap<>();
|
||
|
||
List list = new ArrayList<>();
|
||
List topList = new ArrayList<>();
|
||
List saleList = new ArrayList<>();
|
||
|
||
|
||
// 新书
|
||
List<BookEntity> newBookList = bookService.getBaseMapper().selectList(new QueryWrapper<BookEntity>().eq("state", 1).last("limit 6").orderByDesc("create_time"));
|
||
for (BookEntity book : newBookList) {
|
||
String authorName = "";
|
||
String publisherName = "";
|
||
BookIndexVo bookIndexVo = new BookIndexVo();
|
||
String authorId = book.getAuthorId();
|
||
|
||
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();
|
||
}
|
||
publisherName = publisherName.startsWith(",") ? publisherName.substring(1) : publisherName;
|
||
|
||
bookIndexVo.setBookName(book.getName());
|
||
bookIndexVo.setAuthorName(authorName);
|
||
bookIndexVo.setBookid(book.getId());
|
||
bookIndexVo.setImage(book.getImages());
|
||
bookIndexVo.setIntroduce(book.getDescription());
|
||
bookIndexVo.setPublisherName(publisherName);
|
||
bookIndexVo.setIsVip(book.getIsVip());
|
||
list.add(bookIndexVo);
|
||
}
|
||
|
||
// 推荐
|
||
|
||
List<BookEntity> topBookList = bookService.getBaseMapper().selectList(new QueryWrapper<BookEntity>().eq("state", 1).eq("istop", 1).last("limit 6").orderByDesc("sort"));
|
||
|
||
for (BookEntity book : topBookList) {
|
||
String authorName = "";
|
||
String publisherName = "";
|
||
|
||
BookIndexVo bookIndexVo = new BookIndexVo();
|
||
String authorId = book.getAuthorId();
|
||
|
||
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();
|
||
}
|
||
publisherName = publisherName.startsWith(",") ? publisherName.substring(1) : publisherName;
|
||
|
||
bookIndexVo.setBookName(book.getName());
|
||
bookIndexVo.setAuthorName(authorName);
|
||
bookIndexVo.setBookid(book.getId());
|
||
bookIndexVo.setImage(book.getImages());
|
||
bookIndexVo.setIntroduce(book.getDescription());
|
||
bookIndexVo.setPublisherName(publisherName);
|
||
bookIndexVo.setIsVip(book.getIsVip());
|
||
topList.add(bookIndexVo);
|
||
}
|
||
|
||
//秒杀
|
||
List<BookEntity> saleBookList = bookService.getBaseMapper().selectList(new QueryWrapper<BookEntity>().eq("state", 1).eq("is_sale", 1).last("limit 6").orderByDesc("create_time"));
|
||
|
||
for (BookEntity book : saleBookList) {
|
||
String authorName = "";
|
||
String publisherName = "";
|
||
|
||
BookIndexVo bookIndexVo = new BookIndexVo();
|
||
String authorId = book.getAuthorId();
|
||
|
||
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();
|
||
}
|
||
publisherName = publisherName.startsWith(",") ? publisherName.substring(1) : publisherName;
|
||
|
||
bookIndexVo.setBookName(book.getName());
|
||
bookIndexVo.setAuthorName(authorName);
|
||
bookIndexVo.setBookid(book.getId());
|
||
bookIndexVo.setImage(book.getImages());
|
||
bookIndexVo.setIntroduce(book.getDescription());
|
||
bookIndexVo.setPublisherName(publisherName);
|
||
bookIndexVo.setIsVip(book.getIsVip());
|
||
bookIndexVo.setPrice(book.getPrice());
|
||
bookIndexVo.setSalePrice(book.getSalePrice());
|
||
saleList.add(bookIndexVo);
|
||
}
|
||
|
||
|
||
map.put("newBookList", list);
|
||
map.put("topBookList", topList);
|
||
map.put("saleList", saleList);
|
||
|
||
return R.ok().put("bookIndex", map);
|
||
}
|
||
|
||
|
||
//精选
|
||
@RequestMapping("/getBestBook")
|
||
public R getBestBook(@RequestParam Map<String, Object> params) {
|
||
PageUtils page = bookService.getBestBook(params);
|
||
return R.ok().put("page", page);
|
||
}
|
||
|
||
|
||
//新书
|
||
@RequestMapping("/getNewBook")
|
||
public R getNewBook(@RequestParam Map<String, Object> params) {
|
||
PageUtils page = bookService.getNewBook(params);
|
||
return R.ok().put("page", page);
|
||
}
|
||
|
||
|
||
//特价
|
||
@RequestMapping("/getSaleBook")
|
||
public R getSaleBook(@RequestParam Map<String, Object> params) {
|
||
PageUtils page = bookService.getSaleBook(params);
|
||
return R.ok().put("page", page);
|
||
}
|
||
|
||
//生成电子书 目录
|
||
@RequestMapping("/getWordChapter")
|
||
public R getWordChapter(@RequestParam Map<String, Object> params) {
|
||
bookService.getWordChapter(14);
|
||
return R.ok();
|
||
}
|
||
|
||
@RequestMapping("/file")
|
||
public String getFile() {
|
||
String filePath = "C:\\Users\\Administrator\\IdeaProjects\\peanut_book\\2020年8月中华人民共和国县以上行政区划代码.json";
|
||
List<ProvinceEntity> provinceList = ReadProvinceUtil.getFile(filePath);
|
||
// System.out.println(provinceList);
|
||
if (provinceList != null && provinceList.size() > 0) {
|
||
for (ProvinceEntity province : provinceList) {
|
||
// ProvinceEntity provinceEntity = new ProvinceEntity();
|
||
// provinceEntity.setProvName(province.getProvName());
|
||
// provinceEntity.setCreateDate(province.getCreateDate());
|
||
// provinceEntity.setRegionCode(province.getRegionCode());
|
||
provinceService.save(province);
|
||
List<CityEntity> cityList = province.getCityList();
|
||
if (cityList != null && cityList.size() > 0) {
|
||
for (CityEntity city : cityList) {
|
||
// CityEntity cityEntity = new CityEntity();
|
||
// cityEntity.setCreateDate(city.getCreateDate());
|
||
// cityEntity.setCityName(city.getCityName());
|
||
// cityEntity.setRegionCode(city.getRegionCode());
|
||
// city.setProvId(province.getProvId());
|
||
city.setProvId(province.getProvId());
|
||
cityService.save(city);
|
||
List<CountyEntity> countyList = city.getCountyList();
|
||
if (countyList != null && countyList.size() > 0) {
|
||
for (CountyEntity county : countyList) {
|
||
// CountyEntity countyEntity = new CountyEntity();
|
||
county.setCityId(city.getCityId());
|
||
// countyEntity.setCountyName(county.getCountyName());
|
||
// countyEntity.setCreateDate(county.getCreateDate());
|
||
// countyEntity.setRegionCode(county.getRegionCode());
|
||
countyService.save(county);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
}
|