package org.dromara.demo.controller; import java.util.List; import java.util.Map; 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 org.dromara.common.core.domain.R; 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.utils.ExcelUtil; import org.dromara.demo.domain.vo.RsTrafficIndexVo; import org.dromara.demo.domain.bo.RsTrafficIndexBo; import org.dromara.demo.service.IRsTrafficIndexService; import org.dromara.common.mybatis.core.page.TableDataInfo; /** * 交通指数 * * @author Lion Li * @date 2024-02-26 */ @Validated @RequiredArgsConstructor @RestController @RequestMapping("/rs/trafficIndex") public class RsTrafficIndexController extends BaseController { private final IRsTrafficIndexService rsTrafficIndexService; /** * 查询交通指数列表 */ @SaCheckPermission("rs:trafficIndex:list") @GetMapping("/list") public TableDataInfo list(RsTrafficIndexBo bo, PageQuery pageQuery) { return rsTrafficIndexService.queryPageList(bo, pageQuery); } /** * 查询交通指数图标配置 */ @SaCheckPermission("rs:trafficIndex:list") @GetMapping("/icon") public List> icon() { return rsTrafficIndexService.icon(); } /** * 导出交通指数列表 */ @SaCheckPermission("rs:trafficIndex:export") @Log(title = "交通指数", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(RsTrafficIndexBo bo, HttpServletResponse response) { List list = rsTrafficIndexService.queryList(bo); ExcelUtil.exportExcel(list, "交通指数", RsTrafficIndexVo.class, response); } /** * 获取交通指数详细信息 * * @param id 主键 */ @SaCheckPermission("rs:trafficIndex:query") @GetMapping("/{id}") public R getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) { return R.ok(rsTrafficIndexService.queryById(id)); } /** * 新增交通指数 */ @SaCheckPermission("rs:trafficIndex:add") @Log(title = "交通指数", businessType = BusinessType.INSERT) @RepeatSubmit() @PostMapping() public R add(@Validated(AddGroup.class) @RequestBody RsTrafficIndexBo bo) { return toAjax(rsTrafficIndexService.insertByBo(bo)); } /** * 修改交通指数 */ @SaCheckPermission("rs:trafficIndex:edit") @Log(title = "交通指数", businessType = BusinessType.UPDATE) @RepeatSubmit() @PutMapping() public R edit(@Validated(EditGroup.class) @RequestBody RsTrafficIndexBo bo) { return toAjax(rsTrafficIndexService.updateByBo(bo)); } /** * 删除交通指数 * * @param ids 主键串 */ @SaCheckPermission("rs:trafficIndex:remove") @Log(title = "交通指数", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public R remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) { return toAjax(rsTrafficIndexService.deleteWithValidByIds(List.of(ids), true)); } }