谁被相关
This commit is contained in:
parent
c84d090ad2
commit
69b2688153
|
@ -0,0 +1,52 @@
|
||||||
|
package com.ruoyi.bst.suit.domain;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 套餐对象 bst_suit
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2025-04-25
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Suit extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long suitId;
|
||||||
|
|
||||||
|
@Excel(name = "商户ID")
|
||||||
|
@ApiModelProperty("商户ID")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Excel(name = "店铺ID")
|
||||||
|
@ApiModelProperty("店铺ID")
|
||||||
|
private Long storeId;
|
||||||
|
|
||||||
|
@Excel(name = "充值金额", readConverterExp = "单=位:元")
|
||||||
|
@ApiModelProperty("充值金额")
|
||||||
|
private BigDecimal rechargeAmount;
|
||||||
|
|
||||||
|
@Excel(name = "爆灯次数")
|
||||||
|
@ApiModelProperty("爆灯次数")
|
||||||
|
private Long lightingNums;
|
||||||
|
|
||||||
|
@Excel(name = "套餐名称")
|
||||||
|
@ApiModelProperty("套餐名称")
|
||||||
|
private String suitName;
|
||||||
|
|
||||||
|
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||||
|
@ApiModelProperty("状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Excel(name = "显示顺序")
|
||||||
|
@ApiModelProperty("显示顺序")
|
||||||
|
private Integer orderNum;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.ruoyi.bst.suit.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SuitQuery extends SuitVO{
|
||||||
|
|
||||||
|
@ApiModelProperty("套餐ID列表")
|
||||||
|
private List<Long> suitIds;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.ruoyi.bst.suit.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SuitVO extends Suit{
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.ruoyi.bst.suit.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.bst.suit.domain.Suit;
|
||||||
|
import com.ruoyi.bst.suit.domain.SuitVO;
|
||||||
|
import com.ruoyi.bst.suit.domain.SuitQuery;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 套餐Mapper接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2025-04-25
|
||||||
|
*/
|
||||||
|
public interface SuitMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询套餐
|
||||||
|
*
|
||||||
|
* @param suitId 套餐主键
|
||||||
|
* @return 套餐
|
||||||
|
*/
|
||||||
|
SuitVO selectSuitBySuitId(Long suitId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询套餐列表
|
||||||
|
*
|
||||||
|
* @param query 套餐
|
||||||
|
* @return 套餐集合
|
||||||
|
*/
|
||||||
|
List<SuitVO> selectSuitList(@Param("query")SuitQuery query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增套餐
|
||||||
|
*
|
||||||
|
* @param suit 套餐
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int insertSuit(Suit suit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增套餐
|
||||||
|
*/
|
||||||
|
int batchInsert(@Param("list") List<? extends Suit> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量修改套餐
|
||||||
|
*/
|
||||||
|
int batchUpdate(@Param("list") List<? extends Suit> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改套餐
|
||||||
|
*
|
||||||
|
* @param suit 套餐
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateSuit(@Param("data") Suit suit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除套餐
|
||||||
|
*
|
||||||
|
* @param suitId 套餐主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteSuitBySuitId(Long suitId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除套餐
|
||||||
|
*
|
||||||
|
* @param suitIds 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSuitBySuitIds(List<Long> suitIds);
|
||||||
|
}
|
|
@ -0,0 +1,259 @@
|
||||||
|
<?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.bst.suit.mapper.SuitMapper">
|
||||||
|
|
||||||
|
<resultMap type="SuitVO" id="SuitResult" autoMapping="true">
|
||||||
|
<result property="suitId" column="suit_id" />
|
||||||
|
<result property="userId" column="user_id" />
|
||||||
|
<result property="storeId" column="store_id" />
|
||||||
|
<result property="rechargeAmount" column="recharge_amount" />
|
||||||
|
<result property="lightingNums" column="lighting_nums" />
|
||||||
|
<result property="suitName" column="suit_name" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="deleted" column="deleted" />
|
||||||
|
<result property="orderNum" column="order_num" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectSuitVo">
|
||||||
|
select
|
||||||
|
bsu.suit_id,
|
||||||
|
bsu.user_id,
|
||||||
|
bsu.store_id,
|
||||||
|
bsu.recharge_amount,
|
||||||
|
bsu.lighting_nums,
|
||||||
|
bsu.suit_name,
|
||||||
|
bsu.status,
|
||||||
|
bsu.create_time,
|
||||||
|
bsu.deleted,
|
||||||
|
bsu.order_num,
|
||||||
|
bs.user_id
|
||||||
|
from bst_suit bsu
|
||||||
|
left join bst_store bs on bsu.store_id = bs.store_id
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<sql id="searchCondition">
|
||||||
|
<if test="query.userId != null "> and bsu.user_id = #{query.userId}</if>
|
||||||
|
<if test="query.storeId != null "> and bsu.store_id = #{query.storeId}</if>
|
||||||
|
<if test="query.rechargeAmount != null "> and bsu.recharge_amount = #{query.rechargeAmount}</if>
|
||||||
|
<if test="query.lightingNums != null "> and bsu.lighting_nums = #{query.lightingNums}</if>
|
||||||
|
<if test="query.suitName != null and query.suitName != ''"> and bsu.suit_name like concat('%', #{query.suitName}, '%')</if>
|
||||||
|
<if test="query.status != null and query.status != ''"> and bsu.status = #{query.status}</if>
|
||||||
|
<if test="query.deleted != null "> and bsu.deleted = #{query.deleted}</if>
|
||||||
|
<if test="query.orderNum != null "> and bsu.order_num = #{query.orderNum}</if>
|
||||||
|
${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope)
|
||||||
|
.userSetAlias("bs.user_id")
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
${query.params.dataScope}
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectSuitList" parameterType="SuitQuery" resultMap="SuitResult">
|
||||||
|
<include refid="selectSuitVo"/>
|
||||||
|
<where>
|
||||||
|
<include refid="searchCondition"/>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectSuitBySuitId" parameterType="Long" resultMap="SuitResult">
|
||||||
|
<include refid="selectSuitVo"/>
|
||||||
|
where suit_id = #{suitId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertSuit" parameterType="Suit" useGeneratedKeys="true" keyProperty="suitId">
|
||||||
|
insert into bst_suit
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="userId != null">user_id,</if>
|
||||||
|
<if test="storeId != null">store_id,</if>
|
||||||
|
<if test="rechargeAmount != null">recharge_amount,</if>
|
||||||
|
<if test="lightingNums != null">lighting_nums,</if>
|
||||||
|
<if test="suitName != null">suit_name,</if>
|
||||||
|
<if test="status != null">status,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="deleted != null">deleted,</if>
|
||||||
|
<if test="orderNum != null">order_num,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="userId != null">#{userId},</if>
|
||||||
|
<if test="storeId != null">#{storeId},</if>
|
||||||
|
<if test="rechargeAmount != null">#{rechargeAmount},</if>
|
||||||
|
<if test="lightingNums != null">#{lightingNums},</if>
|
||||||
|
<if test="suitName != null">#{suitName},</if>
|
||||||
|
<if test="status != null">#{status},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="deleted != null">#{deleted},</if>
|
||||||
|
<if test="orderNum != null">#{orderNum},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert id="batchInsert" parameterType="Suit" useGeneratedKeys="true" keyProperty="suitId">
|
||||||
|
insert into bst_suit
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
user_id,
|
||||||
|
store_id,
|
||||||
|
recharge_amount,
|
||||||
|
lighting_nums,
|
||||||
|
suit_name,
|
||||||
|
status,
|
||||||
|
create_time,
|
||||||
|
deleted,
|
||||||
|
order_num,
|
||||||
|
</trim>
|
||||||
|
values
|
||||||
|
<foreach collection="list" item="i" separator=",">
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="i.userId != null ">#{i.userId},</if>
|
||||||
|
<if test="i.userId == null ">default,</if>
|
||||||
|
<if test="i.storeId != null ">#{i.storeId},</if>
|
||||||
|
<if test="i.storeId == null ">default,</if>
|
||||||
|
<if test="i.rechargeAmount != null ">#{i.rechargeAmount},</if>
|
||||||
|
<if test="i.rechargeAmount == null ">default,</if>
|
||||||
|
<if test="i.lightingNums != null ">#{i.lightingNums},</if>
|
||||||
|
<if test="i.lightingNums == null ">default,</if>
|
||||||
|
<if test="i.suitName != null ">#{i.suitName},</if>
|
||||||
|
<if test="i.suitName == null ">default,</if>
|
||||||
|
<if test="i.status != null ">#{i.status},</if>
|
||||||
|
<if test="i.status == null ">default,</if>
|
||||||
|
<if test="i.createTime != null ">#{i.createTime},</if>
|
||||||
|
<if test="i.createTime == null ">default,</if>
|
||||||
|
<if test="i.deleted != null ">#{i.deleted},</if>
|
||||||
|
<if test="i.deleted == null ">default,</if>
|
||||||
|
<if test="i.orderNum != null ">#{i.orderNum},</if>
|
||||||
|
<if test="i.orderNum == null ">default,</if>
|
||||||
|
</trim>
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="batchUpdate">
|
||||||
|
update bst_suit
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<foreach open="user_id = CASE suit_id" collection="list" item="item" close="END,">
|
||||||
|
<choose>
|
||||||
|
<when test="item.userId != null ">
|
||||||
|
WHEN #{item.suit_id} THEN #{item.userId}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
WHEN #{item.suit_id} THEN `user_id`
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</foreach>
|
||||||
|
<foreach open="store_id = CASE suit_id" collection="list" item="item" close="END,">
|
||||||
|
<choose>
|
||||||
|
<when test="item.storeId != null ">
|
||||||
|
WHEN #{item.suit_id} THEN #{item.storeId}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
WHEN #{item.suit_id} THEN `store_id`
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</foreach>
|
||||||
|
<foreach open="recharge_amount = CASE suit_id" collection="list" item="item" close="END,">
|
||||||
|
<choose>
|
||||||
|
<when test="item.rechargeAmount != null ">
|
||||||
|
WHEN #{item.suit_id} THEN #{item.rechargeAmount}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
WHEN #{item.suit_id} THEN `recharge_amount`
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</foreach>
|
||||||
|
<foreach open="lighting_nums = CASE suit_id" collection="list" item="item" close="END,">
|
||||||
|
<choose>
|
||||||
|
<when test="item.lightingNums != null ">
|
||||||
|
WHEN #{item.suit_id} THEN #{item.lightingNums}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
WHEN #{item.suit_id} THEN `lighting_nums`
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</foreach>
|
||||||
|
<foreach open="suit_name = CASE suit_id" collection="list" item="item" close="END,">
|
||||||
|
<choose>
|
||||||
|
<when test="item.suitName != null ">
|
||||||
|
WHEN #{item.suit_id} THEN #{item.suitName}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
WHEN #{item.suit_id} THEN `suit_name`
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</foreach>
|
||||||
|
<foreach open="status = CASE suit_id" collection="list" item="item" close="END,">
|
||||||
|
<choose>
|
||||||
|
<when test="item.status != null ">
|
||||||
|
WHEN #{item.suit_id} THEN #{item.status}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
WHEN #{item.suit_id} THEN `status`
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</foreach>
|
||||||
|
<foreach open="create_time = CASE suit_id" collection="list" item="item" close="END,">
|
||||||
|
<choose>
|
||||||
|
<when test="item.createTime != null ">
|
||||||
|
WHEN #{item.suit_id} THEN #{item.createTime}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
WHEN #{item.suit_id} THEN `create_time`
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</foreach>
|
||||||
|
<foreach open="deleted = CASE suit_id" collection="list" item="item" close="END,">
|
||||||
|
<choose>
|
||||||
|
<when test="item.deleted != null ">
|
||||||
|
WHEN #{item.suit_id} THEN #{item.deleted}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
WHEN #{item.suit_id} THEN `deleted`
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</foreach>
|
||||||
|
<foreach open="order_num = CASE suit_id" collection="list" item="item" close="END,">
|
||||||
|
<choose>
|
||||||
|
<when test="item.orderNum != null ">
|
||||||
|
WHEN #{item.suit_id} THEN #{item.orderNum}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
WHEN #{item.suit_id} THEN `order_num`
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</foreach>
|
||||||
|
</trim>
|
||||||
|
where suit_id in
|
||||||
|
<foreach item="item" collection="list" open="(" separator="," close=")">
|
||||||
|
#{item.suitId}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="updateSuit" parameterType="Suit">
|
||||||
|
update bst_suit
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<include refid="updateColumns"/>
|
||||||
|
</trim>
|
||||||
|
where suit_id = #{data.suitId}
|
||||||
|
</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.rechargeAmount != null">recharge_amount = #{data.rechargeAmount},</if>
|
||||||
|
<if test="data.lightingNums != null">lighting_nums = #{data.lightingNums},</if>
|
||||||
|
<if test="data.suitName != null">suit_name = #{data.suitName},</if>
|
||||||
|
<if test="data.status != null">status = #{data.status},</if>
|
||||||
|
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||||
|
<if test="data.deleted != null">deleted = #{data.deleted},</if>
|
||||||
|
<if test="data.orderNum != null">order_num = #{data.orderNum},</if>
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<delete id="deleteSuitBySuitId" parameterType="Long">
|
||||||
|
delete from bst_suit where suit_id = #{suitId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteSuitBySuitIds" parameterType="String">
|
||||||
|
delete from bst_suit where suit_id in
|
||||||
|
<foreach item="suitId" collection="array" open="(" separator="," close=")">
|
||||||
|
#{suitId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.ruoyi.bst.suit.service;
|
||||||
|
|
||||||
|
import com.ruoyi.bst.store.domain.Store;
|
||||||
|
import com.ruoyi.bst.suit.domain.Suit;
|
||||||
|
|
||||||
|
public interface SuitConverter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时转换为PO
|
||||||
|
*/
|
||||||
|
Suit toPoByCreate(Suit data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时转换为PO
|
||||||
|
*/
|
||||||
|
Suit toPoByUpdate(Suit data);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
package com.ruoyi.bst.suit.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.bst.store.domain.StoreQuery;
|
||||||
|
import com.ruoyi.bst.store.domain.StoreVO;
|
||||||
|
import com.ruoyi.bst.suit.domain.Suit;
|
||||||
|
import com.ruoyi.bst.suit.domain.SuitVO;
|
||||||
|
import com.ruoyi.bst.suit.domain.SuitQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 套餐Service接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2025-04-25
|
||||||
|
*/
|
||||||
|
public interface SuitService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询套餐
|
||||||
|
*
|
||||||
|
* @param suitId 套餐主键
|
||||||
|
* @return 套餐
|
||||||
|
*/
|
||||||
|
public SuitVO selectSuitBySuitId(Long suitId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询套餐列表
|
||||||
|
*
|
||||||
|
* @param suit 套餐
|
||||||
|
* @return 套餐集合
|
||||||
|
*/
|
||||||
|
public List<SuitVO> selectSuitList(SuitQuery suit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增套餐
|
||||||
|
*
|
||||||
|
* @param suit 套餐
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertSuit(Suit suit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改套餐
|
||||||
|
*
|
||||||
|
* @param suit 套餐
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateSuit(Suit suit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除套餐
|
||||||
|
*
|
||||||
|
* @param suitIds 需要删除的套餐主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSuitBySuitIds(List<Long> suitIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除套餐信息
|
||||||
|
*
|
||||||
|
* @param suitId 套餐主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSuitBySuitId(Long suitId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询店铺
|
||||||
|
*
|
||||||
|
* @param id 店铺主键
|
||||||
|
* @return 店铺
|
||||||
|
*/
|
||||||
|
public SuitVO selectSuitById(Long id, boolean scope);
|
||||||
|
|
||||||
|
default SuitVO selectSuitById(Long id) {
|
||||||
|
return this.selectSuitById(id, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuitVO selectOne(SuitQuery query);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.ruoyi.bst.suit.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface SuitValidator {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断当前用户是否可以编辑套餐
|
||||||
|
* @param storeId 分区ID
|
||||||
|
* @return 是否允许
|
||||||
|
*/
|
||||||
|
boolean canEdit(Long storeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断当前用户是否可以删除套餐
|
||||||
|
* @param storeIds 分区ID
|
||||||
|
* @return 是否允许
|
||||||
|
*/
|
||||||
|
boolean canDeleteAll(List<Long> storeIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断当前用户是否可以选择制定分区
|
||||||
|
* @param storeId 分区ID
|
||||||
|
* @return 是否允许
|
||||||
|
*/
|
||||||
|
boolean canCheckForSuit(Long storeId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.ruoyi.bst.suit.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.bst.store.domain.Store;
|
||||||
|
import com.ruoyi.bst.store.service.StoreConverter;
|
||||||
|
import com.ruoyi.bst.suit.domain.Suit;
|
||||||
|
import com.ruoyi.bst.suit.service.SuitConverter;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SuitConverterImpl implements SuitConverter {
|
||||||
|
@Override
|
||||||
|
public Suit toPoByCreate(Suit data) {
|
||||||
|
if (data == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Suit po = new Suit();
|
||||||
|
// 设置基本信息
|
||||||
|
po.setLightingNums(data.getLightingNums());
|
||||||
|
po.setSuitName(data.getSuitName());
|
||||||
|
po.setRechargeAmount(data.getRechargeAmount());
|
||||||
|
po.setStatus(data.getStatus());
|
||||||
|
return po;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Suit toPoByUpdate(Suit data) {
|
||||||
|
if (data == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Suit po = new Suit();
|
||||||
|
// 设置基本信息
|
||||||
|
po.setSuitId(data.getSuitId());
|
||||||
|
po.setLightingNums(data.getLightingNums());
|
||||||
|
po.setSuitName(data.getSuitName());
|
||||||
|
po.setRechargeAmount(data.getRechargeAmount());
|
||||||
|
po.setStatus(data.getStatus());
|
||||||
|
return po;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,132 @@
|
||||||
|
package com.ruoyi.bst.suit.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.ruoyi.bst.store.domain.StoreQuery;
|
||||||
|
import com.ruoyi.bst.store.domain.StoreVO;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.utils.ServiceUtil;
|
||||||
|
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.ruoyi.bst.suit.mapper.SuitMapper;
|
||||||
|
import com.ruoyi.bst.suit.domain.Suit;
|
||||||
|
import com.ruoyi.bst.suit.domain.SuitVO;
|
||||||
|
import com.ruoyi.bst.suit.domain.SuitQuery;
|
||||||
|
import com.ruoyi.bst.suit.service.SuitService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 套餐Service业务层处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2025-04-25
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SuitServiceImpl implements SuitService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private SuitMapper suitMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询套餐
|
||||||
|
*
|
||||||
|
* @param suitId 套餐主键
|
||||||
|
* @return 套餐
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SuitVO selectSuitBySuitId(Long suitId)
|
||||||
|
{
|
||||||
|
return suitMapper.selectSuitBySuitId(suitId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询套餐列表
|
||||||
|
*
|
||||||
|
* @param suit 套餐
|
||||||
|
* @return 套餐
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SuitVO> selectSuitList(SuitQuery suit)
|
||||||
|
{
|
||||||
|
return suitMapper.selectSuitList(suit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增套餐
|
||||||
|
*
|
||||||
|
* @param suit 套餐
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertSuit(Suit suit)
|
||||||
|
{
|
||||||
|
suit.setCreateTime(DateUtils.getNowDate());
|
||||||
|
return suitMapper.insertSuit(suit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改套餐
|
||||||
|
*
|
||||||
|
* @param suit 套餐
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateSuit(Suit suit)
|
||||||
|
{
|
||||||
|
return suitMapper.updateSuit(suit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除套餐
|
||||||
|
*
|
||||||
|
* @param suitIds 需要删除的套餐主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteSuitBySuitIds(List<Long> suitIds)
|
||||||
|
{
|
||||||
|
return suitMapper.deleteSuitBySuitIds(suitIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除套餐信息
|
||||||
|
*
|
||||||
|
* @param suitId 套餐主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteSuitBySuitId(Long suitId)
|
||||||
|
{
|
||||||
|
return suitMapper.deleteSuitBySuitId(suitId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询店铺
|
||||||
|
*
|
||||||
|
* @param storeId 店铺主键
|
||||||
|
* @return 店铺
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SuitVO selectSuitById(Long storeId, boolean scope)
|
||||||
|
{
|
||||||
|
if (storeId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
SuitQuery query = new SuitQuery();
|
||||||
|
query.setStoreId(storeId);
|
||||||
|
query.setScope(scope);
|
||||||
|
return this.selectOne(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuitVO selectOne(SuitQuery query) {
|
||||||
|
PageHelper.startPage(1, 1);
|
||||||
|
List<SuitVO> list = suitMapper.selectSuitList(query);
|
||||||
|
if(list.isEmpty()) {
|
||||||
|
ServiceUtil.assertion(true,"当前店铺信息不属于您");
|
||||||
|
}
|
||||||
|
return CollectionUtils.firstElement(list);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
package com.ruoyi.bst.suit.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.bst.store.domain.StoreQuery;
|
||||||
|
import com.ruoyi.bst.store.domain.StoreVO;
|
||||||
|
import com.ruoyi.bst.store.service.StoreService;
|
||||||
|
import com.ruoyi.bst.store.service.StoreValidator;
|
||||||
|
import com.ruoyi.bst.suit.domain.SuitQuery;
|
||||||
|
import com.ruoyi.bst.suit.domain.SuitVO;
|
||||||
|
import com.ruoyi.bst.suit.service.SuitService;
|
||||||
|
import com.ruoyi.bst.suit.service.SuitValidator;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SuitValidatorImpl implements SuitValidator {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SuitService suitService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canEdit(Long suidId) {
|
||||||
|
return canOperate(Arrays.asList(suidId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canDeleteAll(List<Long> suitIds) {
|
||||||
|
return canOperate(suitIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canCheckForSuit(Long storeId) {
|
||||||
|
return canOperate(Arrays.asList(storeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否可以操作店铺
|
||||||
|
private boolean canOperate(List<Long> suitIds) {
|
||||||
|
if (SecurityUtils.isSysAdmin()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmptyElement(suitIds)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 查询店铺
|
||||||
|
SuitQuery query = new SuitQuery();
|
||||||
|
query.setSuitIds(suitIds);
|
||||||
|
query.setScope(true);
|
||||||
|
List<SuitVO> SuitVOList = suitService.selectSuitList(query);
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
|
||||||
|
// 判断是否可以操作店铺
|
||||||
|
for (Long suitId : suitIds) {
|
||||||
|
SuitVO suit = SuitVOList.stream()
|
||||||
|
.filter(item -> item.getSuitId().equals(suitId))
|
||||||
|
.findFirst().orElse(null);
|
||||||
|
|
||||||
|
if (suit == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
boolean canOperate = isMch(suit, userId);
|
||||||
|
if (!canOperate) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isMch(SuitVO suit, Long userId) {
|
||||||
|
return suit != null && suit.getUserId() != null && suit.getUserId().equals(userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ public class DeviceController extends BaseController
|
||||||
startPage();
|
startPage();
|
||||||
startOrderBy();
|
startOrderBy();
|
||||||
query.setDeleted(false);
|
query.setDeleted(false);
|
||||||
|
query.setScope(true);
|
||||||
List<DeviceVO> list = deviceService.selectDeviceList(query);
|
List<DeviceVO> list = deviceService.selectDeviceList(query);
|
||||||
deviceIotService.pullDeviceInfoList(list, IotConstants.ONLINE_TYPE_COMMAND);
|
deviceIotService.pullDeviceInfoList(list, IotConstants.ONLINE_TYPE_COMMAND);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
|
|
134
ruoyi-web/src/main/java/com/ruoyi/web/bst/SuitController.java
Normal file
134
ruoyi-web/src/main/java/com/ruoyi/web/bst/SuitController.java
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
package com.ruoyi.web.bst;
|
||||||
|
|
||||||
|
import com.ruoyi.bst.store.service.StoreValidator;
|
||||||
|
import com.ruoyi.bst.suit.domain.Suit;
|
||||||
|
import com.ruoyi.bst.suit.domain.SuitQuery;
|
||||||
|
import com.ruoyi.bst.suit.domain.SuitVO;
|
||||||
|
import com.ruoyi.bst.suit.service.SuitConverter;
|
||||||
|
import com.ruoyi.bst.suit.service.SuitService;
|
||||||
|
import com.ruoyi.bst.suit.service.SuitValidator;
|
||||||
|
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.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.system.user.service.UserValidator;
|
||||||
|
import org.checkerframework.checker.units.qual.A;
|
||||||
|
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.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 套餐Controller
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2025-04-25
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/bst/suit")
|
||||||
|
public class SuitController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private SuitService suitService;
|
||||||
|
@Autowired
|
||||||
|
private UserValidator userValidator;
|
||||||
|
@Autowired
|
||||||
|
private SuitConverter suitConverter;
|
||||||
|
@Autowired
|
||||||
|
private SuitValidator suitValidator;
|
||||||
|
@Autowired
|
||||||
|
private StoreValidator storeValidator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询套餐列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('bst:suit:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(SuitQuery query)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
startOrderBy();
|
||||||
|
query.setDeleted(false);
|
||||||
|
query.setScope(true);
|
||||||
|
List<SuitVO> list = suitService.selectSuitList(query);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出套餐列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('bst:suit:export')")
|
||||||
|
@Log(title = "套餐", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, SuitQuery query)
|
||||||
|
{
|
||||||
|
query.setScope(true);
|
||||||
|
List<SuitVO> list = suitService.selectSuitList(query);
|
||||||
|
ExcelUtil<SuitVO> util = new ExcelUtil<SuitVO>(SuitVO.class);
|
||||||
|
util.exportExcel(response, list, "套餐数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取套餐详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('bst:suit:query')")
|
||||||
|
@GetMapping(value = "/{suitId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("suitId") Long suitId)
|
||||||
|
{
|
||||||
|
return success(suitService.selectSuitById(suitId,true));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增套餐
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('bst:suit:add')")
|
||||||
|
@Log(title = "套餐", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody Suit suit)
|
||||||
|
{
|
||||||
|
// 若不能操作他人,则设置为当前用户
|
||||||
|
if (!userValidator.canView(suit.getUserId())) {
|
||||||
|
suit.setUserId(getUserId());
|
||||||
|
}
|
||||||
|
suit.setUserId(getUserId());
|
||||||
|
suitConverter.toPoByCreate(suit);
|
||||||
|
return toAjax(suitService.insertSuit(suit));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改套餐
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('bst:suit:edit')")
|
||||||
|
@Log(title = "套餐", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody Suit suit)
|
||||||
|
{
|
||||||
|
if (!storeValidator.canEdit(suit.getStoreId())){
|
||||||
|
return AjaxResult.error("您没有权限修改ID为" + suit.getStoreId() + "的商铺信息");
|
||||||
|
}
|
||||||
|
// 若不能操作他人,则不修改用户ID
|
||||||
|
if (!userValidator.canView(suit.getUserId())) {
|
||||||
|
suit.setUserId(null);
|
||||||
|
}
|
||||||
|
suitConverter.toPoByUpdate(suit);
|
||||||
|
return toAjax(suitService.updateSuit(suit));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除套餐
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('bst:suit:remove')")
|
||||||
|
@Log(title = "套餐", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult remove(@PathVariable List<Long> ids)
|
||||||
|
{
|
||||||
|
if (!storeValidator.canDeleteAll(ids)) {
|
||||||
|
return AjaxResult.error("您没有权限删除ID为" + ids + "的店铺信息");
|
||||||
|
}
|
||||||
|
return toAjax(suitService.deleteSuitBySuitIds(ids));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user