|
@@ -0,0 +1,125 @@
|
|
|
+package com.qmrb.system.controller;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import com.qmrb.system.framework.security.util.SecurityUtils;
|
|
|
+import org.springdoc.core.annotations.ParameterObject;
|
|
|
+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.CrossOrigin;
|
|
|
+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 io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.qmrb.system.common.result.PageResult;
|
|
|
+import com.qmrb.system.common.result.Result;
|
|
|
+import com.qmrb.system.common.result.ResultCode;
|
|
|
+import com.qmrb.system.framework.resubmit.Resubmit;
|
|
|
+import com.qmrb.system.service.IInvoiceTitleService;
|
|
|
+import com.qmrb.system.pojo.form.InvoiceTitleForm;
|
|
|
+import com.qmrb.system.pojo.vo.InvoiceTitleVO;
|
|
|
+import com.qmrb.system.pojo.query.InvoiceTitleQuery;
|
|
|
+import com.qmrb.system.pojo.vo.Option;
|
|
|
+
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import jakarta.validation.Valid;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 发票抬头表 前端控制器
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author gs
|
|
|
+ * @since 2025-04-07
|
|
|
+ */
|
|
|
+@Tag(name = "发票抬头表接口")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/v1/title")
|
|
|
+@CrossOrigin
|
|
|
+public class InvoiceTitleController{
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IInvoiceTitleService invoiceTitleService;
|
|
|
+
|
|
|
+ @Operation(summary = "发票抬头表分页列表", security = {@SecurityRequirement(name = "Authorization")})
|
|
|
+ @GetMapping("/page")
|
|
|
+ public PageResult<InvoiceTitleVO> getPage(
|
|
|
+ @ParameterObject InvoiceTitleQuery queryParams
|
|
|
+ ) {
|
|
|
+ Page<InvoiceTitleVO> result = invoiceTitleService.getPage(queryParams);
|
|
|
+ return PageResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Operation(summary = "发票抬头表分页列表", security = {@SecurityRequirement(name = "Authorization")})
|
|
|
+ @GetMapping("/getInvoiceTitles")
|
|
|
+ public PageResult<InvoiceTitleVO> getInvoiceTitles(
|
|
|
+ @ParameterObject InvoiceTitleQuery queryParams
|
|
|
+ ) {
|
|
|
+ if(SecurityUtils.getUserId() == null){
|
|
|
+ return PageResult.success(null);
|
|
|
+ }
|
|
|
+ queryParams.setUserId(SecurityUtils.getUserId());
|
|
|
+ Page<InvoiceTitleVO> result = invoiceTitleService.getPage(queryParams);
|
|
|
+ return PageResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Operation(summary = "新增发票抬头表", security = {@SecurityRequirement(name = "Authorization")})
|
|
|
+ @PostMapping
|
|
|
+ @Resubmit
|
|
|
+ public Result<InvoiceTitleForm> saveForm(
|
|
|
+ @RequestBody @Valid InvoiceTitleForm form
|
|
|
+ ) {
|
|
|
+ InvoiceTitleForm result = invoiceTitleService.saveForm(form);
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Operation(summary = "发票抬头表表单数据", security = {@SecurityRequirement(name = "Authorization")})
|
|
|
+ @GetMapping("/{id}/form")
|
|
|
+ public Result<InvoiceTitleForm> getForm(
|
|
|
+ @Parameter(description = "发票抬头表ID") @PathVariable Long id
|
|
|
+ ) {
|
|
|
+ InvoiceTitleForm formData = invoiceTitleService.getFormData(id);
|
|
|
+ return Result.success(formData);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Operation(summary = "修改发票抬头表", security = {@SecurityRequirement(name = "Authorization")})
|
|
|
+ @PutMapping(value = "/{id}")
|
|
|
+ public Result<?> updateForm(
|
|
|
+ @Parameter(description = "发票抬头表ID") @PathVariable Long id,
|
|
|
+ @RequestBody @Validated InvoiceTitleForm form) {
|
|
|
+
|
|
|
+ boolean result = invoiceTitleService.updateForm(id,form);
|
|
|
+ return Result.judge(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Operation(summary = "删除发票抬头表", security = {@SecurityRequirement(name = "Authorization")})
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ public Result<?> deleteUsers(
|
|
|
+ @Parameter(description = "发票抬头表ID,多个以英文逗号(,)分割") @PathVariable String ids
|
|
|
+ ) {
|
|
|
+ if(StrUtil.isBlank(ids)) {
|
|
|
+ return Result.failed(ResultCode.PARAM_ERROR, "删除的发票抬头表数据为空");
|
|
|
+ }
|
|
|
+ // 逻辑删除
|
|
|
+ List<Long> idList = Arrays.asList(ids.split(",")).stream()
|
|
|
+ .map(idStr -> Long.parseLong(idStr)).collect(Collectors.toList());
|
|
|
+ boolean result = invoiceTitleService.removeByIds(idList);
|
|
|
+ return Result.judge(result);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|