This commit is contained in:
PQZ 2025-03-18 17:18:38 +08:00
parent 90b2145b28
commit e1e1fc3b83
7 changed files with 128 additions and 62 deletions

View File

@ -1,62 +1,64 @@
package com.ruoyi.member.controller;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.member.domain.MemberUser;
import com.ruoyi.member.service.IMemberUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.member.vo.MemberUserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 会员Controller
*
*
* @author pqz
* @date 2025-03-17
*/
@RestController
@RequestMapping("/member/member")
public class MemberUserController extends BaseController
{
public class MemberUserController extends BaseController {
@Autowired
private IMemberUserService memberUserService;
/**
* 查询会员列表
*/
@PreAuthorize("@ss.hasPermi('base:user:list')")
* 博主/通告主列表查询
*
* @param memberUser {@link MemberUserVO}
* @param pageNum 分页参数
* @param pageSize 分页参数
* @return com.ruoyi.common.core.domain.AjaxResult
* @author PQZ
* @date 14:58 2025/3/18
**/
@GetMapping("/list")
public AjaxResult list(MemberUser memberUser,
public AjaxResult list(MemberUserVO memberUser,
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize)
{
Page<MemberUser> page = new Page<>(pageNum, pageSize);
IPage<MemberUser> list = memberUserService.queryListPage(memberUser,page);
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<MemberUserVO> page = new Page<>(pageNum, pageSize);
IPage<MemberUserVO> list = memberUserService.queryListPage(memberUser, page);
return success(list);
}
/**
* 导出会员列表
*/
@PreAuthorize("@ss.hasPermi('member:member:export')")
@Log(title = "会员", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, MemberUser memberUser)
{
public void export(HttpServletResponse response, MemberUser memberUser) {
List<MemberUser> list = memberUserService.list();
ExcelUtil<MemberUser> util = new ExcelUtil<MemberUser>(MemberUser.class);
util.exportExcel(response, list, "会员数据");
@ -67,8 +69,7 @@ public class MemberUserController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('member:member:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
public AjaxResult getInfo(@PathVariable("id") String id) {
return success(memberUserService.getById(id));
}
@ -78,8 +79,7 @@ public class MemberUserController extends BaseController
@PreAuthorize("@ss.hasPermi('member:member:add')")
@Log(title = "会员", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MemberUser memberUser)
{
public AjaxResult add(@RequestBody MemberUser memberUser) {
return toAjax(memberUserService.save(memberUser));
}
@ -89,8 +89,7 @@ public class MemberUserController extends BaseController
@PreAuthorize("@ss.hasPermi('member:member:edit')")
@Log(title = "会员", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MemberUser memberUser)
{
public AjaxResult edit(@RequestBody MemberUser memberUser) {
return toAjax(memberUserService.updateById(memberUser));
}
@ -99,9 +98,8 @@ public class MemberUserController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('member:member:remove')")
@Log(title = "会员", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids) {
List<String> list = new ArrayList<>(Arrays.asList(ids));
return toAjax(memberUserService.removeByIds(list));
}

View File

@ -42,6 +42,10 @@ public class MemberCard extends DlBaseEntity
@Excel(name = "会员卡id")
private String cardId;
/** 会员名称 */
@Excel(name = "会员卡名称")
private String cardName;
/** 生效日期(含) */
@Excel(name = "生效日期", readConverterExp = "含=")
private Date startDate;

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.member.domain.MemberUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.member.vo.MemberUserVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -21,11 +22,11 @@ public interface MemberUserMapper extends BaseMapper<MemberUser> {
/**
* 分页查询会员
*
* @param entity {@link MemberUser}
* @param entity {@link MemberUserVO}
* @param page 分页参数
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.ruoyi.member.domain.MemberUser>
* @author PQZ
* @date 15:34 2025/3/17
**/
IPage<MemberUser> queryListPage(@Param("entity") MemberUser entity, Page<MemberUser> page);
IPage<MemberUserVO> queryListPage(@Param("entity") MemberUserVO entity, Page<MemberUserVO> page);
}

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.member.domain.MemberUser;
import com.ruoyi.member.vo.MemberUserVO;
/**
* 会员Service接口
@ -18,12 +19,12 @@ public interface IMemberUserService extends IService<MemberUser> {
/**
* 分页列表查询
*
* @param pageReqVO {@link MemberUser}
* @param pageReqVO {@link MemberUserVO}
* @param page 分页参数
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.ruoyi.member.domain.MemberUser>
* @author PQZ
* @date 15:32 2025/3/17
**/
IPage<MemberUser> queryListPage(MemberUser pageReqVO, Page<MemberUser> page);
IPage<MemberUserVO> queryListPage(MemberUserVO pageReqVO, Page<MemberUserVO> page);
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.member.vo.MemberUserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -28,14 +29,14 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper,MemberUs
/**
* 分页列表查询
*
* @param pageReqVO {@link MemberUser}
* @param pageReqVO {@link MemberUserVO}
* @param page 分页参数
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.ruoyi.member.domain.MemberUser>
* @author PQZ
* @date 15:32 2025/3/17
**/
@Override
public IPage<MemberUser> queryListPage(MemberUser pageReqVO, Page<MemberUser> page) {
public IPage<MemberUserVO> queryListPage(MemberUserVO pageReqVO, Page<MemberUserVO> page) {
return memberUserMapper.queryListPage(pageReqVO, page);
}
}

View File

@ -0,0 +1,20 @@
package com.ruoyi.member.vo;
import com.ruoyi.member.domain.MemberUser;
import lombok.Data;
@Data
public class MemberUserVO extends MemberUser {
/**用户昵称*/
String nickName;
/**账号状态*/
String status;
/**手机号*/
String phonenumber;
/**会员卡名称*/
String memberCardName;
/**头像地址*/
String avatar;
/**会员卡名称*/
String cardName;
}

View File

@ -5,36 +5,77 @@
<mapper namespace="com.ruoyi.member.mapper.MemberUserMapper">
<resultMap type="MemberUser" id="MemberUserResult">
<result property="id" column="id" />
<result property="userType" column="user_type" />
<result property="identityType" column="identity_type" />
<result property="userId" column="user_id" />
<result property="tel" column="tel" />
<result property="tRemaining" column="t_remaining" />
<result property="tTotalNum" column="t_total_num" />
<result property="tFansNum" column="t_fans_num" />
<result property="tOpenDisturb" column="t_open_disturb" />
<result property="tRecipientName" column="t_recipient_name" />
<result property="tRecipientImage" column="t_recipient_image" />
<result property="bPoints" column="b_points" />
<result property="creator" column="creator" />
<result property="createTime" column="create_time" />
<result property="updater" column="updater" />
<result property="updateTime" column="update_time" />
<result property="delFlag" column="del_flag" />
<result property="id" column="id"/>
<result property="userType" column="user_type"/>
<result property="identityType" column="identity_type"/>
<result property="userId" column="user_id"/>
<result property="tel" column="tel"/>
<result property="tRemaining" column="t_remaining"/>
<result property="tTotalNum" column="t_total_num"/>
<result property="tFansNum" column="t_fans_num"/>
<result property="tOpenDisturb" column="t_open_disturb"/>
<result property="tRecipientName" column="t_recipient_name"/>
<result property="tRecipientImage" column="t_recipient_image"/>
<result property="bPoints" column="b_points"/>
<result property="creator" column="creator"/>
<result property="createTime" column="create_time"/>
<result property="updater" column="updater"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
</resultMap>
<sql id="selectMemberUserVo">
select id, user_type, identity_type, user_id, tel, t_remaining, t_total_num, t_fans_num, t_open_disturb, t_recipient_name, t_recipient_image, b_points, creator, create_time, updater, update_time, del_flag from dl_member_user
select id,
user_type,
identity_type,
user_id,
tel,
t_remaining,
t_total_num,
t_fans_num,
t_open_disturb,
t_recipient_name,
t_recipient_image,
b_points,
creator,
create_time,
updater,
update_time,
del_flag
from dl_member_user
</sql>
<select id="queryListPage" parameterType="MemberUser" resultMap="MemberUserResult">
<include refid="selectMemberUserVo"/>
<select id="queryListPage" resultType="com.ruoyi.member.vo.MemberUserVO">
select main.id AS id,
main.user_type AS userType,
main.identity_type AS identityType,
main.user_id AS userId,
main.tel AS tel,
main.t_remaining AS tRemaining,
main.t_total_num AS tTotalNum,
main.t_fans_num AS tFansNum,
main.t_open_disturb AS tOpenDisturb,
main.t_recipient_name AS tRecipientName,
main.t_recipient_image AS tRecipientImage,
main.b_points AS bPoints,
su.nick_name AS nickName,
su.status AS status,
su.avatar AS avatar,
su.phonenumber AS phonenumber,
GROUP_CONCAT(mc.card_name SEPARATOR ', ') AS cardNames
from dl_member_user main
LEFT JOIN sys_user su ON main.user_id = su.user_id AND su.del_flag = 0
LEFT JOIN dl_member_card mc ON main.user_id = mc.user_id AND mc.start_date &lt;= CURDATE() AND mc.end_date &gt;= CURDATE() AND mc.del_flag = 0
<where>
<if test="entity.userType != null and entity.userType != ''"> and user_type = #{entity.userType}</if>
<if test="entity.identityType != null and entity.identityType != ''"> and identity_type = #{entity.identityType}</if>
<if test="entity.bPoints != null "> and b_points = #{entity.bPoints}</if>
main.del_flag = 0
<if test="entity.userType != null and entity.userType != ''">and main.user_type = #{entity.userType}</if>
<if test="entity.identityType != null and entity.identityType != ''">and main.identity_type =
#{entity.identityType}
</if>
<if test="entity.nickName != null and entity.nickName != '' ">and su.nack_name = #{entity.nickName}</if>
</where>
GROUP BY main.user_id
ORDER BY mc.create_time desc
</select>