Blame view

SessionsDictController.java 3.23 KB
涂亚平 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
package com.meishu.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.meishu.common.ResponseData;
import com.meishu.common.ResponseVO;
import com.meishu.common.interceptor.LoginRequired;
import com.meishu.dto.sessions.SessionsDictPageDTO;
import com.meishu.model.LaboratorySessionMappingDO;
import com.meishu.model.SessionsDictDO;
import com.meishu.service.SessionsDictService;
import com.meishu.util.ConstantUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;

/**
 * <p>
 * 场次字典表 前端控制器
 * </p>
 *
 * @author DengMin
 * @since 2021-08-17
 */
@RestController
@Api(tags = "场次字典表 - D")
@RequestMapping("/sessionsDict")
public class SessionsDictController {

    @Autowired
    private SessionsDictService sessionsDictService;

    @PostMapping(value = "/getListAll")
    @ApiOperation("手机端 -- 查询全部场次")
    public ResponseVO getListAll() {
        return ResponseData.generateCreatedResponse(0, sessionsDictService.list());
    }

    @PostMapping(value = "/getListById")
    @ApiOperation("根据实验室ID查询场次: laboratoryDictId/实验室ID")
    public ResponseVO getListById(@RequestBody LaboratorySessionMappingDO laboratorySessionMappingDO) {
        return ResponseData.generateCreatedResponse(0, sessionsDictService.getListById(laboratorySessionMappingDO.getLaboratoryDictId()));
    }

    @PostMapping(value = "/getSessionsDictPage")
    @ApiOperation("分页查询场次:pageNo/当前页数, pageSize/每页显示条数")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO getSessionsDictPage(@RequestBody SessionsDictPageDTO sessionsDictPageDTO) {
       return ResponseData.generateCreatedResponse(0, sessionsDictService.page(new Page(sessionsDictPageDTO.getPageNo(), sessionsDictPageDTO.getPageSize())));
    }

    @PostMapping(value = "/add")
    @ApiOperation("添加场次:timeSlot/时间段(字符串:08:20 - 08:4)")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO add(@RequestBody SessionsDictDO sessionsDictDO) {
        sessionsDictService.save(sessionsDictDO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping(value = "/update")
    @ApiOperation("编辑场次:id/ID, timeSlot/时间段(字符串:08:20 - 08:04)")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO update(@RequestBody SessionsDictDO sessionsDictDO) {
        sessionsDictService.updateById(sessionsDictDO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping(value = "/delete")
    @ApiOperation("删除场次:id/ID")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO delete(@RequestBody SessionsDictDO sessionsDictDO) {
        sessionsDictService.removeById(sessionsDictDO.getId());
        return ResponseData.generateCreatedResponse(0);
    }

}