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 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.RsTrafficAccidentVo;
|
import org.dromara.demo.domain.bo.RsTrafficAccidentBo;
|
import org.dromara.demo.service.IRsTrafficAccidentService;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
/**
|
* 交通事故
|
*
|
* @author gonghl
|
* @date 2024-03-11
|
*/
|
@Validated
|
@RequiredArgsConstructor
|
@RestController
|
@RequestMapping("/demo/trafficAccident")
|
public class RsTrafficAccidentController extends BaseController {
|
|
private final IRsTrafficAccidentService rsTrafficAccidentService;
|
|
/**
|
* 查询交通事故列表
|
*/
|
@SaCheckPermission("demo:trafficAccident:list")
|
@GetMapping("/list")
|
public TableDataInfo<RsTrafficAccidentVo> list(RsTrafficAccidentBo bo, PageQuery pageQuery) {
|
return rsTrafficAccidentService.queryPageList(bo, pageQuery);
|
}
|
|
/**
|
* 导出交通事故列表
|
*/
|
@SaCheckPermission("demo:trafficAccident:export")
|
@Log(title = "交通事故", businessType = BusinessType.EXPORT)
|
@PostMapping("/export")
|
public void export(RsTrafficAccidentBo bo, HttpServletResponse response) {
|
List<RsTrafficAccidentVo> list = rsTrafficAccidentService.queryList(bo);
|
ExcelUtil.exportExcel(list, "交通事故", RsTrafficAccidentVo.class, response);
|
}
|
|
/**
|
* 获取交通事故详细信息
|
*
|
* @param id 主键
|
*/
|
@SaCheckPermission("demo:trafficAccident:query")
|
@GetMapping("/{id}")
|
public R<RsTrafficAccidentVo> getInfo(@NotNull(message = "主键不能为空")
|
@PathVariable String id) {
|
return R.ok(rsTrafficAccidentService.queryById(id));
|
}
|
|
/**
|
* 新增交通事故
|
*/
|
@SaCheckPermission("demo:trafficAccident:add")
|
@Log(title = "交通事故", businessType = BusinessType.INSERT)
|
@RepeatSubmit()
|
@PostMapping()
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody RsTrafficAccidentBo bo) {
|
return toAjax(rsTrafficAccidentService.insertByBo(bo));
|
}
|
|
/**
|
* 修改交通事故
|
*/
|
@SaCheckPermission("demo:trafficAccident:edit")
|
@Log(title = "交通事故", businessType = BusinessType.UPDATE)
|
@RepeatSubmit()
|
@PutMapping()
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody RsTrafficAccidentBo bo) {
|
return toAjax(rsTrafficAccidentService.updateByBo(bo));
|
}
|
|
/**
|
* 删除交通事故
|
*
|
* @param ids 主键串
|
*/
|
@SaCheckPermission("demo:trafficAccident:remove")
|
@Log(title = "交通事故", businessType = BusinessType.DELETE)
|
@DeleteMapping("/{ids}")
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
@PathVariable String[] ids) {
|
return toAjax(rsTrafficAccidentService.deleteWithValidByIds(List.of(ids), true));
|
}
|
}
|