diff --git a/zt-module-base/zt-module-base-api/src/main/java/com/zt/plat/module/base/enums/ErrorCodeConstants.java b/zt-module-base/zt-module-base-api/src/main/java/com/zt/plat/module/base/enums/ErrorCodeConstants.java index a53335b..c36bd6e 100644 --- a/zt-module-base/zt-module-base-api/src/main/java/com/zt/plat/module/base/enums/ErrorCodeConstants.java +++ b/zt-module-base/zt-module-base-api/src/main/java/com/zt/plat/module/base/enums/ErrorCodeConstants.java @@ -19,6 +19,7 @@ public interface ErrorCodeConstants { ErrorCode COMPANY_RELATIVITY_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在"); ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在"); ErrorCode FACTORY_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在"); + ErrorCode TAX_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在"); ErrorCode BUSINESS_RULE_NOT_EXISTS = new ErrorCode(1_027_100_001, "规则模型不存在"); diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/base/TaxController.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/base/TaxController.java new file mode 100644 index 0000000..0e8ff36 --- /dev/null +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/base/TaxController.java @@ -0,0 +1,105 @@ +package com.zt.plat.module.base.controller.admin.base; + +import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog; +import com.zt.plat.framework.business.interceptor.BusinessControllerMarker; +import com.zt.plat.framework.common.pojo.CommonResult; +import com.zt.plat.framework.common.pojo.PageParam; +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO; +import com.zt.plat.framework.common.util.object.BeanUtils; +import com.zt.plat.framework.excel.core.util.ExcelUtils; +import com.zt.plat.module.base.controller.admin.base.vo.TaxPageReqVO; +import com.zt.plat.module.base.controller.admin.base.vo.TaxRespVO; +import com.zt.plat.module.base.controller.admin.base.vo.TaxSaveReqVO; +import com.zt.plat.module.base.dal.dataobject.base.TaxDO; +import com.zt.plat.module.base.service.base.TaxService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.io.IOException; +import java.util.List; + +import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.EXPORT; +import static com.zt.plat.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 税码信息") +@RestController +@RequestMapping("/base/tax") +@Validated +public class TaxController implements BusinessControllerMarker { + + + @Resource + private TaxService taxService; + + @PostMapping("/create") + @Operation(summary = "创建税码信息") + @PreAuthorize("@ss.hasPermission('base:tax:create')") + public CommonResult createTax(@Valid @RequestBody TaxSaveReqVO createReqVO) { + return success(taxService.createTax(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新税码信息") + @PreAuthorize("@ss.hasPermission('base:tax:update')") + public CommonResult updateTax(@Valid @RequestBody TaxSaveReqVO updateReqVO) { + taxService.updateTax(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除税码信息") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('base:tax:delete')") + public CommonResult deleteTax(@RequestParam("id") Long id) { + taxService.deleteTax(id); + return success(true); + } + + @DeleteMapping("/delete-list") + @Parameter(name = "ids", description = "编号", required = true) + @Operation(summary = "批量删除税码信息") + @PreAuthorize("@ss.hasPermission('base:tax:delete')") + public CommonResult deleteTaxList(@RequestBody BatchDeleteReqVO req) { + taxService.deleteTaxListByIds(req.getIds()); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得税码信息") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('base:tax:query')") + public CommonResult getTax(@RequestParam("id") Long id) { + TaxDO tax = taxService.getTax(id); + return success(BeanUtils.toBean(tax, TaxRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得税码信息分页") + @PreAuthorize("@ss.hasPermission('base:tax:query')") + public CommonResult> getTaxPage(@Valid TaxPageReqVO pageReqVO) { + PageResult pageResult = taxService.getTaxPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, TaxRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出税码信息 Excel") + @PreAuthorize("@ss.hasPermission('base:tax:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportTaxExcel(@Valid TaxPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = taxService.getTaxPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "税码信息.xls", "数据", TaxRespVO.class, + BeanUtils.toBean(list, TaxRespVO.class)); + } + +} \ No newline at end of file diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/base/vo/TaxPageReqVO.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/base/vo/TaxPageReqVO.java new file mode 100644 index 0000000..49acb7c --- /dev/null +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/base/vo/TaxPageReqVO.java @@ -0,0 +1,45 @@ +package com.zt.plat.module.base.controller.admin.base.vo; + +import com.zt.plat.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 税码信息分页 Request VO") +@Data +public class TaxPageReqVO extends PageParam { + + @Schema(description = "类型(字典: SPLY_BSN_TP)", example = "2") + private String type; + + @Schema(description = "类别") + private String category; + + @Schema(description = "税码") + private String taxCoding; + + @Schema(description = "税码描述") + private String remark; + + @Schema(description = "税率") + private BigDecimal tax; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "是否启用") + private String isEnable; + + @Schema(description = "公司编码") + private String customerNumber; + + @Schema(description = "公司名称", example = "王五") + private String customerName; + +} \ No newline at end of file diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/base/vo/TaxRespVO.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/base/vo/TaxRespVO.java new file mode 100644 index 0000000..dfc4b67 --- /dev/null +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/base/vo/TaxRespVO.java @@ -0,0 +1,56 @@ +package com.zt.plat.module.base.controller.admin.base.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 税码信息 Response VO") +@Data +@ExcelIgnoreUnannotated +public class TaxRespVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "26656") + @ExcelProperty("主键") + private Long id; + + @Schema(description = "类型(字典: SPLY_BSN_TP)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @ExcelProperty("类型(字典: SPLY_BSN_TP)") + private String type; + + @Schema(description = "类别", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("类别") + private String category; + + @Schema(description = "税码", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("税码") + private String taxCoding; + + @Schema(description = "税码描述") + @ExcelProperty("税码描述") + private String remark; + + @Schema(description = "税率") + @ExcelProperty("税率") + private BigDecimal tax; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "是否启用") + @ExcelProperty("是否启用") + private String isEnable; + + @Schema(description = "公司编码") + @ExcelProperty("公司编码") + private String customerNumber; + + @Schema(description = "公司名称", example = "王五") + @ExcelProperty("公司名称") + private String customerName; + +} \ No newline at end of file diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/base/vo/TaxSaveReqVO.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/base/vo/TaxSaveReqVO.java new file mode 100644 index 0000000..3d3ba94 --- /dev/null +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/base/vo/TaxSaveReqVO.java @@ -0,0 +1,43 @@ +package com.zt.plat.module.base.controller.admin.base.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import lombok.Data; + +import java.math.BigDecimal; + +@Schema(description = "管理后台 - 税码信息新增/修改 Request VO") +@Data +public class TaxSaveReqVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "26656") + private Long id; + + @Schema(description = "类型(字典: SPLY_BSN_TP)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @NotEmpty(message = "类型(字典: SPLY_BSN_TP)不能为空") + private String type; + + @Schema(description = "类别", requiredMode = Schema.RequiredMode.REQUIRED) + @NotEmpty(message = "类别不能为空") + private String category; + + @Schema(description = "税码", requiredMode = Schema.RequiredMode.REQUIRED) + @NotEmpty(message = "税码不能为空") + private String taxCoding; + + @Schema(description = "税码描述") + private String remark; + + @Schema(description = "税率") + private BigDecimal tax; + + @Schema(description = "是否启用") + private String isEnable; + + @Schema(description = "公司编码") + private String customerNumber; + + @Schema(description = "公司名称", example = "王五") + private String customerName; + +} \ No newline at end of file diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/dataobject/base/TaxDO.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/dataobject/base/TaxDO.java new file mode 100644 index 0000000..2235d36 --- /dev/null +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/dataobject/base/TaxDO.java @@ -0,0 +1,69 @@ +package com.zt.plat.module.base.dal.dataobject.base; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO; +import lombok.*; + +import java.math.BigDecimal; +/** +* 税码信息 DO +* +* @author 后台管理-1 +*/ +@TableName("sply_tax") +@KeySequence("sply_tax_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +/** +* 支持业务基类继承:isBusiness=true 时继承 BusinessBaseDO,否则继承 BaseDO +*/ +public class TaxDO extends BusinessBaseDO { + + + + /** + * 主键 + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + /** + * 类型(字典: SPLY_BSN_TP) + */ + private String type; + /** + * 类别 + */ + private String category; + /** + * 税码 + */ + private String taxCoding; + /** + * 税码描述 + */ + private String remark; + /** + * 税率 + */ + private BigDecimal tax; + /** + * 是否启用 + */ + private String isEnable; + /** + * 公司编码 + */ + private String customerNumber; + /** + * 公司名称 + */ + private String customerName; + +} \ No newline at end of file diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/base/TaxMapper.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/base/TaxMapper.java new file mode 100644 index 0000000..ca0dc83 --- /dev/null +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/base/TaxMapper.java @@ -0,0 +1,32 @@ +package com.zt.plat.module.base.dal.mysql.base; + +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX; +import com.zt.plat.module.base.dal.dataobject.base.TaxDO; +import org.apache.ibatis.annotations.Mapper; +import com.zt.plat.module.base.controller.admin.base.vo.*; + +/** + * 税码信息 Mapper + * + * @author 后台管理-1 + */ +@Mapper +public interface TaxMapper extends BaseMapperX { + + default PageResult selectPage(TaxPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(TaxDO::getType, reqVO.getType()) + .eqIfPresent(TaxDO::getCategory, reqVO.getCategory()) + .eqIfPresent(TaxDO::getTaxCoding, reqVO.getTaxCoding()) + .eqIfPresent(TaxDO::getRemark, reqVO.getRemark()) + .eqIfPresent(TaxDO::getTax, reqVO.getTax()) + .betweenIfPresent(TaxDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(TaxDO::getIsEnable, reqVO.getIsEnable()) + .eqIfPresent(TaxDO::getCustomerNumber, reqVO.getCustomerNumber()) + .likeIfPresent(TaxDO::getCustomerName, reqVO.getCustomerName()) + .orderByDesc(TaxDO::getId)); + } + +} \ No newline at end of file diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/base/TaxService.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/base/TaxService.java new file mode 100644 index 0000000..eabf8f5 --- /dev/null +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/base/TaxService.java @@ -0,0 +1,64 @@ +package com.zt.plat.module.base.service.base; + +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.module.base.controller.admin.base.vo.TaxPageReqVO; +import com.zt.plat.module.base.controller.admin.base.vo.TaxRespVO; +import com.zt.plat.module.base.controller.admin.base.vo.TaxSaveReqVO; +import com.zt.plat.module.base.dal.dataobject.base.TaxDO; +import jakarta.validation.Valid; + +import java.util.List; + +/** + * 税码信息 Service 接口 + * + * @author 后台管理-1 + */ +public interface TaxService { + + /** + * 创建税码信息 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + TaxRespVO createTax(@Valid TaxSaveReqVO createReqVO); + + /** + * 更新税码信息 + * + * @param updateReqVO 更新信息 + */ + void updateTax(@Valid TaxSaveReqVO updateReqVO); + + /** + * 删除税码信息 + * + * @param id 编号 + */ + void deleteTax(Long id); + + /** + * 批量删除税码信息 + * + * @param ids 编号 + */ + void deleteTaxListByIds(List ids); + + /** + * 获得税码信息 + * + * @param id 编号 + * @return 税码信息 + */ + TaxDO getTax(Long id); + + /** + * 获得税码信息分页 + * + * @param pageReqVO 分页查询 + * @return 税码信息分页 + */ + PageResult getTaxPage(TaxPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/base/TaxServiceImpl.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/base/TaxServiceImpl.java new file mode 100644 index 0000000..09f5c03 --- /dev/null +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/base/TaxServiceImpl.java @@ -0,0 +1,89 @@ +package com.zt.plat.module.base.service.base; + +import cn.hutool.core.collection.CollUtil; +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.common.util.object.BeanUtils; +import com.zt.plat.module.base.controller.admin.base.vo.TaxPageReqVO; +import com.zt.plat.module.base.controller.admin.base.vo.TaxRespVO; +import com.zt.plat.module.base.controller.admin.base.vo.TaxSaveReqVO; +import com.zt.plat.module.base.dal.dataobject.base.TaxDO; +import com.zt.plat.module.base.dal.mysql.base.TaxMapper; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.util.List; + +import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.zt.plat.module.base.enums.ErrorCodeConstants.TAX_NOT_EXISTS; + +/** + * 税码信息 Service 实现类 + * + * @author 后台管理-1 + */ +@Service +@Validated +public class TaxServiceImpl implements TaxService { + + @Resource + private TaxMapper taxMapper; + + @Override + public TaxRespVO createTax(TaxSaveReqVO createReqVO) { + // 插入 + TaxDO tax = BeanUtils.toBean(createReqVO, TaxDO.class); + taxMapper.insert(tax); + // 返回 + return BeanUtils.toBean(tax, TaxRespVO.class); + } + + @Override + public void updateTax(TaxSaveReqVO updateReqVO) { + // 校验存在 + validateTaxExists(updateReqVO.getId()); + // 更新 + TaxDO updateObj = BeanUtils.toBean(updateReqVO, TaxDO.class); + taxMapper.updateById(updateObj); + } + + @Override + public void deleteTax(Long id) { + // 校验存在 + validateTaxExists(id); + // 删除 + taxMapper.deleteById(id); + } + + @Override + public void deleteTaxListByIds(List ids) { + // 校验存在 + validateTaxExists(ids); + // 删除 + taxMapper.deleteByIds(ids); + } + + private void validateTaxExists(List ids) { + List list = taxMapper.selectByIds(ids); + if (CollUtil.isEmpty(list) || list.size() != ids.size()) { + throw exception(TAX_NOT_EXISTS); + } + } + + private void validateTaxExists(Long id) { + if (taxMapper.selectById(id) == null) { + throw exception(TAX_NOT_EXISTS); + } + } + + @Override + public TaxDO getTax(Long id) { + return taxMapper.selectById(id); + } + + @Override + public PageResult getTaxPage(TaxPageReqVO pageReqVO) { + return taxMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/zt-module-base/zt-module-base-server/src/main/resources/mapper/base/TaxMapper.xml b/zt-module-base/zt-module-base-server/src/main/resources/mapper/base/TaxMapper.xml new file mode 100644 index 0000000..6b11765 --- /dev/null +++ b/zt-module-base/zt-module-base-server/src/main/resources/mapper/base/TaxMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file