|
@@ -0,0 +1,104 @@
|
|
|
+package cn.iocoder.yudao.module.expense.controller.admin.expensetype;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+import cn.iocoder.yudao.module.expense.controller.admin.expensetype.vo.ExpenseTypePageReqVO;
|
|
|
+import cn.iocoder.yudao.module.expense.controller.admin.expensetype.vo.ExpenseTypeRespVO;
|
|
|
+import cn.iocoder.yudao.module.expense.controller.admin.expensetype.vo.ExpenseTypeSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.expense.dal.dataobject.expenseitem.ExpenseItemDO;
|
|
|
+import cn.iocoder.yudao.module.expense.dal.dataobject.expensetype.ExpenseTypeDO;
|
|
|
+import cn.iocoder.yudao.module.expense.service.expensetype.ExpenseTypeService;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 报销类型信息")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/expense/type")
|
|
|
+@Validated
|
|
|
+public class ExpenseTypeController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ExpenseTypeService typeService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建报销类型信息")
|
|
|
+ @PreAuthorize("@ss.hasPermission('expense:type:create')")
|
|
|
+ public CommonResult<Long> createType(@Valid @RequestBody ExpenseTypeSaveReqVO createReqVO) {
|
|
|
+ return success(typeService.createType(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新报销类型信息")
|
|
|
+ @PreAuthorize("@ss.hasPermission('expense:type:update')")
|
|
|
+ public CommonResult<Boolean> updateType(@Valid @RequestBody ExpenseTypeSaveReqVO updateReqVO) {
|
|
|
+ typeService.updateType(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除报销类型信息")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('expense:type:delete')")
|
|
|
+ public CommonResult<Boolean> deleteType(@RequestParam("id") Long id) {
|
|
|
+ typeService.deleteType(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得报销类型信息")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('expense:type:query')")
|
|
|
+ public CommonResult<ExpenseTypeRespVO> getType(@RequestParam("id") Long id) {
|
|
|
+ ExpenseTypeDO type = typeService.getType(id);
|
|
|
+ return success(BeanUtils.toBean(type, ExpenseTypeRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得报销类型信息分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('expense:type:query')")
|
|
|
+ public CommonResult<PageResult<ExpenseTypeRespVO>> getTypePage(@Valid ExpenseTypePageReqVO pageReqVO) {
|
|
|
+ PageResult<ExpenseTypeDO> pageResult = typeService.getTypePage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, ExpenseTypeRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出报销类型信息 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('expense:type:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportTypeExcel(@Valid ExpenseTypePageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<ExpenseTypeDO> list = typeService.getTypePage(pageReqVO).getList();
|
|
|
+
|
|
|
+ ExcelUtils.write(response, "报销类型信息.xls", "数据", ExpenseTypeRespVO.class,
|
|
|
+ BeanUtils.toBean(list, ExpenseTypeRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/item/list-by-expense-type-id")
|
|
|
+ @Operation(summary = "获得报销费用项目信息列表")
|
|
|
+ @Parameter(name = "expenseTypeId", description = "报销类型主键id")
|
|
|
+ @PreAuthorize("@ss.hasPermission('expense:type:query')")
|
|
|
+ public CommonResult<List<ExpenseItemDO>> getItemListByExpenseTypeId(@RequestParam("expenseTypeId") Long expenseTypeId) {
|
|
|
+ return success(typeService.getItemListByExpenseTypeId(expenseTypeId));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|