后台存酒取酒功能完善

This commit is contained in:
SjS 2025-06-07 18:02:37 +08:00
parent 4428217266
commit eca9ffa036
41 changed files with 829 additions and 128 deletions

View File

@ -26,7 +26,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_user su on bua.user_id = su.user_id
</sql>
<!--TODO:商家要能查询到app的信息-->
<sql id="searchCondition">
<if test="query.id != null "> and ba.id = #{query.id}</if>
<if test="query.name != null and query.name != ''"> and ba.name like concat('%', #{query.name}, '%')</if>

View File

@ -35,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.type != null and query.type != ''"> and type = #{query.type}</if>
<if test="query.picture != null and query.picture != ''"> and picture = #{query.picture}</if>
<if test="query.contact != null and query.contact != ''"> and contact like concat('%', #{query.contact}, '%')</if>
<if test="query.userName != null and query.userName != ''"> and su.userName like concat('%', #{query.userName}, '%')</if>
<if test="query.userName != null and query.userName != ''"> and su.user_name like concat('%', #{query.userName}, '%')</if>
${query.params.dataScope}
</sql>

View File

@ -1,5 +1,6 @@
package com.ruoyi.bst.location.domain;
import com.ruoyi.common.core.validate.ValidGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
@ -7,6 +8,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_location
*
@ -22,10 +26,12 @@ public class Location extends BaseEntity
@Excel(name = "店铺ID")
@ApiModelProperty("店铺ID")
@NotNull(message = "店铺ID不能为空",groups = {ValidGroup.Create.class})
private Long storeId;
@Excel(name = "位置名称")
@ApiModelProperty("位置名称")
@NotBlank(message = "位置名称不能为空",groups = {ValidGroup.Create.class})
private String name;
}

View File

@ -1,7 +1,14 @@
package com.ruoyi.bst.location.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class LocationQuery extends LocationVO{
@ApiModelProperty("位置ID列表")
private List<Long> locationIds;
}

View File

@ -1,7 +1,12 @@
package com.ruoyi.bst.location.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class LocationVO extends Location{
@ApiModelProperty("当前位置物品数量")
private Integer currentNum;
}

View File

@ -70,5 +70,7 @@ public interface LocationMapper
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteLocationByIds(Long[] ids);
public int deleteLocationByIds(List<Long> ids);
List<Long> selectIdByQuery(@Param("query") LocationQuery query);
}

View File

@ -13,17 +13,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectLocationVo">
select
id,
store_id,
name,
create_time
from bst_location
bl.id,
bl.store_id,
bl.name,
bl.create_time
from
<include refid="searchTables"/>
</sql>
<sql id="searchTables">
bst_location
bl
left join bst_store bs on bl.store_id = bs.store_id
</sql>
<sql id="searchCondition">
<if test="query.id != null "> and id = #{query.id}</if>
<if test="query.storeId != null "> and store_id = #{query.storeId}</if>
<if test="query.name != null and query.name != ''"> and name like concat('%', #{query.name}, '%')</if>
<if test="query.id != null ">and bl.id = #{query.id}</if>
<if test="query.storeId != null ">and bl.store_id = #{query.storeId}</if>
<if test="query.name != null and query.name != ''">and bl.name like concat('%', #{query.name}, '%')</if>
<if test="query.locationIds != null and query.locationIds.size() > 0">
and bl.id in
<foreach item="ids" index="index" collection="query.locationIds" open="(" separator="," close=")">
#{ids}
</foreach>
</if>
${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope)
.userSetAlias("bs.user_id")
.storeAlias("bl.store_id",query.storePermissions)
.build()
}
${query.params.dataScope}
</sql>
@ -39,6 +57,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</select>
<select id="selectIdByQuery" resultType="java.lang.Long">
select bl.id from
<include refid="searchTables"/>
<where>
<include refid="searchCondition"/>
</where>
</select>
<insert id="insertLocation" parameterType="Location" useGeneratedKeys="true" keyProperty="id">
insert into bst_location
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -128,7 +154,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<delete id="deleteLocationById" parameterType="Long">
delete from bst_location where id = #{id}
delete
from bst_location
where id = #{id}
</delete>
<delete id="deleteLocationByIds" parameterType="String">

View File

@ -0,0 +1,17 @@
package com.ruoyi.bst.location.service;
import com.ruoyi.bst.location.domain.LocationVO;
import com.ruoyi.bst.team.domain.TeamVO;
import java.util.List;
public interface LocationAssembler {
/**
* 拼接存酒数量
* @param list
*/
void assembleStorageNum(List<LocationVO> list);
}

View File

@ -19,8 +19,13 @@ public interface LocationService
* @param id 存放位置主键
* @return 存放位置
*/
public LocationVO selectLocationById(Long id);
public LocationVO selectLocationById(Long id,boolean scope);
default LocationVO selectLocationById(Long id){
return this.selectLocationById(id,false);
}
public LocationVO selectOne(LocationQuery query);
/**
* 查询存放位置列表
*
@ -51,7 +56,7 @@ public interface LocationService
* @param ids 需要删除的存放位置主键集合
* @return 结果
*/
public int deleteLocationByIds(Long[] ids);
public int deleteLocationByIds(List<Long> ids);
/**
* 删除存放位置信息

View File

@ -0,0 +1,21 @@
package com.ruoyi.bst.location.service;
import java.util.List;
public interface LocationValidator {
/**
* 判断当前用户是否可以修改位置信息
* @param locationId 位置ID
* @return 是否允许
*/
boolean canEdit(Long locationId);
/**
* 判断当前用户是否可以删除位置信息
* @param locationIds 位置ID集合
* @return 是否允许
*/
boolean canDelete(List<Long> locationIds);
}

View File

@ -0,0 +1,51 @@
package com.ruoyi.bst.location.service.impl;
import com.ruoyi.bst.location.domain.LocationQuery;
import com.ruoyi.bst.location.domain.LocationVO;
import com.ruoyi.bst.location.service.LocationAssembler;
import com.ruoyi.bst.location.service.LocationService;
import com.ruoyi.bst.storage.domain.StorageQuery;
import com.ruoyi.bst.storage.domain.StorageVO;
import com.ruoyi.bst.storage.service.StorageService;
import com.ruoyi.bst.team.domain.TeamVO;
import com.ruoyi.bst.team.service.TeamAssembler;
import com.ruoyi.bst.teamUser.domain.TeamUserQuery;
import com.ruoyi.bst.teamUser.domain.TeamUserVO;
import com.ruoyi.bst.teamUser.domain.enums.RoleType;
import com.ruoyi.bst.teamUser.service.TeamUserService;
import com.ruoyi.common.utils.collection.CollectionUtils;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class LocationAssemblerImpl implements LocationAssembler {
@Autowired
private StorageService storageService;
@Override
public void assembleStorageNum(List<LocationVO> list) {
if (CollectionUtils.isEmptyElement(list)) {
return;
}
List<Long> locationIds = CollectionUtils.map(list, LocationVO::getId);
StorageQuery query = new StorageQuery();
query.setLocationIds(locationIds);
List<StorageVO> storageList = storageService.selectCurrentNum(query);
Map<Long, Integer> idToCurrentNum = storageList.stream().collect(Collectors.toMap(StorageVO::getLocationId, StorageVO::getCurrentNum));
for (LocationVO location : list) {
Integer currentNum = idToCurrentNum.get(location.getId());
location.setCurrentNum(currentNum);
}
}
}

View File

@ -1,7 +1,17 @@
package com.ruoyi.bst.location.service.impl;
import java.util.List;
import com.github.pagehelper.PageHelper;
import com.ruoyi.bst.storage.domain.StorageQuery;
import com.ruoyi.bst.storage.domain.StorageVO;
import com.ruoyi.bst.storage.service.StorageService;
import com.ruoyi.bst.storeStaff.domain.enums.StoreStaffPermission;
import com.ruoyi.bst.team.domain.TeamQuery;
import com.ruoyi.bst.team.domain.TeamVO;
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.location.mapper.LocationMapper;
@ -17,10 +27,11 @@ import com.ruoyi.bst.location.service.LocationService;
* @date 2025-06-06
*/
@Service
public class LocationServiceImpl implements LocationService
{
public class LocationServiceImpl implements LocationService {
@Autowired
private LocationMapper locationMapper;
@Autowired
private StorageService storageService;
/**
* 查询存放位置
@ -29,9 +40,22 @@ public class LocationServiceImpl implements LocationService
* @return 存放位置
*/
@Override
public LocationVO selectLocationById(Long id)
{
return locationMapper.selectLocationById(id);
public LocationVO selectLocationById(Long id, boolean scope) {
if (id == null) {
return null;
}
LocationQuery query = new LocationQuery();
query.setId(id);
query.setScope(scope);
query.addStorePermission(StoreStaffPermission.LOCATION_VIEW.getCode());
return this.selectOne(query);
}
@Override
public LocationVO selectOne(LocationQuery query) {
PageHelper.startPage(1, 1);
List<LocationVO> list = this.selectLocationList(query);
return CollectionUtils.firstElement(list);
}
/**
@ -41,8 +65,7 @@ public class LocationServiceImpl implements LocationService
* @return 存放位置
*/
@Override
public List<LocationVO> selectLocationList(LocationQuery location)
{
public List<LocationVO> selectLocationList(LocationQuery location) {
return locationMapper.selectLocationList(location);
}
@ -53,8 +76,7 @@ public class LocationServiceImpl implements LocationService
* @return 结果
*/
@Override
public int insertLocation(Location location)
{
public int insertLocation(Location location) {
location.setCreateTime(DateUtils.getNowDate());
return locationMapper.insertLocation(location);
}
@ -66,8 +88,7 @@ public class LocationServiceImpl implements LocationService
* @return 结果
*/
@Override
public int updateLocation(Location location)
{
public int updateLocation(Location location) {
return locationMapper.updateLocation(location);
}
@ -78,8 +99,11 @@ public class LocationServiceImpl implements LocationService
* @return 结果
*/
@Override
public int deleteLocationByIds(Long[] ids)
{
public int deleteLocationByIds(List<Long> ids) {
StorageQuery query = new StorageQuery();
query.setLocationIds(ids);
List<StorageVO> storageList = storageService.selectStorageList(query);
ServiceUtil.assertion(storageList != null && !storageList.isEmpty(),"当前位置有物品存放,不允许删除");
return locationMapper.deleteLocationByIds(ids);
}
@ -90,8 +114,7 @@ public class LocationServiceImpl implements LocationService
* @return 结果
*/
@Override
public int deleteLocationById(Long id)
{
public int deleteLocationById(Long id) {
return locationMapper.deleteLocationById(id);
}
}

View File

@ -0,0 +1,53 @@
package com.ruoyi.bst.location.service.impl;
import com.ruoyi.bst.location.domain.LocationQuery;
import com.ruoyi.bst.location.domain.LocationVO;
import com.ruoyi.bst.location.mapper.LocationMapper;
import com.ruoyi.bst.location.service.LocationValidator;
import com.ruoyi.bst.storeStaff.domain.enums.StoreStaffPermission;
import com.ruoyi.bst.team.domain.TeamQuery;
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.HashSet;
import java.util.List;
@Service
public class LocationValidatorImpl implements LocationValidator {
@Autowired
private LocationMapper locationMapper;
@Override
public boolean canEdit(Long locationId) {
return canOperate(Arrays.asList(locationId));
}
@Override
public boolean canDelete(List<Long> locationIds) {
return canOperate(locationIds);
}
private boolean canOperate(List<Long> locationIds) {
return hasPermission(locationIds, StoreStaffPermission.LOCATION_EDIT.getCode());
}
private boolean hasPermission(List<Long> locationIds, String permission) {
if (SecurityUtils.isSysAdmin()) {
return true;
}
if (CollectionUtils.isEmptyElement(locationIds)) {
return true;
}
// 查询拼桌
LocationQuery query = new LocationQuery();
query.setLocationIds(locationIds);
query.setScope(true);
query.addStorePermission(permission);
List<Long> locationIdList = locationMapper.selectIdByQuery(query);
return new HashSet<>(locationIdList).containsAll(locationIds);
}
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.bst.specValue.domain.SpecValue;
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_storage
*
@ -27,26 +31,32 @@ public class Storage extends BaseEntity
@Excel(name = "存放位置ID")
@ApiModelProperty("存放位置ID")
@NotNull(message = "存放位置ID不能为空",groups = {ValidGroup.Create.class})
private Long locationId;
@Excel(name = "店铺ID")
@ApiModelProperty("店铺ID")
@NotNull(message = "店铺ID不能为空",groups = {ValidGroup.Create.class})
private Long storeId;
@Excel(name = "用户ID")
@ApiModelProperty("用户ID")
@NotNull(message = "用户ID不能为空",groups = {ValidGroup.Create.class})
private Long userId;
@Excel(name = "商品skuID")
@ApiModelProperty("商品skuID")
@NotNull(message = "商品skuID不能为空",groups = {ValidGroup.Create.class})
private Long skuId;
@Excel(name = "商品名称")
@ApiModelProperty("商品名称")
@NotBlank(message = "商品名称不能为空",groups = {ValidGroup.Create.class})
private String goodsName;
@Excel(name = "存放数量")
@ApiModelProperty("存放数量")
@NotNull(message = "存放数量不能为空",groups = {ValidGroup.Create.class})
private Integer totalNum;
@Excel(name = "已取数量")
@ -59,6 +69,7 @@ public class Storage extends BaseEntity
private Date deadline;
@ApiModelProperty("规格值列表")
@NotNull(message = "规格值列表不能为空",groups = {ValidGroup.Create.class})
private List<SpecValue> specValue;
}

View File

@ -1,7 +1,17 @@
package com.ruoyi.bst.storage.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class StorageQuery extends StorageVO{
@ApiModelProperty("位置ID列表")
private List<Long> locationIds;
@ApiModelProperty("存酒信息ID列表")
private List<Long> storageIds;
}

View File

@ -1,7 +1,30 @@
package com.ruoyi.bst.storage.domain;
import com.ruoyi.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class StorageVO extends Storage{
@ApiModelProperty("用户名称")
private String userName;
@ApiModelProperty("商品名称")
private String goodsName;
@ApiModelProperty("店铺名称")
private String storeName;
@ApiModelProperty("位置名称")
private String locationName;
@Excel(name = "当前数量")
@ApiModelProperty("当前数量")
private Integer currentNum;
public Integer getCurrentNum() {
return getTotalNum() - getTakenNum();
}
}

View File

@ -0,0 +1,15 @@
package com.ruoyi.bst.storage.domain.dto;
import com.ruoyi.bst.storage.domain.Storage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class StorageDTO {
@ApiModelProperty("存酒信息ID")
private Long storageId;
@ApiModelProperty("取酒数量")
private Integer number;
}

View File

@ -71,4 +71,10 @@ public interface StorageMapper
* @return 结果
*/
public int deleteStorageByIds(Long[] ids);
List<StorageVO> selectCurrentNum(@Param("query") StorageQuery query);
List<Long> selectIdByQuery(@Param("query") StorageQuery query);
int batchGetWine(@Param("list") List<Storage> toStorageUpdate);
}

View File

@ -14,7 +14,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="totalNum" column="total_num"/>
<result property="takenNum" column="taken_num"/>
<result property="deadline" column="deadline"/>
<result property="specValue" column="spec_value" typeHandler="com.ruoyi.bst.storage.mapper.typehandler.SpecValueListTypeHandler" />
<result property="specValue" column="spec_value"
typeHandler="com.ruoyi.bst.storage.mapper.typehandler.SpecValueListTypeHandler"/>
<result property="remark" column="remark"/>
<result property="createTime" column="create_time"/>
</resultMap>
@ -33,11 +34,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bst.spec_value,
bst.remark,
bst.create_time,
bs.name as goods_name,
bstor.name as store_name,
su.name as user_name,
bg.name as goods_name,
bstor.store_name,
su.user_name,
bl.name as location_name
from <include refid="searchTables"/>
from
<include refid="searchTables"/>
</sql>
<sql id="searchTables">
@ -45,22 +47,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join bst_sku bsk on bst.sku_id = bsk.id
left join bst_goods bg on bsk.goods_id = bg.id
left join sys_user su on bst.user_id = su.user_id
left join bst_store bstor on bst.store_id = bstor.id
left join bst_store bstor on bst.store_id = bstor.store_id
left join bst_location bl on bst.location_id = bl.id
</sql>
<sql id="searchCondition">
<if test="query.id != null "> and id = #{query.id}</if>
<if test="query.locationId != null "> and location_id = #{query.locationId}</if>
<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.skuId != null "> and sku_id = #{query.skuId}</if>
<if test="query.goodsName != null and query.goodsName != ''"> and goods_name like concat('%', #{query.goodsName}, '%')</if>
<if test="query.totalNum != null "> and total_num = #{query.totalNum}</if>
<if test="query.takenNum != null "> and taken_num = #{query.takenNum}</if>
<if test="query.deadline != null "> and deadline = #{query.deadline}</if>
<if test="query.specValue != null "> and spec_value = #{query.specValue}</if>
<if test="query.remark != null and query.remark != ''"> and remark like concat('%', #{query.remark}, '%')</if>
<if test="query.id != null ">and bst.id = #{query.id}</if>
<if test="query.locationId != null ">and bst.location_id = #{query.locationId}</if>
<if test="query.storeId != null ">and bst.store_id = #{query.storeId}</if>
<if test="query.userId != null ">and bst.user_id = #{query.userId}</if>
<if test="query.skuId != null ">and bst.sku_id = #{query.skuId}</if>
<if test="query.goodsName != null and query.goodsName != ''">and bst.goods_name like concat('%', #{query.goodsName}, '%')</if>
<if test="query.totalNum != null ">and bst.total_num = #{query.totalNum}</if>
<if test="query.takenNum != null ">and bst.taken_num = #{query.takenNum}</if>
<if test="query.deadline != null ">and bst.deadline &lt;= #{query.deadline}</if>
<if test="query.specValue != null ">and bst.spec_value = #{query.specValue}</if>
<if test="query.remark != null and query.remark != ''">and bst.remark like concat('%', #{query.remark}, '%')</if>
<if test="query.userName != null and query.userName != ''">and su.user_name like concat('%', #{query.userName}, '%')</if>
<if test="query.locationIds != null and query.locationIds.size() > 0">
and bst.location_id in
<foreach item="ids" index="index" collection="query.locationIds" open="(" separator="," close=")">
#{ids}
</foreach>
</if>
${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope)
.userSetAlias("bsotr.user_id")
.storeAlias("bst.store_id",query.storePermissions)
.build()
}
${query.params.dataScope}
</sql>
@ -76,6 +90,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</select>
<!--selectCurrentNum-->
<select id="selectCurrentNum" resultType="com.ruoyi.bst.storage.domain.StorageVO">
SELECT
bst.location_id,SUM(bst.total_num) as total_num,SUM(bst.taken_num) as taken_num
FROM
bst_storage bst
<where>
<include refid="searchCondition"/>
</where>
GROUP BY bst.location_id
</select>
<select id="selectIdByQuery" resultType="java.lang.Long">
select bst.id from
<include refid="searchTables"/>
<where>
<include refid="searchTables"/>
</where>
</select>
<insert id="insertStorage" parameterType="Storage" useGeneratedKeys="true" keyProperty="id">
insert into bst_storage
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -100,7 +134,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="totalNum != null">#{totalNum},</if>
<if test="takenNum != null">#{takenNum},</if>
<if test="deadline != null">#{deadline},</if>
<if test="specValue != null">#{specValue,typeHandler=com.ruoyi.bst.storage.mapper.typehandler.SpecValueListTypeHandler,</if>
<if test="specValue != null">
#{specValue,typeHandler=com.ruoyi.bst.storage.mapper.typehandler.SpecValueListTypeHandler,
</if>
<if test="remark != null">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
@ -140,7 +176,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="i.takenNum == null ">default,</if>
<if test="i.deadline != null ">#{i.deadline},</if>
<if test="i.deadline == null ">default,</if>
<if test="i.specValue != null ">#{i.specValue,typeHandler=com.ruoyi.bst.storage.mapper.typehandler.SpecValueListTypeHandler},</if>
<if test="i.specValue != null ">
#{i.specValue,typeHandler=com.ruoyi.bst.storage.mapper.typehandler.SpecValueListTypeHandler},
</if>
<if test="i.specValue == null ">default,</if>
<if test="i.remark != null ">#{i.remark},</if>
<if test="i.remark == null ">default,</if>
@ -236,7 +274,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<foreach open="spec_value = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.specValue != null ">
WHEN #{item.id} THEN #{item.specValue,typeHandler=com.ruoyi.bst.storage.mapper.typehandler.SpecValueListTypeHandler}
WHEN #{item.id} THEN
#{item.specValue,typeHandler=com.ruoyi.bst.storage.mapper.typehandler.SpecValueListTypeHandler}
</when>
<otherwise>
WHEN #{item.id} THEN `spec_value`
@ -271,11 +310,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<update id="updateStorage" parameterType="Storage">
update bst_storage
update bst_storage bst
<trim prefix="SET" suffixOverrides=",">
<include refid="updateColumns"/>
</trim>
where id = #{data.id}
where bst.id = #{data.id}
</update>
<!--batchGetWine-->
<update id="batchGetWine">
UPDATE bst_storage bs
JOIN (
<foreach collection="list" item="item" separator=" UNION ALL ">
SELECT #{item.id} AS id, #{item.takenNum} AS delta
</foreach>
) AS updates ON bs.id = updates.id
SET bs.taken_num = bs.taken_num + updates.delta
WHERE (bs.taken_num + updates.delta) &lt;= bs.total_num
</update>
<sql id="updateColumns">
@ -287,13 +338,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="data.totalNum != null">total_num = #{data.totalNum},</if>
<if test="data.takenNum != null">taken_num = #{data.takenNum},</if>
<if test="data.deadline != null">deadline = #{data.deadline},</if>
<if test="data.specValue != null">spec_value = #{data.specValue,typeHandler=com.ruoyi.bst.storage.mapper.typehandler.SpecValueListTypeHandler},</if>
<if test="data.specValue != null">spec_value =
#{data.specValue,typeHandler=com.ruoyi.bst.storage.mapper.typehandler.SpecValueListTypeHandler},
</if>
<if test="data.remark != null">remark = #{data.remark},</if>
<if test="data.createTime != null">create_time = #{data.createTime},</if>
</sql>
<delete id="deleteStorageById" parameterType="Long">
delete from bst_storage where id = #{id}
delete
from bst_storage
where id = #{id}
</delete>
<delete id="deleteStorageByIds" parameterType="String">

View File

@ -0,0 +1,19 @@
package com.ruoyi.bst.storage.service;
import com.ruoyi.bst.model.domain.Model;
import com.ruoyi.bst.storage.domain.Storage;
public interface StorageConverter {
/**
* 创建时转换为PO
*/
Storage toPoByCreate(Storage data);
/**
* 更新时转换为PO
*/
Storage toPoByUpdate(Storage data);
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.ruoyi.bst.storage.domain.Storage;
import com.ruoyi.bst.storage.domain.StorageVO;
import com.ruoyi.bst.storage.domain.StorageQuery;
import com.ruoyi.bst.storage.domain.dto.StorageDTO;
/**
* 存酒Service接口
@ -19,7 +20,13 @@ public interface StorageService
* @param id 存酒主键
* @return 存酒
*/
public StorageVO selectStorageById(Long id);
public StorageVO selectStorageById(Long id,boolean scope);
default StorageVO selectStorageById(Long id){
return selectStorageById(id,false);
}
public StorageVO selectOne(StorageQuery query);
/**
* 查询存酒列表
@ -62,4 +69,9 @@ public interface StorageService
public int deleteStorageById(Long id);
int storageWine(List<Storage> storageList);
List<StorageVO> selectCurrentNum(StorageQuery query);
int getWine(List<StorageDTO> list);
}

View File

@ -0,0 +1,23 @@
package com.ruoyi.bst.storage.service;
import java.util.List;
public interface StorageValidator {
/**
* 判断当前用户是否可以修改存酒信息
* @param storageId 存酒信息ID
* @return 是否允许
*/
boolean canEdit(Long storageId);
boolean canEdit(List<Long> storageIds);
/**
* 判断当前用户是否可以删除存酒信息
* @param storageIds 位置ID集合
* @return 是否允许
*/
boolean canDelete(List<Long> storageIds);
}

View File

@ -0,0 +1,50 @@
package com.ruoyi.bst.storage.service.impl;
import com.ruoyi.bst.model.domain.Model;
import com.ruoyi.bst.storage.domain.Storage;
import com.ruoyi.bst.storage.service.StorageConverter;
import org.springframework.stereotype.Service;
@Service
public class StorageConverterImpl implements StorageConverter {
@Override
public Storage toPoByCreate(Storage data) {
if (data == null) {
return null;
}
Storage po = new Storage();
po.setLocationId(data.getLocationId());
po.setStoreId(data.getStoreId());
po.setUserId(data.getUserId());
po.setSkuId(data.getSkuId());
po.setGoodsName(data.getGoodsName());
po.setTotalNum(data.getTotalNum());
po.setDeadline(data.getDeadline());
po.setSpecValue(data.getSpecValue());
po.setRemark(data.getRemark());
return po;
}
@Override
public Storage toPoByUpdate(Storage data) {
if (data == null) {
return null;
}
Storage po = new Storage();
po.setId(data.getId());
po.setLocationId(data.getLocationId());
po.setStoreId(data.getStoreId());
po.setUserId(data.getUserId());
po.setSkuId(data.getSkuId());
po.setGoodsName(data.getGoodsName());
po.setTotalNum(data.getTotalNum());
po.setDeadline(data.getDeadline());
po.setSpecValue(data.getSpecValue());
po.setRemark(data.getRemark());
return po;
}
}

View File

@ -1,7 +1,21 @@
package com.ruoyi.bst.storage.service.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.github.pagehelper.PageHelper;
import com.ruoyi.bst.location.domain.LocationQuery;
import com.ruoyi.bst.location.domain.LocationVO;
import com.ruoyi.bst.storage.domain.dto.StorageDTO;
import com.ruoyi.bst.storageRecord.domain.StorageRecord;
import com.ruoyi.bst.storageRecord.service.StorageRecordService;
import com.ruoyi.bst.storeStaff.domain.enums.StoreStaffPermission;
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.storage.mapper.StorageMapper;
@ -9,6 +23,7 @@ import com.ruoyi.bst.storage.domain.Storage;
import com.ruoyi.bst.storage.domain.StorageVO;
import com.ruoyi.bst.storage.domain.StorageQuery;
import com.ruoyi.bst.storage.service.StorageService;
import org.springframework.transaction.support.TransactionTemplate;
/**
* 存酒Service业务层处理
@ -21,6 +36,12 @@ public class StorageServiceImpl implements StorageService
{
@Autowired
private StorageMapper storageMapper;
@Autowired
private TransactionTemplate transactionTemplate;
@Autowired
private StorageRecordService storageRecordService;
@Autowired
private StorageService storageService;
/**
* 查询存酒
@ -29,11 +50,25 @@ public class StorageServiceImpl implements StorageService
* @return 存酒
*/
@Override
public StorageVO selectStorageById(Long id)
public StorageVO selectStorageById(Long id,boolean scope)
{
return storageMapper.selectStorageById(id);
if (id == null) {
return null;
}
StorageQuery query = new StorageQuery();
query.setId(id);
query.setScope(scope);
query.addStorePermission(StoreStaffPermission.STORAGE_VIEW.getCode());
return this.selectOne(query);
}
@Override
public StorageVO selectOne(StorageQuery query) {
PageHelper.startPage(1, 1);
List<StorageVO> list = this.selectStorageList(query);
return CollectionUtils.firstElement(list);
}
/**
* 查询存酒列表
*
@ -102,4 +137,63 @@ public class StorageServiceImpl implements StorageService
});
return storageMapper.batchInsert(storageList);
}
@Override
public List<StorageVO> selectCurrentNum(StorageQuery query) {
return storageMapper.selectCurrentNum(query);
}
@Override
public int getWine(List<StorageDTO> list) {
// 查询需要更新的存酒信息id列表
List<Long> ids = list.stream()
.map(StorageDTO::getStorageId)
.collect(Collectors.toList());
// 查询出对应的map用于更新数据
StorageQuery query = new StorageQuery();
query.setStorageIds(ids);
Map<Long,Storage> storageMap = storageMapper.selectStorageList(query)
.stream()
.collect(Collectors.toMap(Storage::getId,Storage->Storage));
List<Storage> toStorageUpdate = new ArrayList<>();
List<StorageRecord> toStorageRecordInsert = new ArrayList<>();
for (StorageDTO dto : list) {
Storage storage = storageMap.get(dto.getStorageId());
if (storage == null) {
continue;
}
// 生成数据用于批量取酒
StorageVO data = new StorageVO();
data.setId(storage.getId());
data.setTakenNum(dto.getNumber());
toStorageUpdate.add(data);
// 生成记录
StorageRecord record = new StorageRecord();
record.setStorageId(storage.getId());
record.setStoreId(storage.getStoreId());
record.setUserId(storage.getUserId());
record.setReason("用户"+storage.getUserId()+"取酒"+dto.getNumber()+"");
record.setNumber(dto.getNumber());
record.setCreateTime(DateUtils.getNowDate());
toStorageRecordInsert.add(record);
}
Integer result = transactionTemplate.execute(status -> {
// 批量减少数量,根据ID限制
int i = storageMapper.batchGetWine(toStorageUpdate);
ServiceUtil.assertion(i != toStorageUpdate.size(),"物品数量不足,取酒失败");
// 批量插入记录
i = storageRecordService.batchInsert(toStorageRecordInsert);
ServiceUtil.assertion(i <= 0,"生成记录失败");
return i;
});
return result == null ? 0 : result;
}
}

View File

@ -0,0 +1,62 @@
package com.ruoyi.bst.storage.service.impl;
import com.ruoyi.bst.location.domain.LocationQuery;
import com.ruoyi.bst.location.mapper.LocationMapper;
import com.ruoyi.bst.location.service.LocationValidator;
import com.ruoyi.bst.storage.domain.StorageQuery;
import com.ruoyi.bst.storage.mapper.StorageMapper;
import com.ruoyi.bst.storage.service.StorageValidator;
import com.ruoyi.bst.storeStaff.domain.enums.StoreStaffPermission;
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 StorageValidatorImpl implements StorageValidator {
private final StorageMapper storageMapper;
public StorageValidatorImpl(StorageMapper storageMapper) {
this.storageMapper = storageMapper;
}
@Override
public boolean canEdit(Long storageId) {
return canOperate(Arrays.asList(storageId));
}
@Override
public boolean canEdit(List<Long> storageIds) {
return canOperate(storageIds);
}
@Override
public boolean canDelete(List<Long> storageIds) {
return canOperate(storageIds);
}
private boolean canOperate(List<Long> storageIds) {
return hasPermission(storageIds, StoreStaffPermission.STORAGE_EDIT.getCode());
}
private boolean hasPermission(List<Long> storageIds, String permission) {
if (SecurityUtils.isSysAdmin()) {
return true;
}
if (CollectionUtils.isEmptyElement(storageIds)) {
return true;
}
// 查询拼桌
StorageQuery query = new StorageQuery();
query.setStorageIds(storageIds);
query.setScope(true);
query.addStorePermission(permission);
List<Long> storageIdList = storageMapper.selectIdByQuery(query);
return new HashSet<>(storageIdList).containsAll(storageIds);
}
}

View File

@ -26,9 +26,12 @@ public enum StoreStaffPermission {
GOODS_CATEGORY_VIEW("goods:category:view","查看商品分类"),
GOODS_CATEGORY_EDIT("goods:category:edit","修改商品分类"),
GOODS_VIEW("goods:view","查看商品"),
GOODS_EDIT("goods:edit","修改商品");
GOODS_EDIT("goods:edit","修改商品"),
LOCATION_VIEW("location:view","查看存放位置"),
LOCATION_EDIT("location:edit","修改存放位置"),
STORAGE_VIEW("storage:view","查看存酒明细"),
STORAGE_EDIT("storage:edit","修改存酒明细"),
STORAGE_RECORD_VIEW("storage:record:edit","查看取酒记录");
private final String code;

View File

@ -70,7 +70,7 @@ public interface TeamMapper
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteTeamByIds(Long[] ids);
public int deleteTeamByIds(List<Long> ids);
int addCurrentNums(@Param("data") TeamVO vo);

View File

@ -57,6 +57,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.status != null "> and bt.status = #{query.status}</if>
<if test="query.storeName != null "> and bs.store_name like concat('%', #{query.storeName}, '%')</if>
<if test="query.boothName != null "> and bb.booth_name like concat('%', #{query.boothName}, '%')</if>
<if test="query.teamIds != null and query.teamIds.size() > 0">
and bt.id in
<foreach item="ids" index="index" collection="query.teamIds" open="(" separator="," close=")">
#{ids}
</foreach>
</if>
${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope)
.userSetAlias("bs.user_id")
.storeAlias("bt.store_id",query.storePermissions)

View File

@ -61,7 +61,7 @@ public interface TeamService
* @param ids 需要删除的拼桌主键集合
* @return 结果
*/
public int deleteTeamByIds(Long[] ids);
public int deleteTeamByIds(List<Long> ids);
/**
* 删除拼桌信息

View File

@ -1,5 +1,7 @@
package com.ruoyi.bst.team.service;
import java.util.List;
public interface TeamValidator {
/**
@ -9,7 +11,18 @@ public interface TeamValidator {
*/
boolean canAddUser(Long teamId);
/**
* 判断当前用户是否可以编辑拼桌信息
* @param teamId 拼桌ID
* @return 是否允许
*/
boolean canEdit(Long teamId);
/**
* 判断当前用户是否可以删除拼桌信息
* @param teamIds 拼桌ID
* @return 是否允许
*/
boolean canDelete(List<Long> teamIds);
}

View File

@ -134,7 +134,7 @@ public class TeamServiceImpl implements TeamService {
* @return 结果
*/
@Override
public int deleteTeamByIds(Long[] ids) {
public int deleteTeamByIds(List<Long> ids) {
return teamMapper.deleteTeamByIds(ids);
}

View File

@ -39,6 +39,11 @@ public class TeamValidatorImpl implements TeamValidator {
return canOperate(Arrays.asList(teamId));
}
@Override
public boolean canDelete(List<Long> teamIds) {
return canOperate(teamIds);
}
// 是否可以操作拼桌队伍
private boolean canOperate(List<Long> teamIds) {
return hasPermission(teamIds, StoreStaffPermission.TEAM_EDIT.getCode());

View File

@ -82,4 +82,6 @@ public interface TeamUserMapper
List<Long> selectUserIdsByTeamId(@Param("teamId") Long teamId);
List<TeamUserVO> selectDistinctTeamUserList(@Param("query") TeamUserQuery query);
List<Long> selectIdByQuery(@Param("query") TeamUserQuery query);
}

View File

@ -33,7 +33,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
su.avatar,
su.sex,
su_inviter.nick_name as inviter_name
from bst_team_user btu
from <include refid="searchTables"/>
</sql>
<sql id="searchTables">
bst_team_user btu
left join bst_team bt on btu.team_id = bt.id
left join bst_store bs on bt.store_id = bs.store_id
left join sys_user su on btu.user_id = su.user_id
@ -105,6 +109,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
distinct by btu.user_id
</select>
<select id="selectIdByQuery" resultType="java.lang.Long">
select btu.id from
<include refid="searchTables"/>
<where>
<include refid="searchCondition"/>
</where>
</select>
<insert id="insertTeamUser" parameterType="TeamUser" useGeneratedKeys="true" keyProperty="id">
insert into bst_team_user
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -11,10 +11,10 @@ public interface TeamUserValidator {
/**
* 判断当前用户是否可以编辑拼桌信息
* @param teamId 用户ID
* @param teamUserId 用户ID
* @return 是否允许
*/
boolean canEdit(Long teamId);
boolean canEdit(Long teamUserId);
/**

View File

@ -40,8 +40,8 @@ public class TeamUserValidatorImpl implements TeamUserValidator {
}
@Override
public boolean canEdit(Long teamId) {
return canOperate(Arrays.asList(teamId));
public boolean canEdit(Long teamUserId) {
return canOperate(Arrays.asList(teamUserId));
}
@Override
@ -55,26 +55,24 @@ public class TeamUserValidatorImpl implements TeamUserValidator {
}
// 是否可以操作拼桌队员
private boolean canOperate(List<Long> teamIds) {
return hasPermission(teamIds, StoreStaffPermission.TEAM_USER_EDIT.getCode());
private boolean canOperate(List<Long> teamUserIds) {
return hasPermission(teamUserIds, StoreStaffPermission.TEAM_USER_EDIT.getCode());
}
private boolean hasPermission(List<Long> teamIds, String permission) {
private boolean hasPermission(List<Long> teamUserIds, String permission) {
if (SecurityUtils.isSysAdmin()) {
return true;
}
if (CollectionUtils.isEmptyElement(teamIds)) {
if (CollectionUtils.isEmptyElement(teamUserIds)) {
return true;
}
// 查询拼桌用户
TeamUserQuery query = new TeamUserQuery();
query.setTeamUserIds(teamIds);
query.setTeamUserIds(teamUserIds);
query.setScope(true);
query.addStorePermission(permission);
//List<Long> teamIdList = teamMapper.selectIdByQuery(query);
//return new HashSet<>(teamIdList).containsAll(teamIds);
return true;
List<Long> teamUserIdList = teamUserMapper.selectIdByQuery(query);
return new HashSet<>(teamUserIdList).containsAll(teamUserIds);
}
}

View File

@ -1,8 +1,11 @@
package com.ruoyi.web.app;
import com.ruoyi.bst.storage.domain.Storage;
import com.ruoyi.bst.storage.domain.StorageQuery;
import com.ruoyi.bst.storage.service.StorageService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -11,7 +14,7 @@ import java.util.List;
@RestController
@RequestMapping("/app/storage")
public class AppStorageController {
public class AppStorageController extends BaseController {
@Autowired
private StorageService storageService;
@ -22,4 +25,13 @@ public class AppStorageController {
return AjaxResult.success(storageService.storageWine(storageList));
}
@ApiOperation("我的存酒信息")
@GetMapping("/myWine")
public TableDataInfo myWine(@RequestParam Long storeId) {
StorageQuery query = new StorageQuery();
query.setUserId(getUserId());
query.setStoreId(storeId);
return getDataTable(storageService.selectStorageList(query));
}
}

View File

@ -3,15 +3,21 @@ package com.ruoyi.web.bst;
import com.ruoyi.bst.location.domain.Location;
import com.ruoyi.bst.location.domain.LocationQuery;
import com.ruoyi.bst.location.domain.LocationVO;
import com.ruoyi.bst.location.service.LocationAssembler;
import com.ruoyi.bst.location.service.LocationService;
import com.ruoyi.bst.location.service.LocationValidator;
import com.ruoyi.bst.storeStaff.domain.enums.StoreStaffPermission;
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.core.validate.ValidGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
@ -29,6 +35,10 @@ public class LocationController extends BaseController
{
@Autowired
private LocationService locationService;
@Autowired
private LocationAssembler locationAssembler;
@Autowired
private LocationValidator locationValidator;
/**
* 查询存放位置列表
@ -39,7 +49,10 @@ public class LocationController extends BaseController
{
startPage();
startOrderBy();
query.setScope(true);
query.addStorePermission(StoreStaffPermission.LOCATION_VIEW.getCode());
List<LocationVO> list = locationService.selectLocationList(query);
locationAssembler.assembleStorageNum(list);
return getDataTable(list);
}
@ -51,6 +64,7 @@ public class LocationController extends BaseController
@PostMapping("/export")
public void export(HttpServletResponse response, LocationQuery query)
{
query.setScope(true);
List<LocationVO> list = locationService.selectLocationList(query);
ExcelUtil<LocationVO> util = new ExcelUtil<LocationVO>(LocationVO.class);
util.exportExcel(response, list, "存放位置数据");
@ -63,7 +77,7 @@ public class LocationController extends BaseController
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(locationService.selectLocationById(id));
return success(locationService.selectLocationById(id,true));
}
/**
@ -72,7 +86,7 @@ public class LocationController extends BaseController
@PreAuthorize("@ss.hasPermi('bst:location:add')")
@Log(title = "存放位置", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Location location)
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) Location location)
{
return toAjax(locationService.insertLocation(location));
}
@ -83,8 +97,11 @@ public class LocationController extends BaseController
@PreAuthorize("@ss.hasPermi('bst:location:edit')")
@Log(title = "存放位置", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Location location)
public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) Location location)
{
if (!locationValidator.canEdit(location.getId())){
return AjaxResult.error("您没有权限修改存放位置信息");
}
return toAjax(locationService.updateLocation(location));
}
@ -94,8 +111,11 @@ public class LocationController extends BaseController
@PreAuthorize("@ss.hasPermi('bst:location:remove')")
@Log(title = "存放位置", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
public AjaxResult remove(@PathVariable List<Long> ids)
{
if (!locationValidator.canDelete(ids)){
return AjaxResult.error("您没有权限修改存放位置信息");
}
return toAjax(locationService.deleteLocationByIds(ids));
}
}

View File

@ -3,18 +3,25 @@ package com.ruoyi.web.bst;
import com.ruoyi.bst.storage.domain.Storage;
import com.ruoyi.bst.storage.domain.StorageQuery;
import com.ruoyi.bst.storage.domain.StorageVO;
import com.ruoyi.bst.storage.domain.dto.StorageDTO;
import com.ruoyi.bst.storage.service.StorageConverter;
import com.ruoyi.bst.storage.service.StorageService;
import com.ruoyi.bst.storage.service.StorageValidator;
import com.ruoyi.bst.storeStaff.domain.enums.StoreStaffPermission;
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.core.validate.ValidGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
@ -29,6 +36,10 @@ public class StorageController extends BaseController
{
@Autowired
private StorageService storageService;
@Autowired
private StorageConverter storageConverter;
@Autowired
private StorageValidator storageValidator;
/**
* 查询存酒列表
@ -39,6 +50,8 @@ public class StorageController extends BaseController
{
startPage();
startOrderBy();
query.setScope(true);
query.addStorePermission(StoreStaffPermission.STORAGE_VIEW.getCode());
List<StorageVO> list = storageService.selectStorageList(query);
return getDataTable(list);
}
@ -51,6 +64,7 @@ public class StorageController extends BaseController
@PostMapping("/export")
public void export(HttpServletResponse response, StorageQuery query)
{
query.setScope(true);
List<StorageVO> list = storageService.selectStorageList(query);
ExcelUtil<StorageVO> util = new ExcelUtil<StorageVO>(StorageVO.class);
util.exportExcel(response, list, "存酒数据");
@ -63,7 +77,7 @@ public class StorageController extends BaseController
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(storageService.selectStorageById(id));
return success(storageService.selectStorageById(id,true));
}
/**
@ -72,8 +86,9 @@ public class StorageController extends BaseController
@PreAuthorize("@ss.hasPermi('bst:storage:add')")
@Log(title = "存酒", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Storage storage)
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) Storage storage)
{
storageConverter.toPoByCreate(storage);
return toAjax(storageService.insertStorage(storage));
}
@ -83,19 +98,32 @@ public class StorageController extends BaseController
@PreAuthorize("@ss.hasPermi('bst:storage:edit')")
@Log(title = "存酒", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Storage storage)
public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) Storage storage)
{
if (!storageValidator.canEdit(storage.getId())){
return AjaxResult.error("您无权限修改当前存酒信息");
}
return toAjax(storageService.updateStorage(storage));
}
/**
* 删除存酒
* 修改存酒
*/
@PreAuthorize("@ss.hasPermi('bst:storage:remove')")
@Log(title = "", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
@PreAuthorize("@ss.hasPermi('bst:storage:getWine')")
@Log(title = "", businessType = BusinessType.UPDATE)
@PutMapping("/getWine")
public AjaxResult getWine(@RequestBody List<StorageDTO> dtoList)
{
return toAjax(storageService.deleteStorageByIds(ids));
// 权限相关校验
List<Long> ids = new ArrayList<>();
dtoList.forEach(storage->{
ids.add(storage.getStorageId());
});
if (!storageValidator.canEdit(ids)){
return AjaxResult.error("您无权限修改当前存酒信息");
}
return toAjax(storageService.getWine(dtoList));
}
}

View File

@ -126,8 +126,11 @@ public class TeamController extends BaseController
@PreAuthorize("@ss.hasPermi('bst:team:remove')")
@Log(title = "拼桌", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
public AjaxResult remove(@PathVariable List<Long> ids)
{
if (teamValidator.canDelete(ids)){
return AjaxResult.error("您没有权限删除当前拼桌信息");
}
return toAjax(teamService.deleteTeamByIds(ids));
}

View File

@ -60,6 +60,7 @@ public class TeamUserController extends BaseController
@PostMapping("/export")
public void export(HttpServletResponse response, TeamUserQuery query)
{
query.setScope(true);
List<TeamUserVO> list = teamUserService.selectTeamUserList(query);
ExcelUtil<TeamUserVO> util = new ExcelUtil<TeamUserVO>(TeamUserVO.class);
util.exportExcel(response, list, "拼桌用户数据");
@ -108,6 +109,7 @@ public class TeamUserController extends BaseController
return toAjax(teamUserService.deleteTeamUserByIds(ids));
}
@PreAuthorize("@ss.hasPermi('bst:teamUser:kick')")
@Log(title = "踢出用户", businessType = BusinessType.OTHER)
@PutMapping("/kick")