提交
This commit is contained in:
parent
c1e1df2807
commit
aacf734ba4
|
@ -823,6 +823,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
ServiceUtil.assertion(DeviceStatus.FIXING.getStatus().equals(device.getStatus()), "设备正在维修中,无法使用");
|
||||
|
||||
Long deviceId = device.getDeviceId();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
Boolean result = transactionTemplate.execute(status -> {
|
||||
// 更新数据库时长
|
||||
|
@ -837,7 +838,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
// 物联网设备增加时长
|
||||
if (withIot) {
|
||||
DeviceVO newDevice = selectById(deviceId);
|
||||
long betweenSeconds = Duration.between(LocalDateTime.now(), newDevice.getExpireTime()).getSeconds();
|
||||
long betweenSeconds = Duration.between(now, newDevice.getExpireTime()).getSeconds();
|
||||
if (betweenSeconds > 0) {
|
||||
CommandResponse rechargeResult = iotService.setTime(device, betweenSeconds);
|
||||
ServiceUtil.assertion(!rechargeResult.isSuccess(), "设备充值失败,请检查设备是否在线");
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.ValidateResult;
|
|||
import com.ruoyi.common.core.domain.entity.SmUser;
|
||||
import com.ruoyi.ss.user.domain.SmUserVO;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -59,4 +60,8 @@ public interface UserValidator {
|
|||
* @return
|
||||
*/
|
||||
boolean isAgent(Long userId);
|
||||
|
||||
default boolean isExist(Long userId) {
|
||||
return isExist(Collections.singletonList(userId));
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package com.ruoyi.ss.vip.domain;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* 会员对象 ss_vip
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
@Data
|
||||
public class Vip extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
@Excel(name = "用户ID")
|
||||
@ApiModelProperty("用户ID")
|
||||
private Long userId;
|
||||
|
||||
@Excel(name = "店铺ID")
|
||||
@ApiModelProperty("店铺ID")
|
||||
private Long storeId;
|
||||
|
||||
@Excel(name = "会员等级ID")
|
||||
@ApiModelProperty("会员等级ID")
|
||||
private Long levelId;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "有效期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("有效期")
|
||||
private LocalDateTime expireTime;
|
||||
|
||||
@Excel(name = "过期类型", readConverterExp = "1=永久,2=时限")
|
||||
@ApiModelProperty("过期类型")
|
||||
private String expireType;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.ruoyi.ss.vip.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/12/9
|
||||
*/
|
||||
@Data
|
||||
public class VipQuery extends VipVO{
|
||||
|
||||
@ApiModelProperty("排除ID")
|
||||
private Long excludeId;
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.ruoyi.ss.vip.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/12/9
|
||||
*/
|
||||
@Data
|
||||
public class VipVO extends Vip{
|
||||
|
||||
@ApiModelProperty("用户名称")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("店铺名称")
|
||||
private String storeName;
|
||||
|
||||
@ApiModelProperty("VIP等级名称")
|
||||
private String vipLevelName;
|
||||
|
||||
@ApiModelProperty("店铺商户ID")
|
||||
private String storeMchId;
|
||||
|
||||
@ApiModelProperty("VIP商户ID")
|
||||
private String vipMchId;
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.ruoyi.ss.vip.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.ss.vip.domain.Vip;
|
||||
import com.ruoyi.ss.vip.domain.VipVO;
|
||||
import com.ruoyi.ss.vip.domain.VipQuery;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 会员Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
public interface VipMapper
|
||||
{
|
||||
/**
|
||||
* 查询会员
|
||||
*
|
||||
* @param id 会员主键
|
||||
* @return 会员
|
||||
*/
|
||||
public VipVO selectVipById(Long id);
|
||||
|
||||
/**
|
||||
* 查询会员列表
|
||||
*
|
||||
* @param query 会员
|
||||
* @return 会员集合
|
||||
*/
|
||||
public List<VipVO> selectVipList(@Param("query")VipQuery query);
|
||||
|
||||
/**
|
||||
* 新增会员
|
||||
*
|
||||
* @param vip 会员
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertVip(Vip vip);
|
||||
|
||||
/**
|
||||
* 修改会员
|
||||
*
|
||||
* @param vip 会员
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateVip(@Param("data") Vip vip);
|
||||
|
||||
/**
|
||||
* 删除会员
|
||||
*
|
||||
* @param id 会员主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteVipById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除会员
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteVipByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 查询数量
|
||||
*/
|
||||
int selectCount(@Param("query") VipQuery query);
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ss.vip.mapper.VipMapper">
|
||||
|
||||
<resultMap type="VipVO" id="VipResult" autoMapping="true"/>
|
||||
|
||||
<sql id="selectVipVo">
|
||||
select
|
||||
sv.id,
|
||||
sv.user_id,
|
||||
sv.store_id,
|
||||
sv.level_id,
|
||||
sv.expire_time,
|
||||
sv.create_time,
|
||||
if(su.is_real, su.real_name, su.user_name) as user_name,
|
||||
ss.name as store_name,
|
||||
ss.user_id as store_mch_id,
|
||||
svl.name as vip_level_name,
|
||||
svl.mch_id as vip_mch_id
|
||||
from ss_vip sv
|
||||
left join sm_user su on su.user_id = sv.user_id
|
||||
left join sm_store ss on ss.store_id = sv.store_id
|
||||
left join ss_vip_level svl on svl.id = sv.level_id
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
<if test="query.id != null "> and sv.id = #{query.id}</if>
|
||||
<if test="query.userId != null "> and sv.user_id = #{query.userId}</if>
|
||||
<if test="query.storeId != null "> and sv.store_id = #{query.storeId}</if>
|
||||
<if test="query.levelId != null "> and sv.level_id = #{query.levelId}</if>
|
||||
<if test="query.userName != null and query.userName != ''">and if(su.is_real, su.real_name, su.user_name) like concat('%',#{query.userName},'%')</if>
|
||||
<if test="query.storeName != null and query.storeName != ''">and ss.name like concat('%',#{query.storeName},'%')</if>
|
||||
<if test="query.vipLevelName != null and query.vipLevelName != ''">and svl.name like concat('%',#{query.vipLevelName},'%')</if>
|
||||
<if test="query.excludeId != null">and sv.id != #{query.excludeId}</if>
|
||||
</sql>
|
||||
|
||||
<select id="selectVipList" parameterType="VipQuery" resultMap="VipResult">
|
||||
<include refid="selectVipVo"/>
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectVipById" parameterType="Long" resultMap="VipResult">
|
||||
<include refid="selectVipVo"/>
|
||||
where sv.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectCount" resultType="java.lang.Integer">
|
||||
select count(sv.id)
|
||||
from ss_vip sv
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insertVip" parameterType="Vip" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ss_vip
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="storeId != null">store_id,</if>
|
||||
<if test="levelId != null">level_id,</if>
|
||||
<if test="expireTime != null">expire_time,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="storeId != null">#{storeId},</if>
|
||||
<if test="levelId != null">#{levelId},</if>
|
||||
<if test="expireTime != null">#{expireTime},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateVip" parameterType="Vip">
|
||||
update ss_vip
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<include refid="updateColumns"/>
|
||||
</trim>
|
||||
where id = #{data.id}
|
||||
</update>
|
||||
|
||||
<sql id="updateColumns">
|
||||
<if test="data.userId != null">user_id = #{data.userId},</if>
|
||||
<if test="data.storeId != null">store_id = #{data.storeId},</if>
|
||||
<if test="data.levelId != null">level_id = #{data.levelId},</if>
|
||||
<if test="data.expireTime != null">expire_time = #{data.expireTime},</if>
|
||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteVipById" parameterType="Long">
|
||||
delete from ss_vip where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteVipByIds" parameterType="String">
|
||||
delete from ss_vip where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,70 @@
|
|||
package com.ruoyi.ss.vip.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.ss.vip.domain.Vip;
|
||||
import com.ruoyi.ss.vip.domain.VipVO;
|
||||
import com.ruoyi.ss.vip.domain.VipQuery;
|
||||
|
||||
/**
|
||||
* 会员Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
public interface VipService
|
||||
{
|
||||
/**
|
||||
* 查询会员
|
||||
*
|
||||
* @param id 会员主键
|
||||
* @return 会员
|
||||
*/
|
||||
public VipVO selectVipById(Long id);
|
||||
|
||||
/**
|
||||
* 查询会员列表
|
||||
*
|
||||
* @param vip 会员
|
||||
* @return 会员集合
|
||||
*/
|
||||
public List<VipVO> selectVipList(VipQuery vip);
|
||||
|
||||
/**
|
||||
* 新增会员
|
||||
*
|
||||
* @param vip 会员
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertVip(Vip vip);
|
||||
|
||||
/**
|
||||
* 修改会员
|
||||
*
|
||||
* @param vip 会员
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateVip(Vip vip);
|
||||
|
||||
/**
|
||||
* 批量删除会员
|
||||
*
|
||||
* @param ids 需要删除的会员主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteVipByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除会员信息
|
||||
*
|
||||
* @param id 会员主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteVipById(Long id);
|
||||
|
||||
/**
|
||||
* 查询数量
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
int selectCount(VipQuery query);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.ruoyi.ss.vip.service;
|
||||
|
||||
import com.ruoyi.ss.vip.domain.Vip;
|
||||
import com.ruoyi.ss.vip.domain.VipVO;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/12/9
|
||||
*/
|
||||
public interface VipValidator {
|
||||
|
||||
/**
|
||||
* 新增、更新前校验
|
||||
*/
|
||||
void beforeCheck(Vip data);
|
||||
|
||||
/**
|
||||
* 新增、更新后校验
|
||||
*/
|
||||
void afterCheck(VipVO vo);
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
package com.ruoyi.ss.vip.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.ss.vip.service.VipValidator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.ss.vip.mapper.VipMapper;
|
||||
import com.ruoyi.ss.vip.domain.Vip;
|
||||
import com.ruoyi.ss.vip.domain.VipVO;
|
||||
import com.ruoyi.ss.vip.domain.VipQuery;
|
||||
import com.ruoyi.ss.vip.service.VipService;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
/**
|
||||
* 会员Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
@Service
|
||||
public class VipServiceImpl implements VipService
|
||||
{
|
||||
@Autowired
|
||||
private VipMapper vipMapper;
|
||||
|
||||
@Autowired
|
||||
private VipValidator vipValidator;
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
/**
|
||||
* 查询会员
|
||||
*
|
||||
* @param id 会员主键
|
||||
* @return 会员
|
||||
*/
|
||||
@Override
|
||||
public VipVO selectVipById(Long id)
|
||||
{
|
||||
return vipMapper.selectVipById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询会员列表
|
||||
*
|
||||
* @param vip 会员
|
||||
* @return 会员
|
||||
*/
|
||||
@Override
|
||||
public List<VipVO> selectVipList(VipQuery vip)
|
||||
{
|
||||
return vipMapper.selectVipList(vip);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增会员
|
||||
*
|
||||
* @param vip 会员
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertVip(Vip vip) {
|
||||
vipValidator.beforeCheck(vip);
|
||||
|
||||
vip.setCreateTime(DateUtils.getNowDate());
|
||||
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
int insert = vipMapper.insertVip(vip);
|
||||
|
||||
if (insert == 1) {
|
||||
VipVO vo = this.selectVipById(vip.getId());
|
||||
vipValidator.afterCheck(vo);
|
||||
}
|
||||
|
||||
return insert;
|
||||
});
|
||||
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改会员
|
||||
*
|
||||
* @param vip 会员
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateVip(Vip vip) {
|
||||
vipValidator.beforeCheck(vip);
|
||||
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
int update = vipMapper.updateVip(vip);
|
||||
|
||||
if (update == 1) {
|
||||
VipVO vo = this.selectVipById(vip.getId());
|
||||
vipValidator.afterCheck(vo);
|
||||
}
|
||||
|
||||
return update;
|
||||
});
|
||||
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除会员
|
||||
*
|
||||
* @param ids 需要删除的会员主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteVipByIds(Long[] ids) {
|
||||
return vipMapper.deleteVipByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员信息
|
||||
*
|
||||
* @param id 会员主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteVipById(Long id)
|
||||
{
|
||||
return vipMapper.deleteVipById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectCount(VipQuery query) {
|
||||
return vipMapper.selectCount(query);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.ruoyi.ss.vip.service.impl;
|
||||
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.ss.store.service.StoreValidator;
|
||||
import com.ruoyi.ss.user.service.UserValidator;
|
||||
import com.ruoyi.ss.vip.domain.Vip;
|
||||
import com.ruoyi.ss.vip.domain.VipQuery;
|
||||
import com.ruoyi.ss.vip.domain.VipVO;
|
||||
import com.ruoyi.ss.vip.service.VipService;
|
||||
import com.ruoyi.ss.vip.service.VipValidator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/12/9
|
||||
*/
|
||||
@Service
|
||||
public class VipValidatorImpl implements VipValidator {
|
||||
|
||||
@Autowired
|
||||
private VipService vipService;
|
||||
|
||||
@Autowired
|
||||
private UserValidator userValidator;
|
||||
|
||||
@Autowired
|
||||
private StoreValidator storeValidator;
|
||||
|
||||
/**
|
||||
* 新增、更新前校验
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void beforeCheck(Vip data) {
|
||||
ServiceUtil.assertion(data == null, "参数错误");
|
||||
|
||||
this.checkRepeatUserStore(data.getId(), data.getUserId(), data.getStoreId());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterCheck(VipVO vo) {
|
||||
if (vo == null) {
|
||||
return;
|
||||
}
|
||||
this.checkRepeatUserStore(vo.getId(), vo.getUserId(), vo.getStoreId());
|
||||
|
||||
this.checkMch(vo.getStoreMchId(), vo.getVipMchId());
|
||||
}
|
||||
|
||||
private void checkMch(String storeMchId, String vipMchId) {
|
||||
ServiceUtil.assertion(!Objects.equals(storeMchId, vipMchId), "当前选择的VIP等级与店铺商户不一致");
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户是否重复成为店铺会员
|
||||
* @param id 会员ID
|
||||
* @param userId 用户ID
|
||||
* @param storeId 店铺ID
|
||||
*/
|
||||
private void checkRepeatUserStore(Long id, Long userId, Long storeId) {
|
||||
if (userId == null || storeId == null) {
|
||||
return;
|
||||
}
|
||||
VipQuery query = new VipQuery();
|
||||
query.setUserId(userId);
|
||||
query.setStoreId(storeId);
|
||||
query.setExcludeId(id);
|
||||
ServiceUtil.assertion(vipService.selectCount(query) > 0, "当前用户已经是店铺VIP,无法重复绑定");;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.ruoyi.ss.vipLevel.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.ruoyi.common.core.domain.ValidGroup;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 会员等级对象 ss_vip_level
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
@Data
|
||||
public class VipLevel extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
@Excel(name = "商户ID")
|
||||
@ApiModelProperty("商户ID")
|
||||
@NotNull(message = "商户不允许为空", groups = {ValidGroup.Create.class})
|
||||
private Long mchId;
|
||||
|
||||
@Excel(name = "等级名称")
|
||||
@ApiModelProperty("等级名称")
|
||||
@NotBlank(message = "等级名称不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
|
||||
@Size(max = 30, message = "等级名称长度不能超过30个字符")
|
||||
private String name;
|
||||
|
||||
@Excel(name = "折扣")
|
||||
@ApiModelProperty("折扣")
|
||||
@Min(value = 0, message = "折扣不允许小于0折")
|
||||
@Max(value = 10, message = "折扣不允许大于10折")
|
||||
private BigDecimal discount;
|
||||
|
||||
@Excel(name = "描述文本")
|
||||
@ApiModelProperty("描述文本")
|
||||
@Size(max = 1000, message = "描述不允许超过1000个字符")
|
||||
private String description;
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.ruoyi.ss.vipLevel.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/12/9
|
||||
*/
|
||||
@Data
|
||||
public class VipLevelQuery extends VipLevelVO {
|
||||
|
||||
@ApiModelProperty("ID列表")
|
||||
private List<Long> ids;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.ruoyi.ss.vipLevel.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/12/9
|
||||
*/
|
||||
@Data
|
||||
public class VipLevelVO extends VipLevel{
|
||||
|
||||
@ApiModelProperty("商户名称")
|
||||
private String mchName;
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.ruoyi.ss.vipLevel.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevel;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevelVO;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevelQuery;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 会员等级Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
public interface VipLevelMapper
|
||||
{
|
||||
/**
|
||||
* 查询会员等级
|
||||
*
|
||||
* @param id 会员等级主键
|
||||
* @return 会员等级
|
||||
*/
|
||||
public VipLevelVO selectVipLevelById(Long id);
|
||||
|
||||
/**
|
||||
* 查询会员等级列表
|
||||
*
|
||||
* @param query 会员等级
|
||||
* @return 会员等级集合
|
||||
*/
|
||||
public List<VipLevelVO> selectVipLevelList(@Param("query")VipLevelQuery query);
|
||||
|
||||
/**
|
||||
* 新增会员等级
|
||||
*
|
||||
* @param vipLevel 会员等级
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertVipLevel(VipLevel vipLevel);
|
||||
|
||||
/**
|
||||
* 修改会员等级
|
||||
*
|
||||
* @param vipLevel 会员等级
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateVipLevel(@Param("data") VipLevel vipLevel);
|
||||
|
||||
/**
|
||||
* 删除会员等级
|
||||
*
|
||||
* @param id 会员等级主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteVipLevelById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除会员等级
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteVipLevelByIds(@Param("ids") List<Long> ids);
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ss.vipLevel.mapper.VipLevelMapper">
|
||||
|
||||
<resultMap type="VipLevelVO" id="VipLevelResult" autoMapping="true"/>
|
||||
|
||||
<sql id="selectVipLevelVo">
|
||||
select
|
||||
svl.id,
|
||||
svl.mch_id,
|
||||
svl.name,
|
||||
svl.discount,
|
||||
svl.create_time,
|
||||
svl.description,
|
||||
if (mch.is_real, mch.real_name, mch.user_name) as mch_name
|
||||
from ss_vip_level svl
|
||||
left join sm_user mch on mch.user_id = svl.mch_id
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
<if test="query.id != null "> and svl.id = #{query.id}</if>
|
||||
<if test="query.mchId != null "> and svl.mch_id = #{query.mchId}</if>
|
||||
<if test="query.name != null and query.name != ''"> and svl.name like concat('%', #{query.name}, '%')</if>
|
||||
<if test="query.description != null and query.description != ''"> and svl.description like concat('%', #{query.description}, '%')</if>
|
||||
<if test="query.mchName != null and query.mchName != ''">
|
||||
and if (mch.is_real, mch.real_name, mch.user_name) like concat('%', #{query.mchName}, '%')
|
||||
</if>
|
||||
<if test="query.ids != null and query.ids.size() > 0">
|
||||
and id in
|
||||
<foreach collection="query.ids" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="selectVipLevelList" parameterType="VipLevelQuery" resultMap="VipLevelResult">
|
||||
<include refid="selectVipLevelVo"/>
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectVipLevelById" parameterType="Long" resultMap="VipLevelResult">
|
||||
<include refid="selectVipLevelVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertVipLevel" parameterType="VipLevel" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ss_vip_level
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="mchId != null">mch_id,</if>
|
||||
<if test="name != null and name != ''">`name`,</if>
|
||||
<if test="discount != null">discount,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="description != null">`description`,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="mchId != null">#{mchId},</if>
|
||||
<if test="name != null and name != ''">#{name},</if>
|
||||
<if test="discount != null">#{discount},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="description != null">#{description},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateVipLevel" parameterType="VipLevel">
|
||||
update ss_vip_level
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<include refid="updateColumns"/>
|
||||
</trim>
|
||||
where id = #{data.id}
|
||||
</update>
|
||||
|
||||
<sql id="updateColumns">
|
||||
<if test="data.mchId != null">mch_id = #{data.mchId},</if>
|
||||
<if test="data.name != null and data.name != ''">`name` = #{data.name},</if>
|
||||
<if test="data.discount != null">discount = #{data.discount},</if>
|
||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||
<if test="data.description != null">`description` = #{data.description},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteVipLevelById" parameterType="Long">
|
||||
delete from ss_vip_level where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteVipLevelByIds" parameterType="String">
|
||||
delete from ss_vip_level where id in
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,65 @@
|
|||
package com.ruoyi.ss.vipLevel.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevel;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevelVO;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevelQuery;
|
||||
|
||||
/**
|
||||
* 会员等级Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
public interface VipLevelService
|
||||
{
|
||||
/**
|
||||
* 查询会员等级
|
||||
*
|
||||
* @param id 会员等级主键
|
||||
* @return 会员等级
|
||||
*/
|
||||
public VipLevelVO selectVipLevelById(Long id);
|
||||
|
||||
/**
|
||||
* 查询会员等级列表
|
||||
*
|
||||
* @param vipLevel 会员等级
|
||||
* @return 会员等级集合
|
||||
*/
|
||||
public List<VipLevelVO> selectVipLevelList(VipLevelQuery vipLevel);
|
||||
|
||||
/**
|
||||
* 新增会员等级
|
||||
*
|
||||
* @param vipLevel 会员等级
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertVipLevel(VipLevel vipLevel);
|
||||
|
||||
/**
|
||||
* 修改会员等级
|
||||
*
|
||||
* @param vipLevel 会员等级
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateVipLevel(VipLevel vipLevel);
|
||||
|
||||
/**
|
||||
* 批量删除会员等级
|
||||
*
|
||||
* @param ids 需要删除的会员等级主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteVipLevelByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 删除会员等级信息
|
||||
*
|
||||
* @param id 会员等级主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteVipLevelById(Long id);
|
||||
|
||||
List<VipLevelVO> selectByIds(List<Long> ids);
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.ruoyi.ss.vipLevel.service;
|
||||
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevelVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/12/9
|
||||
*/
|
||||
public interface VipLevelValidator {
|
||||
|
||||
/**
|
||||
* 用户是否可见
|
||||
*/
|
||||
boolean canView(VipLevelVO vo, Long userId);
|
||||
|
||||
/**
|
||||
* 用户是否可操作
|
||||
*/
|
||||
boolean canOpera(Long id, Long userId);
|
||||
|
||||
/**
|
||||
* 用户是否可操作全部
|
||||
*/
|
||||
boolean canOperaAll(List<Long> ids, Long userId);
|
||||
|
||||
/**
|
||||
* 是否允许操作
|
||||
*/
|
||||
boolean canOpera(VipLevelVO vo, Long userId);
|
||||
|
||||
/**
|
||||
* 删除前校验
|
||||
*/
|
||||
void beforeDel(List<Long> ids);
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package com.ruoyi.ss.vipLevel.service.impl;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.ss.vipLevel.service.VipLevelValidator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.ss.vipLevel.mapper.VipLevelMapper;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevel;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevelVO;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevelQuery;
|
||||
import com.ruoyi.ss.vipLevel.service.VipLevelService;
|
||||
|
||||
/**
|
||||
* 会员等级Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
@Service
|
||||
public class VipLevelServiceImpl implements VipLevelService
|
||||
{
|
||||
@Autowired
|
||||
private VipLevelMapper vipLevelMapper;
|
||||
|
||||
@Autowired
|
||||
private VipLevelValidator vipLevelValidator;
|
||||
|
||||
/**
|
||||
* 查询会员等级
|
||||
*
|
||||
* @param id 会员等级主键
|
||||
* @return 会员等级
|
||||
*/
|
||||
@Override
|
||||
public VipLevelVO selectVipLevelById(Long id)
|
||||
{
|
||||
return vipLevelMapper.selectVipLevelById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询会员等级列表
|
||||
*
|
||||
* @param vipLevel 会员等级
|
||||
* @return 会员等级
|
||||
*/
|
||||
@Override
|
||||
public List<VipLevelVO> selectVipLevelList(VipLevelQuery vipLevel)
|
||||
{
|
||||
return vipLevelMapper.selectVipLevelList(vipLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增会员等级
|
||||
*
|
||||
* @param vipLevel 会员等级
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertVipLevel(VipLevel vipLevel)
|
||||
{
|
||||
vipLevel.setCreateTime(DateUtils.getNowDate());
|
||||
return vipLevelMapper.insertVipLevel(vipLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改会员等级
|
||||
*
|
||||
* @param vipLevel 会员等级
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateVipLevel(VipLevel vipLevel)
|
||||
{
|
||||
return vipLevelMapper.updateVipLevel(vipLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除会员等级
|
||||
*
|
||||
* @param ids 需要删除的会员等级主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteVipLevelByIds(List<Long> ids) {
|
||||
vipLevelValidator.beforeDel(ids);
|
||||
|
||||
return vipLevelMapper.deleteVipLevelByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员等级信息
|
||||
*
|
||||
* @param id 会员等级主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteVipLevelById(Long id)
|
||||
{
|
||||
return vipLevelMapper.deleteVipLevelById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VipLevelVO> selectByIds(List<Long> ids) {
|
||||
if (CollectionUtils.isEmptyElement(ids)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
VipLevelQuery query = new VipLevelQuery();
|
||||
query.setIds(ids);
|
||||
return this.selectVipLevelList(query);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.ruoyi.ss.vipLevel.service.impl;
|
||||
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.ss.vip.service.VipService;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevelVO;
|
||||
import com.ruoyi.ss.vipLevel.service.VipLevelService;
|
||||
import com.ruoyi.ss.vipLevel.service.VipLevelValidator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/12/9
|
||||
*/
|
||||
@Service
|
||||
public class VipLevelValidatorImpl implements VipLevelValidator {
|
||||
|
||||
@Autowired
|
||||
private VipLevelService vipLevelService;
|
||||
|
||||
@Autowired
|
||||
private VipService vipService;
|
||||
|
||||
/**
|
||||
* 用户是否可见
|
||||
*
|
||||
* @param vo
|
||||
* @param userId
|
||||
*/
|
||||
@Override
|
||||
public boolean canView(VipLevelVO vo, Long userId) {
|
||||
return vo != null && userId != null && Objects.equals(vo.getMchId(), userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOpera(Long id, Long userId) {
|
||||
if (userId == null || id == null) {
|
||||
return false;
|
||||
}
|
||||
VipLevelVO vo = vipLevelService.selectVipLevelById(id);
|
||||
return canOpera(vo, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOperaAll(List<Long> ids, Long userId) {
|
||||
if (CollectionUtils.isEmptyElement(ids) || userId == null) {
|
||||
return false;
|
||||
}
|
||||
List<VipLevelVO> list = vipLevelService.selectByIds(ids);
|
||||
for (VipLevelVO vo : list) {
|
||||
if (!this.canOpera(vo, userId)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOpera(VipLevelVO vo, Long userId) {
|
||||
return vo != null && userId != null && Objects.equals(vo.getMchId(), userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeDel(List<Long> ids) {
|
||||
ServiceUtil.assertion(CollectionUtils.isEmptyElement(ids), "参数错误");
|
||||
|
||||
// TODO
|
||||
// vipService.selectVip
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.ruoyi.web.controller.mch;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.ValidGroup;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevel;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevelQuery;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevelVO;
|
||||
import com.ruoyi.ss.vipLevel.service.VipLevelService;
|
||||
import com.ruoyi.ss.vipLevel.service.VipLevelValidator;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/12/9
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/mch/vipLevel")
|
||||
public class MchVipLevelController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private VipLevelService vipLevelService;
|
||||
|
||||
@Autowired
|
||||
private VipLevelValidator vipLevelValidator;
|
||||
|
||||
@ApiOperation("商户获取VIP等级列表")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(VipLevelQuery query) {
|
||||
startPage();
|
||||
query.setMchId(getUserId());
|
||||
List<VipLevelVO> list = vipLevelService.selectVipLevelList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@ApiModelProperty("获取VIP等级明细")
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult getById(@PathVariable Long id) {
|
||||
VipLevelVO vo = vipLevelService.selectVipLevelById(id);
|
||||
if (!vipLevelValidator.canView(vo, getUserId())) {
|
||||
return error("您无权查看该信息");
|
||||
}
|
||||
return success(vo);
|
||||
}
|
||||
|
||||
@ApiModelProperty("新增VIP等级")
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody @Validated(ValidGroup.FrontCreate.class) VipLevel data) {
|
||||
data.setMchId(getUserId());
|
||||
return toAjax(vipLevelService.insertVipLevel(data));
|
||||
}
|
||||
|
||||
@ApiModelProperty("修改VIP等级")
|
||||
@PutMapping
|
||||
public AjaxResult update(@RequestBody @Validated(ValidGroup.FrontUpdate.class) VipLevel data) {
|
||||
if (!vipLevelValidator.canOpera(data.getId(), getUserId())) {
|
||||
return error("您无权操作该数据");
|
||||
}
|
||||
return toAjax(vipLevelService.updateVipLevel(data));
|
||||
}
|
||||
|
||||
@ApiModelProperty("删除VIP等级")
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult del(@PathVariable List<Long> ids) {
|
||||
if (!vipLevelValidator.canOperaAll(ids, getUserId())) {
|
||||
return error("您无权操作该数据");
|
||||
}
|
||||
return toAjax(vipLevelService.deleteVipLevelByIds(ids));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package com.ruoyi.web.controller.ss;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
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.ss.vip.domain.Vip;
|
||||
import com.ruoyi.ss.vip.domain.VipVO;
|
||||
import com.ruoyi.ss.vip.domain.VipQuery;
|
||||
import com.ruoyi.ss.vip.service.VipService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 会员Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ss/vip")
|
||||
public class VipController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private VipService vipService;
|
||||
|
||||
/**
|
||||
* 查询会员列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vip:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(VipQuery query)
|
||||
{
|
||||
startPage();
|
||||
startOrderBy();
|
||||
List<VipVO> list = vipService.selectVipList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出会员列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vip:export')")
|
||||
@Log(title = "会员", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, VipQuery query)
|
||||
{
|
||||
List<VipVO> list = vipService.selectVipList(query);
|
||||
ExcelUtil<VipVO> util = new ExcelUtil<VipVO>(VipVO.class);
|
||||
util.exportExcel(response, list, "会员数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vip:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(vipService.selectVipById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增会员
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vip:add')")
|
||||
@Log(title = "会员", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Vip vip)
|
||||
{
|
||||
return toAjax(vipService.insertVip(vip));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改会员
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vip:edit')")
|
||||
@Log(title = "会员", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Vip vip) {
|
||||
return toAjax(vipService.updateVip(vip));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vip:remove')")
|
||||
@Log(title = "会员", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(vipService.deleteVipByIds(ids));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
package com.ruoyi.web.controller.ss;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.common.core.domain.ValidGroup;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
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.ss.vipLevel.domain.VipLevel;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevelVO;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevelQuery;
|
||||
import com.ruoyi.ss.vipLevel.service.VipLevelService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 会员等级Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ss/vipLevel")
|
||||
public class VipLevelController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private VipLevelService vipLevelService;
|
||||
|
||||
/**
|
||||
* 查询会员等级列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vipLevel:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(VipLevelQuery query)
|
||||
{
|
||||
startPage();
|
||||
startOrderBy();
|
||||
List<VipLevelVO> list = vipLevelService.selectVipLevelList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询会员等级列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vipLevel:list')")
|
||||
@PostMapping("/listByIds")
|
||||
public AjaxResult list(@RequestBody List<Long> ids)
|
||||
{
|
||||
VipLevelQuery query = new VipLevelQuery();
|
||||
query.setIds(ids);
|
||||
List<VipLevelVO> list = vipLevelService.selectVipLevelList(query);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出会员等级列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vipLevel:export')")
|
||||
@Log(title = "会员等级", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, VipLevelQuery query)
|
||||
{
|
||||
List<VipLevelVO> list = vipLevelService.selectVipLevelList(query);
|
||||
ExcelUtil<VipLevelVO> util = new ExcelUtil<VipLevelVO>(VipLevelVO.class);
|
||||
util.exportExcel(response, list, "会员等级数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员等级详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vipLevel:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(vipLevelService.selectVipLevelById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增会员等级
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vipLevel:add')")
|
||||
@Log(title = "会员等级", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) VipLevel vipLevel)
|
||||
{
|
||||
return toAjax(vipLevelService.insertVipLevel(vipLevel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改会员等级
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vipLevel:edit')")
|
||||
@Log(title = "会员等级", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) VipLevel vipLevel)
|
||||
{
|
||||
return toAjax(vipLevelService.updateVipLevel(vipLevel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员等级
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vipLevel:remove')")
|
||||
@Log(title = "会员等级", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable List<Long> ids)
|
||||
{
|
||||
return toAjax(vipLevelService.deleteVipLevelByIds(ids));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user