店铺相关模块
This commit is contained in:
parent
c9a65f993c
commit
ea53005a37
|
@ -7,6 +7,9 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 卡座对象 bst_booth
|
||||
*
|
||||
|
@ -22,10 +25,12 @@ public class Booth extends BaseEntity
|
|||
|
||||
@Excel(name = "分区ID")
|
||||
@ApiModelProperty("分区ID")
|
||||
@NotNull(message = "分区ID不能为空")
|
||||
private Long partId;
|
||||
|
||||
@Excel(name = "卡座名称")
|
||||
@ApiModelProperty("卡座名称")
|
||||
@NotBlank(message = "卡座名称不能为空")
|
||||
private String boothName;
|
||||
|
||||
@Excel(name = "分区图片")
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
package com.ruoyi.bst.booth.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BoothQuery extends Booth {
|
||||
public class BoothQuery extends BoothVO {
|
||||
|
||||
@ApiModelProperty("卡座ID列表")
|
||||
private List<Long> ids;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
package com.ruoyi.bst.booth.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BoothVO extends Booth{
|
||||
|
||||
@Excel(name = "分区名称")
|
||||
@ApiModelProperty("分区名称")
|
||||
private String partName;
|
||||
|
||||
}
|
||||
|
|
|
@ -14,18 +14,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<sql id="selectBoothVo">
|
||||
select
|
||||
booth_id,
|
||||
part_id,
|
||||
booth_name,
|
||||
picture,
|
||||
create_time
|
||||
from bst_booth
|
||||
bb.booth_id,
|
||||
bb.part_id,
|
||||
bb.booth_name,
|
||||
bb.picture,
|
||||
bb.create_time,
|
||||
bp.part_name as partName,
|
||||
bs.user_id
|
||||
<include refid="searchTables"/>
|
||||
</sql>
|
||||
|
||||
<sql id="searchTables">
|
||||
from bst_booth bb
|
||||
left join bst_part bp on bp.part_id = bb.part_id
|
||||
left join bst_floor bf on bp.floor_id = bf.floor_id
|
||||
left join bst_store bs on bf.store_id = bs.store_id
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
<if test="query.partId != null "> and part_id = #{query.partId}</if>
|
||||
<if test="query.boothName != null and query.boothName != ''"> and booth_name like concat('%', #{query.boothName}, '%')</if>
|
||||
<if test="query.picture != null and query.picture != ''"> and picture = #{query.picture}</if>
|
||||
<if test="query.partName != null and query.partName != ''"> and bp.part_name like concat('%', #{query.partName}, '%') </if>
|
||||
${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope)
|
||||
.userSetAlias("bs.user_id")
|
||||
.build()
|
||||
}
|
||||
${query.params.dataScope}
|
||||
</sql>
|
||||
|
||||
|
@ -41,6 +55,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where booth_id = #{boothId}
|
||||
</select>
|
||||
|
||||
<!-- selectIdByQuery -->
|
||||
<select id="selectIdByQuery" resultType="Long">
|
||||
select bb.booth_id <include refid="searchTables"/>
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insertBooth" parameterType="Booth" useGeneratedKeys="true" keyProperty="boothId">
|
||||
insert into bst_booth
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
@ -151,7 +173,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<delete id="deleteBoothByBoothIds" parameterType="String">
|
||||
delete from bst_booth where booth_id in
|
||||
<foreach item="boothId" collection="array" open="(" separator="," close=")">
|
||||
<foreach item="boothId" collection="ids" open="(" separator="," close=")">
|
||||
#{boothId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
|
|
@ -7,6 +7,9 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.TreeEntity;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 分区对象 bst_part
|
||||
*
|
||||
|
@ -20,12 +23,14 @@ public class Part extends TreeEntity
|
|||
|
||||
private Long partId;
|
||||
|
||||
@Excel(name = "店铺ID")
|
||||
@ApiModelProperty("店铺ID")
|
||||
private Long storeId;
|
||||
@Excel(name = "楼层ID")
|
||||
@ApiModelProperty("楼层ID")
|
||||
@NotNull(message = "楼层ID不能为空")
|
||||
private Long floorId;
|
||||
|
||||
@Excel(name = "分区名称")
|
||||
@ApiModelProperty("分区名称")
|
||||
@NotBlank(message = "分区名称不能为空")
|
||||
private String partName;
|
||||
|
||||
@Excel(name = "分区图片")
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
package com.ruoyi.bst.part.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PartQuery extends Part {
|
||||
public class PartQuery extends PartVO {
|
||||
|
||||
@ApiModelProperty("分区ID列表")
|
||||
private List<Long> ids;
|
||||
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import lombok.Data;
|
|||
@Data
|
||||
public class PartVO extends Part{
|
||||
|
||||
@Excel(name = "店铺名称")
|
||||
@ApiModelProperty("店铺名称")
|
||||
private Long storeName;
|
||||
@Excel(name = "楼层名称")
|
||||
@ApiModelProperty("楼层名称")
|
||||
private String floorName;
|
||||
|
||||
}
|
||||
|
|
|
@ -70,5 +70,7 @@ public interface PartMapper
|
|||
* @param partIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePartByPartIds(Long[] partIds);
|
||||
public int deletePartByPartIds(@Param("ids") List<Long> partIds);
|
||||
|
||||
public List<Long> selectIdByQuery(@Param("query") PartQuery query);
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<resultMap type="PartVO" id="PartResult" autoMapping="true">
|
||||
<result property="partId" column="part_id" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="storeId" column="store_id" />
|
||||
<result property="floorId" column="floor_id" />
|
||||
<result property="partName" column="part_name" />
|
||||
<result property="picture" column="picture" />
|
||||
<result property="createTime" column="create_time" />
|
||||
|
@ -16,21 +15,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<sql id="selectPartVo">
|
||||
select
|
||||
bp.part_id,
|
||||
bp.parent_id,
|
||||
bp.store_id,
|
||||
bp.floor_id,
|
||||
bp.part_name,
|
||||
bp.picture,
|
||||
bp.create_time,
|
||||
bs.store_name
|
||||
bs.store_name,
|
||||
bs.user_id,
|
||||
bf.floor_name as floorName
|
||||
<include refid="searchTables"/>
|
||||
</sql>
|
||||
|
||||
<sql id="searchTables">
|
||||
from bst_part bp
|
||||
left join bst_store bs on bp.store_id = bs.store_id
|
||||
left join bst_floor bf on bp.floor_id = bf.floor_id
|
||||
left join bst_store bs on bf.store_id = bs.store_id
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
<if test="query.parentId != null "> and parent_id = #{query.parentId}</if>
|
||||
<if test="query.storeId != null "> and store_id = #{query.storeId}</if>
|
||||
|
||||
<if test="query.floorId != null "> and floor_id = #{query.floor_id}</if>
|
||||
<if test="query.partName != null and query.partName != ''"> and part_name like concat('%', #{query.partName}, '%')</if>
|
||||
<if test="query.picture != null and query.picture != ''"> and picture = #{query.picture}</if>
|
||||
<if test="query.floorName != null and query.floorName != ''"> and bf.floor_name like concat('%', #{query.floorName}, '%') </if>
|
||||
${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope)
|
||||
.userSetAlias("bs.user_id")
|
||||
.build()
|
||||
}
|
||||
${query.params.dataScope}
|
||||
</sql>
|
||||
|
||||
|
@ -43,21 +53,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="selectPartByPartId" parameterType="Long" resultMap="PartResult">
|
||||
<include refid="selectPartVo"/>
|
||||
where part_id = #{partId}
|
||||
where bp.part_id = #{partId}
|
||||
</select>
|
||||
|
||||
<!-- selectIdByQuery -->
|
||||
<select id="selectIdByQuery" resultType="Long">
|
||||
select bp.part_id <include refid="searchTables"/>
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insertPart" parameterType="Part" useGeneratedKeys="true" keyProperty="partId">
|
||||
insert into bst_part
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="storeId != null">store_id,</if>
|
||||
<if test="floorId != null">floor_id,</if>
|
||||
<if test="partName != null">part_name,</if>
|
||||
<if test="picture != null">picture,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="storeId != null">#{storeId},</if>
|
||||
<if test="floorId != null">#{floorId},</if>
|
||||
<if test="partName != null">#{partName},</if>
|
||||
<if test="picture != null">#{picture},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
|
@ -67,7 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<insert id="batchInsert" parameterType="Part" useGeneratedKeys="true" keyProperty="partId">
|
||||
insert into bst_part
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
parent_id,
|
||||
floor_id
|
||||
store_id,
|
||||
part_name,
|
||||
picture,
|
||||
|
@ -76,10 +92,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
values
|
||||
<foreach collection="list" item="i" separator=",">
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="i.parentId != null ">#{i.parentId},</if>
|
||||
<if test="i.parentId == null ">default,</if>
|
||||
<if test="i.storeId != null ">#{i.storeId},</if>
|
||||
<if test="i.storeId == null ">default,</if>
|
||||
<if test="i.floorId != null ">#{i.floorId},</if>
|
||||
<if test="i.floorId == null ">default,</if>
|
||||
<if test="i.partName != null ">#{i.partName},</if>
|
||||
<if test="i.partName == null ">default,</if>
|
||||
<if test="i.picture != null ">#{i.picture},</if>
|
||||
|
@ -93,20 +107,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<update id="batchUpdate">
|
||||
update bst_part
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<foreach open="parent_id = CASE part_id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.parentId != null ">
|
||||
WHEN #{item.part_id} THEN #{item.parentId}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.part_id} THEN `parent_id`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="store_id = CASE part_id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.storeId != null ">
|
||||
WHEN #{item.part_id} THEN #{item.storeId}
|
||||
<when test="item.floorId != null ">
|
||||
WHEN #{item.part_id} THEN #{item.floorId}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.part_id} THEN `store_id`
|
||||
|
@ -159,8 +163,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</update>
|
||||
|
||||
<sql id="updateColumns">
|
||||
<if test="data.parentId != null">parent_id = #{data.parentId},</if>
|
||||
<if test="data.storeId != null">store_id = #{data.storeId},</if>
|
||||
<if test="data.floorId != null">store_id = #{data.floorId},</if>
|
||||
<if test="data.partName != null">part_name = #{data.partName},</if>
|
||||
<if test="data.picture != null">picture = #{data.picture},</if>
|
||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||
|
@ -172,7 +175,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<delete id="deletePartByPartIds" parameterType="String">
|
||||
delete from bst_part where part_id in
|
||||
<foreach item="partId" collection="array" open="(" separator="," close=")">
|
||||
<foreach item="partId" collection="ids" open="(" separator="," close=")">
|
||||
#{partId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
|
|
@ -16,10 +16,16 @@ public interface PartService
|
|||
/**
|
||||
* 查询分区
|
||||
*
|
||||
* @param partId 分区主键
|
||||
* @param id 分区主键
|
||||
* @return 分区
|
||||
*/
|
||||
public PartVO selectPartByPartId(Long partId);
|
||||
public PartVO selectPartById(Long id, boolean scope);
|
||||
|
||||
default PartVO selectPartById(Long id) {
|
||||
return this.selectPartById(id, false);
|
||||
}
|
||||
|
||||
public PartVO selectOne(PartQuery query);
|
||||
|
||||
/**
|
||||
* 查询分区列表
|
||||
|
@ -51,7 +57,7 @@ public interface PartService
|
|||
* @param partIds 需要删除的分区主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePartByPartIds(Long[] partIds);
|
||||
public int deletePartByPartIds(List<Long> partIds);
|
||||
|
||||
/**
|
||||
* 删除分区信息
|
||||
|
@ -60,4 +66,6 @@ public interface PartService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deletePartByPartId(Long partId);
|
||||
|
||||
Long getUserId(Part part);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package com.ruoyi.bst.part.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PartValidator {
|
||||
|
||||
|
||||
/**
|
||||
* 判断当前用户是否可以选择制定分区
|
||||
* @param partId 分区ID
|
||||
* @return 是否允许
|
||||
*/
|
||||
boolean canCheckForPart(Long partId);
|
||||
|
||||
|
||||
/**
|
||||
* 当前用户是否可以编辑分区
|
||||
* @param partId 分区ID
|
||||
* @return 是否可以编辑
|
||||
*/
|
||||
boolean canEdit(Long partId);
|
||||
|
||||
/**
|
||||
* 当前用户是否可以删除分区
|
||||
* @param partIds 分区ID列表
|
||||
* @return 是否可以删除
|
||||
*/
|
||||
boolean canDeleteAll(List<Long> partIds);
|
||||
}
|
|
@ -1,7 +1,12 @@
|
|||
package com.ruoyi.bst.part.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.ruoyi.bst.store.service.StoreService;
|
||||
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.part.mapper.PartMapper;
|
||||
|
@ -21,17 +26,32 @@ public class PartServiceImpl implements PartService
|
|||
{
|
||||
@Autowired
|
||||
private PartMapper partMapper;
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
/**
|
||||
* 查询分区
|
||||
*
|
||||
* @param partId 分区主键
|
||||
* @param id 分区主键
|
||||
* @return 分区
|
||||
*/
|
||||
@Override
|
||||
public PartVO selectPartByPartId(Long partId)
|
||||
public PartVO selectPartById(Long id, boolean scope)
|
||||
{
|
||||
return partMapper.selectPartByPartId(partId);
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
PartQuery query = new PartQuery();
|
||||
query.setPartId(id);
|
||||
query.setScope(scope);
|
||||
return this.selectOne(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PartVO selectOne(PartQuery query) {
|
||||
PageHelper.startPage(1, 1);
|
||||
List<PartVO> list = partMapper.selectPartList(query);
|
||||
return CollectionUtils.firstElement(list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,7 +98,7 @@ public class PartServiceImpl implements PartService
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePartByPartIds(Long[] partIds)
|
||||
public int deletePartByPartIds(List<Long> partIds)
|
||||
{
|
||||
return partMapper.deletePartByPartIds(partIds);
|
||||
}
|
||||
|
@ -94,4 +114,9 @@ public class PartServiceImpl implements PartService
|
|||
{
|
||||
return partMapper.deletePartByPartId(partId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getUserId(Part part) {
|
||||
return storeService.selectStoreById(part.getFloorId()).getUserId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package com.ruoyi.bst.part.service.impl;
|
||||
|
||||
import com.ruoyi.bst.part.domain.PartQuery;
|
||||
import com.ruoyi.bst.part.mapper.PartMapper;
|
||||
import com.ruoyi.bst.part.service.PartValidator;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class PartValidatorImpl implements PartValidator {
|
||||
|
||||
private final PartMapper partMapper;
|
||||
|
||||
public PartValidatorImpl(PartMapper partMapper) {
|
||||
this.partMapper = partMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCheckForPart(Long partId) {
|
||||
return canOperate(Arrays.asList(partId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEdit(Long partId) {
|
||||
return canOperate(Arrays.asList(partId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDeleteAll(List<Long> partIds) {
|
||||
return canOperate(partIds);
|
||||
}
|
||||
|
||||
// 是否可以操作运营区
|
||||
private boolean canOperate(List<Long> partIds) {
|
||||
return hasPermission(partIds);
|
||||
}
|
||||
|
||||
// 是否有运营区权限
|
||||
private boolean hasPermission(List<Long> partIds) {
|
||||
if (SecurityUtils.isSysAdmin()) {
|
||||
return true;
|
||||
}
|
||||
if (CollectionUtils.isEmptyElement(partIds)) {
|
||||
return true;
|
||||
}
|
||||
// 查询运营区
|
||||
PartQuery query = new PartQuery();
|
||||
query.setIds(partIds);
|
||||
query.setScope(true);
|
||||
List<Long> partIdList = partMapper.selectIdByQuery(query);
|
||||
return new HashSet<>(partIdList).containsAll(partIds);
|
||||
}
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import java.time.LocalDateTime;
|
|||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.core.validate.ValidGroup;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
@ -12,6 +13,9 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 店铺对象 bst_store
|
||||
*
|
||||
|
@ -31,24 +35,29 @@ public class Store extends BaseEntity
|
|||
|
||||
@Excel(name = "店铺名称")
|
||||
@ApiModelProperty("店铺名称")
|
||||
@NotBlank(message = "店铺名称不能为空",groups = {ValidGroup.Create.class})
|
||||
private String storeName;
|
||||
|
||||
@Excel(name = "联系人")
|
||||
@ApiModelProperty("联系人")
|
||||
@NotBlank(message = "联系人不能为空",groups = {ValidGroup.Create.class})
|
||||
private String userName;
|
||||
|
||||
@Excel(name = "联系电话")
|
||||
@ApiModelProperty("联系电话")
|
||||
@NotBlank(message = "联系电话不能为空",groups = {ValidGroup.Create.class})
|
||||
private String phone;
|
||||
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@Excel(name = "营业开始时间", width = 30, dateFormat = "HH:mm")
|
||||
@ApiModelProperty("营业开始时间")
|
||||
@NotNull(message = "营业开始时间不能为空",groups = {ValidGroup.Create.class})
|
||||
private LocalTime startTime;
|
||||
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@Excel(name = "营业结束时间", width = 30, dateFormat = "HH:mm")
|
||||
@ApiModelProperty("营业结束时间")
|
||||
@NotNull(message = "营业结束时间不能为空",groups = {ValidGroup.Create.class})
|
||||
private LocalTime endTime;
|
||||
|
||||
@Excel(name = "经度")
|
||||
|
@ -61,6 +70,7 @@ public class Store extends BaseEntity
|
|||
|
||||
@Excel(name = "详细地址")
|
||||
@ApiModelProperty("详细地址")
|
||||
@NotBlank(message = "详细地址不能为空",groups = {ValidGroup.Create.class})
|
||||
private String address;
|
||||
|
||||
@Excel(name = "门店照片")
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
package com.ruoyi.bst.store.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class StoreQuery extends Store{
|
||||
public class StoreQuery extends StoreVO{
|
||||
|
||||
@ApiModelProperty("店铺ID列表")
|
||||
private List<Long> storeIds;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package com.ruoyi.bst.store.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum StorePermission {
|
||||
|
||||
STORE_EDIT("store:edit", "操作店铺");
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import com.ruoyi.bst.store.domain.Store;
|
|||
import com.ruoyi.bst.store.domain.StoreVO;
|
||||
import com.ruoyi.bst.store.domain.StoreQuery;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.security.core.parameters.P;
|
||||
|
||||
/**
|
||||
* 店铺Mapper接口
|
||||
|
@ -71,4 +72,6 @@ public interface StoreMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteStoreByStoreIds(Long[] storeIds);
|
||||
|
||||
int logicDel(@Param("ids") List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -17,26 +17,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="address" column="address" />
|
||||
<result property="picture" column="picture" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="deleted" column="deleted" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectStoreVo">
|
||||
select
|
||||
store_id,
|
||||
user_id,
|
||||
store_name,
|
||||
user_name,
|
||||
phone,
|
||||
start_time,
|
||||
end_time,
|
||||
longitude,
|
||||
latitude,
|
||||
address,
|
||||
picture,
|
||||
create_time
|
||||
from bst_store
|
||||
bs.store_id,
|
||||
bs.user_id,
|
||||
bs.store_name,
|
||||
bs.user_name,
|
||||
bs.phone,
|
||||
bs.start_time,
|
||||
bs.end_time,
|
||||
bs.longitude,
|
||||
bs.latitude,
|
||||
bs.address,
|
||||
bs.picture,
|
||||
bs.create_time
|
||||
from bst_store bs
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
<if test="query.storeId != null "> and store_id = #{query.storeId}</if>
|
||||
<if test="query.userId != null "> and user_id = #{query.userId}</if>
|
||||
<if test="query.storeName != null and query.storeName != ''"> and store_name like concat('%', #{query.storeName}, '%')</if>
|
||||
<if test="query.userName != null and query.userName != ''"> and user_name like concat('%', #{query.userName}, '%')</if>
|
||||
|
@ -47,6 +49,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.latitude != null "> and latitude = #{query.latitude}</if>
|
||||
<if test="query.address != null and query.address != ''"> and address like concat('%', #{query.address}, '%')</if>
|
||||
<if test="query.picture != null and query.picture != ''"> and picture = #{query.picture}</if>
|
||||
<if test="query.deleted != null"> and deleted = #{query.deleted}</if>
|
||||
${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope)
|
||||
.userSetAlias("bs.user_id")
|
||||
.build()
|
||||
}
|
||||
${query.params.dataScope}
|
||||
</sql>
|
||||
|
||||
|
@ -288,4 +295,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{storeId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!--logicDel-->
|
||||
<update id="logicDel">
|
||||
update bst_store
|
||||
set deleted = true
|
||||
where store_id in
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
and deleted = false
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
package com.ruoyi.bst.store.service;
|
||||
|
||||
public interface StoreConverter {
|
||||
}
|
|
@ -16,10 +16,16 @@ public interface StoreService
|
|||
/**
|
||||
* 查询店铺
|
||||
*
|
||||
* @param storeId 店铺主键
|
||||
* @param id 店铺主键
|
||||
* @return 店铺
|
||||
*/
|
||||
public StoreVO selectStoreByStoreId(Long storeId);
|
||||
public StoreVO selectStoreById(Long id, boolean scope);
|
||||
|
||||
default StoreVO selectStoreById(Long id) {
|
||||
return this.selectStoreById(id, false);
|
||||
}
|
||||
|
||||
public StoreVO selectOne(StoreQuery query);
|
||||
|
||||
/**
|
||||
* 查询店铺列表
|
||||
|
@ -60,4 +66,6 @@ public interface StoreService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteStoreByStoreId(Long storeId);
|
||||
|
||||
public int logicDel(List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package com.ruoyi.bst.store.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface StoreValidator {
|
||||
|
||||
|
||||
/**
|
||||
* 判断当前用户是否可以编辑店铺
|
||||
* @param storeId 分区ID
|
||||
* @return 是否允许
|
||||
*/
|
||||
boolean canEdit(Long storeId);
|
||||
|
||||
/**
|
||||
* 判断当前用户是否可以删除店铺
|
||||
* @param storeIds 分区ID
|
||||
* @return 是否允许
|
||||
*/
|
||||
boolean canDeleteAll(List<Long> storeIds);
|
||||
|
||||
/**
|
||||
* 判断当前用户是否可以选择制定分区
|
||||
* @param storeId 分区ID
|
||||
* @return 是否允许
|
||||
*/
|
||||
boolean canCheckForStore(Long storeId);
|
||||
|
||||
}
|
|
@ -1,7 +1,11 @@
|
|||
package com.ruoyi.bst.store.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
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.store.mapper.StoreMapper;
|
||||
|
@ -29,9 +33,25 @@ public class StoreServiceImpl implements StoreService
|
|||
* @return 店铺
|
||||
*/
|
||||
@Override
|
||||
public StoreVO selectStoreByStoreId(Long storeId)
|
||||
public StoreVO selectStoreById(Long storeId,boolean scope)
|
||||
{
|
||||
return storeMapper.selectStoreByStoreId(storeId);
|
||||
if (storeId == null) {
|
||||
return null;
|
||||
}
|
||||
StoreQuery query = new StoreQuery();
|
||||
query.setStoreId(storeId);
|
||||
query.setScope(scope);
|
||||
return this.selectOne(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoreVO selectOne(StoreQuery query) {
|
||||
PageHelper.startPage(1, 1);
|
||||
List<StoreVO> list = storeMapper.selectStoreList(query);
|
||||
if(list.isEmpty()) {
|
||||
ServiceUtil.assertion(true,"当前店铺信息不属于您");
|
||||
}
|
||||
return CollectionUtils.firstElement(list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,4 +114,9 @@ public class StoreServiceImpl implements StoreService
|
|||
{
|
||||
return storeMapper.deleteStoreByStoreId(storeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int logicDel(List<Long> ids) {
|
||||
return storeMapper.logicDel(ids);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
package com.ruoyi.bst.store.service.impl;
|
||||
|
||||
import com.ruoyi.bst.store.domain.StoreQuery;
|
||||
import com.ruoyi.bst.store.domain.StoreVO;
|
||||
import com.ruoyi.bst.store.domain.enums.StorePermission;
|
||||
import com.ruoyi.bst.store.service.StoreService;
|
||||
import com.ruoyi.bst.store.service.StoreValidator;
|
||||
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 StoreValidatorImpl implements StoreValidator {
|
||||
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
@Override
|
||||
public boolean canEdit(Long storeId) {
|
||||
return canOperate(Arrays.asList(storeId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDeleteAll(List<Long> storeIds) {
|
||||
return canOperate(storeIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCheckForStore(Long storeId) {
|
||||
return canOperate(Arrays.asList(storeId));
|
||||
}
|
||||
|
||||
// 是否可以操作店铺
|
||||
private boolean canOperate(List<Long> storeIds) {
|
||||
if (SecurityUtils.isSysAdmin()) {
|
||||
return true;
|
||||
}
|
||||
if (CollectionUtils.isEmptyElement(storeIds)) {
|
||||
return true;
|
||||
}
|
||||
// 查询店铺
|
||||
StoreQuery query = new StoreQuery();
|
||||
query.setStoreIds(storeIds);
|
||||
query.setScope(true);
|
||||
List<StoreVO> storeVOList = storeService.selectStoreList(query);
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
|
||||
// 判断是否可以操作店铺
|
||||
for (Long storeId : storeIds) {
|
||||
StoreVO store = storeVOList.stream()
|
||||
.filter(item -> item.getStoreId().equals(storeId))
|
||||
.findFirst().orElse(null);
|
||||
|
||||
if (store == null) {
|
||||
return false;
|
||||
}
|
||||
boolean canOperate = isCreater(store, userId);
|
||||
if (!canOperate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isCreater(StoreVO store, Long userId) {
|
||||
return store != null && store.getUserId() != null && store.getUserId().equals(userId);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +1,18 @@
|
|||
package com.ruoyi.web.bst;
|
||||
|
||||
import com.ruoyi.bst.floor.service.FloorValidator;
|
||||
import com.ruoyi.bst.part.domain.Part;
|
||||
import com.ruoyi.bst.part.domain.PartQuery;
|
||||
import com.ruoyi.bst.part.domain.PartVO;
|
||||
import com.ruoyi.bst.part.service.PartService;
|
||||
import com.ruoyi.bst.part.service.PartValidator;
|
||||
import com.ruoyi.bst.store.service.StoreValidator;
|
||||
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.system.user.service.UserValidator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -28,15 +32,22 @@ public class PartController extends BaseController
|
|||
{
|
||||
@Autowired
|
||||
private PartService partService;
|
||||
@Autowired
|
||||
private PartValidator partValidator;
|
||||
@Autowired
|
||||
private StoreValidator storeValidator;
|
||||
@Autowired
|
||||
private FloorValidator floorValidator;
|
||||
|
||||
/**
|
||||
* 查询分区列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:part:list')")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(PartQuery partQuery)
|
||||
public AjaxResult list(PartQuery query)
|
||||
{
|
||||
List<PartVO> list = partService.selectPartList(partQuery);
|
||||
query.setScope(true);
|
||||
List<PartVO> list = partService.selectPartList(query);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
|
@ -48,6 +59,7 @@ public class PartController extends BaseController
|
|||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PartQuery query)
|
||||
{
|
||||
query.setScope(true);
|
||||
List<PartVO> list = partService.selectPartList(query);
|
||||
ExcelUtil<PartVO> util = new ExcelUtil<PartVO>(PartVO.class);
|
||||
util.exportExcel(response, list, "分区数据");
|
||||
|
@ -60,7 +72,7 @@ public class PartController extends BaseController
|
|||
@GetMapping(value = "/{partId}")
|
||||
public AjaxResult getInfo(@PathVariable("partId") Long partId)
|
||||
{
|
||||
return success(partService.selectPartByPartId(partId));
|
||||
return success(partService.selectPartById(partId,true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,6 +83,10 @@ public class PartController extends BaseController
|
|||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Part part)
|
||||
{
|
||||
// 判断能否选择楼层
|
||||
if (!floorValidator.canCheckForFloor(part.getFloorId())) {
|
||||
return AjaxResult.error("您无权选择ID为" + part.getFloorId() + "的店铺");
|
||||
}
|
||||
return toAjax(partService.insertPart(part));
|
||||
}
|
||||
|
||||
|
@ -82,6 +98,9 @@ public class PartController extends BaseController
|
|||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Part part)
|
||||
{
|
||||
if (!partValidator.canEdit(part.getPartId())) {
|
||||
return AjaxResult.error("您没有权限修改ID为" + part.getPartId() + "的分区");
|
||||
}
|
||||
return toAjax(partService.updatePart(part));
|
||||
}
|
||||
|
||||
|
@ -90,9 +109,12 @@ public class PartController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:part:remove')")
|
||||
@Log(title = "分区", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{partIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] partIds)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable List<Long> ids)
|
||||
{
|
||||
return toAjax(partService.deletePartByPartIds(partIds));
|
||||
if (!partValidator.canDeleteAll(ids)) {
|
||||
return AjaxResult.error("您没有权限删除ID为" + ids + "的分区");
|
||||
}
|
||||
return toAjax(partService.deletePartByPartIds(ids));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,14 @@ import com.ruoyi.bst.store.domain.Store;
|
|||
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.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.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -30,6 +32,11 @@ public class StoreController extends BaseController
|
|||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
@Autowired
|
||||
private UserValidator userValidator;
|
||||
@Autowired
|
||||
private StoreValidator storeValidator;
|
||||
|
||||
/**
|
||||
* 查询店铺列表
|
||||
*/
|
||||
|
@ -39,6 +46,8 @@ public class StoreController extends BaseController
|
|||
{
|
||||
startPage();
|
||||
startOrderBy();
|
||||
query.setScope(true);
|
||||
query.setDeleted(false);
|
||||
List<StoreVO> list = storeService.selectStoreList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
@ -51,6 +60,7 @@ public class StoreController extends BaseController
|
|||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, StoreQuery query)
|
||||
{
|
||||
query.setScope(true);
|
||||
List<StoreVO> list = storeService.selectStoreList(query);
|
||||
ExcelUtil<StoreVO> util = new ExcelUtil<StoreVO>(StoreVO.class);
|
||||
util.exportExcel(response, list, "店铺数据");
|
||||
|
@ -63,7 +73,7 @@ public class StoreController extends BaseController
|
|||
@GetMapping(value = "/{storeId}")
|
||||
public AjaxResult getInfo(@PathVariable("storeId") Long storeId)
|
||||
{
|
||||
return success(storeService.selectStoreByStoreId(storeId));
|
||||
return success(storeService.selectStoreById(storeId,true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,6 +84,11 @@ public class StoreController extends BaseController
|
|||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Store store)
|
||||
{
|
||||
// 若不能操作他人,则设置为当前用户
|
||||
if (!userValidator.canView(store.getUserId())) {
|
||||
store.setUserId(getUserId());
|
||||
}
|
||||
store.setUserId(getUserId());
|
||||
return toAjax(storeService.insertStore(store));
|
||||
}
|
||||
|
||||
|
@ -85,6 +100,13 @@ public class StoreController extends BaseController
|
|||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Store store)
|
||||
{
|
||||
if (!storeValidator.canEdit(store.getStoreId())){
|
||||
return AjaxResult.error("您没有权限修改ID为" + store.getStoreId() + "的商铺信息");
|
||||
}
|
||||
// 若不能操作他人,则不修改用户ID
|
||||
if (!userValidator.canView(store.getUserId())) {
|
||||
store.setUserId(null);
|
||||
}
|
||||
return toAjax(storeService.updateStore(store));
|
||||
}
|
||||
|
||||
|
@ -93,9 +115,12 @@ public class StoreController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:store:remove')")
|
||||
@Log(title = "店铺", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{storeIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] storeIds)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable List<Long> ids)
|
||||
{
|
||||
return toAjax(storeService.deleteStoreByStoreIds(storeIds));
|
||||
if (!storeValidator.canDeleteAll(ids)) {
|
||||
return AjaxResult.error("您没有权限删除ID为" + ids + "的店铺信息");
|
||||
}
|
||||
return toAjax(storeService.logicDel(ids));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user