package org.jeecg.modules.mdc.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.mdc.entity.MdcVacationManagement; import org.jeecg.modules.mdc.service.IMdcVacationManagementService; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * @Description: 假期管理 * @Author: ym * @Date: 2023-07-05 */ @Slf4j @RestController @Api(tags = "假期管理") @RequestMapping("/mdc/mdcVacationManagement") public class MdcVacationManagementController extends JeecgController { @Resource private IMdcVacationManagementService mdcVacationManagementService; /** * 根据id查询 * * @param id * @return */ @AutoLog(value = "假期管理-根据id查询") @ApiOperation(value = "假期管理-根据id查询", notes = "假期管理-根据id查询") @GetMapping("/queryById") public Result queryById(@RequestParam(required = true, name = "id") String id) { MdcVacationManagement mdcVacationManagement = mdcVacationManagementService.queryById(id); //查询不为空则返回数据 return null != mdcVacationManagement ? Result.OK(mdcVacationManagement) : Result.error("未找到对应数据"); } /** * 新增 * * @param mdcVacationManagement * @return */ @AutoLog(value = "假期管理-新增") @ApiOperation(value = "假期管理-新增", notes = "假期管理-新增") @PostMapping("/addVacation") public Result addVacation(@RequestBody MdcVacationManagement mdcVacationManagement) { if (StringUtils.isBlank(mdcVacationManagement.getEquipmentIds())) { return Result.error("未选择设备,请排查"); } boolean flag = mdcVacationManagementService.addVacation(mdcVacationManagement); return flag ? Result.ok("新增成功") : Result.error("新增失败"); } /** * 修改 * * @param mdcVacationManagement * @return */ @AutoLog(value = "假期管理-修改") @ApiOperation(value = "假期管理-修改", notes = "假期管理-修改") @PutMapping("/editVacation") public Result editVacation(@RequestBody MdcVacationManagement mdcVacationManagement) { boolean flag = mdcVacationManagementService.editVacation(mdcVacationManagement); return flag ? Result.ok("修改成功") : Result.error("修改失败"); } /** * 根据id删除假期管理 * * @param id * @return */ @AutoLog(value = "假期管理-根据id删除") @ApiOperation(value = "假期管理-根据id删除", notes = "假期管理-根据id删除") @DeleteMapping("/deleteVacation") public Result deleteVacation(@RequestParam(required = true, name = "id") String id) { boolean flag = mdcVacationManagementService.deleteVacation(id); return flag ? Result.ok("删除成功") : Result.error("删除失败"); } /** * 批量删除 * * @param ids * @return */ @AutoLog(value = "假期管理-批量删除") @ApiOperation(value = "假期管理-批量删除", notes = "假期管理-批量删除") @DeleteMapping("/deleteBatchVacation") public Result deleteBatchVacation(@RequestParam(required = true, name = "ids") String ids) { boolean flag = mdcVacationManagementService.deleteBatchVacation(ids); return flag ? Result.ok("批量删除成功") : Result.error("批量删除失败"); } /** * 导出excel * * @param request * @param mdcVacationManagement * @return */ @AutoLog(value = "假期管理-导出excel") @ApiOperation(value = "假期管理-导出excel",notes = "假期管理-导出excel") @RequestMapping("/exportXls") public ModelAndView exportXls(HttpServletRequest request, MdcVacationManagement mdcVacationManagement) { LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = user.getId(); return mdcVacationManagementService.exportXls(userId, mdcVacationManagement); } /** * 导入excel * * @param request * @param response * @return */ @RequestMapping("/importExcel") public Result importExcel(HttpServletRequest request, HttpServletResponse response) { return super.importExcel(request, response, MdcVacationManagement.class); } /** * 分页查询 * @param mdcVacationManagement * @param pageNo * @param pageSize * @param request * @return */ @AutoLog(value = "假期管理-分页查询") @ApiOperation(value = "假期管理-分页查询",notes = "假期管理-分页查询") @GetMapping("/pageList") public Result pageList(MdcVacationManagement mdcVacationManagement, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) { if (mdcVacationManagement == null) { return Result.error("请传递有效参数"); } LoginUser user=(LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId= user.getId(); Page page=new Page(pageNo,pageSize); IPage mdcVacationManagementIPage= mdcVacationManagementService.pageList(userId,page,request,mdcVacationManagement); return Result.ok(mdcVacationManagementIPage); } }