package com.peanut.modules.book.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.peanut.common.utils.R; import com.peanut.modules.book.entity.ChineseMedicineResearch; import com.peanut.modules.book.service.ChineseMedicineResearchService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; import java.util.Map; @Slf4j @RestController @RequestMapping("book/chineseMedicineResearch") public class ChineseMedicineResearchController { @Autowired private ChineseMedicineResearchService chineseMedicineResearchService; /** * 中医研究列表 */ @RequestMapping(path = "/researchByType") public R researchByType(String type) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); if (StringUtils.isNotEmpty(type)){ wrapper.eq(ChineseMedicineResearch::getType,type); } wrapper.orderByAsc(ChineseMedicineResearch::getSort); List list = chineseMedicineResearchService.list(wrapper); return R.ok().put("result", list); } /** * 中医研究列表 */ @RequestMapping(path = "/researchByPage") public R researchByPage(@RequestBody Map map) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); if (map.containsKey("type")&&StringUtils.isNotEmpty(map.get("type").toString())){ wrapper.eq(ChineseMedicineResearch::getType,map.get("type")); } wrapper.orderByAsc(ChineseMedicineResearch::getSort); Page page = chineseMedicineResearchService.page(new Page<>( Long.parseLong(map.get("current").toString()), Long.parseLong(map.get("limit").toString())),wrapper); return R.ok().put("result", page); } @RequestMapping(path = "/getResearchById") public R getResearchById(String id) { return R.ok().put("result",chineseMedicineResearchService.getById(id)); } @RequestMapping(path = "/saveOrUpdateResearch") public R saveOrUpdateResearch(@RequestBody ChineseMedicineResearch research) { chineseMedicineResearchService.saveOrUpdate(research); return R.ok(); } @RequestMapping(path = "/delResearch") public R delResearch(String id) { chineseMedicineResearchService.removeById(id); return R.ok(); } }