Merge pull request 'khy' (#45) from khy into master
Some checks are pending
continuous-integration/drone/push Build is running

Reviewed-on: #45
This commit is contained in:
root 2024-10-16 13:57:22 +08:00
commit 53128f0685
20 changed files with 913 additions and 59 deletions

View File

@ -3,7 +3,8 @@ import request from '@/config/axios'
// 付费会员权益 VO // 付费会员权益 VO
export interface PaidMemberBenefitVO { export interface PaidMemberBenefitVO {
id: number // 编号 id: number // 编号
name: string // 名称 benName: string // 权益名称
showName: string // 展示名称
iconUrl: string // 图标地址 iconUrl: string // 图标地址
intro: string // 描述 intro: string // 描述
status: boolean // 状态:(默认)0隐藏 1显示 status: boolean // 状态:(默认)0隐藏 1显示

View File

@ -0,0 +1,45 @@
import request from '@/config/axios'
// 会员卡类型 VO
export interface cardVO {
id: number // id
name: string // 会员名
vid: string // 有效期
originalPrice: number // 原价
specialPrice: number // 优惠价
sort: string // 排序
status: number// 是否禁用
}
// 会员卡类型 API
export const cardApi = {
// 查询会员卡类型分页
getcardPage: async (params: any) => {
return await request.get({ url: `/paid/member/card/type/page`, params })
},
// 查询会员卡类型详情
getcard: async (id: number) => {
return await request.get({ url: `/paid/member/card/type/get?id=` + id })
},
// 新增会员卡类型
createcard: async (data: cardVO) => {
return await request.post({ url: `/paid/member/card/type/create`, data })
},
// 修改会员卡类型
updatecard: async (data: cardVO) => {
return await request.put({ url: `/paid/member/card/type/update`, data })
},
// 删除会员卡类型
deletecard: async (id: number) => {
return await request.delete({ url: `/paid/member/card/type/delete?id=` + id })
},
// 导出会员卡类型 Excel
exportcard: async (params) => {
return await request.download({ url: `/paid/member/card/type/export-excel`, params })
},
}

View File

@ -7,15 +7,15 @@
label-width="100px" label-width="100px"
v-loading="formLoading" v-loading="formLoading"
> >
<el-form-item label="名称" prop="name"> <el-form-item label="权益名称" prop="benName">
<el-input v-model="formData.name" placeholder="请输入名称" /> <el-input v-model="formData.benName" placeholder="请输入权益名称" />
</el-form-item>
<el-form-item label="展示名称" prop="showName">
<el-input v-model="formData.showName" placeholder="请输入展示名称" />
</el-form-item> </el-form-item>
<el-form-item label="图标" prop="iconUrl"> <el-form-item label="图标" prop="iconUrl">
<UploadImg v-model="formData.iconUrl" :limit="1" :is-show-tip="false" /> <UploadImg v-model="formData.iconUrl" :limit="1" :is-show-tip="false" />
</el-form-item> </el-form-item>
<el-form-item label="描述" prop="intro">
<el-input v-model="formData.intro" placeholder="请输入描述" />
</el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-select v-model="formData.status" class="!w-240px" placeholder="请选择" clearable> <el-select v-model="formData.status" class="!w-240px" placeholder="请选择" clearable>
<el-option <el-option
@ -26,7 +26,7 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="会员等级" prop="levelIdList"> <!-- <el-form-item label="会员等级" prop="levelIdList">
<el-checkbox-group v-model="formData.levelIdList"> <el-checkbox-group v-model="formData.levelIdList">
<el-checkbox <el-checkbox
v-for="dict in memberLevelList" v-for="dict in memberLevelList"
@ -36,12 +36,14 @@
{{ dict.name }} {{ dict.name }}
</el-checkbox> </el-checkbox>
</el-checkbox-group> </el-checkbox-group>
</el-form-item> -->
<el-form-item label="权益简介" prop="intro">
<el-input v-model="formData.intro" placeholder="请输入描述" />
</el-form-item> </el-form-item>
<!-- <el-form-item label="排序" prop="sort">
<el-form-item label="排序" prop="sort">
<el-input v-model="formData.sort" placeholder="请输入排序" /> <el-input v-model="formData.sort" placeholder="请输入排序" />
</el-form-item> </el-form-item> -->
</el-form> </el-form>
<template #footer> <template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button> <el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
@ -65,7 +67,8 @@ const formLoading = ref(false) // 表单的加载中1修改时的数据加
const formType = ref('') // create - update - const formType = ref('') // create - update -
const formData = ref({ const formData = ref({
id: undefined, id: undefined,
name: undefined, benName: undefined,
showName: undefined,
iconUrl: undefined, iconUrl: undefined,
intro: undefined, intro: undefined,
status: undefined, status: undefined,
@ -73,10 +76,10 @@ const formData = ref({
levelIdList: [] levelIdList: []
}) })
const formRules = reactive({ const formRules = reactive({
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }], benName: [{ required: true, message: '权益名称不能为空', trigger: 'blur' }],
showName: [{ required: true, message: '展示名称不能为空', trigger: 'blur' }],
iconUrl: [{ required: true, message: '图标地址不能为空', trigger: 'blur' }], iconUrl: [{ required: true, message: '图标地址不能为空', trigger: 'blur' }],
status: [{ required: true, message: '状态', trigger: 'blur' }], status: [{ required: true, message: '状态', trigger: 'blur' }],
sort: [{ required: true, message: '排序不能为空', trigger: 'blur' }],
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
const memberLevelList = ref() // const memberLevelList = ref() //
@ -136,7 +139,8 @@ const submitForm = async () => {
const resetForm = () => { const resetForm = () => {
formData.value = { formData.value = {
id: undefined, id: undefined,
name: undefined, benName: undefined,
showName: undefined,
iconUrl: undefined, iconUrl: undefined,
intro: undefined, intro: undefined,
status: undefined, status: undefined,

View File

@ -8,10 +8,10 @@
:inline="true" :inline="true"
label-width="68px" label-width="68px"
> >
<el-form-item label="名称" prop="name"> <el-form-item label="权益名称" prop="benName">
<el-input <el-input
v-model="queryParams.name" v-model="queryParams.benName"
placeholder="请输入名称" placeholder="请输入权益名称"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
class="!w-240px" class="!w-240px"
@ -35,7 +35,7 @@
class="!w-240px" class="!w-240px"
/> />
</el-form-item> --> </el-form-item> -->
<el-form-item label="状态" prop="status"> <el-form-item label="权益状态" prop="status">
<el-select v-model="queryParams.status" class="!w-240px" placeholder="请选择" clearable> <el-select v-model="queryParams.status" class="!w-240px" placeholder="请选择" clearable>
<el-option <el-option
v-for="dict in getIntDictOptions(DICT_TYPE.MEMBER_BENEFIT_STATUS)" v-for="dict in getIntDictOptions(DICT_TYPE.MEMBER_BENEFIT_STATUS)"
@ -45,7 +45,7 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="会员等级" prop="levelId"> <!-- <el-form-item label="会员等级" prop="levelId">
<el-select v-model="queryParams.levelId" class="!w-240px" placeholder="请选择" clearable> <el-select v-model="queryParams.levelId" class="!w-240px" placeholder="请选择" clearable>
<el-option <el-option
v-for="dict in memberLevelList" v-for="dict in memberLevelList"
@ -54,7 +54,7 @@
:value="dict.id" :value="dict.id"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item> -->
<!-- <el-form-item label="排序" prop="sort"> <!-- <el-form-item label="排序" prop="sort">
<el-input <el-input
v-model="queryParams.sort" v-model="queryParams.sort"
@ -102,35 +102,35 @@
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label=" 编号" align="center" prop="id" /> <el-table-column label="权益名称" align="center" prop="benName" />
<el-table-column label="名称" align="center" prop="name" /> <el-table-column label="展示名称" align="center" prop="showName" />
<el-table-column align="center" label="图标" prop="avatar" width="80px"> <el-table-column align="center" label="权益图标" prop="avatar" width="80px">
<template #default="scope"> <template #default="scope">
<img :src="scope.row.iconUrl" style="width: 40px" /> <img :src="scope.row.iconUrl" style="width: 40px" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="描述" align="center" prop="intro" /> <el-table-column label="权益简介" align="center" prop="intro" />
<el-table-column align="center" label="状态" min-width="80"> <el-table-column align="center" label="权益状态" min-width="80">
<template #default="{ row }"> <template #default="{ row }">
<el-switch <el-switch
v-model="row.status" v-model="row.status"
:active-value="1" :active-value="1"
:inactive-value="0" :inactive-value="0"
active-text="显示" active-text="启用"
inactive-text="隐藏" inactive-text="禁用"
inline-prompt inline-prompt
@click="handleStatusChange(row)" @click="handleStatusChange(row)"
/> />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="排序" align="center" prop="sort" /> <!-- <el-table-column label="排序" align="center" prop="sort" />
<el-table-column <el-table-column
label="创建时间" label="创建时间"
align="center" align="center"
prop="createTime" prop="createTime"
:formatter="dateFormatter" :formatter="dateFormatter"
width="180px" width="180px"
/> /> -->
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template #default="scope"> <template #default="scope">
<el-button <el-button
@ -193,7 +193,7 @@ const queryParams = reactive({
createTime: [], createTime: [],
levelId: undefined levelId: undefined
}) })
const memberLevelList = ref() // // const memberLevelList = ref() //
const queryFormRef = ref() // const queryFormRef = ref() //
const exportLoading = ref(false) // const exportLoading = ref(false) //
/** 查询列表 */ /** 查询列表 */
@ -208,14 +208,14 @@ const getList = async () => {
} }
} }
/**查询等级列表 */ // /** */
const getMemberLevelList = async () => { // const getMemberLevelList = async () => {
const queryLevelParams = reactive({ // const queryLevelParams = reactive({
status: 0 // status: 0
}) // })
const resultData = await LevelApi.getLevelList(queryLevelParams) // const resultData = await LevelApi.getLevelList(queryLevelParams)
memberLevelList.value = resultData // memberLevelList.value = resultData
} // }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
@ -265,18 +265,18 @@ const handleExport = async () => {
/** 初始化 **/ /** 初始化 **/
onMounted(() => { onMounted(() => {
getMemberLevelList() // getMemberLevelList()
getList() getList()
}) })
/** 更新显示/隐藏状态 */ /** 更新显示/隐藏状态 */
const handleStatusChange = async (row: any) => { const handleStatusChange = async (row: any) => {
try { try {
// //
const text = row.status ? '显示' : '隐藏' // const text = row.status ? '' : ''
await message.confirm(`确认要${text}"${row.name}"吗?`) // await message.confirm(`${text}"${row.name}"`)
// //
await PaidMemberBenefitApi.updatePaidMemberBenefitStatus({id: row.id, status: row.status }) await PaidMemberBenefitApi.updatePaidMemberBenefitStatus({id: row.id, status: row.status })
message.success(text + '成功') // message.success(text + '')
// //
await getList() await getList()
} catch { } catch {

View File

@ -0,0 +1,112 @@
<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="name">
<el-input v-model="formData.name" placeholder="请输入会员卡名称" />
</el-form-item>
<el-form-item label="会员有效期(天)" prop="vid">
<el-input v-model="formData.vid" placeholder="请输入会员有效期(天)" />
</el-form-item>
<el-form-item label="会员卡原价" prop="originalPrice">
<el-input v-model="formData.originalPrice" placeholder="请输入会员卡原价" />
</el-form-item>
<el-form-item label="会员卡优惠价" prop="specialPrice">
<el-input v-model="formData.specialPrice" 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/type'
/** 会员卡类型 表单 */
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({
id: undefined,
name: undefined,
vid: undefined,
originalPrice: undefined,
specialPrice: undefined,
status: undefined,
})
const formRules = reactive({
name: [{ required: true, message: '会员卡名称不能为空', trigger: 'blur' }],
vid: [{ required: true, message: '会员有效期(天)不能为空', trigger: 'blur' }],
originalPrice: [{ 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 = {
id: undefined,
name: undefined,
vid: undefined,
originalPrice: undefined,
specialPrice: undefined,
status: undefined,
}
formRef.value?.resetFields()
}
</script>

View File

@ -0,0 +1,251 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="140px"
>
<el-form-item label="会员卡名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入会员卡名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="会员有效期(天)" prop="vid">
<el-input
v-model="queryParams.vid"
placeholder="请输入会员有效期(天)"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="会员卡原价" prop="originalPrice">
<el-input
v-model="queryParams.originalPrice"
placeholder="请输入会员卡原价"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="会员卡优惠价" prop="specialPrice">
<el-input
v-model="queryParams.specialPrice"
placeholder="请输入会员卡优惠价"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="是否启用" prop="status">
<el-select
v-model="queryParams.status"
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:paid-member-card-type:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['member:paid-member-card-type: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="id" />
<el-table-column label="会员卡名称" align="center" prop="name" />
<el-table-column label="会员有效期(天)" align="center" prop="vid" />
<el-table-column label="会员卡原价" align="center" prop="originalPrice" />
<el-table-column label="会员卡优惠价" align="center" prop="specialPrice" />
<el-table-column label="是否启用" align="center" prop="status">
<template #default="{row}">
<template v-if="row.status >= 0">
<el-switch
v-model="row.status"
inline-prompt
:active-value=1
:inactive-value=0
active-text="是"
inactive-text="否"
@change="handleStatusChange(row)"
/>
</template>
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['member:paid-member-card-type:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['member:paid-member-card-type: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/type'
import * as typeapi from '@/api/member/type'
import cardForm from './cardForm.vue'
import { any } from 'vue-types'
/** 会员卡类型 列表 */
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,
name: undefined,
vid: undefined,
originalPrice: undefined,
specialPrice: undefined,
sort: undefined,
status: 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 handleStatusChange = async (row: any) =>{
const originalStatus = row.status
try{
//
await cardApi.updatecard(row)
// //
await getList()
}
catch{
row.status = originalStatus
}
}
/** 删除按钮操作 */
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 INPUTCODE_NOT_EXISTS = new ErrorCode(1_004_019_000, "进件码不存在");
ErrorCode CARD_NOT_EXISTS = new ErrorCode(1_004_020_000, "会员卡类型不存在");
} }

View File

@ -15,8 +15,11 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true) @ToString(callSuper = true)
public class PaidMemberBenefitPageReqVO extends PageParam { public class PaidMemberBenefitPageReqVO extends PageParam {
@Schema(description = "名称", example = "王五") @Schema(description = "权益名称", example = "王五")
private String name; private String benName;
@Schema(description = "展示名称", example = "王五")
private String showName;
@Schema(description = "图标地址", example = "https://www.iocoder.cn") @Schema(description = "图标地址", example = "https://www.iocoder.cn")
private String iconUrl; private String iconUrl;

View File

@ -17,9 +17,13 @@ public class PaidMemberBenefitRespVO {
@ExcelProperty(" 编号") @ExcelProperty(" 编号")
private Long id; private Long id;
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") @Schema(description = "权益名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("名称") @ExcelProperty("权益名称")
private String name; private String benName;
@Schema(description = "展示名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("展示名称")
private String showName;
@Schema(description = "图标地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") @Schema(description = "图标地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
@ExcelProperty("图标地址") @ExcelProperty("图标地址")

View File

@ -12,9 +12,13 @@ public class PaidMemberBenefitSaveReqVO {
@Schema(description = " 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29131") @Schema(description = " 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29131")
private Long id; private Long id;
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") @Schema(description = "权益名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "名称不能为空") @NotEmpty(message = "权益名称不能为空")
private String name; private String benName;
@Schema(description = "展示名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "展示名称不能为空")
private String showName;
@Schema(description = "图标地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") @Schema(description = "图标地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
@NotEmpty(message = "图标地址不能为空") @NotEmpty(message = "图标地址不能为空")
@ -27,11 +31,11 @@ public class PaidMemberBenefitSaveReqVO {
@NotNull(message = "状态:(默认)0隐藏 1显示不能为空") @NotNull(message = "状态:(默认)0隐藏 1显示不能为空")
private Integer status; private Integer status;
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) // @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "排序不能为空") // @NotNull(message = "排序不能为空")
private Integer sort; // private Integer sort;
@Schema(description = "等级Id列表", requiredMode = Schema.RequiredMode.REQUIRED) // @Schema(description = "等级Id列表", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "等级Id不能为空") // @NotNull(message = "等级Id不能为空")
private List<Long> levelIdList; // private List<Long> levelIdList;
} }

View File

@ -0,0 +1,95 @@
package cn.iocoder.yudao.module.member.controller.admin.membercardtype;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.member.controller.admin.membercardtype.vo.PaidMemberCardTypePageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.membercardtype.vo.PaidMemberCardTypeRespVO;
import cn.iocoder.yudao.module.member.controller.admin.membercardtype.vo.PaidMemberCardTypeSaveReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.membercardtype.PaidMemberCardTypeDO;
import cn.iocoder.yudao.module.member.service.membercardtype.PaidMemberCardTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 会员卡类型")
@RestController
@RequestMapping("paid/member/card/type")
@Validated
public class PaidMemberCardTypeController {
@Resource
private PaidMemberCardTypeService cardService;
@PostMapping("/create")
@Operation(summary = "创建会员卡类型")
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type:create')")
public CommonResult<Long> createcard(@Valid @RequestBody PaidMemberCardTypeSaveReqVO createReqVO) {
return success(cardService.createcard(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新会员卡类型")
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type:update')")
public CommonResult<Boolean> updatecard(@Valid @RequestBody PaidMemberCardTypeSaveReqVO updateReqVO) {
cardService.updatecard(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除会员卡类型")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type: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:paid-member-card-type:query')")
public CommonResult<PaidMemberCardTypeRespVO> getcard(@RequestParam("id") Long id) {
PaidMemberCardTypeDO card = cardService.getcard(id);
return success(BeanUtils.toBean(card, PaidMemberCardTypeRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得会员卡类型分页")
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type:query')")
public CommonResult<PageResult<PaidMemberCardTypeRespVO>> getcardPage(@Valid PaidMemberCardTypePageReqVO pageReqVO) {
PageResult<PaidMemberCardTypeDO> pageResult = cardService.getcardPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, PaidMemberCardTypeRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出会员卡类型 Excel")
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportcardExcel(@Valid PaidMemberCardTypePageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<PaidMemberCardTypeDO> list = cardService.getcardPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "会员卡类型.xls", "数据", PaidMemberCardTypeRespVO.class,
BeanUtils.toBean(list, PaidMemberCardTypeRespVO.class));
}
}

View File

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.member.controller.admin.membercardtype.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 会员卡类型分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PaidMemberCardTypePageReqVO extends PageParam {
@Schema(description = "会员卡名称", example = "李四")
private String name;
@Schema(description = "会员有效期(天)", example = "13455")
private String vid;
@Schema(description = "会员卡原价", example = "32259")
private BigDecimal originalPrice;
@Schema(description = "会员卡优惠价", example = "12301")
private BigDecimal specialPrice;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "会员卡是否禁用", example = "1")
private Integer status;
}

View File

@ -0,0 +1,46 @@
package cn.iocoder.yudao.module.member.controller.admin.membercardtype.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
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;
@Schema(description = "管理后台 - 会员卡类型 Response VO")
@Data
@ExcelIgnoreUnannotated
public class PaidMemberCardTypeRespVO {
@Schema(description = "会员卡id", requiredMode = Schema.RequiredMode.REQUIRED, example = "25594")
@ExcelProperty("会员卡id")
private Long id;
@Schema(description = "会员卡名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@ExcelProperty("会员卡名称")
private String name;
@Schema(description = "会员有效期(天)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13455")
@ExcelProperty("会员有效期(天)")
private String vid;
@Schema(description = "会员卡原价", requiredMode = Schema.RequiredMode.REQUIRED, example = "32259")
@ExcelProperty("会员卡原价")
private BigDecimal originalPrice;
@Schema(description = "会员卡优惠价", example = "12301")
@ExcelProperty("会员卡优惠价")
private BigDecimal specialPrice;
@Schema(description = "排序")
@ExcelProperty("排序")
private Integer sort;
@Schema(description = "会员卡是否禁用", example = "1")
@ExcelProperty(value = "会员卡是否禁用", converter = DictConvert.class)
@DictFormat("common_status") // TODO 代码优化建议设置到对应的 DictTypeConstants 枚举类中
private Integer status;
}

View File

@ -0,0 +1,38 @@
package cn.iocoder.yudao.module.member.controller.admin.membercardtype.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 会员卡类型新增/修改 Request VO")
@Data
public class PaidMemberCardTypeSaveReqVO {
@Schema(description = "会员卡id", requiredMode = Schema.RequiredMode.REQUIRED, example = "25594")
private Long id;
@Schema(description = "会员卡名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@NotEmpty(message = "会员卡名称不能为空")
private String name;
@Schema(description = "会员有效期(天)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13455")
@NotEmpty(message = "会员有效期(天)不能为空")
private String vid;
@Schema(description = "会员卡原价", requiredMode = Schema.RequiredMode.REQUIRED, example = "32259")
@NotNull(message = "会员卡原价不能为空")
private BigDecimal originalPrice;
@Schema(description = "会员卡优惠价", example = "12301")
private BigDecimal specialPrice;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "会员卡是否禁用", example = "1")
private Integer status;
}

View File

@ -28,9 +28,13 @@ public class PaidMemberBenefitDO extends BaseDO {
@TableId @TableId
private Long id; private Long id;
/** /**
* 名称 * 权益名称
*/ */
private String name; private String benName;
/**
* 展示名称
*/
private String showName;
/** /**
* 图标地址 * 图标地址
*/ */

View File

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.member.dal.dataobject.membercardtype;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.math.BigDecimal;
/**
* 会员卡类型 DO
*
* @author 芋道源码
*/
@TableName("paid_member_card_type")
@KeySequence("paid_member_card_type_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PaidMemberCardTypeDO extends BaseDO {
/**
* id
*/
@TableId
private Long id;
/**
* 会员名
*/
private String name;
/**
* 有效期
*/
private String vid;
/**
* 原价
*/
private BigDecimal originalPrice;
/**
* 优惠价
*/
private BigDecimal specialPrice;
/**
* 排序
*/
private String sort;
/**
* 是否禁用
*/
private Boolean status;
}

View File

@ -19,7 +19,8 @@ public interface PaidMemberBenefitMapper extends BaseMapperX<PaidMemberBenefitDO
default PageResult<PaidMemberBenefitDO> selectPage(PaidMemberBenefitPageReqVO reqVO) { default PageResult<PaidMemberBenefitDO> selectPage(PaidMemberBenefitPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PaidMemberBenefitDO>() return selectPage(reqVO, new LambdaQueryWrapperX<PaidMemberBenefitDO>()
.likeIfPresent(PaidMemberBenefitDO::getName, reqVO.getName()) .likeIfPresent(PaidMemberBenefitDO::getBenName, reqVO.getBenName())
.likeIfPresent(PaidMemberBenefitDO::getShowName, reqVO.getShowName())
.eqIfPresent(PaidMemberBenefitDO::getIconUrl, reqVO.getIconUrl()) .eqIfPresent(PaidMemberBenefitDO::getIconUrl, reqVO.getIconUrl())
.eqIfPresent(PaidMemberBenefitDO::getIntro, reqVO.getIntro()) .eqIfPresent(PaidMemberBenefitDO::getIntro, reqVO.getIntro())
.eqIfPresent(PaidMemberBenefitDO::getStatus, reqVO.getStatus()) .eqIfPresent(PaidMemberBenefitDO::getStatus, reqVO.getStatus())

View File

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.member.dal.mysql.membercardtype;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.membercardtype.vo.PaidMemberCardTypePageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.membercardtype.PaidMemberCardTypeDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 会员卡类型 Mapper
*
* @author 芋道源码
*/
@Mapper
public interface PaidMemberCardTypeMapper extends BaseMapperX<PaidMemberCardTypeDO> {
default PageResult<PaidMemberCardTypeDO> selectPage(PaidMemberCardTypePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PaidMemberCardTypeDO>()
.likeIfPresent(PaidMemberCardTypeDO::getName, reqVO.getName())
.eqIfPresent(PaidMemberCardTypeDO::getVid, reqVO.getVid())
.eqIfPresent(PaidMemberCardTypeDO::getOriginalPrice, reqVO.getOriginalPrice())
.eqIfPresent(PaidMemberCardTypeDO::getSpecialPrice, reqVO.getSpecialPrice())
.eqIfPresent(PaidMemberCardTypeDO::getSort, reqVO.getSort())
.eqIfPresent(PaidMemberCardTypeDO::getStatus, reqVO.getStatus())
.orderByDesc(PaidMemberCardTypeDO::getId));
}
}

View File

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.member.service.membercardtype;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.membercardtype.vo.PaidMemberCardTypePageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.membercardtype.vo.PaidMemberCardTypeSaveReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.membercardtype.PaidMemberCardTypeDO;
import javax.validation.Valid;
/**
* 会员卡类型 Service 接口
*
* @author 芋道源码
*/
public interface PaidMemberCardTypeService {
/**
* 创建会员卡类型
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createcard(@Valid PaidMemberCardTypeSaveReqVO createReqVO);
/**
* 更新会员卡类型
*
* @param updateReqVO 更新信息
*/
void updatecard(@Valid PaidMemberCardTypeSaveReqVO updateReqVO);
/**
* 删除会员卡类型
*
* @param id 编号
*/
void deletecard(Long id);
/**
* 获得会员卡类型
*
* @param id 编号
* @return 会员卡类型
*/
PaidMemberCardTypeDO getcard(Long id);
/**
* 获得会员卡类型分页
*
* @param pageReqVO 分页查询
* @return 会员卡类型分页
*/
PageResult<PaidMemberCardTypeDO> getcardPage(PaidMemberCardTypePageReqVO pageReqVO);
}

View File

@ -0,0 +1,71 @@
package cn.iocoder.yudao.module.member.service.membercardtype;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.member.controller.admin.membercardtype.vo.PaidMemberCardTypePageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.membercardtype.vo.PaidMemberCardTypeSaveReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.membercardtype.PaidMemberCardTypeDO;
import cn.iocoder.yudao.module.member.dal.mysql.membercardtype.PaidMemberCardTypeMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.CARD_NOT_EXISTS;
/**
* 会员卡类型 Service 实现类
*
* @author 芋道源码
*/
@Service
@Validated
public class PaidMemberCardTypeServiceImpl implements PaidMemberCardTypeService {
@Resource
private PaidMemberCardTypeMapper cardMapper;
@Override
public Long createcard(PaidMemberCardTypeSaveReqVO createReqVO) {
// 插入
PaidMemberCardTypeDO card = BeanUtils.toBean(createReqVO, PaidMemberCardTypeDO.class);
cardMapper.insert(card);
// 返回
return card.getId();
}
@Override
public void updatecard(PaidMemberCardTypeSaveReqVO updateReqVO) {
// 校验存在
validatecardExists(updateReqVO.getId());
// 更新
PaidMemberCardTypeDO updateObj = BeanUtils.toBean(updateReqVO, PaidMemberCardTypeDO.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 PaidMemberCardTypeDO getcard(Long id) {
return cardMapper.selectById(id);
}
@Override
public PageResult<PaidMemberCardTypeDO> getcardPage(PaidMemberCardTypePageReqVO pageReqVO) {
return cardMapper.selectPage(pageReqVO);
}
}