package com.ruoyi.web.bst; import java.util.List; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.bst.model.domain.ModelQuery; import com.ruoyi.bst.model.domain.ModelVO; import com.ruoyi.bst.model.domain.dto.ModelDTO; import com.ruoyi.bst.model.service.ModelService; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.validate.ValidGroup; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.user.service.UserValidator; /** * 车辆型号Controller * * @author ruoyi * @date 2025-03-18 */ @RestController @RequestMapping("/bst/model") public class ModelController extends BaseController { @Autowired private ModelService modelService; @Autowired private UserValidator userValidator; /** * 查询车辆型号列表 */ @PreAuthorize("@ss.hasPermi('bst:model:list')") @GetMapping("/list") public TableDataInfo list(ModelQuery query) { startPage(); startOrderBy(); List list = modelService.selectModelList(query); return getDataTable(list); } /** * 导出车辆型号列表 */ @PreAuthorize("@ss.hasPermi('bst:model:export')") @Log(title = "车辆型号", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, ModelQuery query) { List list = modelService.selectModelList(query); ExcelUtil util = new ExcelUtil(ModelVO.class); util.exportExcel(response, list, "车辆型号数据"); } /** * 获取车辆型号详细信息 */ @PreAuthorize("@ss.hasPermi('bst:model:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return success(modelService.selectModelById(id)); } /** * 新增车辆型号 */ @PreAuthorize("@ss.hasPermi('bst:model:add')") @Log(title = "车辆型号", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) ModelDTO dto) { // TODO 校验用户是否可选 return toAjax(modelService.insertModel(dto)); } /** * 修改车辆型号 */ @PreAuthorize("@ss.hasPermi('bst:model:edit')") @Log(title = "车辆型号", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) ModelDTO dto) { return toAjax(modelService.updateModel(dto)); } /** * 删除车辆型号 */ @PreAuthorize("@ss.hasPermi('bst:model:remove')") @Log(title = "车辆型号", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(modelService.deleteModelByIds(ids)); } }