| | |
| | | package com.ks.vip.service.remote; |
| | | |
| | | |
| | | import com.ks.vip.exception.VipGradePotenceException; |
| | | import com.ks.vip.mapper.VipGradePotenceMapper; |
| | | import com.ks.vip.mapper.VipGradePotenceMapper; |
| | | import com.ks.vip.pojo.DO.VipGrade; |
| | | import com.ks.vip.pojo.DO.VipGradePotence; |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | import com.ks.vip.query.VipGradePotenceQuery; |
| | | import com.ks.vip.service.VipGradePotenceService; |
| | | import com.ks.vip.service.VipGradePotenceService; |
| | | import com.ks.vip.service.VipGradeService; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service(version = "1.0") |
| | |
| | | |
| | | @Resource |
| | | private VipGradePotenceMapper vipGradePotenceMapper; |
| | | |
| | | @Resource |
| | | private VipGradeService vipGradeService; |
| | | |
| | | |
| | | @Override |
| | |
| | | return vipGradePotenceMapper.listByPage(query); |
| | | } |
| | | |
| | | @Override |
| | | public VipGradePotence getPotenceByGradeId(Long gradeId) { |
| | | return vipGradePotenceMapper.getByGradeId(gradeId); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void save(VipGradePotence t) throws VipGradePotenceException { |
| | | Long gradeId = t.getGradeId(); |
| | | if (gradeId == null) { |
| | | throw new VipGradePotenceException(1, "等级ID为空"); |
| | | } |
| | | |
| | | if(t.getId() != null && t.getId().longValue() > 0) { |
| | | t.setUpdateTime(new Date()); |
| | | vipGradePotenceMapper.updateByPrimaryKeySelective(t); |
| | | } else { |
| | | VipGradePotence obj = vipGradePotenceMapper.getByGradeId(gradeId); |
| | | if (obj == null) { |
| | | t.setCreateTime(new Date()); |
| | | vipGradePotenceMapper.insertSelective(t); |
| | | } else { |
| | | t.setId(obj.getId()); |
| | | t.setUpdateTime(new Date()); |
| | | vipGradePotenceMapper.updateByPrimaryKeySelective(t); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public VipGradePotence getDefaultGradePotence() { |
| | | VipGrade grade = vipGradeService.getDefaultGrade(); |
| | | if (grade == null) { |
| | | return null; |
| | | } |
| | | return vipGradePotenceMapper.getByGradeId(grade.getId()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public VipGradePotence getPotenceByVipEnum(VIPEnum vipEnum) { |
| | | VipGrade grade = vipGradeService.getByVipEnum(vipEnum); |
| | | if (grade == null) { |
| | | return null; |
| | | } |
| | | return vipGradePotenceMapper.getByGradeId(grade.getId()); |
| | | } |
| | | |
| | | } |