package com.ruoyi.web.controller.rc; import java.util.List; import javax.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.rc.domain.TOpenItem; import com.ruoyi.rc.service.ITOpenItemService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; /** * 开项Controller * * @author ruoyi * @date 2024-07-19 */ @RestController @RequestMapping("/rc/openitem") public class TOpenItemController extends BaseController { @Autowired private ITOpenItemService tOpenItemService; /** * 查询开项列表 */ @PreAuthorize("@ss.hasPermi('rc:openitem:list')") @GetMapping("/list") public TableDataInfo list(TOpenItem tOpenItem) { startPage(); List list = tOpenItemService.selectTOpenItemList(tOpenItem); return getDataTable(list); } /** * 导出开项列表 */ @PreAuthorize("@ss.hasPermi('rc:openitem:export')") @Log(title = "开项", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, TOpenItem tOpenItem) { List list = tOpenItemService.selectTOpenItemList(tOpenItem); ExcelUtil util = new ExcelUtil(TOpenItem.class); util.exportExcel(response, list, "开项数据"); } /** * 获取开项详细信息 */ @PreAuthorize("@ss.hasPermi('rc:openitem:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return success(tOpenItemService.selectTOpenItemById(id)); } /** * 新增开项 */ @PreAuthorize("@ss.hasPermi('rc:openitem:add')") @Log(title = "开项", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody TOpenItem tOpenItem) { tOpenItem.setDeptId(getLoginUser().getDeptId()); return toAjax(tOpenItemService.insertTOpenItem(tOpenItem)); } /** * 修改开项 */ @PreAuthorize("@ss.hasPermi('rc:openitem:edit')") @Log(title = "开项", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody TOpenItem tOpenItem) { return toAjax(tOpenItemService.updateTOpenItem(tOpenItem)); } /** * 删除开项 */ @PreAuthorize("@ss.hasPermi('rc:openitem:remove')") @Log(title = "开项", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(tOpenItemService.deleteTOpenItemByIds(ids)); } }