保存营销信息

定义Service

找到CourseMarketService,新增保存课程营销信息方法:

CourseMarketService
/**
* <p>
* 课程营销信息 服务类
* </p>
*
* @author sw-code
* @since 2023-08-18
*/
public interface CourseMarketService extends IService<CourseMarket> {

/**
* 保存课程营销信息
*
* @param courseMarket 课程营销信息
* @return 是否保存成功
*/
public boolean saveOrUpdateCourseMarket(CourseMarket courseMarket);

}

找到CourseMarketServiceImpl,实现该方法:

CourseMarketServiceImpl
/**
* <p>
* 课程营销信息 服务实现类
* </p>
*
* @author sw-code
* @since 2023-08-18
*/
@Service
public class CourseMarketServiceImpl extends ServiceImpl<CourseMarketMapper, CourseMarket> implements CourseMarketService {

/**
* 保存课程营销信息
*
* @param courseMarket 课程营销信息
* @return 是否保存成功
*/
@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

commit "完成课程类别查询功能"