123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- package com.yunzhi.demo.controller;
-
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.yunzhi.demo.common.BaseController;
- import com.yunzhi.demo.common.Constants;
- import com.yunzhi.demo.common.ResponseBean;
- import com.yunzhi.demo.common.StringUtils;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import com.yunzhi.demo.service.ITdSchoolService;
- import com.yunzhi.demo.entity.TdSchool;
-
-
-
- @Api(tags = "学校")
- @RestController
- @RequestMapping("/")
- public class TdSchoolController extends BaseController {
-
- private final Logger logger = LoggerFactory.getLogger(TdSchoolController.class);
-
- @Autowired
- public ITdSchoolService iTdSchoolService;
-
- @GetMapping("/ma/school")
- @ApiOperation(value="小程序学校字典", notes = "学校列表", httpMethod = "GET", response = ResponseBean.class)
- public ResponseBean maSchoolList(@ApiParam(value = "名称", required = false) @RequestParam(value ="name", required = false) String name) throws Exception {
- QueryWrapper<TdSchool> queryWrapper = new QueryWrapper<TdSchool>()
- .like(!StringUtils.isEmpty(name), "name", "%"+name+"%")
- .eq("status", Constants.STATUS_NORMAL)
- .orderByAsc("sort_no")
- .orderByDesc("create_date");
-
- return ResponseBean.success(iTdSchoolService.list(queryWrapper));
- }
-
-
-
- @RequestMapping(value="/tdSchool",method= RequestMethod.GET)
- @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
- public ResponseBean tdSchoolList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
-
- IPage<TdSchool> pg = new Page<>(pageNum, pageSize);
- QueryWrapper<TdSchool> queryWrapper = new QueryWrapper<>();
- queryWrapper.orderByDesc("create_date");
-
- IPage<TdSchool> result = iTdSchoolService.page(pg, queryWrapper);
- return ResponseBean.success(result);
- }
-
-
-
- @RequestMapping(value="/tdSchool",method= RequestMethod.POST)
- @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
- public ResponseBean tdSchoolAdd(@ApiParam("保存内容") @RequestBody TdSchool tdSchool) throws Exception{
-
- if (iTdSchoolService.save(tdSchool)){
- return ResponseBean.success(tdSchool);
- }else {
- return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
- }
- }
-
-
-
- @RequestMapping(value="/tdSchool/{id}", method= RequestMethod.DELETE)
- @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
- public ResponseBean tdSchoolDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
- if(iTdSchoolService.removeById(id)){
- return ResponseBean.success("success");
- }else {
- return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
- }
- }
-
-
-
- @RequestMapping(value="/tdSchool/{id}",method= RequestMethod.PUT)
- @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
- public ResponseBean tdSchoolUpdate(@ApiParam("对象ID") @PathVariable Integer id,
- @ApiParam("更新内容") @RequestBody TdSchool tdSchool) throws Exception{
-
- if (iTdSchoolService.updateById(tdSchool)){
- return ResponseBean.success(iTdSchoolService.getById(id));
- }else {
- return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
- }
- }
-
-
-
- @RequestMapping(value="/tdSchool/{id}",method= RequestMethod.GET)
- @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
- public ResponseBean tdSchoolGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
- return ResponseBean.success(iTdSchoolService.getById(id));
- }
- }
|