diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..49330ee --- /dev/null +++ b/.gitignore @@ -0,0 +1,54 @@ +###################################################################### +# Build Tools + +.gradle +/build/ +!gradle/wrapper/gradle-wrapper.jar + +target/ +!.mvn/wrapper/maven-wrapper.jar + +.flattened-pom.xml + +###################################################################### +# IDE + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +nbproject/private/ +build/* +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ + +###################################################################### +# Others +*.log +*.xml.versionsBackup +*.swp + +!*/build/*.java +!*/build/*.html +!*/build/*.xml + +### JRebel ### +rebel.xml + +application-my.yaml + +/yudao-ui-app/unpackage/ +**/.DS_Store diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/PageParam.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/PageParam.java index 97819f9..6831109 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/PageParam.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/PageParam.java @@ -29,7 +29,7 @@ public class PageParam implements Serializable { @Schema(description = "每页条数,最大值为 100", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") @NotNull(message = "每页条数不能为空") - @Min(value = 1, message = "每页条数最小值为 1") +// @Min(value = 1, message = "每页条数最小值为 1") @Max(value = 100, message = "每页条数最大值为 100") private Integer pageSize = PAGE_SIZE; diff --git a/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/controller/admin/customtag/CustomTagController.java b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/controller/admin/customtag/CustomTagController.java new file mode 100644 index 0000000..c453fe2 --- /dev/null +++ b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/controller/admin/customtag/CustomTagController.java @@ -0,0 +1,104 @@ +package cn.iocoder.yudao.module.ydoyun.controller.admin.customtag; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.ydoyun.controller.admin.customtag.vo.*; +import cn.iocoder.yudao.module.ydoyun.dal.dataobject.customtag.CustomTagDO; +import cn.iocoder.yudao.module.ydoyun.service.customtag.CustomTagService; + +@Tag(name = "管理后台 - 自定义标签") +@RestController +@RequestMapping("/ydoyun/custom-tag") +@Validated +public class CustomTagController { + + @Resource + private CustomTagService customTagService; + + @PostMapping("/create") + @Operation(summary = "创建自定义标签") + @PreAuthorize("@ss.hasPermission('ydoyun:custom-tag:create')") + public CommonResult createCustomTag(@Valid @RequestBody CustomTagSaveReqVO createReqVO) { + return success(customTagService.createCustomTag(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新自定义标签") + @PreAuthorize("@ss.hasPermission('ydoyun:custom-tag:update')") + public CommonResult updateCustomTag(@Valid @RequestBody CustomTagSaveReqVO updateReqVO) { + customTagService.updateCustomTag(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除自定义标签") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('ydoyun:custom-tag:delete')") + public CommonResult deleteCustomTag(@RequestParam("id") Long id) { + customTagService.deleteCustomTag(id); + return success(true); + } + + @DeleteMapping("/delete-list") + @Parameter(name = "ids", description = "编号", required = true) + @Operation(summary = "批量删除自定义标签") + @PreAuthorize("@ss.hasPermission('ydoyun:custom-tag:delete')") + public CommonResult deleteCustomTagList(@RequestParam("ids") List ids) { + customTagService.deleteCustomTagListByIds(ids); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得自定义标签") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('ydoyun:custom-tag:query')") + public CommonResult getCustomTag(@RequestParam("id") Long id) { + CustomTagDO customTag = customTagService.getCustomTag(id); + return success(BeanUtils.toBean(customTag, CustomTagRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得自定义标签分页") + @PreAuthorize("@ss.hasPermission('ydoyun:custom-tag:query')") + public CommonResult> getCustomTagPage(@Valid CustomTagPageReqVO pageReqVO) { + PageResult pageResult = customTagService.getCustomTagPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, CustomTagRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出自定义标签 Excel") + @PreAuthorize("@ss.hasPermission('ydoyun:custom-tag:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportCustomTagExcel(@Valid CustomTagPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = customTagService.getCustomTagPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "自定义标签.xls", "数据", CustomTagRespVO.class, + BeanUtils.toBean(list, CustomTagRespVO.class)); + } + +} \ No newline at end of file diff --git a/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/controller/admin/customtag/vo/CustomTagPageReqVO.java b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/controller/admin/customtag/vo/CustomTagPageReqVO.java new file mode 100644 index 0000000..bfdf157 --- /dev/null +++ b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/controller/admin/customtag/vo/CustomTagPageReqVO.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.ydoyun.controller.admin.customtag.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 自定义标签分页 Request VO") +@Data +public class CustomTagPageReqVO extends PageParam { + + @Schema(description = "标签名称", example = "王五") + private String name; + + @Schema(description = "标签表达式") + private String expression; + + @Schema(description = "标签颜色") + private String color; + + @Schema(description = "SQL脚本") + private String sqlScript; + + @Schema(description = "标签类型(product/store/supplier)") + private String type; + + @Schema(description = "是否代入参数(0否 1是)") + private Boolean useParams; + + @Schema(description = "参数列表(逗号分隔)") + private String params; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/controller/admin/customtag/vo/CustomTagRespVO.java b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/controller/admin/customtag/vo/CustomTagRespVO.java new file mode 100644 index 0000000..120be0c --- /dev/null +++ b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/controller/admin/customtag/vo/CustomTagRespVO.java @@ -0,0 +1,50 @@ +package cn.iocoder.yudao.module.ydoyun.controller.admin.customtag.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import cn.idev.excel.annotation.*; + +@Schema(description = "管理后台 - 自定义标签 Response VO") +@Data +@ExcelIgnoreUnannotated +public class CustomTagRespVO { + + @Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17700") + @ExcelProperty("主键ID") + private Long id; + + @Schema(description = "标签名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") + @ExcelProperty("标签名称") + private String name; + + @Schema(description = "标签表达式") + @ExcelProperty("标签表达式") + private String expression; + + @Schema(description = "标签颜色") + @ExcelProperty("标签颜色") + private String color; + + @Schema(description = "SQL脚本") + @ExcelProperty("SQL脚本") + private String sqlScript; + + @Schema(description = "标签类型(product/store/supplier)") + private String type; + + @Schema(description = "是否代入参数(0否 1是)", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("是否代入参数(0否 1是)") + private Boolean useParams; + + @Schema(description = "参数列表(逗号分隔)") + @ExcelProperty("参数列表(逗号分隔)") + private String params; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/controller/admin/customtag/vo/CustomTagSaveReqVO.java b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/controller/admin/customtag/vo/CustomTagSaveReqVO.java new file mode 100644 index 0000000..ed1436d --- /dev/null +++ b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/controller/admin/customtag/vo/CustomTagSaveReqVO.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.module.ydoyun.controller.admin.customtag.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 自定义标签新增/修改 Request VO") +@Data +public class CustomTagSaveReqVO { + + @Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17700") + private Long id; + + @Schema(description = "标签名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") + @NotEmpty(message = "标签名称不能为空") + private String name; + + @Schema(description = "标签表达式") + private String expression; + + @Schema(description = "标签颜色") + private String color; + + @Schema(description = "SQL脚本") + private String sqlScript; + + @Schema(description = "标签类型(product/store/supplier)") + private String type; + + @Schema(description = "是否代入参数(0否 1是)", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "是否代入参数(0否 1是)不能为空") + private Boolean useParams; + + @Schema(description = "参数列表(逗号分隔)") + private String params; + +} \ No newline at end of file diff --git a/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/dal/dataobject/customtag/CustomTagDO.java b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/dal/dataobject/customtag/CustomTagDO.java new file mode 100644 index 0000000..448155a --- /dev/null +++ b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/dal/dataobject/customtag/CustomTagDO.java @@ -0,0 +1,59 @@ +package cn.iocoder.yudao.module.ydoyun.dal.dataobject.customtag; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 自定义标签 DO + * + * @author 衣朵云源码 + */ +@TableName("ydoyun_custom_tag") +@KeySequence("ydoyun_custom_tag_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CustomTagDO extends BaseDO { + + /** + * 主键ID + */ + @TableId + private Long id; + /** + * 标签名称 + */ + private String name; + /** + * 标签表达式 + */ + private String expression; + /** + * 标签颜色 + */ + private String color; + /** + * SQL脚本 + */ + private String sqlScript; + + private String type; + /** + * 是否代入参数(0否 1是) + */ + private Boolean useParams; + /** + * 参数列表(逗号分隔) + */ + private String params; + + +} \ No newline at end of file diff --git a/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/dal/mysql/customtag/CustomTagMapper.java b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/dal/mysql/customtag/CustomTagMapper.java new file mode 100644 index 0000000..4a9f818 --- /dev/null +++ b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/dal/mysql/customtag/CustomTagMapper.java @@ -0,0 +1,33 @@ +package cn.iocoder.yudao.module.ydoyun.dal.mysql.customtag; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.ydoyun.dal.dataobject.customtag.CustomTagDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.ydoyun.controller.admin.customtag.vo.*; + +/** + * 自定义标签 Mapper + * + * @author 衣朵云源码 + */ +@Mapper +public interface CustomTagMapper extends BaseMapperX { + + default PageResult selectPage(CustomTagPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(CustomTagDO::getName, reqVO.getName()) + .likeIfPresent(CustomTagDO::getExpression, reqVO.getExpression()) + .eqIfPresent(CustomTagDO::getColor, reqVO.getColor()) + .eqIfPresent(CustomTagDO::getType, reqVO.getType()) + .eqIfPresent(CustomTagDO::getSqlScript, reqVO.getSqlScript()) + .eqIfPresent(CustomTagDO::getUseParams, reqVO.getUseParams()) + .eqIfPresent(CustomTagDO::getParams, reqVO.getParams()) + .betweenIfPresent(CustomTagDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(CustomTagDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/enums/ErrorCodeConstants.java b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/enums/ErrorCodeConstants.java index afc428b..21442d2 100644 --- a/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/enums/ErrorCodeConstants.java +++ b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/enums/ErrorCodeConstants.java @@ -24,6 +24,6 @@ public interface ErrorCodeConstants { ErrorCode REPORT_NOT_EXISTS = new ErrorCode(1_024_000_007, "报表配置不存在"); ErrorCode STORE_NOT_EXISTS = new ErrorCode(1_024_000_008, "门店不存在"); - ErrorCode STORE_USER_NOT_EXISTS = new ErrorCode(1_024_000_008, "门店用户记录不存在"); - + ErrorCode STORE_USER_NOT_EXISTS = new ErrorCode(1_024_000_009, "门店用户记录不存在"); + ErrorCode CUSTOM_TAG_NOT_EXISTS = new ErrorCode(1_024_000_010, "自定义标签不存在"); } diff --git a/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/service/customtag/CustomTagService.java b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/service/customtag/CustomTagService.java new file mode 100644 index 0000000..885f7bc --- /dev/null +++ b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/service/customtag/CustomTagService.java @@ -0,0 +1,62 @@ +package cn.iocoder.yudao.module.ydoyun.service.customtag; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.ydoyun.controller.admin.customtag.vo.*; +import cn.iocoder.yudao.module.ydoyun.dal.dataobject.customtag.CustomTagDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 自定义标签 Service 接口 + * + * @author 衣朵云源码 + */ +public interface CustomTagService { + + /** + * 创建自定义标签 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createCustomTag(@Valid CustomTagSaveReqVO createReqVO); + + /** + * 更新自定义标签 + * + * @param updateReqVO 更新信息 + */ + void updateCustomTag(@Valid CustomTagSaveReqVO updateReqVO); + + /** + * 删除自定义标签 + * + * @param id 编号 + */ + void deleteCustomTag(Long id); + + /** + * 批量删除自定义标签 + * + * @param ids 编号 + */ + void deleteCustomTagListByIds(List ids); + + /** + * 获得自定义标签 + * + * @param id 编号 + * @return 自定义标签 + */ + CustomTagDO getCustomTag(Long id); + + /** + * 获得自定义标签分页 + * + * @param pageReqVO 分页查询 + * @return 自定义标签分页 + */ + PageResult getCustomTagPage(CustomTagPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/service/customtag/CustomTagServiceImpl.java b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/service/customtag/CustomTagServiceImpl.java new file mode 100644 index 0000000..ffa5c86 --- /dev/null +++ b/yudao-module-ydoyun/src/main/java/cn/iocoder/yudao/module/ydoyun/service/customtag/CustomTagServiceImpl.java @@ -0,0 +1,85 @@ +package cn.iocoder.yudao.module.ydoyun.service.customtag; + +import cn.hutool.core.collection.CollUtil; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.ydoyun.controller.admin.customtag.vo.*; +import cn.iocoder.yudao.module.ydoyun.dal.dataobject.customtag.CustomTagDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.ydoyun.dal.mysql.customtag.CustomTagMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList; +import static cn.iocoder.yudao.module.ydoyun.enums.ErrorCodeConstants.*; + +/** + * 自定义标签 Service 实现类 + * + * @author 衣朵云源码 + */ +@Service +@Validated +public class CustomTagServiceImpl implements CustomTagService { + + @Resource + private CustomTagMapper customTagMapper; + + @Override + public Long createCustomTag(CustomTagSaveReqVO createReqVO) { + // 插入 + CustomTagDO customTag = BeanUtils.toBean(createReqVO, CustomTagDO.class); + customTagMapper.insert(customTag); + + // 返回 + return customTag.getId(); + } + + @Override + public void updateCustomTag(CustomTagSaveReqVO updateReqVO) { + // 校验存在 + validateCustomTagExists(updateReqVO.getId()); + // 更新 + CustomTagDO updateObj = BeanUtils.toBean(updateReqVO, CustomTagDO.class); + customTagMapper.updateById(updateObj); + } + + @Override + public void deleteCustomTag(Long id) { + // 校验存在 + validateCustomTagExists(id); + // 删除 + customTagMapper.deleteById(id); + } + + @Override + public void deleteCustomTagListByIds(List ids) { + // 删除 + customTagMapper.deleteByIds(ids); + } + + + private void validateCustomTagExists(Long id) { + if (customTagMapper.selectById(id) == null) { + throw exception(CUSTOM_TAG_NOT_EXISTS); + } + } + + @Override + public CustomTagDO getCustomTag(Long id) { + return customTagMapper.selectById(id); + } + + @Override + public PageResult getCustomTagPage(CustomTagPageReqVO pageReqVO) { + return customTagMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/yudao-module-ydoyun/src/main/resources/mapper/customtag/CustomTagMapper.xml b/yudao-module-ydoyun/src/main/resources/mapper/customtag/CustomTagMapper.xml new file mode 100644 index 0000000..7285535 --- /dev/null +++ b/yudao-module-ydoyun/src/main/resources/mapper/customtag/CustomTagMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file