Compare commits

...

1 Commits
master ... lu

Author SHA1 Message Date
Your Name
ec177140c5 付费会员月卡管理 2024-10-14 18:42:17 +08:00
14 changed files with 826 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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 })
},
}

View File

@ -0,0 +1,113 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
>
<el-form-item label="会员卡名称" prop="memberCardName">
<el-input v-model="formData.memberCardName" placeholder="请输入会员卡名称" />
</el-form-item>
<el-form-item label="会员有效期(天)" prop="memberCardVid">
<el-input v-model="formData.memberCardVid" placeholder="请输入会员有效期(天)" />
</el-form-item>
<el-form-item label="会员卡原价" prop="memberCardOriginalPrice">
<el-input v-model="formData.memberCardOriginalPrice" placeholder="请输入会员卡原价" />
</el-form-item>
<el-form-item label="会员卡优惠价" prop="memberCardSpecialPrice">
<el-input v-model="formData.memberCardSpecialPrice" placeholder="请输入会员卡优惠价" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import { cardApi, cardVO } from '@/api/member/membercard'
/** 会员卡类型 表单 */
defineOptions({ name: 'cardForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
memberCardId: undefined,
memberCardName: undefined,
memberCardVid: undefined,
memberCardOriginalPrice: undefined,
memberCardSpecialPrice: undefined,
memberCardStatus: undefined,
})
const formRules = reactive({
memberCardName: [{ required: true, message: '会员卡名称不能为空', trigger: 'blur' }],
memberCardVid: [{ required: true, message: '会员有效期(天)不能为空', trigger: 'blur' }],
memberCardOriginalPrice: [{ required: true, message: '会员卡原价不能为空', trigger: 'blur' }],
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await cardApi.getcard(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = formData.value as unknown as cardVO
if (formType.value === 'create') {
await cardApi.createcard(data)
message.success(t('common.createSuccess'))
} else {
await cardApi.updatecard(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
memberCardId: undefined,
memberCardName: undefined,
memberCardVid: undefined,
memberCardOriginalPrice: undefined,
memberCardSpecialPrice: undefined,
memberCardSort: undefined,
memberCardStatus: undefined,
}
formRef.value?.resetFields()
}
</script>

View File

@ -0,0 +1,230 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="140px"
>
<el-form-item label="会员卡名称" prop="memberCardName">
<el-input
v-model="queryParams.memberCardName"
placeholder="请输入会员卡名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="会员有效期(天)" prop="memberCardVid">
<el-input
v-model="queryParams.memberCardVid"
placeholder="请输入会员有效期(天)"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="会员卡原价" prop="memberCardOriginalPrice">
<el-input
v-model="queryParams.memberCardOriginalPrice"
placeholder="请输入会员卡原价"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="会员卡优惠价" prop="memberCardSpecialPrice">
<el-input
v-model="queryParams.memberCardSpecialPrice"
placeholder="请输入会员卡优惠价"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="是否启用" prop="memberCardStatus">
<el-select
v-model="queryParams.memberCardStatus"
placeholder="请选择会员卡是否禁用"
clearable
class="!w-240px"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['member:card:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['member:card:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="会员卡id" align="center" prop="memberCardId" />
<el-table-column label="会员卡名称" align="center" prop="memberCardName" />
<el-table-column label="会员有效期(天)" align="center" prop="memberCardVid" />
<el-table-column label="会员卡原价" align="center" prop="memberCardOriginalPrice" />
<el-table-column label="会员卡优惠价" align="center" prop="memberCardSpecialPrice" />
<el-table-column label="是否启用" align="center" prop="memberCardStatus">
<template #default="scope">
<el-switch
v-model="scope.row.memberCardStatus"
inline-prompt
active-value=1
inactive-value=0
active-text="是"
inactive-text="否"
/>
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.memberCardId)"
v-hasPermi="['member:card:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.memberCardId)"
v-hasPermi="['member:card:delete']"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<cardForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts">
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import download from '@/utils/download'
import { cardApi, cardVO } from '@/api/member/membercard'
import cardForm from './cardForm.vue'
/** 会员卡类型 列表 */
defineOptions({ name: 'Membercard' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref<cardVO[]>([]) //
const total = ref(0) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
memberCardName: undefined,
memberCardVid: undefined,
memberCardOriginalPrice: undefined,
memberCardSpecialPrice: undefined,
memberCardSort: undefined,
memberCardStatus: undefined,
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await cardApi.getcardPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: int, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await cardApi.deletecard(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await cardApi.exportcard(queryParams)
download.excel(data, '会员卡类型.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>

View File

@ -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, "会员卡类型不存在");
}

View File

@ -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<Long> createcard(@Valid @RequestBody MembercardSaveReqVO createReqVO) {
return success(cardService.createcard(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新会员卡类型")
@PreAuthorize("@ss.hasPermission('member:card:update')")
public CommonResult<Boolean> 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<Boolean> 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<MembercardRespVO> 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<PageResult<MembercardRespVO>> getcardPage(@Valid MembercardPageReqVO pageReqVO) {
PageResult<MembercardDO> 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<MembercardDO> list = cardService.getcardPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "会员卡类型.xls", "数据", MembercardRespVO.class,
BeanUtils.toBean(list, MembercardRespVO.class));
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 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;
}

View File

@ -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<MembercardDO> {
default PageResult<MembercardDO> selectPage(MembercardPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MembercardDO>()
.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));
}
}

View File

@ -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<MembercardDO> getcardPage(MembercardPageReqVO pageReqVO);
}

View File

@ -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<MembercardDO> getcardPage(MembercardPageReqVO pageReqVO) {
return cardMapper.selectPage(pageReqVO);
}
}