package com.boying.controller; import com.boying.common.BaseController; import com.boying.entity.Dictionary; import com.boying.service.DictionaryService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; @RestController @RequestMapping("dictionary") public class DictionaryController extends BaseController { @Autowired private DictionaryService dictionaryService; @PostMapping("findPage") public Object findPage(int type,int page,int pageSize) { Pageable pageable = PageRequest.of(page-1,pageSize, Sort.Direction.DESC,"id"); Page pages = dictionaryService.findPage(pageable,"type",type); return success("",pages); } @PostMapping("findByType") public Object findByType(int type) { List pages = dictionaryService.findAll("type",type); return success("",pages); } @PostMapping("save") public Object save(Dictionary dictionary) { dictionaryService.save(dictionary); return success("保存成功"); } @PostMapping("delete") public Object delete(Long id) { dictionaryService.delete(id); return success("删除成功"); } }