| | |
| | | package org.dromara.demo.controller; |
| | | |
| | | import java.util.List; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.*; |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.dromara.common.idempotent.annotation.RepeatSubmit; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.excel.core.ExcelResult; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.demo.domain.vo.RsSceneryOperationDataVo; |
| | | import org.dromara.demo.domain.bo.RsSceneryOperationDataBo; |
| | | import org.dromara.demo.service.IRsSceneryOperationDataService; |
| | | import org.dromara.common.idempotent.annotation.RepeatSubmit; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.demo.domain.RsSceneryOperationData; |
| | | import org.dromara.demo.domain.bo.RsSceneryOperationDataBo; |
| | | import org.dromara.demo.domain.vo.RsSceneryOperationDataVo; |
| | | import org.dromara.demo.service.IRsSceneryOperationDataService; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 景区运行数据 |
| | | * |
| | | * @author Lion Li |
| | | * @date 2024-02-27 |
| | | * @author gonghl |
| | | * @date 2024-03-05 |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/sc/sceneryOperationData") |
| | | @RequestMapping("/demo/sceneryOperationData") |
| | | public class RsSceneryOperationDataController extends BaseController { |
| | | |
| | | private final IRsSceneryOperationDataService rsSceneryOperationDataService; |
| | | private final StringBuilder successMsg = new StringBuilder(); |
| | | private final StringBuilder failureMsg = new StringBuilder(); |
| | | |
| | | /** |
| | | * 查询景区运行数据列表 |
| | | */ |
| | | @SaCheckPermission("rs:sceneryOperationData:list") |
| | | @SaCheckPermission("demo:sceneryOperationData:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<RsSceneryOperationDataVo> list(RsSceneryOperationDataBo bo, PageQuery pageQuery) { |
| | | return rsSceneryOperationDataService.queryPageList(bo, pageQuery); |
| | |
| | | /** |
| | | * 导出景区运行数据列表 |
| | | */ |
| | | @SaCheckPermission("rs:sceneryOperationData:export") |
| | | @SaCheckPermission("demo:sceneryOperationData:export") |
| | | @Log(title = "景区运行数据", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(RsSceneryOperationDataBo bo, HttpServletResponse response) { |
| | |
| | | ExcelUtil.exportExcel(list, "景区运行数据", RsSceneryOperationDataVo.class, response); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导入数据 |
| | | * |
| | | * @param file 导入文件 |
| | | */ |
| | | @Log(title = "导入数据", businessType = BusinessType.IMPORT) |
| | | @SaCheckPermission("demo:sceneryOperationData:import") |
| | | @PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | public R<Void> importData(@RequestPart("file") MultipartFile file) throws Exception { |
| | | ExcelResult<RsSceneryOperationDataVo> result = ExcelUtil.importExcel(file.getInputStream(), RsSceneryOperationDataVo.class, true); |
| | | List<RsSceneryOperationData> list = MapstructUtils.convert(result.getList(), RsSceneryOperationData.class); |
| | | return R.ok(rsSceneryOperationDataService.importExcel(list)); |
| | | } |
| | | |
| | | /** |
| | | * 获取导入模板 |
| | | */ |
| | | @SaCheckPermission("demo:sceneryOperationData:importTemplate") |
| | | @PostMapping("/importTemplate") |
| | | public void importTemplate(HttpServletResponse response) { |
| | | ExcelUtil.exportExcel(new ArrayList<>(), "景区运行数据", RsSceneryOperationDataVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 获取景区运行数据详细信息 |
| | | * |
| | | * @param id 主键 |
| | | */ |
| | | @SaCheckPermission("rs:sceneryOperationData:query") |
| | | @SaCheckPermission("demo:sceneryOperationData:query") |
| | | @GetMapping("/{id}") |
| | | public R<RsSceneryOperationDataVo> getInfo(@NotNull(message = "主键不能为空") |
| | | @PathVariable Long id) { |
| | | @PathVariable String id) { |
| | | return R.ok(rsSceneryOperationDataService.queryById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 新增景区运行数据 |
| | | */ |
| | | @SaCheckPermission("system:sceneryOperationData:add") |
| | | @SaCheckPermission("demo:sceneryOperationData:add") |
| | | @Log(title = "景区运行数据", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit() |
| | | @PostMapping() |
| | |
| | | /** |
| | | * 修改景区运行数据 |
| | | */ |
| | | @SaCheckPermission("system:sceneryOperationData:edit") |
| | | @SaCheckPermission("demo:sceneryOperationData:edit") |
| | | @Log(title = "景区运行数据", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit() |
| | | @PutMapping() |
| | |
| | | * |
| | | * @param ids 主键串 |
| | | */ |
| | | @SaCheckPermission("system:sceneryOperationData:remove") |
| | | @SaCheckPermission("demo:sceneryOperationData:remove") |
| | | @Log(title = "景区运行数据", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ids) { |
| | | @PathVariable String[] ids) { |
| | | return toAjax(rsSceneryOperationDataService.deleteWithValidByIds(List.of(ids), true)); |
| | | } |
| | | } |