package cn.gistack.sm.exam.controller;
|
|
import java.util.Arrays;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
|
import cn.gistack.sm.exam.entity.ExamPlan;
|
import cn.gistack.sm.exam.service.IExamPlanService;
|
import cn.gistack.sm.exam.vo.ExamPlanVO;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import lombok.AllArgsConstructor;
|
import org.apache.commons.lang3.StringUtils;
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
import org.springblade.core.mp.support.Condition;
|
import org.springblade.core.mp.support.Query;
|
import org.springblade.core.tool.api.R;
|
import org.springframework.web.bind.annotation.*;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
|
/**
|
* @Description: 考核方案
|
*/
|
@Slf4j
|
@Api(tags = "考核方案")
|
@RestController
|
@RequestMapping("/exam/examPlan")
|
@AllArgsConstructor
|
public class ExamPlanController extends BladeController {
|
private final IExamPlanService examPlanService;
|
// private final IQuartzJobService quartzJobService;
|
|
/**
|
* 分页列表查询
|
*
|
* @param examPlan
|
* @return
|
*/
|
@ApiOperation(value = "考核方案-分页列表查询", notes = "考核方案-分页列表查询")
|
@GetMapping(value = "/list")
|
public R queryPageList(ExamPlan examPlan, Query query) {
|
IPage<ExamPlan> pageList = examPlanService.page(Condition.getPage(query), Condition.getQueryWrapper(examPlan));
|
return R.data(pageList);
|
}
|
|
|
/**
|
* 自定义分页列表查询
|
*
|
* @param examPlan
|
* @return
|
*/
|
@ApiOperation(value = "考核方案-自定义分页列表查询", notes = "考核方案-自定义分页列表查询")
|
@GetMapping(value = "/page")
|
public R page(ExamPlan examPlan, Query query) {
|
IPage<ExamPlanVO> examPlanVOIPage = examPlanService.selectExamPlanPage(Condition.getPage(query), examPlan);
|
return R.data(examPlanVOIPage);
|
}
|
|
/**
|
* 添加
|
*
|
* @param examPlan
|
* @return
|
*/
|
@ApiOperation(value = "考核方案-添加", notes = "考核方案-添加")
|
@PostMapping(value = "/add")
|
public R add(@RequestBody ExamPlan examPlan) {
|
return R.data(examPlanService.save(examPlan));
|
}
|
|
/**
|
* 编辑
|
*
|
* @param examPlan
|
* @return
|
*/
|
@ApiOperation(value = "考核方案-编辑", notes = "考核方案-编辑")
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
public R edit(@RequestBody ExamPlan examPlan) {
|
return R.data(examPlanService.updateById(examPlan));
|
}
|
|
/**
|
* 启用/禁用
|
*
|
* @param examPlan
|
* @return
|
*/
|
@ApiOperation(value = "考核方案-启用/禁用", notes = "考核方案-编辑")
|
@RequestMapping(value = "/enableOrDisable", method = {RequestMethod.PUT, RequestMethod.POST})
|
public R<?> enableOrDisable(@RequestBody ExamPlan examPlan) {
|
if (StringUtils.isEmpty(examPlan.getId().toString()) || null == examPlan.getStatus()) {
|
return R.fail("参数错误!");
|
}
|
return R.data(examPlanService.enableOrDisable(examPlan.getId().toString(), examPlan.getStatus()));
|
}
|
|
// /**
|
// * 立即执行
|
// *
|
// * @param id
|
// * @return
|
// */
|
// //@RequiresRoles("admin")
|
// @GetMapping("/execute")
|
// public R<?> execute(@RequestParam(name = "id", required = true) String id) {
|
// ExamPlan examPlan = examPlanService.getById(id);
|
// if (examPlan == null) {
|
// return R.fail("未找到对应实体");
|
// }
|
// try {
|
// quartzJobService.execute(examPlan);
|
// } catch (Exception e) {
|
// //e.printStackTrace();
|
// log.info("定时任务 立即执行失败>>" + e.getMessage());
|
// return R.fail("执行失败!");
|
// }
|
// return R.success("执行成功!");
|
// }
|
|
/**
|
* 添加所有
|
*
|
* @param examPlan
|
* @return
|
*/
|
@ApiOperation(value = "考核方案-添加所有", notes = "考核方案-添加所有")
|
@PostMapping(value = "/addAll")
|
public R<?> addAll(@RequestBody ExamPlanVO examPlan) {
|
return R.data(examPlanService.saveAll(examPlan));
|
}
|
|
/**
|
* 编辑所有
|
*
|
* @param examPlan
|
* @return
|
*/
|
@ApiOperation(value = "考核方案-编辑所有", notes = "考核方案-编辑所有")
|
@RequestMapping(value = "/editAll", method = {RequestMethod.PUT, RequestMethod.POST})
|
public R<?> editAll(@RequestBody ExamPlanVO examPlan) {
|
return R.data(examPlanService.updateAll(examPlan));
|
}
|
|
/**
|
* 通过id删除
|
*
|
* @param id
|
* @return
|
*/
|
@ApiOperation(value = "考核方案-通过id删除", notes = "考核方案-通过id删除")
|
@PostMapping(value = "/delete")
|
public R<?> delete(@RequestParam(name = "id", required = true) String id) {
|
return R.data(examPlanService.removeById(id));
|
}
|
|
/**
|
* 批量删除
|
*
|
* @param ids
|
* @return
|
*/
|
@ApiOperation(value = "考核方案-批量删除", notes = "考核方案-批量删除")
|
@PostMapping(value = "/deleteBatch")
|
public R<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
return R.data(this.examPlanService.removeByIds(Arrays.asList(ids.split(","))));
|
}
|
|
/**
|
* 通过id查询
|
*
|
* @param id
|
* @return
|
*/
|
@ApiOperation(value = "考核方案-通过id查询", notes = "考核方案-通过id查询")
|
@GetMapping(value = "/queryById")
|
public R<?> queryById(@RequestParam(name = "id", required = true) String id) {
|
ExamPlan examPlan = examPlanService.getById(id);
|
return R.data(examPlan);
|
}
|
|
}
|