拼桌bug修正与新增商品功能完善
This commit is contained in:
parent
35389c3cd3
commit
79c487eb20
|
@ -70,7 +70,7 @@ public interface GoodsMapper
|
|||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGoodsByIds(List<Long> ids);
|
||||
public int deleteGoodsByIds(@Param("ids") List<Long> ids);
|
||||
|
||||
List<Long> selectIdByQuery(@Param("query") GoodsQuery query);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
<sql id="searchCondition">
|
||||
<if test="query.storeId != null ">and bg.store_id = #{query.storeId}</if>
|
||||
<if test="query.id != null ">and bg.id = #{query.id}</if>
|
||||
<if test="query.categoryId != null ">and bg.category_id = #{query.categoryId}</if>
|
||||
<if test="query.name != null and query.name != ''">and bg.name like concat('%', #{query.name}, '%')</if>
|
||||
<if test="query.image != null and query.image != ''">and bg.image = #{query.image}</if>
|
||||
|
@ -283,7 +284,7 @@
|
|||
|
||||
<delete id="deleteGoodsByIds" parameterType="String">
|
||||
delete from bst_goods where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.ruoyi.bst.goods.service;
|
||||
|
||||
import com.ruoyi.bst.goods.domain.Goods;
|
||||
import com.ruoyi.bst.goods.domain.GoodsVO;
|
||||
import com.ruoyi.bst.store.domain.Store;
|
||||
|
||||
public interface GoodsConverter {
|
||||
|
||||
/**
|
||||
* 创建时转换为PO
|
||||
*/
|
||||
GoodsVO toPoByCreate(GoodsVO data);
|
||||
|
||||
/**
|
||||
* 更新时转换为PO
|
||||
*/
|
||||
GoodsVO toPoByUpdate(GoodsVO data);
|
||||
|
||||
}
|
|
@ -44,10 +44,10 @@ public interface GoodsService
|
|||
/**
|
||||
* 修改商品
|
||||
*
|
||||
* @param goods 商品
|
||||
* @param goodsVO 商品
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGoods(Goods goods);
|
||||
public int updateGoods(GoodsVO goodsVO);
|
||||
|
||||
/**
|
||||
* 批量删除商品
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package com.ruoyi.bst.goods.service.impl;
|
||||
|
||||
import com.ruoyi.bst.goods.domain.GoodsVO;
|
||||
import com.ruoyi.bst.goods.service.GoodsConverter;
|
||||
import com.ruoyi.bst.store.domain.Store;
|
||||
import com.ruoyi.bst.store.service.StoreConverter;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class GoodsConverterImpl implements GoodsConverter {
|
||||
@Override
|
||||
public GoodsVO toPoByCreate(GoodsVO data) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
GoodsVO po = new GoodsVO();
|
||||
// 设置基本信息
|
||||
po.setStoreId(data.getStoreId());
|
||||
po.setCategoryId(data.getCategoryId());
|
||||
po.setName(data.getName());
|
||||
po.setImage(data.getImage());
|
||||
po.setDeposit(data.getDeposit());
|
||||
po.setStatus(data.getStatus());
|
||||
po.setSort(data.getSort());
|
||||
|
||||
// 设置规格值信息
|
||||
po.setSpecVO(data.getSpecVO());
|
||||
|
||||
// 设置SKU信息
|
||||
po.setSkuVO(data.getSkuVO());
|
||||
return po;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GoodsVO toPoByUpdate(GoodsVO data) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
GoodsVO po = new GoodsVO();
|
||||
// 设置基本信息
|
||||
po.setId(data.getId());
|
||||
po.setStoreId(data.getStoreId());
|
||||
po.setCategoryId(data.getCategoryId());
|
||||
po.setName(data.getName());
|
||||
po.setImage(data.getImage());
|
||||
po.setDeposit(data.getDeposit());
|
||||
po.setStatus(data.getStatus());
|
||||
po.setSort(data.getSort());
|
||||
|
||||
// 设置规格值信息
|
||||
po.setSpecVO(data.getSpecVO());
|
||||
|
||||
// 设置SKU信息
|
||||
po.setSkuVO(data.getSkuVO());
|
||||
|
||||
return po;
|
||||
}
|
||||
}
|
|
@ -111,7 +111,7 @@ public class GoodsServiceImpl implements GoodsService
|
|||
// 通过商品ID查询旧数据
|
||||
List<SkuVO> oldList = skuService.selectListByGoodsId(goodsVO.getId());
|
||||
// 分离数据
|
||||
DiffListVO<SkuVO, SkuVO> diff = CollectionUtils.convertToDiffList(goodsVO.getSkuVO(), oldList, SkuVO::getGoodsId);
|
||||
DiffListVO<SkuVO, SkuVO> diff = CollectionUtils.convertToDiffList(goodsVO.getSkuVO(), oldList, SkuVO::getId);
|
||||
// 增改删
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
int rows = 0;
|
||||
|
@ -148,7 +148,7 @@ public class GoodsServiceImpl implements GoodsService
|
|||
// 通过商品ID查询旧数据
|
||||
List<SpecValueVO> oldList = specValueService.selectListByGoodsId(goodsVO.getId());
|
||||
// 分离数据
|
||||
DiffListVO<SpecValueVO, SpecValueVO> diff = CollectionUtils.convertToDiffList(specValueVOList, oldList, SpecValueVO::getGoodsId);
|
||||
DiffListVO<SpecValueVO, SpecValueVO> diff = CollectionUtils.convertToDiffList(specValueVOList, oldList, SpecValueVO::getId);
|
||||
// 增改删
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
int rows = 0;
|
||||
|
@ -210,13 +210,30 @@ public class GoodsServiceImpl implements GoodsService
|
|||
/**
|
||||
* 修改商品
|
||||
*
|
||||
* @param goods 商品
|
||||
* @param goodsVO 商品
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateGoods(Goods goods)
|
||||
public int updateGoods(GoodsVO goodsVO)
|
||||
{
|
||||
return goodsMapper.updateGoods(goods);
|
||||
goodsVO.setUpdateTime(DateUtils.getNowDate());
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
// 修改商品
|
||||
int i = goodsMapper.updateGoods(goodsVO);
|
||||
ServiceUtil.assertion(i != 1,"修改商品失败");
|
||||
|
||||
// 保存规格项
|
||||
this.saveSpec(goodsVO);
|
||||
|
||||
// 保存规格值
|
||||
this.saveSpecVal(goodsVO);
|
||||
|
||||
// 保存SKU
|
||||
this.saveSku(goodsVO);
|
||||
|
||||
return i;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.ruoyi.bst.sku.domain.Sku;
|
|||
import com.ruoyi.bst.sku.domain.SkuVO;
|
||||
import com.ruoyi.bst.sku.domain.SkuQuery;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.security.core.parameters.P;
|
||||
|
||||
/**
|
||||
* 商品SKUMapper接口
|
||||
|
@ -70,5 +71,5 @@ public interface SkuMapper
|
|||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSkuByIds(List<Long> ids);
|
||||
public int deleteSkuByIds(@Param("ids") List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<delete id="deleteSkuByIds" parameterType="String">
|
||||
delete from bst_sku where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
|
|
@ -70,5 +70,5 @@ public interface SpecMapper
|
|||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSpecByIds(List<Long> ids);
|
||||
public int deleteSpecByIds(@Param("ids") List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<delete id="deleteSpecByIds" parameterType="String">
|
||||
delete from bst_spec where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
|
|
@ -72,6 +72,6 @@ public interface SpecValueMapper
|
|||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSpecValueByIds(List<Long> ids);
|
||||
public int deleteSpecValueByIds(@Param("ids") List<Long> ids);
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select
|
||||
bsv.id,
|
||||
bsv.spec_id,
|
||||
bsv.value
|
||||
bsv.value,
|
||||
bg.id as goods_id
|
||||
from <include refid="searchTables"/>
|
||||
</sql>
|
||||
|
||||
|
@ -27,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<sql id="searchCondition">
|
||||
<if test="query.specId != null "> and bsv.spec_id = #{query.specId}</if>
|
||||
<if test="query.value != null and query.value != ''"> and bsv.value = #{query.value}</if>
|
||||
<if test="query.goodsId != null and query.value != ''"> and bg.id = #{query.goodsId}</if>
|
||||
<if test="query.goodsId != null and query.goodsId != ''"> and bg.id = #{query.goodsId}</if>
|
||||
<if test="query.specIds != null and query.specIds.size() > 0">
|
||||
and bsv.spec_id in
|
||||
<foreach collection="query.specIds" item="id" open="(" separator="," close=")">
|
||||
|
@ -133,7 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<delete id="deleteSpecValueByIds" parameterType="string">
|
||||
delete from bst_spec_value where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
|
|
@ -21,6 +21,9 @@ public class TeamVO extends Team{
|
|||
@ApiModelProperty("发起人头像")
|
||||
private String sponsorAvatar;
|
||||
|
||||
@ApiModelProperty("发起人性别")
|
||||
private String sponsorSex;
|
||||
|
||||
@ApiModelProperty("发起人ID")
|
||||
private Long sponsorId;
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ public class TeamAssemblerImpl implements TeamAssembler {
|
|||
team.setSponsorId(teamUserMap.get(team.getId()).getUserId());
|
||||
team.setSponsorName(teamUserMap.get(team.getId()).getNickName());
|
||||
team.setSponsorAvatar(teamUserMap.get(team.getId()).getAvatar());
|
||||
team.setSponsorSex(teamUserMap.get(team.getId()).getSex());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.ruoyi.bst.team.service.impl;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.ruoyi.bst.account.domain.AccountQuery;
|
||||
|
@ -14,6 +15,7 @@ import com.ruoyi.bst.store.domain.StoreQuery;
|
|||
import com.ruoyi.bst.store.domain.StoreVO;
|
||||
import com.ruoyi.bst.storeStaff.domain.enums.StoreStaffPermission;
|
||||
import com.ruoyi.bst.team.domain.enums.TeamStatus;
|
||||
import com.ruoyi.bst.team.service.TeamAssembler;
|
||||
import com.ruoyi.bst.team.service.TeamValidator;
|
||||
import com.ruoyi.bst.teamUser.domain.TeamUser;
|
||||
import com.ruoyi.bst.teamUser.domain.TeamUserQuery;
|
||||
|
@ -66,6 +68,8 @@ public class TeamServiceImpl implements TeamService {
|
|||
private TeamValidator teamValidator;
|
||||
@Autowired
|
||||
private ChatService chatService;
|
||||
@Autowired
|
||||
private TeamAssembler teamAssembler;
|
||||
|
||||
/**
|
||||
* 查询拼桌
|
||||
|
@ -244,6 +248,7 @@ public class TeamServiceImpl implements TeamService {
|
|||
public TeamVO getTeamInfo(TeamQuery query) {
|
||||
TeamVO vo = teamService.selectOne(query);
|
||||
ServiceUtil.assertion(vo == null,"该拼桌不存在或已解散");
|
||||
teamAssembler.assembleSponsor(Collections.singletonList(vo));
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@ public class TeamUserVO extends TeamUser{
|
|||
@ApiModelProperty("用户头像")
|
||||
private String avatar;
|
||||
|
||||
@ApiModelProperty("用户性别")
|
||||
private String sex;
|
||||
|
||||
@ApiModelProperty("店铺ID")
|
||||
private Long storeId;
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bs.store_id,
|
||||
su.nick_name,
|
||||
su.avatar,
|
||||
su.sex,
|
||||
su_inviter.nick_name as inviter_name
|
||||
from bst_team_user btu
|
||||
left join bst_team bt on btu.team_id = bt.id
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.ruoyi.bst.team.service.TeamService;
|
|||
import com.ruoyi.bst.teamUser.domain.TeamUser;
|
||||
import com.ruoyi.bst.teamUser.domain.TeamUserQuery;
|
||||
import com.ruoyi.bst.teamUser.domain.TeamUserVO;
|
||||
import com.ruoyi.bst.teamUser.domain.enums.UserStatus;
|
||||
import com.ruoyi.bst.teamUser.service.TeamUserAssembler;
|
||||
import com.ruoyi.bst.teamUser.service.TeamUserService;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.ruoyi.bst.team.domain.TeamVO;
|
||||
import com.ruoyi.bst.team.service.TeamAssembler;
|
||||
import com.ruoyi.bst.team.service.TeamService;
|
||||
import com.ruoyi.bst.teamUser.domain.enums.TeamUserStatus;
|
||||
|
||||
|
@ -35,6 +36,8 @@ public class TeamUserServiceImpl implements TeamUserService
|
|||
private TeamUserService teamUserService;
|
||||
@Autowired
|
||||
private TeamService teamService;
|
||||
@Autowired
|
||||
private TeamAssembler teamAssembler;
|
||||
|
||||
/**
|
||||
* 查询拼桌用户
|
||||
|
@ -135,6 +138,7 @@ public class TeamUserServiceImpl implements TeamUserService
|
|||
if (teamUserVO != null) {
|
||||
TeamVO teamVO = teamService.selectTeamById(teamUserVO.getTeamId());
|
||||
if (teamVO != null) {
|
||||
teamAssembler.assembleSponsor(Collections.singletonList(teamVO));
|
||||
teamUserVO.setTeam(teamVO);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.ruoyi.web.bst;
|
|||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.bst.goods.service.GoodsConverter;
|
||||
import com.ruoyi.bst.goods.service.GoodsService;
|
||||
import com.ruoyi.bst.goods.service.GoodsValidator;
|
||||
import com.ruoyi.bst.store.service.StoreValidator;
|
||||
|
@ -42,6 +43,8 @@ public class GoodsController extends BaseController {
|
|||
private StoreValidator storeValidator;
|
||||
@Autowired
|
||||
private GoodsValidator goodsValidator;
|
||||
@Autowired
|
||||
private GoodsConverter goodsConverter;
|
||||
|
||||
/**
|
||||
* 查询商品列表
|
||||
|
@ -89,7 +92,8 @@ public class GoodsController extends BaseController {
|
|||
if (!storeValidator.canEdit(goodsVO.getStoreId())) {
|
||||
return error("您无权限修改该店铺相关信息");
|
||||
}
|
||||
return toAjax(goodsService.insertGoods(goodsVO));
|
||||
GoodsVO goods = goodsConverter.toPoByCreate(goodsVO);
|
||||
return toAjax(goodsService.insertGoods(goods));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,13 +102,14 @@ public class GoodsController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('bst:goods:edit')")
|
||||
@Log(title = "商品", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Goods goods) {
|
||||
if (!goodsValidator.canEdit(goods.getId())){
|
||||
public AjaxResult edit(@RequestBody GoodsVO goodsVO) {
|
||||
if (!goodsValidator.canEdit(goodsVO.getId())){
|
||||
return error("您无权限修改该商品相关信息");
|
||||
}
|
||||
if (!storeValidator.canEdit(goods.getStoreId())) {
|
||||
if (!storeValidator.canEdit(goodsVO.getStoreId())) {
|
||||
return error("您无权限修改该店铺相关信息");
|
||||
}
|
||||
GoodsVO goods = goodsConverter.toPoByUpdate(goodsVO);
|
||||
return toAjax(goodsService.updateGoods(goods));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user