套餐相关
This commit is contained in:
parent
69b2688153
commit
2ad61c071d
|
@ -1,6 +1,8 @@
|
|||
package com.ruoyi.bst.suit.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.ruoyi.common.core.validate.ValidGroup;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
@ -8,6 +10,11 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 套餐对象 bst_suit
|
||||
*
|
||||
|
@ -27,22 +34,30 @@ public class Suit extends BaseEntity
|
|||
|
||||
@Excel(name = "店铺ID")
|
||||
@ApiModelProperty("店铺ID")
|
||||
@NotNull(message = "店铺ID不能为空",groups = {ValidGroup.Create.class})
|
||||
private Long storeId;
|
||||
|
||||
@Excel(name = "充值金额", readConverterExp = "单=位:元")
|
||||
@ApiModelProperty("充值金额")
|
||||
@NotNull(message = "充值金额不能为空",groups = {ValidGroup.Create.class})
|
||||
@Min(value = 0,message = "充值金额不能小于0")
|
||||
private BigDecimal rechargeAmount;
|
||||
|
||||
@Excel(name = "爆灯次数")
|
||||
@ApiModelProperty("爆灯次数")
|
||||
@NotNull(message = "爆灯次数不能为空",groups = {ValidGroup.Create.class})
|
||||
@Min(value = 0,message = "爆灯次数不能为负数")
|
||||
private Long lightingNums;
|
||||
|
||||
@Excel(name = "套餐名称")
|
||||
@ApiModelProperty("套餐名称")
|
||||
@NotBlank(message = "套餐名称不能为空",groups = {ValidGroup.Create.class})
|
||||
@Size(max = 32, message = "套餐名称不能超过32个字符")
|
||||
private String suitName;
|
||||
|
||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||
@ApiModelProperty("状态")
|
||||
@NotNull(message = "状态不能为空", groups = {ValidGroup.Create.class})
|
||||
private String status;
|
||||
|
||||
@Excel(name = "显示顺序")
|
||||
|
|
|
@ -12,4 +12,5 @@ public class SuitQuery extends SuitVO{
|
|||
private List<Long> suitIds;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
package com.ruoyi.bst.suit.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SuitVO extends Suit{
|
||||
|
||||
@ApiModelProperty("店铺名称")
|
||||
private String storeName;
|
||||
|
||||
}
|
||||
|
|
|
@ -71,4 +71,13 @@ public interface SuitMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteSuitBySuitIds(List<Long> suitIds);
|
||||
|
||||
/**
|
||||
* 逻辑删除套餐
|
||||
*
|
||||
* @param ids 需要删除的套餐主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int logicDel(@Param("ids") List<Long> ids);
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bsu.create_time,
|
||||
bsu.deleted,
|
||||
bsu.order_num,
|
||||
bs.user_id
|
||||
bs.user_id,
|
||||
bs.store_name
|
||||
from bst_suit bsu
|
||||
left join bst_store bs on bsu.store_id = bs.store_id
|
||||
</sql>
|
||||
|
@ -234,6 +235,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where suit_id = #{data.suitId}
|
||||
</update>
|
||||
|
||||
<!--logicDel-->
|
||||
<update id="logicDel">
|
||||
update bst_suit
|
||||
set deleted = true
|
||||
where suit_id in
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
and deleted = false
|
||||
</update>
|
||||
|
||||
<sql id="updateColumns">
|
||||
<if test="data.userId != null">user_id = #{data.userId},</if>
|
||||
<if test="data.storeId != null">store_id = #{data.storeId},</if>
|
||||
|
|
|
@ -65,10 +65,10 @@ public interface SuitService
|
|||
public int deleteSuitBySuitId(Long suitId);
|
||||
|
||||
/**
|
||||
* 查询店铺
|
||||
* 查询套餐
|
||||
*
|
||||
* @param id 店铺主键
|
||||
* @return 店铺
|
||||
* @param id 套餐主键
|
||||
* @return 套餐
|
||||
*/
|
||||
public SuitVO selectSuitById(Long id, boolean scope);
|
||||
|
||||
|
@ -79,4 +79,12 @@ public interface SuitService
|
|||
public SuitVO selectOne(SuitQuery query);
|
||||
|
||||
|
||||
/**
|
||||
* 逻辑删除套餐
|
||||
*
|
||||
* @param ids 需要删除的运营区主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int logicDel(List<Long> ids);
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@ public class SuitConverterImpl implements SuitConverter {
|
|||
}
|
||||
Suit po = new Suit();
|
||||
// 设置基本信息
|
||||
po.setUserId(data.getUserId());
|
||||
po.setStoreId(data.getStoreId());
|
||||
po.setOrderNum(data.getOrderNum());
|
||||
po.setLightingNums(data.getLightingNums());
|
||||
po.setSuitName(data.getSuitName());
|
||||
po.setRechargeAmount(data.getRechargeAmount());
|
||||
|
@ -30,6 +33,8 @@ public class SuitConverterImpl implements SuitConverter {
|
|||
Suit po = new Suit();
|
||||
// 设置基本信息
|
||||
po.setSuitId(data.getSuitId());
|
||||
po.setOrderNum(data.getOrderNum());
|
||||
po.setStoreId(data.getStoreId());
|
||||
po.setLightingNums(data.getLightingNums());
|
||||
po.setSuitName(data.getSuitName());
|
||||
po.setRechargeAmount(data.getRechargeAmount());
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import com.github.pagehelper.PageHelper;
|
||||
import com.ruoyi.bst.store.domain.StoreQuery;
|
||||
import com.ruoyi.bst.store.domain.StoreVO;
|
||||
import com.ruoyi.bst.store.service.StoreService;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
|
@ -27,6 +28,8 @@ public class SuitServiceImpl implements SuitService
|
|||
{
|
||||
@Autowired
|
||||
private SuitMapper suitMapper;
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
/**
|
||||
* 查询套餐
|
||||
|
@ -74,6 +77,9 @@ public class SuitServiceImpl implements SuitService
|
|||
@Override
|
||||
public int updateSuit(Suit suit)
|
||||
{
|
||||
StoreVO storeVO = storeService.selectStoreById(suit.getStoreId());
|
||||
ServiceUtil.assertion(storeVO==null,"当前店铺不存在");
|
||||
suit.setUserId(storeVO.getUserId());
|
||||
return suitMapper.updateSuit(suit);
|
||||
}
|
||||
|
||||
|
@ -103,19 +109,19 @@ public class SuitServiceImpl implements SuitService
|
|||
|
||||
|
||||
/**
|
||||
* 查询店铺
|
||||
* 查询套餐
|
||||
*
|
||||
* @param storeId 店铺主键
|
||||
* @param suitId 店铺主键
|
||||
* @return 店铺
|
||||
*/
|
||||
@Override
|
||||
public SuitVO selectSuitById(Long storeId, boolean scope)
|
||||
public SuitVO selectSuitById(Long suitId, boolean scope)
|
||||
{
|
||||
if (storeId == null) {
|
||||
if (suitId == null) {
|
||||
return null;
|
||||
}
|
||||
SuitQuery query = new SuitQuery();
|
||||
query.setStoreId(storeId);
|
||||
query.setSuitId(suitId);
|
||||
query.setScope(scope);
|
||||
return this.selectOne(query);
|
||||
}
|
||||
|
@ -125,8 +131,20 @@ public class SuitServiceImpl implements SuitService
|
|||
PageHelper.startPage(1, 1);
|
||||
List<SuitVO> list = suitMapper.selectSuitList(query);
|
||||
if(list.isEmpty()) {
|
||||
ServiceUtil.assertion(true,"当前店铺信息不属于您");
|
||||
ServiceUtil.assertion(true,"当前套餐信息不属于您");
|
||||
}
|
||||
return CollectionUtils.firstElement(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除套餐
|
||||
*
|
||||
* @param ids 需要删除的套餐主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int logicDel(List<Long> ids)
|
||||
{
|
||||
return suitMapper.logicDel(ids);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,14 @@ 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 com.ruoyi.system.user.service.UserValidator;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -88,7 +90,7 @@ public class SuitController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('bst:suit:add')")
|
||||
@Log(title = "套餐", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Suit suit)
|
||||
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) Suit suit)
|
||||
{
|
||||
// 若不能操作他人,则设置为当前用户
|
||||
if (!userValidator.canView(suit.getUserId())) {
|
||||
|
@ -105,7 +107,7 @@ public class SuitController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('bst:suit:edit')")
|
||||
@Log(title = "套餐", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Suit suit)
|
||||
public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) Suit suit)
|
||||
{
|
||||
if (!storeValidator.canEdit(suit.getStoreId())){
|
||||
return AjaxResult.error("您没有权限修改ID为" + suit.getStoreId() + "的商铺信息");
|
||||
|
@ -121,14 +123,28 @@ public class SuitController extends BaseController
|
|||
/**
|
||||
* 删除套餐
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('bst:suit:remove')")
|
||||
// @Log(title = "套餐", businessType = BusinessType.DELETE)
|
||||
// @DeleteMapping("/{ids}")
|
||||
// public AjaxResult remove(@PathVariable List<Long> ids)
|
||||
// {
|
||||
// if (!storeValidator.canDeleteAll(ids)) {
|
||||
// return AjaxResult.error("您没有权限删除ID为" + ids + "的店铺信息");
|
||||
// }
|
||||
// return toAjax(suitService.deleteSuitBySuitIds(ids));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 逻辑删除套餐
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:suit:remove')")
|
||||
@Log(title = "套餐", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable List<Long> ids)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult logicDel(@PathVariable List<Long> ids)
|
||||
{
|
||||
if (!storeValidator.canDeleteAll(ids)) {
|
||||
return AjaxResult.error("您没有权限删除ID为" + ids + "的店铺信息");
|
||||
}
|
||||
return toAjax(suitService.deleteSuitBySuitIds(ids));
|
||||
return toAjax(suitService.logicDel(ids));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user