保存营销信息
定义Service
找到CourseMarketService
,新增保存课程营销信息方法:
CourseMarketService
public interface CourseMarketService extends IService<CourseMarket> {
public boolean saveOrUpdateCourseMarket(CourseMarket courseMarket);
}
|
找到CourseMarketServiceImpl
,实现该方法:
CourseMarketServiceImpl
@Service public class CourseMarketServiceImpl extends ServiceImpl<CourseMarketMapper, CourseMarket> implements CourseMarketService {
@Override @Transactional(rollbackFor = Exception.class) public boolean saveOrUpdateCourseMarket(CourseMarket courseMarket) { String charge = courseMarket.getCharge(); if (StringUtils.isEmpty(charge)) { throw new BizException("收费规则为空"); } if (charge.equals("201001")) { if (courseMarket.getPrice() == null || courseMarket.getPrice() <= 0) { throw new BizException("课程的价格不能为空且必须大于0"); } } CourseMarket dbMarket = getById(courseMarket.getId()); if (dbMarket == null) { return save(courseMarket); } else { BeanUtils.copyProperties(courseMarket, dbMarket); dbMarket.setId(courseMarket.getId()); return updateById(dbMarket); } } }
|
Push到Git