111 lines
3.1 KiB
Java
111 lines
3.1 KiB
Java
package com.peanut.modules.book.controller;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.peanut.common.utils.PageUtils;
|
|
import com.peanut.common.utils.R;
|
|
import com.peanut.modules.book.entity.Publisher;
|
|
import com.peanut.modules.book.service.BookService;
|
|
import com.peanut.modules.book.service.PublisherService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.*;
|
|
|
|
/**
|
|
* 出版商表
|
|
*
|
|
* @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")
|
|
public R list(@RequestParam Map<String, Object> params){
|
|
PageUtils page = publisherService.queryPage(params);
|
|
return R.ok().put("page", page);
|
|
}
|
|
|
|
/**
|
|
* 列表
|
|
*/
|
|
@RequestMapping("/publisherList")
|
|
public R publisherList(){
|
|
List<Publisher> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<Publisher>());
|
|
ArrayList<Object> list = new ArrayList<>();
|
|
for (Publisher 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}")
|
|
public R info(@PathVariable("id") Integer id){
|
|
Publisher publisher = publisherService.getById(id);
|
|
return R.ok().put("publisher", publisher);
|
|
}
|
|
|
|
|
|
/**
|
|
* 信息
|
|
*/
|
|
@RequestMapping("/appGetInfo/{id}/{limit}/{page}")
|
|
public R appGetInfo(@PathVariable("id") Integer id,
|
|
@PathVariable("limit") String limit,
|
|
@PathVariable("page") String page){
|
|
Publisher publisher = publisherService.getById(id);
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
map.put("publisherName", publisher.getPublisherName());
|
|
map.put("limit",limit);
|
|
map.put("page",page);
|
|
PageUtils pageUtils = bookService.queryPage(map);
|
|
return R.ok().put("publisherInfo", publisher).put("publisherBooks",pageUtils);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* 保存
|
|
*/
|
|
@RequestMapping("/save")
|
|
// @RequiresPermissions("book:publisher:save")
|
|
public R save(@RequestBody Publisher publisher){
|
|
publisher.setDelFlag(0);
|
|
publisherService.save(publisher);
|
|
return R.ok();
|
|
}
|
|
|
|
/**
|
|
* 修改
|
|
*/
|
|
@RequestMapping("/update")
|
|
public R update(@RequestBody Publisher publisher){
|
|
publisherService.updateById(publisher);
|
|
return R.ok();
|
|
}
|
|
|
|
/**
|
|
* 删除
|
|
*/
|
|
@RequestMapping("/delete")
|
|
public R delete(@RequestBody Integer[] ids){
|
|
publisherService.removeByIds(Arrays.asList(ids));
|
|
return R.ok();
|
|
}
|
|
}
|