diff --git a/yudao-admin-vue3/.env b/yudao-admin-vue3/.env index 5109f33..6b80983 100644 --- a/yudao-admin-vue3/.env +++ b/yudao-admin-vue3/.env @@ -11,7 +11,8 @@ VITE_OPEN=true VITE_APP_TENANT_ENABLE=true # 验证码的开关 -VITE_APP_CAPTCHA_ENABLE=true +VITE_APP_CAPTCHA_ENABLE=false +# VITE_APP_CAPTCHA_ENABLE=true # 文档地址的开关 VITE_APP_DOCALERT_ENABLE=false diff --git a/yudao-admin-vue3/.env.local b/yudao-admin-vue3/.env.local index 120bda0..256754a 100644 --- a/yudao-admin-vue3/.env.local +++ b/yudao-admin-vue3/.env.local @@ -5,7 +5,7 @@ VITE_DEV=true # 请求路径 #VITE_BASE_URL='https://zysc.fjptzykj.com' -VITE_BASE_URL='http://192.168.1.12:6127' +VITE_BASE_URL='http://localhost:6127' # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务 VITE_UPLOAD_TYPE=server diff --git a/yudao-admin-vue3/src/api/member/membercard/index.ts b/yudao-admin-vue3/src/api/member/membercard/index.ts new file mode 100644 index 0000000..f7a7905 --- /dev/null +++ b/yudao-admin-vue3/src/api/member/membercard/index.ts @@ -0,0 +1,45 @@ +import request from '@/config/axios' + +// 会员卡类型 VO +export interface cardVO { + memberCardId: number // 会员卡id + memberCardName: string // 会员卡名称 + memberCardVid: string // 会员有效期(天) + memberCardOriginalPrice: number // 会员卡原价 + memberCardSpecialPrice: number // 会员卡优惠价 + memberCardSort: number // 排序 + memberCardStatus: number // 会员卡是否禁用 +} + +// 会员卡类型 API +export const cardApi = { + // 查询会员卡类型分页 + getcardPage: async (params: any) => { + return await request.get({ url: `/member/card/page`, params }) + }, + + // 查询会员卡类型详情 + getcard: async (id: number) => { + return await request.get({ url: `/member/card/get?id=` + id }) + }, + + // 新增会员卡类型 + createcard: async (data: cardVO) => { + return await request.post({ url: `/member/card/create`, data }) + }, + + // 修改会员卡类型 + updatecard: async (data: cardVO) => { + return await request.put({ url: `/member/card/update`, data }) + }, + + // 删除会员卡类型 + deletecard: async (id: number) => { + return await request.delete({ url: `/member/card/delete?id=` + id }) + }, + + // 导出会员卡类型 Excel + exportcard: async (params) => { + return await request.download({ url: `/member/card/export-excel`, params }) + }, +} \ No newline at end of file diff --git a/yudao-admin-vue3/src/views/member/membercard/cardForm.vue b/yudao-admin-vue3/src/views/member/membercard/cardForm.vue new file mode 100644 index 0000000..3a2f8c2 --- /dev/null +++ b/yudao-admin-vue3/src/views/member/membercard/cardForm.vue @@ -0,0 +1,113 @@ + + \ No newline at end of file diff --git a/yudao-admin-vue3/src/views/member/membercard/index.vue b/yudao-admin-vue3/src/views/member/membercard/index.vue new file mode 100644 index 0000000..02698f7 --- /dev/null +++ b/yudao-admin-vue3/src/views/member/membercard/index.vue @@ -0,0 +1,230 @@ + + + \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java index 534860b..b7e3b04 100644 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java +++ b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java @@ -65,4 +65,5 @@ public interface ErrorCodeConstants { // ========== ========== ErrorCode INPUTCODE_NOT_EXISTS = new ErrorCode(1_004_019_000, "进件码不存在"); + ErrorCode CARD_NOT_EXISTS = new ErrorCode(1_004_020_000, "会员卡类型不存在"); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/membercard/MembercardController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/membercard/MembercardController.java new file mode 100644 index 0000000..b9ba3ee --- /dev/null +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/membercard/MembercardController.java @@ -0,0 +1,96 @@ +package cn.iocoder.yudao.module.member.controller.admin.membercard; + +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.member.controller.admin.membercard.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.membercard.MembercardDO; +import cn.iocoder.yudao.module.member.service.membercard.MembercardService; + +@Tag(name = "管理后台 - 会员卡类型") +@RestController +@RequestMapping("/member/card") +@Validated +public class MembercardController { + + @Resource + private MembercardService cardService; + + @PostMapping("/create") + @Operation(summary = "创建会员卡类型") + @PreAuthorize("@ss.hasPermission('member:card:create')") + public CommonResult createcard(@Valid @RequestBody MembercardSaveReqVO createReqVO) { + return success(cardService.createcard(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新会员卡类型") + @PreAuthorize("@ss.hasPermission('member:card:update')") + public CommonResult updatecard(@Valid @RequestBody MembercardSaveReqVO updateReqVO) { + cardService.updatecard(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除会员卡类型") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('member:card:delete')") + public CommonResult deletecard(@RequestParam("id") long memberCardId) { + System.out.println(memberCardId); + cardService.deletecard(memberCardId); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得会员卡类型") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('member:card:query')") + public CommonResult getcard(@RequestParam("id") Long id) { + MembercardDO card = cardService.getcard(id); + return success(BeanUtils.toBean(card, MembercardRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得会员卡类型分页") + @PreAuthorize("@ss.hasPermission('member:card:query')") + public CommonResult> getcardPage(@Valid MembercardPageReqVO pageReqVO) { + PageResult pageResult = cardService.getcardPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, MembercardRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出会员卡类型 Excel") + @PreAuthorize("@ss.hasPermission('member:card:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportcardExcel(@Valid MembercardPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = cardService.getcardPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "会员卡类型.xls", "数据", MembercardRespVO.class, + BeanUtils.toBean(list, MembercardRespVO.class)); + } + +} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/membercard/vo/MembercardPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/membercard/vo/MembercardPageReqVO.java new file mode 100644 index 0000000..59479f9 --- /dev/null +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/membercard/vo/MembercardPageReqVO.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.member.controller.admin.membercard.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import java.math.BigDecimal; +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 +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class MembercardPageReqVO extends PageParam { + + @Schema(description = "会员卡名称", example = "李四") + private String memberCardName; + + @Schema(description = "会员有效期(天)", example = "13455") + private String memberCardVid; + + @Schema(description = "会员卡原价", example = "32259") + private BigDecimal memberCardOriginalPrice; + + @Schema(description = "会员卡优惠价", example = "12301") + private BigDecimal memberCardSpecialPrice; + + @Schema(description = "排序") + private Integer memberCardSort; + + @Schema(description = "会员卡是否禁用", example = "1") + private Integer memberCardStatus; + +} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/membercard/vo/MembercardRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/membercard/vo/MembercardRespVO.java new file mode 100644 index 0000000..8356b0e --- /dev/null +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/membercard/vo/MembercardRespVO.java @@ -0,0 +1,45 @@ +package cn.iocoder.yudao.module.member.controller.admin.membercard.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +import com.alibaba.excel.annotation.*; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 会员卡类型 Response VO") +@Data +@ExcelIgnoreUnannotated +public class MembercardRespVO { + + @Schema(description = "会员卡id", requiredMode = Schema.RequiredMode.REQUIRED, example = "25594") + @ExcelProperty("会员卡id") + private Long memberCardId; + + @Schema(description = "会员卡名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") + @ExcelProperty("会员卡名称") + private String memberCardName; + + @Schema(description = "会员有效期(天)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13455") + @ExcelProperty("会员有效期(天)") + private String memberCardVid; + + @Schema(description = "会员卡原价", requiredMode = Schema.RequiredMode.REQUIRED, example = "32259") + @ExcelProperty("会员卡原价") + private BigDecimal memberCardOriginalPrice; + + @Schema(description = "会员卡优惠价", example = "12301") + @ExcelProperty("会员卡优惠价") + private BigDecimal memberCardSpecialPrice; + + @Schema(description = "排序") + @ExcelProperty("排序") + private Integer memberCardSort; + + @Schema(description = "会员卡是否禁用", example = "1") + @ExcelProperty(value = "会员卡是否禁用", converter = DictConvert.class) + @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer memberCardStatus; + +} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/membercard/vo/MembercardSaveReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/membercard/vo/MembercardSaveReqVO.java new file mode 100644 index 0000000..c2c77b3 --- /dev/null +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/membercard/vo/MembercardSaveReqVO.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.member.controller.admin.membercard.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.math.BigDecimal; + +@Schema(description = "管理后台 - 会员卡类型新增/修改 Request VO") +@Data +public class MembercardSaveReqVO { + + @Schema(description = "会员卡id", requiredMode = Schema.RequiredMode.REQUIRED, example = "25594") + private Long memberCardId; + + @Schema(description = "会员卡名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") + @NotEmpty(message = "会员卡名称不能为空") + private String memberCardName; + + @Schema(description = "会员有效期(天)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13455") + @NotEmpty(message = "会员有效期(天)不能为空") + private String memberCardVid; + + @Schema(description = "会员卡原价", requiredMode = Schema.RequiredMode.REQUIRED, example = "32259") + @NotNull(message = "会员卡原价不能为空") + private BigDecimal memberCardOriginalPrice; + + @Schema(description = "会员卡优惠价", example = "12301") + private BigDecimal memberCardSpecialPrice; + + @Schema(description = "排序") + private Integer memberCardSort; + + @Schema(description = "会员卡是否禁用", example = "1") + private Integer memberCardStatus; + +} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/membercard/MembercardDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/membercard/MembercardDO.java new file mode 100644 index 0000000..d1f54b0 --- /dev/null +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/membercard/MembercardDO.java @@ -0,0 +1,59 @@ +package cn.iocoder.yudao.module.member.dal.dataobject.membercard; + +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +import java.math.BigDecimal; +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("member_card") +@KeySequence("member_card_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MembercardDO extends BaseDO { + + /** + * 会员卡id + */ + @TableId + private long memberCardId; + /** + * 会员卡名称 + */ + private String memberCardName; + /** + * 会员有效期(天) + */ + private String memberCardVid; + /** + * 会员卡原价 + */ + private BigDecimal memberCardOriginalPrice; + /** + * 会员卡优惠价 + */ + private BigDecimal memberCardSpecialPrice; + /** + * 排序 + */ + private Integer memberCardSort; + /** + * 会员卡是否禁用 + * + * 枚举 {@link TODO common_status 对应的类} + */ + private Integer memberCardStatus; + +} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/membercard/MembercardMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/membercard/MembercardMapper.java new file mode 100644 index 0000000..872ab12 --- /dev/null +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/membercard/MembercardMapper.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.member.dal.mysql.membercard; + +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.member.dal.dataobject.membercard.MembercardDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.member.controller.admin.membercard.vo.*; + +/** + * 会员卡类型 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface MembercardMapper extends BaseMapperX { + + default PageResult selectPage(MembercardPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(MembercardDO::getMemberCardName, reqVO.getMemberCardName()) + .eqIfPresent(MembercardDO::getMemberCardVid, reqVO.getMemberCardVid()) + .eqIfPresent(MembercardDO::getMemberCardOriginalPrice, reqVO.getMemberCardOriginalPrice()) + .eqIfPresent(MembercardDO::getMemberCardSpecialPrice, reqVO.getMemberCardSpecialPrice()) + .eqIfPresent(MembercardDO::getMemberCardSort, reqVO.getMemberCardSort()) + .eqIfPresent(MembercardDO::getMemberCardStatus, reqVO.getMemberCardStatus()) + .orderByDesc(MembercardDO::getMemberCardId)); + } + +} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/membercard/MembercardService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/membercard/MembercardService.java new file mode 100644 index 0000000..c36d88a --- /dev/null +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/membercard/MembercardService.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.member.service.membercard; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.member.controller.admin.membercard.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.membercard.MembercardDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 会员卡类型 Service 接口 + * + * @author 芋道源码 + */ +public interface MembercardService { + + /** + * 创建会员卡类型 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createcard(@Valid MembercardSaveReqVO createReqVO); + + /** + * 更新会员卡类型 + * + * @param updateReqVO 更新信息 + */ + void updatecard(@Valid MembercardSaveReqVO updateReqVO); + + /** + * 删除会员卡类型 + * + * @param id 编号 + */ + void deletecard(Long id); + + /** + * 获得会员卡类型 + * + * @param id 编号 + * @return 会员卡类型 + */ + MembercardDO getcard(Long id); + + /** + * 获得会员卡类型分页 + * + * @param pageReqVO 分页查询 + * @return 会员卡类型分页 + */ + PageResult getcardPage(MembercardPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/membercard/MembercardServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/membercard/MembercardServiceImpl.java new file mode 100644 index 0000000..d693b90 --- /dev/null +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/membercard/MembercardServiceImpl.java @@ -0,0 +1,74 @@ +package cn.iocoder.yudao.module.member.service.membercard; + +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.member.controller.admin.membercard.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.membercard.MembercardDO; +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.member.dal.mysql.membercard.MembercardMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; + +/** + * 会员卡类型 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class MembercardServiceImpl implements MembercardService { + + @Resource + private MembercardMapper cardMapper; + + @Override + public Long createcard(MembercardSaveReqVO createReqVO) { + // 插入 + MembercardDO card = BeanUtils.toBean(createReqVO, MembercardDO.class); + cardMapper.insert(card); + // 返回 + return card.getMemberCardId(); + } + + @Override + public void updatecard(MembercardSaveReqVO updateReqVO) { + // 校验存在 + validatecardExists(updateReqVO.getMemberCardId()); + // 更新 + MembercardDO updateObj = BeanUtils.toBean(updateReqVO, MembercardDO.class); + cardMapper.updateById(updateObj); + } + + @Override + public void deletecard(Long id) { + // 校验存在 + validatecardExists(id); + // 删除 + cardMapper.deleteById(id); + } + + private void validatecardExists(Long id) { + if (cardMapper.selectById(id) == null) { + throw exception(CARD_NOT_EXISTS); + } + } + + @Override + public MembercardDO getcard(Long id) { + return cardMapper.selectById(id); + } + + @Override + public PageResult getcardPage(MembercardPageReqVO pageReqVO) { + return cardMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file