SessionsDictController.java 3.23 KB
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);
    }

}