mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 01:01:52 +08:00
Banner管理-for review
This commit is contained in:
parent
e1c08c4661
commit
e31091c0df
@ -0,0 +1,66 @@
|
||||
package cn.iocoder.yudao.module.market.service.banner;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.market.controller.admin.activity.vo.ActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.market.controller.admin.activity.vo.ActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.market.controller.admin.activity.vo.ActivityUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页Banner Service 接口
|
||||
*
|
||||
* @author xia
|
||||
*/
|
||||
public interface ActivityService {
|
||||
|
||||
/**
|
||||
* 创建促销活动
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createActivity(@Valid ActivityCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新促销活动
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateActivity(@Valid ActivityUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除促销活动
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteActivity(Long id);
|
||||
|
||||
/**
|
||||
* 获得促销活动
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 促销活动
|
||||
*/
|
||||
ActivityDO getActivity(Long id);
|
||||
|
||||
/**
|
||||
* 获得促销活动列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 促销活动列表
|
||||
*/
|
||||
List<ActivityDO> getActivityList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得促销活动分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 促销活动分页
|
||||
*/
|
||||
PageResult<ActivityDO> getActivityPage(ActivityPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package cn.iocoder.yudao.module.market.service.banner;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.market.controller.admin.activity.vo.ActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.market.controller.admin.activity.vo.ActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.market.controller.admin.activity.vo.ActivityUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.market.convert.activity.ActivityConvert;
|
||||
import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO;
|
||||
import cn.iocoder.yudao.module.market.dal.mysql.activity.ActivityMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.market.enums.ErrorCodeConstants.ACTIVITY_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 首页banner 实现类
|
||||
*
|
||||
* @author xia
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ActivityServiceImpl implements ActivityService {
|
||||
|
||||
@Resource
|
||||
private ActivityMapper activityMapper;
|
||||
|
||||
@Override
|
||||
public Long createActivity(ActivityCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
ActivityDO activity = ActivityConvert.INSTANCE.convert(createReqVO);
|
||||
activityMapper.insert(activity);
|
||||
// 返回
|
||||
return activity.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateActivity(ActivityUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validateActivityExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ActivityDO updateObj = ActivityConvert.INSTANCE.convert(updateReqVO);
|
||||
activityMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteActivity(Long id) {
|
||||
// 校验存在
|
||||
this.validateActivityExists(id);
|
||||
// 删除
|
||||
activityMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateActivityExists(Long id) {
|
||||
if (activityMapper.selectById(id) == null) {
|
||||
throw exception(ACTIVITY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityDO getActivity(Long id) {
|
||||
return activityMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActivityDO> getActivityList(Collection<Long> ids) {
|
||||
return activityMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ActivityDO> getActivityPage(ActivityPageReqVO pageReqVO) {
|
||||
return activityMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user