Banner管理-for review

pull/2/head
xiaxiaoYY 2022-05-31 15:57:30 +08:00
parent e1c08c4661
commit e31091c0df
2 changed files with 145 additions and 0 deletions

View File

@ -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);
}

View File

@ -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);
}
}