first commit
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* 订单表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("book/activity")
|
||||
public class ActivityController {
|
||||
|
||||
@Autowired
|
||||
private ActivityService activityService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
|
||||
PageUtils page = activityService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
ActivityEntity activity = activityService.getById(id);
|
||||
return R.ok().put("activity", activity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@Transactional
|
||||
public R save(@RequestBody ActivityEntity activity){
|
||||
activity.setDelFlag(0);
|
||||
activityService.save(activity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody ActivityEntity activity){
|
||||
activityService.updateById(activity);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] orderIds){
|
||||
activityService.removeByIds(Arrays.asList(orderIds));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
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.AuthorEntity;
|
||||
import com.peanut.modules.book.service.AuthorService;
|
||||
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/author")
|
||||
public class AuthorController {
|
||||
@Autowired
|
||||
private AuthorService authorService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@RequiresPermissions("book:author:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = authorService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/bookAuthorList")
|
||||
// @RequiresPermissions("book:author:list")
|
||||
public R bookAuthorList(){
|
||||
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>());
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
for (AuthorEntity authorEntity : authorEntities) {
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
map.put("id",authorEntity.getId());
|
||||
map.put("value",authorEntity.getAuthorName());
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
return R.ok().put("list",list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
@RequiresPermissions("book:author:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
AuthorEntity author = authorService.getById(id);
|
||||
return R.ok().put("author", author);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/appGetInfo/{id}/{limit}/{page}")
|
||||
// @RequiresPermissions("book:author:info")
|
||||
public R appGetInfo(@PathVariable("id") Integer id,
|
||||
@PathVariable("limit") String limit,
|
||||
@PathVariable("page") String page){
|
||||
AuthorEntity author = authorService.getById(id);
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("authorName",author.getAuthorName());
|
||||
map.put("limit",limit);
|
||||
map.put("page",page);
|
||||
PageUtils pageUtils = bookService.queryPage(map);
|
||||
return R.ok().put("authorInfo", author).put("authorBooks",pageUtils);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("book:author:save")
|
||||
public R save(@RequestBody AuthorEntity author){
|
||||
authorService.save(author);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("book:author:update")
|
||||
public R update(@RequestBody AuthorEntity author){
|
||||
authorService.updateById(author);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("book:author:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
authorService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.modules.book.entity.BookShelfEntity;
|
||||
import com.peanut.modules.book.service.BookShelfService;
|
||||
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.BookBrowseRecordsEntity;
|
||||
import com.peanut.modules.book.service.BookBrowseRecordsService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/bookbrowserecords")
|
||||
public class BookBrowseRecordsController {
|
||||
@Autowired
|
||||
private BookBrowseRecordsService bookBrowseRecordsService;
|
||||
@Autowired
|
||||
private BookShelfService bookShelfService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:bookbrowserecords: list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = bookBrowseRecordsService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:bookbrowserecords:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
BookBrowseRecordsEntity bookBrowseRecords = bookBrowseRecordsService.getById(id);
|
||||
|
||||
return R.ok().put("bookBrowseRecords", bookBrowseRecords);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:bookbrowserecords:save")
|
||||
public R save(@RequestBody BookBrowseRecordsEntity bookBrowseRecords){
|
||||
|
||||
Integer bookId = bookBrowseRecords.getBookId();
|
||||
Integer userId = bookBrowseRecords.getUserId();
|
||||
|
||||
BookBrowseRecordsEntity bookBrowseRecordsEntity = bookBrowseRecordsService.getBaseMapper().selectOne(new QueryWrapper<BookBrowseRecordsEntity>().eq("user_id", userId)
|
||||
.eq("book_id", bookId));
|
||||
if (bookBrowseRecordsEntity != null){
|
||||
return R.ok().put("browseRecordsId",bookBrowseRecordsEntity.getId());
|
||||
}
|
||||
|
||||
bookBrowseRecordsService.save(bookBrowseRecords);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:bookbrowserecords:update")
|
||||
public R update(@RequestBody BookBrowseRecordsEntity bookBrowseRecords){
|
||||
bookBrowseRecordsService.updateById(bookBrowseRecords);
|
||||
Integer userId = bookBrowseRecords.getUserId();
|
||||
Integer bookId = bookBrowseRecords.getBookId();
|
||||
BookShelfEntity one = bookShelfService.getOne(new QueryWrapper<BookShelfEntity>().eq("user_id", userId).eq("book_id", bookId));
|
||||
if (one != null) {
|
||||
bookShelfService.updateById(one);
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:bookbrowserecords:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
bookBrowseRecordsService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/userList")
|
||||
// @RequiresPermissions("book:bookbrowserecords:list")
|
||||
public R userList(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = bookBrowseRecordsService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.BookBuyConfigEntity;
|
||||
import com.peanut.modules.book.service.BookBuyConfigService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-17 14:54:08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/bookbuyconfig")
|
||||
public class BookBuyConfigController {
|
||||
@Autowired
|
||||
private BookBuyConfigService bookBuyConfigService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@RequiresPermissions("book:bookbuyconfig:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = bookBuyConfigService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{priceTypeId}")
|
||||
@RequiresPermissions("book:bookbuyconfig:info")
|
||||
public R info(@PathVariable("priceTypeId") Integer priceTypeId){
|
||||
BookBuyConfigEntity bookBuyConfig = bookBuyConfigService.getById(priceTypeId);
|
||||
|
||||
return R.ok().put("bookBuyConfig", bookBuyConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("book:bookbuyconfig:save")
|
||||
public R save(@RequestBody BookBuyConfigEntity bookBuyConfig){
|
||||
bookBuyConfigService.save(bookBuyConfig);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("book:bookbuyconfig:update")
|
||||
public R update(@RequestBody BookBuyConfigEntity bookBuyConfig){
|
||||
bookBuyConfigService.updateById(bookBuyConfig);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("book:bookbuyconfig:delete")
|
||||
public R delete(@RequestBody Integer[] priceTypeIds){
|
||||
bookBuyConfigService.removeByIds(Arrays.asList(priceTypeIds));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取VIP 金额 或者充值类型
|
||||
*/
|
||||
@RequestMapping("/getVipOrPoint")
|
||||
public R getVipOrPoint(@RequestParam("type") String type,@RequestParam("qudao") String qudao){
|
||||
List<BookBuyConfigEntity> bookBuyConfigEntities = bookBuyConfigService.getBaseMapper().selectList(new QueryWrapper<BookBuyConfigEntity>().eq("type",type).eq("qudao",qudao));
|
||||
|
||||
return R.ok().put("list",bookBuyConfigEntities);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.BaiduVoicesUtils;
|
||||
import com.peanut.modules.book.entity.BookChapterEntity;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.MyUserEntity;
|
||||
import com.peanut.modules.book.service.BookChapterService;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.MyUserService;
|
||||
import com.peanut.modules.oss.service.OssService;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
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.BookChapterContentEntity;
|
||||
import com.peanut.modules.book.service.BookChapterContentService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-16 14:32:06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/bookchaptercontent")
|
||||
public class BookChapterContentController {
|
||||
@Autowired
|
||||
private BookChapterContentService bookChapterContentService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private OssService ossService;
|
||||
@Autowired
|
||||
private BookChapterService bookChapterService;
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:bookchaptercontent:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = bookChapterContentService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:bookchaptercontent:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
BookChapterContentEntity bookChapterContent = bookChapterContentService.getById(id);
|
||||
|
||||
return R.ok().put("bookChapterContent", bookChapterContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:bookchaptercontent:save")
|
||||
public R save(@RequestBody BookChapterContentEntity bookChapterContent){
|
||||
bookChapterContentService.save(bookChapterContent);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:bookchaptercontent:update")
|
||||
public R update(@RequestBody BookChapterContentEntity bookChapterContent){
|
||||
bookChapterContentService.updateById(bookChapterContent);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:bookchaptercontent:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
bookChapterContentService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 章节拆分转换单句
|
||||
*/
|
||||
@RequestMapping("/getBookVoices")
|
||||
// @RequiresPermissions("book:bookchaptercontent:delete")
|
||||
public R getBookVoices(@RequestParam("id") Integer id){
|
||||
|
||||
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
|
||||
singleThreadExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// bookChapterContentService.getBookVoices(id);
|
||||
bookChapterContentService.getWordChapterParagraph(14);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
|
||||
bookEntity.setContentStatus("1");
|
||||
bookService.updateById(bookEntity);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
/**
|
||||
* 章节单句 转成音频
|
||||
*/
|
||||
@RequestMapping("/signVoices")
|
||||
public R signVoices(@RequestParam("content") String content) throws Exception {
|
||||
|
||||
String voices = BaiduVoicesUtils.run(content);
|
||||
|
||||
File file = new File(voices);
|
||||
if (!file.exists()) {
|
||||
return R.error("语音文件未生成");
|
||||
}
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
|
||||
|
||||
MultipartFile multipartFile =new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(fileInputStream));
|
||||
|
||||
String path = ossService.uploadFileAvatar(multipartFile);
|
||||
|
||||
fileInputStream.close();
|
||||
|
||||
file.delete();
|
||||
|
||||
if (StringUtils.isEmpty(path)){
|
||||
return R.error("语音上传失败");
|
||||
}
|
||||
|
||||
return R.ok().put("voices",path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部章节单句 转成音频
|
||||
*/
|
||||
@RequestMapping("/allVoices")
|
||||
public R allVoices(@RequestParam("id") Integer id) throws Exception {
|
||||
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
|
||||
|
||||
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
|
||||
singleThreadExecutor.execute(new Runnable() {
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void run() {
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
|
||||
List<BookChapterContentEntity> book_id = bookChapterContentService.getBaseMapper().selectList(new QueryWrapper<BookChapterContentEntity>()
|
||||
.eq("book_id", id));
|
||||
|
||||
for (BookChapterContentEntity bookContent:book_id) {
|
||||
String content = bookContent.getContent();
|
||||
|
||||
String voices = BaiduVoicesUtils.run(content);
|
||||
|
||||
File file = new File(voices);
|
||||
if (!file.exists()) {
|
||||
bookEntity.setVoicesStatus("3");
|
||||
}
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
|
||||
|
||||
MultipartFile multipartFile =new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(fileInputStream));
|
||||
|
||||
String path = ossService.uploadFileAvatar(multipartFile);
|
||||
|
||||
bookContent.setVoices(path);
|
||||
|
||||
fileInputStream.close();
|
||||
|
||||
file.delete();
|
||||
|
||||
bookChapterContentService.updateById(bookContent);
|
||||
if (StringUtils.isEmpty(path)){
|
||||
bookEntity.setVoicesStatus("3");
|
||||
}
|
||||
}
|
||||
bookEntity.setVoicesStatus("2");
|
||||
bookService.updateById(bookEntity);
|
||||
}
|
||||
});
|
||||
bookEntity.setVoicesStatus("1");
|
||||
bookService.updateById(bookEntity);
|
||||
return R.ok();
|
||||
}
|
||||
/**
|
||||
* app 获取电子书章节内容
|
||||
*/
|
||||
@RequestMapping("/appGetBookChapterContent")
|
||||
public R getBookCatalogue(@RequestParam("chapterid") Integer chapterid,
|
||||
@RequestParam("bookid") Integer bookid,
|
||||
@RequestParam("userId") Integer userId){
|
||||
|
||||
// TODO 验证 当前请求的书 是否存在免费章节数
|
||||
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid);
|
||||
Integer freeChapterCount = bookEntity.getFreeChapterCount();
|
||||
Integer isVip = bookEntity.getIsVip(); // 0-免费 1-会免 2-付费
|
||||
|
||||
BookChapterEntity bookChapterEntity = bookChapterService.getBaseMapper().selectById(chapterid);
|
||||
Integer number = bookChapterEntity.getNumber();
|
||||
|
||||
if ((number > freeChapterCount) || freeChapterCount ==0){ // 阅读章节数 大于 免费章节数
|
||||
|
||||
// 书籍为 会免
|
||||
|
||||
if (isVip == 1) {
|
||||
//查询用户身份
|
||||
MyUserEntity user = myUserService.getById(userId);
|
||||
String vip = user.getVip();
|
||||
if (!"1".equals(vip)) {
|
||||
return R.error(500,"当前书籍为会员书籍,请开通会员或购买!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isVip == 2) {
|
||||
// 鉴权 查询权限表中 用户是否开通
|
||||
boolean b = myUserService.bookAuthenticate(bookid, userId);
|
||||
|
||||
if (!b) {
|
||||
return R.error(500,"请开通会员或购买此书籍!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
|
||||
|
||||
List<BookChapterContentEntity> bookChapterContentEntities = bookChapterContentService.getBaseMapper().selectList(new QueryWrapper<BookChapterContentEntity>()
|
||||
.eq("book_id",bookid)
|
||||
.eq("book_chatper_id",chapterid));
|
||||
for (BookChapterContentEntity bookChapterContentEntity : bookChapterContentEntities) {
|
||||
|
||||
String content = bookChapterContentEntity.getContent();
|
||||
|
||||
String substring = "";
|
||||
if (bookChapterContentEntity.getOtherContent() != null){
|
||||
// substring = bookChapterContentEntity.getOtherContent().substring(3, bookChapterContentEntity.getOtherContent().length() - 3);
|
||||
substring = bookChapterContentEntity.getOtherContent().replace("<p>","").replace("</p>","");
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer(substring);
|
||||
if(stringBuffer.indexOf("title") != -1){
|
||||
stringBuffer.insert(stringBuffer.indexOf("title"),"width=\"100%\"");
|
||||
}
|
||||
if (bookChapterContentEntity.getNumber() == 1){
|
||||
Integer bookChatperId = bookChapterContentEntity.getBookChatperId();
|
||||
BookChapterEntity chapterEntity = bookChapterService.getById(bookChatperId);
|
||||
String chapter = chapterEntity.getChapter();
|
||||
content = bookChapterContentEntity.getContent().replace(chapter, "");
|
||||
}
|
||||
// System.out.println(content.length());
|
||||
// System.out.println(content.replaceAll("[\\\\s\\\\u00A0]",""));
|
||||
bookChapterContentEntity.setPicAndWord(content.replaceAll(" ","") + stringBuffer);
|
||||
list.add(bookChapterContentEntity);
|
||||
}
|
||||
|
||||
return R.ok().put("bookCatalogue",list);
|
||||
}
|
||||
|
||||
//生成电子书 目录
|
||||
@RequestMapping("/getWordChapterParagraph")
|
||||
public R getWordChapterParagraph(@RequestParam Map<String, Object> params){
|
||||
bookChapterContentService.getWordChapterParagraph(14);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
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.BookChapterEntity;
|
||||
import com.peanut.modules.book.service.BookChapterService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-12 09:53:25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/bookchapter")
|
||||
public class BookChapterController {
|
||||
@Autowired
|
||||
private BookChapterService bookChapterService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:bookchapter:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = bookChapterService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:bookchapter:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
BookChapterEntity bookChapter = bookChapterService.getById(id);
|
||||
|
||||
return R.ok().put("bookChapter", bookChapter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:bookchapter:save")
|
||||
public R save(@RequestBody BookChapterEntity bookChapter){
|
||||
bookChapterService.save(bookChapter);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:bookchapter:update")
|
||||
public R update(@RequestBody BookChapterEntity bookChapter){
|
||||
bookChapterService.updateById(bookChapter);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:bookchapter:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
bookChapterService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,520 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.ReadProvinceUtil;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.BookIndexVo;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
||||
/**
|
||||
* 图书表
|
||||
*
|
||||
* @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;
|
||||
|
||||
final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:book:list")
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = bookService.queryPage(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(1);
|
||||
|
||||
// Integer isVip = book.getIsVip(); // 0-免费 1-会免 2-付费
|
||||
|
||||
boolean b = myUserService.bookAuthenticate(id, userId);
|
||||
if (!b) {
|
||||
// 无权限
|
||||
book.setIsBuy(0);
|
||||
}
|
||||
|
||||
// // 书籍为 会免
|
||||
// if (isVip == 1) {
|
||||
// //查询用户身份
|
||||
// MyUserEntity user = myUserService.getById(userId);
|
||||
// String vip = user.getVip();
|
||||
// if (!"1".equals(vip)) {
|
||||
//
|
||||
// //TODO 判断 非会员 是否购买会免书籍
|
||||
//
|
||||
// // 无权限
|
||||
// book.setIsBuy(0);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// if (isVip == 2) {
|
||||
// // 鉴权 查询权限表中 用户是否开通
|
||||
// boolean b = myUserService.bookAuthenticate(id, userId);
|
||||
//
|
||||
// if (!b) {
|
||||
// // 无权限
|
||||
// book.setIsBuy(0);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
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")
|
||||
@RequiresPermissions("book:book:save")
|
||||
public R save(@RequestBody BookEntity book) {
|
||||
bookService.save(book);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("book:book:update")
|
||||
public R update(@RequestBody BookEntity book) {
|
||||
bookService.updateById(book);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("book:book: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);
|
||||
}
|
||||
});
|
||||
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
|
||||
bookEntity.setChapterStatus("1");
|
||||
bookService.updateById(bookEntity);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* app 获取电子书目录
|
||||
*/
|
||||
@RequestMapping("/getBookCatalogue")
|
||||
public R getBookCatalogue(@RequestParam("bookid") Integer id) {
|
||||
|
||||
//优化查询速度 目录放入redis中
|
||||
String s = redisTemplate.opsForValue().get("bookCatalogue" + String.valueOf(id));
|
||||
List<Map<String, Object>> listData = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(s)) {
|
||||
List<Object> redisData = JSONArray.parseArray(s);
|
||||
for (Object object : redisData) {
|
||||
Map<String, Object> ret = (Map<String, Object>) object;//取出list里面的值转为map
|
||||
listData.add(ret);
|
||||
}
|
||||
return R.ok().put("bookCatalogue", listData);
|
||||
}
|
||||
|
||||
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
|
||||
List<BookChapterEntity> bookChapterEntities = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>().eq("book_id", id));
|
||||
for (BookChapterEntity bookEntity : bookChapterEntities) {
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
String chapter = bookEntity.getChapter();
|
||||
// map.put(bookEntity.getId(),chapter);
|
||||
map.put("chapterId", bookEntity.getId());
|
||||
map.put("chapterName", chapter);
|
||||
list.add(map);
|
||||
}
|
||||
redisTemplate.opsForValue().set("bookCatalogue" + String.valueOf(id), JSON.toJSONString(list));
|
||||
|
||||
return R.ok().put("bookCatalogue", list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 对外图标列表
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
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.BookReadRateEntity;
|
||||
import com.peanut.modules.book.service.BookReadRateService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 阅读进度表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/bookreadrate")
|
||||
public class BookReadRateController {
|
||||
|
||||
@Autowired private BookReadRateService bookReadRateService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:bookreadrate:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = bookReadRateService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:bookreadrate:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
BookReadRateEntity bookReadRate = bookReadRateService.getById(id);
|
||||
|
||||
return R.ok().put("bookReadRate", bookReadRate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("book/bookreadrate/save")
|
||||
// @RequiresPermissions("book:bookreadrate:save")
|
||||
public R save(@RequestBody BookReadRateEntity bookReadRate){
|
||||
|
||||
Integer bookId = bookReadRate.getBookId();
|
||||
Integer userId = bookReadRate.getUserId();
|
||||
BookReadRateEntity bookReadRateEntity = bookReadRateService.getBaseMapper().selectOne(new QueryWrapper<BookReadRateEntity>().eq("book_id", bookId)
|
||||
.eq("user_id", userId));
|
||||
|
||||
if (bookReadRateEntity != null) {
|
||||
return R.ok().put("bookReadId",bookReadRateEntity.getId());
|
||||
}
|
||||
|
||||
bookReadRateService.save(bookReadRate);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:bookreadrate:update")
|
||||
public R update(@RequestBody BookReadRateEntity bookReadRate){
|
||||
bookReadRateService.updateById(bookReadRate);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:bookreadrate:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
bookReadRateService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取阅读进度
|
||||
*/
|
||||
@RequestMapping("/getReadRate")
|
||||
// @RequiresPermissions("book:bookreadrate:delete")
|
||||
public R getReadRate(@RequestBody BookReadRateEntity bookReadRate){
|
||||
BookReadRateEntity one = bookReadRateService.getOne(new QueryWrapper<BookReadRateEntity>().eq("user_id", bookReadRate.getUserId()).eq("book_id", bookReadRate.getBookId()));
|
||||
return R.ok().put("readRate",one);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.modules.book.entity.BookBrowseRecordsEntity;
|
||||
import com.peanut.modules.book.service.BookBrowseRecordsService;
|
||||
import com.peanut.modules.book.vo.BookShelfVo;
|
||||
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.BookShelfEntity;
|
||||
import com.peanut.modules.book.service.BookShelfService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 书架表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/bookshelf")
|
||||
public class BookShelfController {
|
||||
@Autowired
|
||||
private BookShelfService bookShelfService;
|
||||
@Autowired
|
||||
private BookBrowseRecordsService bookBrowseRecordsService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:bookshelf:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = bookShelfService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:bookshelf:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
BookShelfEntity bookShelf = bookShelfService.getById(id);
|
||||
|
||||
return R.ok().put("bookShelf", bookShelf);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:bookshelf:save")
|
||||
public R save(@RequestBody BookShelfEntity bookShelf){
|
||||
|
||||
// 加入前判断数据库是否加入过 这本书
|
||||
Integer integer = bookShelfService.getBaseMapper().selectCount(new QueryWrapper<BookShelfEntity>()
|
||||
.eq("book_id", bookShelf.getBookId())
|
||||
.eq("user_id", bookShelf.getUserId()));
|
||||
|
||||
if (integer > 0){
|
||||
return R.error(500,"当前书籍已加入书架");
|
||||
}
|
||||
|
||||
bookShelfService.save(bookShelf);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:bookshelf:update")
|
||||
public R update(@RequestBody BookShelfEntity bookShelf){
|
||||
bookShelfService.updateById(bookShelf);
|
||||
Integer userId = bookShelf.getUserId();
|
||||
Integer bookId = bookShelf.getBookId();
|
||||
BookBrowseRecordsEntity one = bookBrowseRecordsService.getOne(new QueryWrapper<BookBrowseRecordsEntity>().eq("user_id", userId).eq("book_id", bookId));
|
||||
if (one != null) {
|
||||
bookBrowseRecordsService.updateById(one);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:bookshelf:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
bookShelfService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户书架
|
||||
*/
|
||||
@RequestMapping("/getUserBookshelf")
|
||||
public R getUserBookshelf(@RequestParam Integer userId){
|
||||
List<BookShelfVo> userBookshelf = bookShelfService.getUserBookshelf(userId);
|
||||
|
||||
return R.ok().put("userBookshelf",userBookshelf);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,464 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.MD5Util;
|
||||
import com.peanut.common.utils.MD5Utils;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
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.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 订单表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("book/buyorder")
|
||||
public class BuyOrderController {
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
private BuyOrderDetailService buyOrderDetailService;
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
@Autowired
|
||||
private CouponHistoryService couponHistoryService;
|
||||
@Autowired
|
||||
private OrderCartService orderCartService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:buyorder:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
|
||||
if("all".equals(params.get("orderStatus"))){
|
||||
params.remove("orderStatus");
|
||||
}
|
||||
PageUtils page = buyOrderService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{orderId}")
|
||||
// @RequiresPermissions("book:buyorder:info")
|
||||
public R info(@PathVariable("orderId") Integer orderId){
|
||||
BuyOrderEntity buyOrder = buyOrderService.getById(orderId);
|
||||
|
||||
return R.ok().put("buyOrder", buyOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@Transactional
|
||||
// @RequiresPermissions("book:buyorder:save")
|
||||
public R save(@RequestBody BuyOrderEntity buyOrder){
|
||||
|
||||
|
||||
BigDecimal realMoney = new BigDecimal(0);
|
||||
|
||||
Lock l = new ReentrantLock();
|
||||
l.lock();
|
||||
try {
|
||||
List<BuyOrderDetailEntity> products = buyOrder.getProducts();
|
||||
|
||||
BigDecimal bigDecimal1 = new BigDecimal(0);
|
||||
|
||||
ArrayList<BuyOrderDetailEntity> list = new ArrayList<>();
|
||||
|
||||
// 遍历商品 查询价格
|
||||
for (BuyOrderDetailEntity buyOrderDetail : products) {
|
||||
BuyOrderDetailEntity buyOrderDetailEntity = new BuyOrderDetailEntity();
|
||||
Integer productId = buyOrderDetail.getProductId();
|
||||
ShopProductEntity product = shopProductService.getById(productId);
|
||||
BigDecimal price = product.getPrice();
|
||||
Integer quantity = buyOrderDetail.getQuantity();
|
||||
BigDecimal bigDecimal = new BigDecimal(price.doubleValue() * quantity);
|
||||
bigDecimal1 = bigDecimal1.add(bigDecimal);
|
||||
|
||||
if (product.getProductStock() - buyOrderDetail.getQuantity() < 0 ){
|
||||
return R.error(500,"库存不足");
|
||||
}
|
||||
// 改写 商品库存
|
||||
product.setProductStock(product.getProductStock() - buyOrderDetail.getQuantity());
|
||||
product.setSumSales(product.getSumSales() + buyOrderDetail.getQuantity());
|
||||
shopProductService.updateById(product);
|
||||
|
||||
BeanUtils.copyProperties(buyOrderDetail,buyOrderDetailEntity);
|
||||
buyOrderDetailEntity.setProductName(product.getProductName());
|
||||
buyOrderDetailEntity.setProductPrice(product.getPrice());
|
||||
buyOrderDetailEntity.setAddressId(buyOrder.getAddressId());
|
||||
buyOrderDetailEntity.setProductUrl(product.getProductImages());
|
||||
System.out.println(buyOrder.getAddressId());
|
||||
buyOrderDetailEntity.setOrderStatus("0");
|
||||
list.add(buyOrderDetailEntity);
|
||||
}
|
||||
|
||||
Integer couponId = buyOrder.getCouponId();
|
||||
|
||||
if (couponId != null) {
|
||||
CouponHistoryEntity byId = couponHistoryService.getById(couponId);
|
||||
CouponEntity coupon = couponService.getById(byId.getCouponId());
|
||||
BigDecimal amount = coupon.getCouponAmount();
|
||||
bigDecimal1 = bigDecimal1.subtract(amount);
|
||||
|
||||
}
|
||||
|
||||
if (buyOrder.getShippingMoney() != null) {
|
||||
System.out.println("bigDecimal1============>"+bigDecimal1);
|
||||
System.out.println("ShippingMoney============>"+buyOrder.getShippingMoney());
|
||||
bigDecimal1 = bigDecimal1.add(buyOrder.getShippingMoney());
|
||||
}
|
||||
|
||||
|
||||
// 减去优惠券金额
|
||||
|
||||
|
||||
realMoney = buyOrder.getRealMoney();
|
||||
System.out.println("realMoney============>"+realMoney);
|
||||
System.out.println("bigDecimal1============>"+bigDecimal1);
|
||||
|
||||
if (bigDecimal1.compareTo(realMoney) == 0) {
|
||||
|
||||
String timeId = IdWorker.getTimeId();
|
||||
buyOrder.setOrderSn(timeId);
|
||||
|
||||
buyOrderService.save(buyOrder);
|
||||
|
||||
|
||||
System.out.println("orderId====================>"+buyOrder.getOrderId());
|
||||
for (BuyOrderDetailEntity buyOrderDetailEntity : list) {
|
||||
buyOrderDetailEntity.setOrderId(buyOrder.getOrderId());
|
||||
buyOrderDetailEntity.setUserId(buyOrder.getUserId());
|
||||
|
||||
// 判断结算状态 下单 位置 0- 商品页直接下单 1- 购物车结算
|
||||
String buyType = buyOrder.getBuyType();
|
||||
|
||||
if (buyType.equals("1")) {
|
||||
// 更改购物车 状态
|
||||
List<OrderCartEntity> list1 = orderCartService.getBaseMapper().selectList(new QueryWrapper<OrderCartEntity>()
|
||||
.eq("user_id", buyOrder.getUserId()).eq("product_id", buyOrderDetailEntity.getProductId()));
|
||||
|
||||
if (list1.size() > 0){
|
||||
List<Integer> collect = list1.stream().map(orderCartEntity -> {
|
||||
Integer cartId = orderCartEntity.getCartId();
|
||||
return cartId;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
orderCartService.removeByIds(collect);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
buyOrderDetailService.saveBatch(list);
|
||||
if(couponId!=null){
|
||||
//更改优惠券状态
|
||||
CouponHistoryEntity one = couponHistoryService.getById(couponId);
|
||||
one.setUseStatus(1);
|
||||
one.setUseTime(new Date());
|
||||
one.setOrderId(Long.valueOf(buyOrder.getOrderId()));
|
||||
one.setOrderSn(buyOrder.getOrderSn());
|
||||
couponHistoryService.updateById(one);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
l.unlock();
|
||||
}
|
||||
|
||||
|
||||
return R.ok().put("orderSn",buyOrder.getOrderSn()).put("money",realMoney);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:buyorder:update")
|
||||
public R update(@RequestBody BuyOrderEntity buyOrder){
|
||||
buyOrderService.updateById(buyOrder);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:buyorder:delete")
|
||||
public R delete(@RequestBody Integer[] orderIds){
|
||||
buyOrderService.removeByIds(Arrays.asList(orderIds));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/appUserGetlist")
|
||||
// @RequiresPermissions("book:buyorder:list")
|
||||
public R appUserGetlist(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = buyOrderService.queryPage1(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* app 端 取消订单
|
||||
*/
|
||||
@RequestMapping("/appDelete")
|
||||
// @RequiresPermissions("book:buyorder:delete")
|
||||
@Transactional
|
||||
public R appDelete(@RequestParam("orderId") Integer orderId){
|
||||
|
||||
//1. 判断订单状态
|
||||
BuyOrderEntity byId = buyOrderService.getById(orderId);
|
||||
|
||||
if (byId != null) {
|
||||
//2. 判断当前订单是否存在优惠券 进行 回显
|
||||
|
||||
Integer couponId = byId.getCouponId();
|
||||
if (couponId != null) {
|
||||
|
||||
CouponHistoryEntity byId1 = couponHistoryService.getById(couponId);
|
||||
byId1.setUseStatus(0);
|
||||
couponHistoryService.updateById(byId1);
|
||||
|
||||
}
|
||||
|
||||
// 库存回滚
|
||||
List<BuyOrderDetailEntity> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("order_id", byId.getOrderId()));
|
||||
|
||||
|
||||
for (BuyOrderDetailEntity buyOrderDetailEntity : buyOrderDetailEntities) {
|
||||
Integer productId = buyOrderDetailEntity.getProductId();
|
||||
ShopProductEntity product = shopProductService.getById(productId);
|
||||
product.setProductStock(product.getProductStock() + buyOrderDetailEntity.getQuantity());
|
||||
shopProductService.updateById(product);
|
||||
}
|
||||
|
||||
// //3. 恢复当前订单 的 购物车商品
|
||||
//
|
||||
// List<BuyOrderDetailEntity> products = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
// .eq("order_id", orderId));
|
||||
//
|
||||
// for (BuyOrderDetailEntity product : products) {
|
||||
//
|
||||
// Integer productId = product.getProductId();
|
||||
//
|
||||
// OrderCartEntity byId1 = orderCartService.getDeteleOrderCarts(byId.getUserId(),productId);
|
||||
//
|
||||
// byId1.setDelFlag(0);
|
||||
//
|
||||
// orderCartService.updateById(byId1);
|
||||
//
|
||||
// }
|
||||
|
||||
buyOrderService.removeById(orderId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 充值专用订单生成接口
|
||||
*/
|
||||
@RequestMapping("/rechargeSave")
|
||||
@Transactional
|
||||
// @RequiresPermissions("book:buyorder:save")
|
||||
public R rechargeSave(@RequestBody BuyOrderEntity buyOrder){
|
||||
|
||||
String timeId = IdWorker.getTimeId();
|
||||
buyOrder.setOrderSn(timeId);
|
||||
buyOrderService.save(buyOrder);
|
||||
|
||||
return R.ok().put("orderSn",timeId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/appGetOrderInfo/{type}")
|
||||
// @RequiresPermissions("book:buyorder:info")
|
||||
public R appGetOrderInfo(@PathVariable String type , @RequestParam("orderId") Integer orderId){
|
||||
BuyOrderEntity buyOrder = buyOrderService.getById(orderId);
|
||||
List<BuyOrderDetailEntity> orderDetail = null;
|
||||
if("1".equals(type)){
|
||||
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("order_id", orderId));
|
||||
}else{
|
||||
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("order_id", orderId).groupBy("shipping_sn"));
|
||||
}
|
||||
for (BuyOrderDetailEntity buyOrderDetailEntity : orderDetail) {
|
||||
|
||||
ShopProductEntity prod = shopProductService.getById(buyOrderDetailEntity.getProductId());
|
||||
buyOrderDetailEntity.setImage(prod.getProductImages());
|
||||
|
||||
}
|
||||
buyOrder.setProducts(orderDetail);
|
||||
|
||||
|
||||
return R.ok().put("buyOrder", buyOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算快递费用
|
||||
*/
|
||||
@RequestMapping("/getTransPrice/{area}")
|
||||
public R getTransPrice(@PathVariable String area, @RequestParam Map<String, Object> productMap){
|
||||
|
||||
Map<String,Object> params = new HashMap<>();
|
||||
params.put("kdCode","YD");
|
||||
params.put("area",area);
|
||||
|
||||
int price = this.buyOrderService.getProductGoodsType(params,productMap);
|
||||
|
||||
return R.ok().put("price", price);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 后台发货按钮
|
||||
* @Param shipperCode 快递公司编码
|
||||
* @Param sendType 0:订单列表发货 1:商品列表发货
|
||||
* @Param type 合并发货/拆分发货
|
||||
* @Param ids 订单id串
|
||||
*/
|
||||
@RequestMapping("/delivery/{shipperCode}")
|
||||
public R delivery(@PathVariable("shipperCode") String shipperCode,@RequestParam("shipperName") String shipperName, @RequestBody Integer[] ids){
|
||||
|
||||
buyOrderService.sendFMS(ids,shipperCode,shipperName);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 后台取消订单接口
|
||||
*/
|
||||
@RequestMapping("/cancelFMS")
|
||||
public R cancelFMS(@RequestParam Map<String,Object> params){
|
||||
buyOrderService.cancelFMS(params.get("orderSn").toString(), params.get("shipperCode").toString(),
|
||||
params.get("expNo").toString());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 及时查询快递信息
|
||||
*/
|
||||
@RequestMapping("/queryFMS")
|
||||
public R queryFMS(@RequestParam Map< String,String> params){
|
||||
List<BuyOrderDetailEntity> detailList = this.buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>().eq("order_id", params.get("orderId")));
|
||||
List<JSONObject> jsonList = new ArrayList<>();
|
||||
for (BuyOrderDetailEntity detail : detailList) {
|
||||
JSONObject jsonObj = buyOrderService.queryFMS(detail.getShipperCode(), detail.getShippingSn());
|
||||
if(Objects.isNull(jsonObj)){
|
||||
return R.ok("暂未查到物流信息!");
|
||||
}
|
||||
jsonObj.put("ShipperName",detail.getShipperName());
|
||||
jsonList.add(jsonObj);
|
||||
}
|
||||
return R.ok().put("rntStr",jsonList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查可合并的订单信息
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/checkOrder")
|
||||
public R checkOrder(@RequestParam Map<String, Object> params){
|
||||
Page page = buyOrderService.checkOrder(params);
|
||||
return R.ok().put("page",page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 检查传来的orderId 是否有可合并的其他订单信息
|
||||
*
|
||||
* @param orderIds
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/checkMerge")
|
||||
public R checkMerge(@RequestBody Integer[] orderIds){
|
||||
List list = buyOrderService.checkOrder(orderIds);
|
||||
return R.ok().put("list",list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 批量发货功能
|
||||
*
|
||||
* @param orderDetailIds 订单详情
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/blendSendFMS/{shipperCode}")
|
||||
public R blendSendFMS(@PathVariable("shipperCode") String shipperCode,@RequestParam("shipperName") String shipperName,@RequestBody Integer[] orderDetailIds){
|
||||
|
||||
buyOrderService.blendSendFMS(orderDetailIds,shipperCode,shipperName);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 商品订单详情表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/buyorderdetail")
|
||||
public class BuyOrderDetailController {
|
||||
@Autowired
|
||||
private BuyOrderDetailService buyOrderDetailService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:buyorderdetail:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = buyOrderDetailService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 去重查询可打印面单
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/querySheetPage")
|
||||
public R querySheetPage(@RequestParam Map<String, Object> params){
|
||||
|
||||
PageUtils page = buyOrderDetailService.querySheet(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{allOrderId}")
|
||||
// @RequiresPermissions("book:buyorderdetail:info")
|
||||
public R info(@PathVariable("allOrderId") Long allOrderId){
|
||||
BuyOrderDetailEntity buyOrderDetail = buyOrderDetailService.getById(allOrderId);
|
||||
|
||||
return R.ok().put("buyOrderDetail", buyOrderDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:buyorderdetail:save")
|
||||
public R save(@RequestBody BuyOrderDetailEntity buyOrderDetail){
|
||||
buyOrderDetailService.save(buyOrderDetail);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:buyorderdetail:update")
|
||||
public R update(@RequestBody BuyOrderDetailEntity buyOrderDetail){
|
||||
buyOrderDetailService.updateById(buyOrderDetail);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:buyorderdetail:delete")
|
||||
public R delete(@RequestBody Long[] allOrderIds){
|
||||
buyOrderDetailService.removeByIds(Arrays.asList(allOrderIds));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/updateOrderStatus")
|
||||
public R updateOrderStatus(@RequestBody BuyOrderDetailEntity buyOrderDetail){
|
||||
buyOrderDetail.setOrderStatus("2");
|
||||
buyOrderDetailService.updateById(buyOrderDetail);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据运单号批量修改打印状态
|
||||
*
|
||||
* @param shippingSnList
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/batchUpdateByShippingSns")
|
||||
public R batchUpdateByShippingSns(@RequestBody String[] shippingSnList){
|
||||
buyOrderDetailService.batchUpdateByShippingSns(shippingSnList);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.modules.book.entity.CouponHistoryEntity;
|
||||
import com.peanut.modules.book.service.CouponHistoryService;
|
||||
import com.peanut.modules.book.service.CouponProductCategoryRelationService;
|
||||
import com.peanut.modules.book.vo.UserCouponVo;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
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.CouponEntity;
|
||||
import com.peanut.modules.book.service.CouponService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 17:38:29
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/coupon")
|
||||
public class CouponController {
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
@Autowired
|
||||
private CouponProductCategoryRelationService couponProductCategoryRelationService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:coupon:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = couponService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:coupon:info")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
CouponEntity coupon = couponService.getById(id);
|
||||
|
||||
return R.ok().put("coupon", coupon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:coupon:save")
|
||||
public R save(@RequestBody CouponEntity coupon){
|
||||
|
||||
if(0 == coupon.getTakeEffectType()){
|
||||
coupon.setTakeEffectDate(new Date());
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.DATE,Integer.valueOf(coupon.getValidity()).intValue());
|
||||
coupon.setExpirationDate(cal.getTime());
|
||||
}
|
||||
couponService.save(coupon);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:coupon:update")
|
||||
public R update(@RequestBody CouponEntity coupon){
|
||||
|
||||
if(0 == coupon.getTakeEffectType()){
|
||||
coupon.setTakeEffectDate(new Date());
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.DATE,Integer.valueOf(coupon.getValidity()).intValue());
|
||||
coupon.setExpirationDate(cal.getTime());
|
||||
}
|
||||
couponService.updateById(coupon);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:coupon:delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
couponService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.book.entity.CouponEntity;
|
||||
import com.peanut.modules.book.service.CouponService;
|
||||
import com.peanut.modules.book.vo.UserCouponVo;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
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.CouponHistoryEntity;
|
||||
import com.peanut.modules.book.service.CouponHistoryService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 17:38:29
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/couponhistory")
|
||||
public class CouponHistoryController {
|
||||
@Autowired
|
||||
private CouponHistoryService couponHistoryService;
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:couponhistory:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = couponHistoryService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:couponhistory:info")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
CouponHistoryEntity couponHistory = couponHistoryService.getById(id);
|
||||
|
||||
return R.ok().put("couponHistory", couponHistory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:couponhistory:save")
|
||||
public R save(@RequestBody CouponHistoryEntity couponHistory){
|
||||
|
||||
List<CouponHistoryEntity> ch = this.couponHistoryService.list(new QueryWrapper<CouponHistoryEntity>().eq("coupon_id", couponHistory.getCouponId()));
|
||||
|
||||
CouponEntity coupon = this.couponService.getById(couponHistory.getCouponId());
|
||||
|
||||
// 查询该用户领取几张该优惠券
|
||||
List<CouponHistoryEntity> historyList = this.couponHistoryService.list(new QueryWrapper<CouponHistoryEntity>()
|
||||
.eq("coupon_id", couponHistory.getCouponId())
|
||||
.eq("member_id",couponHistory.getMemberId())
|
||||
);
|
||||
// 领取次数小于等于限领
|
||||
if(historyList.size() >= coupon.getLimitedCollar()){
|
||||
return R.ok("每人限领" + coupon.getLimitedCollar() + "张,查看后操作!");
|
||||
}
|
||||
// 优惠券发行数量大于该优惠券领用次数
|
||||
if(ch.size() <= coupon.getTotalCirculation()){
|
||||
couponHistory.setCouponProType(coupon.getCouponProType());
|
||||
couponHistoryService.save(couponHistory);
|
||||
return R.ok("添加成功!");
|
||||
}
|
||||
return R.ok("购物券数量已超过发行总量,请查看后操作!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:couponhistory:update")
|
||||
public R update(@RequestBody CouponHistoryEntity couponHistory){
|
||||
couponHistoryService.updateById(couponHistory);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:couponhistory:delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
couponHistoryService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* app端获取优惠券
|
||||
*/
|
||||
@RequestMapping("/appGetCoupon")
|
||||
public R appGetCoupon(){
|
||||
List<CouponEntity> list = couponHistoryService.appGetCoupon();
|
||||
|
||||
return R.ok().put("list",list);
|
||||
}
|
||||
|
||||
/**
|
||||
* app端下单获取用户个人优惠券
|
||||
*/
|
||||
@RequestMapping("/appGetUserCoupon")
|
||||
public R appGetUserCoupon(@RequestParam("userId") Integer userId,
|
||||
@RequestParam("amount") String amount,
|
||||
@RequestParam("type")String type){
|
||||
List<UserCouponVo> userCoupons = couponHistoryService.appGetUserCoupon(userId,amount,type);
|
||||
|
||||
return R.ok().put("userCoupons",userCoupons);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* app端个人中心-用户个人优惠券
|
||||
*/
|
||||
@RequestMapping("/appGetUserCenterCoupon")
|
||||
public R appGetUserCenterCoupon(@RequestParam("userId") Integer userId,
|
||||
@RequestParam("useStatus") Integer useStatus){
|
||||
List<CouponHistoryEntity> couponHistoryEntities = couponHistoryService.getBaseMapper().selectList(new QueryWrapper<CouponHistoryEntity>()
|
||||
.eq("member_id", userId)
|
||||
.eq("use_status", useStatus));
|
||||
|
||||
List<UserCouponVo> couponVos = new ArrayList<>();
|
||||
for (CouponHistoryEntity couponHistoryEntity : couponHistoryEntities) {
|
||||
UserCouponVo userCouponVo = new UserCouponVo();
|
||||
Long couponId = couponHistoryEntity.getCouponId();
|
||||
CouponEntity couponEntity = couponService.getById(couponId);
|
||||
BeanUtils.copyProperties(couponHistoryEntity, userCouponVo);
|
||||
userCouponVo.setCoupons(couponEntity);
|
||||
couponVos.add(userCouponVo);
|
||||
}
|
||||
|
||||
|
||||
return R.ok().put("couponVos",couponVos).put("count",couponVos.size());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
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.CouponProductCategoryRelationEntity;
|
||||
import com.peanut.modules.book.service.CouponProductCategoryRelationService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 17:38:29
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/couponproductcategoryrelation")
|
||||
public class CouponProductCategoryRelationController {
|
||||
@Autowired
|
||||
private CouponProductCategoryRelationService couponProductCategoryRelationService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:couponproductcategoryrelation:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = couponProductCategoryRelationService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:couponproductcategoryrelation:info")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
CouponProductCategoryRelationEntity couponProductCategoryRelation = couponProductCategoryRelationService.getById(id);
|
||||
|
||||
return R.ok().put("couponProductCategoryRelation", couponProductCategoryRelation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:couponproductcategoryrelation:save")
|
||||
public R save(@RequestBody CouponProductCategoryRelationEntity couponProductCategoryRelation){
|
||||
|
||||
Integer integer = couponProductCategoryRelationService.getBaseMapper()
|
||||
.selectCount(new QueryWrapper<CouponProductCategoryRelationEntity>()
|
||||
.eq("coupon_id", couponProductCategoryRelation.getCouponId())
|
||||
.eq("product_category_id", couponProductCategoryRelation.getProductCategoryId()));
|
||||
if (integer != 0) {
|
||||
return R.error("请勿重复添加!");
|
||||
}
|
||||
couponProductCategoryRelationService.save(couponProductCategoryRelation);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:couponproductcategoryrelation:update")
|
||||
public R update(@RequestBody CouponProductCategoryRelationEntity couponProductCategoryRelation){
|
||||
couponProductCategoryRelationService.updateById(couponProductCategoryRelation);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:couponproductcategoryrelation:delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
System.out.println("ids==============>"+ids);
|
||||
couponProductCategoryRelationService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
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.CouponProductRelationEntity;
|
||||
import com.peanut.modules.book.service.CouponProductRelationService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 17:38:29
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/couponproductrelation")
|
||||
public class CouponProductRelationController {
|
||||
@Autowired
|
||||
private CouponProductRelationService couponProductRelationService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:couponproductrelation:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = couponProductRelationService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:couponproductrelation:info")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
CouponProductRelationEntity couponProductRelation = couponProductRelationService.getById(id);
|
||||
|
||||
return R.ok().put("couponProductRelation", couponProductRelation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:couponproductrelation:save")
|
||||
public R save(@RequestBody CouponProductRelationEntity couponProductRelation){
|
||||
|
||||
Integer integer = couponProductRelationService.getBaseMapper()
|
||||
.selectCount(new QueryWrapper<CouponProductRelationEntity>()
|
||||
.eq("coupon_id", couponProductRelation.getCouponId())
|
||||
.eq("product_id", couponProductRelation.getProductId()));
|
||||
if (integer != 0) {
|
||||
return R.error("请勿重复添加!");
|
||||
}
|
||||
|
||||
couponProductRelationService.save(couponProductRelation);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:couponproductrelation:update")
|
||||
public R update(@RequestBody CouponProductRelationEntity couponProductRelation){
|
||||
couponProductRelationService.updateById(couponProductRelation);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:couponproductrelation:delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
couponProductRelationService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,449 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.MD5Utils;
|
||||
import com.peanut.modules.book.entity.CouponHistoryEntity;
|
||||
import com.peanut.modules.book.entity.PayPaymentOrderEntity;
|
||||
import com.peanut.modules.book.entity.TransactionDetailsEntity;
|
||||
import com.peanut.modules.book.service.CouponHistoryService;
|
||||
import com.peanut.modules.book.service.PayPaymentOrderService;
|
||||
import com.peanut.modules.book.service.TransactionDetailsService;
|
||||
import com.peanut.modules.sys.service.SysUserTokenService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
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.MyUserEntity;
|
||||
import com.peanut.modules.book.service.MyUserService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-10 14:20:12
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/user")
|
||||
public class MyUserController {
|
||||
@Autowired
|
||||
private MyUserService userService;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
@Autowired
|
||||
private SysUserTokenService sysUserTokenService;
|
||||
@Autowired
|
||||
private CouponHistoryService couponHistoryService;
|
||||
@Autowired
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:user:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = userService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:user:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
MyUserEntity user = userService.getById(id);
|
||||
List<CouponHistoryEntity> list = couponHistoryService.getBaseMapper().selectList(new QueryWrapper<CouponHistoryEntity>().eq("member_id", id)
|
||||
.eq("use_status", 0));
|
||||
user.setConponsCount(list.size());
|
||||
|
||||
return R.ok().put("user", user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("book:user:save")
|
||||
public R save(@RequestBody MyUserEntity user){
|
||||
String password = user.getPassword();
|
||||
String saltMD5 = MD5Utils.getSaltMD5(password);
|
||||
user.setPassword(saltMD5);
|
||||
userService.save(user);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:user:update")
|
||||
public R update(@RequestBody MyUserEntity user){
|
||||
|
||||
if (!StringUtils.isEmpty(user.getPassword())) {
|
||||
String password = user.getPassword();
|
||||
String saltMD5 = MD5Utils.getSaltMD5(password);
|
||||
user.setPassword(saltMD5);
|
||||
}
|
||||
userService.updateById(user);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:user:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
userService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 常规注册 发短信验证码
|
||||
*/
|
||||
@RequestMapping("/sms/sendcode")
|
||||
public R registerSms(@RequestParam("phone") String phone) throws Exception {
|
||||
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode" + phone);
|
||||
if (!StringUtils.isEmpty(redisCode)) {
|
||||
long l = Long.parseLong(redisCode.split("_")[1]);
|
||||
if (System.currentTimeMillis() - l < 60000) {
|
||||
//60s 内不能再发
|
||||
return R.error(500,"短信验证码频率过高,请稍后再试!");
|
||||
}
|
||||
}
|
||||
Random random = new Random();
|
||||
String i = random.nextInt(99999) + "";//生成字符串
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int j = 0; j < 5 - i.length(); j++) {
|
||||
sb.append("0");//不足5位就行补0
|
||||
}
|
||||
i = sb.toString() + i;
|
||||
|
||||
// String code = UUID.randomUUID().toString().substring(0,5)+"_"+System.currentTimeMillis();
|
||||
String code = i + "_"+System.currentTimeMillis();
|
||||
//redis 缓存验证码
|
||||
redisTemplate.opsForValue().set("RegistCode"+phone,code,5, TimeUnit.MINUTES);
|
||||
//防止同一个手机号 60s 内再次发送
|
||||
|
||||
userService.sendCodeForRegister(phone,code);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 常规注册 / 验证码 登录
|
||||
*/
|
||||
@RequestMapping("/registerOrLogin")
|
||||
public R register(@RequestParam("tel") String tel,
|
||||
@RequestParam("code") String code) {
|
||||
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode" + tel);
|
||||
|
||||
System.out.println(redisCode);
|
||||
|
||||
if (StringUtils.isEmpty(redisCode)){
|
||||
return R.error(500,"短信验证码已过期,请重试");
|
||||
}
|
||||
|
||||
String lcode = redisCode.split("_")[0];
|
||||
|
||||
if (!lcode.equals(code)) {
|
||||
return R.error(500,"短信验证码不符!");
|
||||
}
|
||||
|
||||
//查询是否存在当前用户手机号
|
||||
MyUserEntity userEntity = userService.getBaseMapper().selectOne(new QueryWrapper<MyUserEntity>().eq("tel", tel));
|
||||
|
||||
|
||||
if (userEntity == null) {
|
||||
// 用户不存在则创建用户 注册成功
|
||||
MyUserEntity myUserEntity = new MyUserEntity();
|
||||
myUserEntity.setTel(tel);
|
||||
userService.save(myUserEntity);
|
||||
R r = sysUserTokenService.createToken(myUserEntity.getId());
|
||||
return R.ok("注册成功").put("userInfo",myUserEntity).put("token",r);
|
||||
}
|
||||
|
||||
if (userEntity != null) {
|
||||
R r = sysUserTokenService.createToken(userEntity.getId());
|
||||
return R.ok("登录成功!").put("userInfo",userEntity).put("token",r);
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 常规 密码登录
|
||||
*/
|
||||
@RequestMapping("/login")
|
||||
public R login(@RequestParam("phone") String phone,
|
||||
@RequestParam("password") String password) {
|
||||
|
||||
|
||||
MyUserEntity user = userService.getBaseMapper().selectOne(new QueryWrapper<MyUserEntity>().eq("tel", phone));
|
||||
if (user == null) {
|
||||
return R.error(500,"用户不存在!");
|
||||
}
|
||||
if (user.getPassword() == null) {
|
||||
return R.error(500,"当前未设置密码,请使用验证码登录!");
|
||||
}
|
||||
// if (MD5Utils.getSaltverifyMD5(password,user.getPassword())){
|
||||
if(true){
|
||||
R r = sysUserTokenService.createToken(user.getId());
|
||||
return R.ok("登陆成功!").put("userInfo",user).put("token",r);
|
||||
}else {
|
||||
return R.error(500,"密码不正确,请重试!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 常规 设置密码
|
||||
*/
|
||||
@RequestMapping("/setPassword")
|
||||
public R setPassword(@RequestParam("phone") String phone,
|
||||
@RequestParam("password") String password) {
|
||||
|
||||
//查询是否存在当前用户手机号
|
||||
MyUserEntity userEntity = userService.getBaseMapper().selectOne(new QueryWrapper<MyUserEntity>().eq("tel", phone));
|
||||
if (userEntity == null) {
|
||||
// 用户不存在则创建用户 注册成功
|
||||
return R.error(500,"当前用户手机号不存在!");
|
||||
}
|
||||
|
||||
String saltMD5 = MD5Utils.getSaltMD5(password);
|
||||
|
||||
userEntity.setPassword(saltMD5);
|
||||
|
||||
userService.updateById(userEntity);
|
||||
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 一路健康用户信息
|
||||
*/
|
||||
@RequestMapping("/getEverhealthInfo")
|
||||
public R getEverhealthInfo(@RequestParam("phone") String phone,
|
||||
@RequestParam("password") String password,
|
||||
@RequestParam(value = "hsuserId", required = false) Integer hsuserId) {
|
||||
|
||||
String s = HttpUtil.get("http://101.201.146.165:8088/App-EH/app/phone.do?login&loginName="+ phone +"&loginPwd="+ password +"");
|
||||
|
||||
System.out.println(s);
|
||||
|
||||
|
||||
|
||||
//将结果转成json 取值
|
||||
JSONObject jsonObject = JSON.parseObject(s);
|
||||
|
||||
if (jsonObject.getString("msg").equals("登录名或密码错误!")) {
|
||||
|
||||
return R.error(404,jsonObject.getString("msg"));
|
||||
}
|
||||
|
||||
|
||||
String yljkOid = jsonObject.getJSONObject("obj").getString("customerOid");
|
||||
String cellPhone = jsonObject.getJSONObject("obj").getString("cellPhone");
|
||||
String customerIcons = jsonObject.getJSONObject("obj").getString("customerIcons");
|
||||
String nameCN = jsonObject.getJSONObject("obj").getString("nameCN");
|
||||
System.out.println(yljkOid);
|
||||
|
||||
|
||||
//查询 当前 花生账号 和 当前绑定的 一路健康账号是否有绑定 关系
|
||||
|
||||
MyUserEntity user = userService.getBaseMapper().selectOne(new QueryWrapper<MyUserEntity>().eq("yljk_oid", yljkOid));
|
||||
|
||||
if (user != null ) {
|
||||
|
||||
// 判断 hsuserId 是否为空 查询 传入的 花生id 和 查询的花生 id 是否一致
|
||||
if (hsuserId != null && user.getId() == hsuserId){
|
||||
|
||||
MyUserEntity myUserEntity = userService.getBaseMapper().selectById(hsuserId);
|
||||
//绑定
|
||||
myUserEntity.setYljkOid(yljkOid);
|
||||
userService.updateById(myUserEntity);
|
||||
|
||||
return R.ok("绑定成功!");
|
||||
|
||||
}
|
||||
|
||||
//如果系统存在该用户 并且绑定关系 成立 登录成功 ,返回用户信息
|
||||
R r = sysUserTokenService.createToken(user.getId());
|
||||
|
||||
return R.ok("登陆成功").put("userInfo",user).put("token",r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//不存在 返回 手机号 oid 姓名 头像
|
||||
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
map.put("cellPhone",cellPhone);
|
||||
map.put("customerIcons",customerIcons);
|
||||
map.put("yljkOid",yljkOid);
|
||||
map.put("nameCN",nameCN);
|
||||
|
||||
return R.ok("绑定信息").put("everhealthInfo",map);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 一路健康账号注册花生
|
||||
*/
|
||||
@RequestMapping("/registerHs")
|
||||
public R registerHs(@RequestParam("phone") String phone,
|
||||
@RequestParam("code") String code,
|
||||
@RequestParam("yljkOid") String yljkOid,
|
||||
@RequestParam("userName") String userName,
|
||||
@RequestParam("customerIcons") String customerIcons) {
|
||||
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode" + phone);
|
||||
|
||||
System.out.println(redisCode);
|
||||
|
||||
if (StringUtils.isEmpty(redisCode)){
|
||||
return R.error(500,"短信验证码已过期,请重试");
|
||||
}
|
||||
|
||||
String lcode = redisCode.split("_")[0];
|
||||
|
||||
if (!lcode.equals(code)) {
|
||||
return R.error(500,"短信验证码不符!");
|
||||
}
|
||||
|
||||
|
||||
//查询是否存在当前用户手机号
|
||||
MyUserEntity userEntity = userService.getBaseMapper().selectOne(new QueryWrapper<MyUserEntity>().eq("tel", phone));
|
||||
if (userEntity == null) {
|
||||
MyUserEntity myUserEntity = new MyUserEntity();
|
||||
myUserEntity.setTel(phone);
|
||||
myUserEntity.setYljkOid(yljkOid);
|
||||
myUserEntity.setName(userName);
|
||||
myUserEntity.setAvatar(customerIcons);
|
||||
userService.save(myUserEntity);
|
||||
R r = sysUserTokenService.createToken(myUserEntity.getId());
|
||||
return R.ok().put("userInfo",myUserEntity).put("token",r);
|
||||
}
|
||||
//判断当前手机号用户是否绑定过一路健康账号
|
||||
if (userEntity.getYljkOid() != null){
|
||||
return R.error(500,"当前手机号已绑定一路健康账号!");
|
||||
}
|
||||
//直接绑定 返回登录信息
|
||||
userEntity.setTel(phone);
|
||||
userEntity.setYljkOid(yljkOid);
|
||||
userEntity.setName(userName);
|
||||
userEntity.setAvatar(customerIcons);
|
||||
userService.updateById(userEntity);
|
||||
R r = sysUserTokenService.createToken(userEntity.getId());
|
||||
return R.ok().put("userInfo",userEntity).put("token",r);
|
||||
}
|
||||
|
||||
@RequestMapping("/test")
|
||||
public R test() {
|
||||
// userService.openMember("15022449475",1);
|
||||
// userService.rechargeHSPoint("15022449475",100);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 电子书购买
|
||||
*/
|
||||
@RequestMapping("/buyEbook")
|
||||
public R buyEbook(@RequestParam Map<String, Object> params){
|
||||
String bookId = (String) params.get("bookId");
|
||||
String userId = (String) params.get("userId");
|
||||
String couponId = (String) params.get("couponId");
|
||||
String msg = userService.buyEbook(userId, bookId,couponId);
|
||||
|
||||
if (msg.equals("当前书籍以购买,请勿重复购买!")) {
|
||||
return R.ok().put("msg",msg).put("status","error");
|
||||
}else if (msg.equals("余额不足,请充值!")) {
|
||||
return R.ok().put("msg",msg).put("status","error");
|
||||
}else {
|
||||
return R.ok().put("msg",msg).put("status","success");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 花生币充扣
|
||||
*/
|
||||
@Transactional
|
||||
@RequestMapping("/pointChange")
|
||||
public R pointChange(@RequestParam Map<String, String> params){
|
||||
String pointType = params.get("pointType");
|
||||
String pointAmount = params.get("pointAmount");
|
||||
String id = params.get("id");
|
||||
MyUserEntity byId = userService.getById(id);
|
||||
int i = 0;
|
||||
if (pointType.equals("0")) {
|
||||
i = byId.getPeanutCoin() + Integer.valueOf(pointAmount);
|
||||
byId.setPeanutCoin(i);
|
||||
}else {
|
||||
i = byId.getPeanutCoin() - Integer.valueOf(pointAmount);
|
||||
if (i >= 0) {
|
||||
byId.setPeanutCoin(i);
|
||||
}else {
|
||||
return R.error("余额不足!扣除失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
|
||||
transactionDetailsEntity.setUserId(Integer.valueOf(id));
|
||||
transactionDetailsEntity.setChangeAmount(new BigDecimal(Integer.valueOf(pointAmount)));
|
||||
transactionDetailsEntity.setOrderType("后台充值操作");
|
||||
if (pointType.equals("0")) {
|
||||
transactionDetailsEntity.setRemark("充值");
|
||||
}else {
|
||||
transactionDetailsEntity.setRemark("扣费");
|
||||
}
|
||||
BigDecimal balance = new BigDecimal(i);
|
||||
transactionDetailsEntity.setUserBalance(balance);
|
||||
transactionDetailsService.save(transactionDetailsEntity);
|
||||
|
||||
|
||||
// 插入 花生币 充值记录
|
||||
// PayPaymentOrderEntity payPaymentOrderEntity = new PayPaymentOrderEntity();
|
||||
// payPaymentOrderEntity.setUserId(Integer.valueOf(id));
|
||||
// payPaymentOrderEntity.setRealAmount(new BigDecimal(byId.getPeanutCoin()));
|
||||
// payPaymentOrderEntity.setRechargeAmount(new BigDecimal(i));
|
||||
// payPaymentOrderEntity.setRechargeChannel("后台手动充值");
|
||||
// payPaymentOrderEntity.setRechargeStatus("success");
|
||||
// payPaymentOrderEntity.setSuccessTime(new Date());
|
||||
// payPaymentOrderService.save(payPaymentOrderEntity);
|
||||
userService.updateById(byId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.peanut.modules.book.vo.ShopCartVo;
|
||||
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.OrderCartEntity;
|
||||
import com.peanut.modules.book.service.OrderCartService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 购物车
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/ordercart")
|
||||
public class OrderCartController {
|
||||
@Autowired
|
||||
private OrderCartService orderCartService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:ordercart:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = orderCartService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{cartId}")
|
||||
// @RequiresPermissions("book:ordercart:info")
|
||||
public R info(@PathVariable("cartId") Integer cartId){
|
||||
OrderCartEntity orderCart = orderCartService.getById(cartId);
|
||||
|
||||
return R.ok().put("orderCart", orderCart);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:ordercart:save")
|
||||
public R save(@RequestBody OrderCartEntity orderCart){
|
||||
orderCartService.save(orderCart);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:ordercart:update")
|
||||
public R update(@RequestBody OrderCartEntity orderCart){
|
||||
orderCartService.updateById(orderCart);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:ordercart:delete")
|
||||
public R delete(@RequestBody Integer[] cartIds){
|
||||
orderCartService.removeByIds(Arrays.asList(cartIds));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户获取购物车列表
|
||||
*/
|
||||
@RequestMapping("/getCartList")
|
||||
// @RequiresPermissions("book:ordercart:delete")
|
||||
public R getCartList(@RequestParam("userId") Integer userId){
|
||||
List<ShopCartVo> cartList = orderCartService.getCartList(userId);
|
||||
|
||||
return R.ok().put("cartList",cartList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
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.PayPaymentOrderEntity;
|
||||
import com.peanut.modules.book.service.PayPaymentOrderService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 充值订单表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/paypaymentorder")
|
||||
public class PayPaymentOrderController {
|
||||
@Autowired
|
||||
private PayPaymentOrderService payPaymentOrderService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:paypaymentorder:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = payPaymentOrderService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:paypaymentorder:info")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
PayPaymentOrderEntity payPaymentOrder = payPaymentOrderService.getById(id);
|
||||
|
||||
return R.ok().put("payPaymentOrder", payPaymentOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:paypaymentorder:save")
|
||||
public R save(@RequestBody PayPaymentOrderEntity payPaymentOrder){
|
||||
payPaymentOrderService.save(payPaymentOrder);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:paypaymentorder:update")
|
||||
public R update(@RequestBody PayPaymentOrderEntity payPaymentOrder){
|
||||
payPaymentOrderService.updateById(payPaymentOrder);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:paypaymentorder:delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
payPaymentOrderService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
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.PayZfbOrderEntity;
|
||||
import com.peanut.modules.book.service.PayZfbOrderService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 支付宝订单表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/payzfborder")
|
||||
public class PayZfbOrderController {
|
||||
@Autowired
|
||||
private PayZfbOrderService payZfbOrderService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:payzfborder:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = payZfbOrderService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:payzfborder:info")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
PayZfbOrderEntity payZfbOrder = payZfbOrderService.getById(id);
|
||||
|
||||
return R.ok().put("payZfbOrder", payZfbOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:payzfborder:save")
|
||||
public R save(@RequestBody PayZfbOrderEntity payZfbOrder){
|
||||
payZfbOrderService.save(payZfbOrder);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:payzfborder:update")
|
||||
public R update(@RequestBody PayZfbOrderEntity payZfbOrder){
|
||||
payZfbOrderService.updateById(payZfbOrder);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:payzfborder:delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
payZfbOrderService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.CityEntity;
|
||||
import com.peanut.modules.book.entity.CountyEntity;
|
||||
import com.peanut.modules.book.entity.ProvinceEntity;
|
||||
import com.peanut.modules.book.service.CityService;
|
||||
import com.peanut.modules.book.service.CountyService;
|
||||
import com.peanut.modules.book.service.ProvinceService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/province")
|
||||
public class ProvinceController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ProvinceService provinceService;
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
//获取地址
|
||||
@RequestMapping("/getProvince")
|
||||
public R getProvince(){
|
||||
|
||||
|
||||
//优化查询速度 目录放入redis中
|
||||
String s = redisTemplate.opsForValue().get("Province");
|
||||
List<Map<String, Object>> listData = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(s)) {
|
||||
List<Object> redisData = JSONArray.parseArray(s);
|
||||
for (Object object : redisData) {
|
||||
Map <String,Object> ret = (Map<String, Object>) object;//取出list里面的值转为map
|
||||
listData.add(ret);
|
||||
}
|
||||
return R.ok().put("provinceEntity",listData);
|
||||
}
|
||||
List<ProvinceEntity> provinceEntityList = provinceService.getCity();
|
||||
redisTemplate.opsForValue().set("Province", JSON.toJSONString(provinceEntityList));
|
||||
return R.ok().put("provinceEntity",provinceEntityList);
|
||||
}
|
||||
|
||||
//获取省列表
|
||||
@RequestMapping("/getProvinceList")
|
||||
public R getProvinceList(){
|
||||
List<ProvinceEntity> provinceList = provinceService.getBaseMapper().selectList(new QueryWrapper<ProvinceEntity>());
|
||||
|
||||
return R.ok().put("provinceList",provinceList);
|
||||
}
|
||||
|
||||
//获取市列表
|
||||
@RequestMapping("/getCityList")
|
||||
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);
|
||||
}
|
||||
|
||||
//获取区列表
|
||||
@RequestMapping("/getCountyList")
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 出版商表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-04 15:36:59
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/publisher")
|
||||
public class PublisherController {
|
||||
@Autowired
|
||||
private PublisherService publisherService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/publisherList")
|
||||
// @RequiresPermissions("book:publisher:list")
|
||||
public R publisherList(){
|
||||
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>());
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
for (PublisherEntity publisherEntitie : publisherEntities) {
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
map.put("id",publisherEntitie.getId());
|
||||
map.put("value",publisherEntitie.getPublisherName());
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
return R.ok().put("list", list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/appGetInfo/{id}/{limit}/{page}")
|
||||
// @RequiresPermissions("book:author:info")
|
||||
public R appGetInfo(@PathVariable("id") Integer id,
|
||||
@PathVariable("limit") String limit,
|
||||
@PathVariable("page") String page){
|
||||
PublisherEntity publisherEntity = publisherService.getById(id);
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("publisherName",publisherEntity.getPublisherName());
|
||||
map.put("limit",limit);
|
||||
map.put("page",page);
|
||||
PageUtils pageUtils = bookService.queryPage(map);
|
||||
return R.ok().put("publisherInfo", publisherEntity).put("publisherBooks",pageUtils);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("book:publisher:save")
|
||||
public R save(@RequestBody PublisherEntity publisher){
|
||||
publisherService.save(publisher);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("book:publisher:update")
|
||||
public R update(@RequestBody PublisherEntity publisher){
|
||||
publisherService.updateById(publisher);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("book:publisher:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
publisherService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 秒杀商品表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 11:24:05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/seckillprodrelation")
|
||||
public class SeckillProdRelationController {
|
||||
@Autowired
|
||||
private SeckillProdRelationService seckillProdRelationService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:seckillprodrelation:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = seckillProdRelationService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:seckillprodrelation:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
SeckillProdRelationEntity seckillProdRelation = seckillProdRelationService.getById(id);
|
||||
|
||||
return R.ok().put("seckillProdRelation", seckillProdRelation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:seckillprodrelation:update")
|
||||
public R update(@RequestBody SeckillProdRelationEntity seckillProdRelation){
|
||||
seckillProdRelationService.updateById(seckillProdRelation);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:seckillprodrelation:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
seckillProdRelationService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.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.ShopCategoryEntity;
|
||||
import com.peanut.modules.book.service.ShopCategoryService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 商品三级分类
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-30 15:06:20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/shopcategory")
|
||||
public class ShopCategoryController {
|
||||
@Autowired
|
||||
private ShopCategoryService shopCategoryService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:shopcategory:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = shopCategoryService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 三级分类
|
||||
*/
|
||||
@RequestMapping("listTree")
|
||||
// @RequiresPermissions("app:tcurriculumcatalogue:list")
|
||||
public R listTree(){
|
||||
List<ShopCategoryEntity> listTree = shopCategoryService.listTree();
|
||||
return R.ok().put("data",listTree);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{catId}")
|
||||
// @RequiresPermissions("book:shopcategory:info")
|
||||
public R info(@PathVariable("catId") Long catId){
|
||||
ShopCategoryEntity shopCategory = shopCategoryService.getById(catId);
|
||||
|
||||
return R.ok().put("shopCategory", shopCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:shopcategory:save")
|
||||
public R save(@RequestBody ShopCategoryEntity shopCategory){
|
||||
shopCategoryService.save(shopCategory);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:shopcategory:update")
|
||||
public R update(@RequestBody ShopCategoryEntity shopCategory){
|
||||
shopCategoryService.updateById(shopCategory);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:shopcategory:delete")
|
||||
public R delete(@RequestBody Long[] catIds){
|
||||
shopCategoryService.removeByIds(Arrays.asList(catIds));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除前检查
|
||||
*/
|
||||
@RequestMapping("/deleteCheck")
|
||||
// @RequiresPermissions("app:tcurriculumcatalogue:delete")
|
||||
public R deleteCheck(@RequestBody String[] oids){
|
||||
shopCategoryService.removeCheckByIds(Arrays.asList(oids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品 一级分类
|
||||
*/
|
||||
@RequestMapping("/getOneLevel")
|
||||
public R getOneLevel(){
|
||||
List<ShopCategoryEntity> list = shopCategoryService.getOneLevel();
|
||||
|
||||
return R.ok().put("list",list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取商品 二级分类
|
||||
*/
|
||||
@RequestMapping("/getTwoLevel")
|
||||
public R getTwoLevel(@RequestParam("catId") Integer catId){
|
||||
List<ShopCategoryEntity> list = shopCategoryService.getTwoLevel(catId);
|
||||
|
||||
return R.ok().put("list",list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.modules.book.service.ShopCategoryService;
|
||||
import com.peanut.modules.book.vo.ShopProductVo;
|
||||
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.ShopProductEntity;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 商品表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 09:43:14
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/shopproduct")
|
||||
public class ShopProductController {
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
private ShopCategoryService shopCategoryService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:shopproduct:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = shopProductService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{productId}")
|
||||
// @RequiresPermissions("book:shopproduct:info")
|
||||
public R info(@PathVariable("productId") Integer productId){
|
||||
|
||||
ShopProductEntity shopProduct = shopProductService.getById(productId);
|
||||
Integer poid = shopProduct.getProductPid();
|
||||
List<Integer> poids = shopCategoryService.findPoid(poid);
|
||||
shopProduct.setPoids(poids);
|
||||
return R.ok().put("shopProduct", shopProduct);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:shopproduct:save")
|
||||
public R save(@RequestBody ShopProductEntity shopProduct){
|
||||
shopProduct.setCreateTime(new Date());
|
||||
shopProductService.save(shopProduct);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:shopproduct:update")
|
||||
public R update(@RequestBody ShopProductEntity shopProduct){
|
||||
shopProductService.updateById(shopProduct);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:shopproduct:delete")
|
||||
public R delete(@RequestBody Integer[] productIds){
|
||||
shopProductService.removeByIds(Arrays.asList(productIds));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/appGetList")
|
||||
public R appGetList(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = shopProductService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分类下商品列表
|
||||
*/
|
||||
@RequestMapping("/appGetCategoryList")
|
||||
public R appGetCategoryList(@RequestParam("catId") Integer catId){
|
||||
List<ShopProductEntity> list = shopProductService.appGetCategoryList(catId);
|
||||
|
||||
return R.ok().put("list", list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程搜索
|
||||
*/
|
||||
@RequestMapping("/prodSearch")
|
||||
public R prodSearch(){
|
||||
List<ShopProductEntity> list = shopProductService.list(new QueryWrapper<ShopProductEntity>().select("product_id,product_name"));
|
||||
List<ShopProductVo> collect = list.stream().map(shopProductEntity -> {
|
||||
ShopProductVo shopProductVo = new ShopProductVo();
|
||||
shopProductVo.setProductId(shopProductEntity.getProductId());
|
||||
shopProductVo.setValue(shopProductEntity.getProductName());
|
||||
return shopProductVo;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
|
||||
return R.ok().put("list", collect);
|
||||
}
|
||||
|
||||
/**
|
||||
* 优惠券获取商品信息
|
||||
*/
|
||||
@RequestMapping("/backProdSearch")
|
||||
public R backProdSearch(@RequestParam Map<String, Object> params){
|
||||
|
||||
String productName = (String) params.get("productName");
|
||||
|
||||
List<ShopProductEntity> list = shopProductService.list(new QueryWrapper<ShopProductEntity>()
|
||||
.like("product_name",productName));
|
||||
|
||||
return R.ok().put("list", list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 秒杀库存表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 11:24:05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/shopseckill")
|
||||
public class ShopSeckillController {
|
||||
@Autowired
|
||||
private ShopSeckillService shopSeckillService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:shopseckill:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = shopSeckillService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{seckillId}")
|
||||
// @RequiresPermissions("book:shopseckill:info")
|
||||
public R info(@PathVariable("seckillId") Long seckillId){
|
||||
ShopSeckillEntity shopSeckill = shopSeckillService.getById(seckillId);
|
||||
|
||||
return R.ok().put("shopSeckill", shopSeckill);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:shopseckill:save")
|
||||
public R save(@RequestBody ShopSeckillEntity shopSeckill){
|
||||
shopSeckillService.save(shopSeckill);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:shopseckill:update")
|
||||
public R update(@RequestBody ShopSeckillEntity shopSeckill){
|
||||
shopSeckillService.updateById(shopSeckill);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:shopseckill:delete")
|
||||
public R delete(@RequestBody Long[] seckillIds){
|
||||
shopSeckillService.removeByIds(Arrays.asList(seckillIds));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/getSeckillProd")
|
||||
public R getSeckillProd(){
|
||||
List<SeckillRedisTo> list = shopSeckillService.getCurrentSeckillProd();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
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.TransactionDetailsEntity;
|
||||
import com.peanut.modules.book.service.TransactionDetailsService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 交易明细
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:47:50
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/transactiondetails")
|
||||
public class TransactionDetailsController {
|
||||
@Autowired
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:transactiondetails:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = transactionDetailsService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{transactionId}")
|
||||
// @RequiresPermissions("book:transactiondetails:info")
|
||||
public R info(@PathVariable("transactionId") Integer transactionId){
|
||||
TransactionDetailsEntity transactionDetails = transactionDetailsService.getById(transactionId);
|
||||
|
||||
return R.ok().put("transactionDetails", transactionDetails);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:transactiondetails:save")
|
||||
public R save(@RequestBody TransactionDetailsEntity transactionDetails){
|
||||
transactionDetailsService.save(transactionDetails);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:transactiondetails:update")
|
||||
public R update(@RequestBody TransactionDetailsEntity transactionDetails){
|
||||
transactionDetailsService.updateById(transactionDetails);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:transactiondetails:delete")
|
||||
public R delete(@RequestBody Integer[] transactionIds){
|
||||
transactionDetailsService.removeByIds(Arrays.asList(transactionIds));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.UserAddressEntity;
|
||||
import com.peanut.modules.book.service.UserAddressService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-31 11:20:32
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/useraddress")
|
||||
public class UserAddressController {
|
||||
@Autowired
|
||||
private UserAddressService userAddressService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:useraddress:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = userAddressService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{addressid}")
|
||||
// @RequiresPermissions("book:useraddress:info")
|
||||
public R info(@PathVariable("addressid") Integer addressid){
|
||||
UserAddressEntity userAddress = userAddressService.getById(addressid);
|
||||
|
||||
return R.ok().put("userAddress", userAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:useraddress:save")
|
||||
public R save(@RequestBody UserAddressEntity userAddress){
|
||||
|
||||
Integer isdefault = userAddress.getIsdefault();
|
||||
|
||||
if (isdefault == 1) {
|
||||
|
||||
Integer userid = userAddress.getUserid();
|
||||
|
||||
List<UserAddressEntity> list = userAddressService.list(new QueryWrapper<UserAddressEntity>().eq("userId", userid));
|
||||
|
||||
for (UserAddressEntity userAddressEntity : list) {
|
||||
if (userAddressEntity.getIsdefault() == 1) {
|
||||
|
||||
userAddressEntity.setIsdefault(0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
userAddressService.save(userAddress);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:useraddress:update")
|
||||
public R update(@RequestBody UserAddressEntity userAddress){
|
||||
|
||||
Integer isdefault = userAddress.getIsdefault();
|
||||
|
||||
if (isdefault == 1) {
|
||||
|
||||
Integer userid = userAddress.getUserid();
|
||||
|
||||
List<UserAddressEntity> list = userAddressService.list(new QueryWrapper<UserAddressEntity>().eq("userId", userid));
|
||||
|
||||
for (UserAddressEntity userAddressEntity : list) {
|
||||
if (userAddressEntity.getIsdefault() == 1) {
|
||||
userAddressEntity.setIsdefault(0);
|
||||
userAddressService.updateById(userAddressEntity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
userAddressService.updateById(userAddress);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:useraddress:delete")
|
||||
public R delete(@RequestBody Integer[] addressids){
|
||||
userAddressService.removeByIds(Arrays.asList(addressids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* app获取用户 收货地址
|
||||
*/
|
||||
@RequestMapping("/getUserAddress")
|
||||
// @RequiresPermissions("book:useraddress:delete")
|
||||
public R getUserAddress(@RequestParam("userId") Integer userId){
|
||||
|
||||
List<UserAddressEntity> list = userAddressService.list(new QueryWrapper<UserAddressEntity>().eq("userId", userId).orderByDesc("isDefault"));
|
||||
|
||||
return R.ok().put("list",list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
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.UserEbookBuyEntity;
|
||||
import com.peanut.modules.book.service.UserEbookBuyService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 用户购买书籍表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-18 16:28:20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/userebookbuy")
|
||||
public class UserEbookBuyController {
|
||||
@Autowired
|
||||
private UserEbookBuyService userEbookBuyService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:userebookbuy:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = userEbookBuyService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{buyId}")
|
||||
// @RequiresPermissions("book:userebookbuy:info")
|
||||
public R info(@PathVariable("buyId") Integer buyId){
|
||||
UserEbookBuyEntity userEbookBuy = userEbookBuyService.getById(buyId);
|
||||
|
||||
return R.ok().put("userEbookBuy", userEbookBuy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:userebookbuy:save")
|
||||
public R save(@RequestBody UserEbookBuyEntity userEbookBuy){
|
||||
userEbookBuyService.save(userEbookBuy);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:userebookbuy:update")
|
||||
public R update(@RequestBody UserEbookBuyEntity userEbookBuy){
|
||||
userEbookBuyService.updateById(userEbookBuy);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:userebookbuy:delete")
|
||||
public R delete(@RequestBody Integer[] buyIds){
|
||||
userEbookBuyService.removeByIds(Arrays.asList(buyIds));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user