| | |
| | | package com.yeshi.fanli.service.impl.user.vip;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.user.vip.TearcherInfoDao;
|
| | | import com.yeshi.fanli.dao.user.vip.UserTearcherMapDao;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserTearcherMap;
|
| | | import com.yeshi.fanli.service.inter.user.vip.TearcherService;
|
| | |
|
| | | @Service
|
| | | public class TearcherServiceImpl implements TearcherService {
|
| | |
|
| | | @Resource
|
| | | private TearcherInfoDao tearcherInfoDao;
|
| | |
|
| | | @Resource
|
| | | private UserTearcherMapDao userTearcherMapDao;
|
| | |
|
| | | @Override
|
| | | public TearcherInfo addTearcherInfo(TearcherInfo info) {
|
| | |
|
| | | if (info.getId() == null)
|
| | | info.setId(UUID.randomUUID().toString());
|
| | |
|
| | | TearcherInfo old = tearcherInfoDao.get(info.getId());
|
| | | if (old != null)
|
| | | return old;
|
| | | tearcherInfoDao.save(info);
|
| | | return info;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void addUserTearcherMap(String tearcherId, Long uid) {
|
| | | UserTearcherMap map = userTearcherMapDao.get(uid);
|
| | | if (map != null)
|
| | | return;
|
| | | map = new UserTearcherMap();
|
| | | map.setCreateTime(new Date());
|
| | | map.setUid(uid);
|
| | | map.setTearcherInfo(new TearcherInfo(tearcherId));
|
| | | userTearcherMapDao.save(map);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<TearcherInfo> listByType(int type, int page, int count) {
|
| | | return tearcherInfoDao.listByType(type, (page - 1) * count, count);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TearcherInfo selectByUid(Long uid) {
|
| | | UserTearcherMap map = userTearcherMapDao.get(uid);
|
| | | if (map != null)
|
| | | return map.getTearcherInfo();
|
| | | else
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.user.vip; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.fanli.dao.user.vip.TearcherInfoDao; |
| | | import com.yeshi.fanli.dao.user.vip.UserTearcherMapDao; |
| | | import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo; |
| | | import com.yeshi.fanli.entity.bus.user.vip.UserTearcherMap; |
| | | import com.yeshi.fanli.service.inter.user.vip.TearcherService; |
| | | |
| | | @Service |
| | | public class TearcherServiceImpl implements TearcherService { |
| | | |
| | | @Resource |
| | | private TearcherInfoDao tearcherInfoDao; |
| | | |
| | | @Resource |
| | | private UserTearcherMapDao userTearcherMapDao; |
| | | |
| | | @Override |
| | | public TearcherInfo addTearcherInfo(TearcherInfo info) { |
| | | |
| | | if (info.getId() == null) |
| | | info.setId(UUID.randomUUID().toString()); |
| | | |
| | | TearcherInfo old = tearcherInfoDao.get(info.getId()); |
| | | if (old != null) |
| | | return old; |
| | | tearcherInfoDao.save(info); |
| | | return info; |
| | | } |
| | | |
| | | @Override |
| | | public void addUserTearcherMap(String tearcherId, Long uid) { |
| | | UserTearcherMap map = userTearcherMapDao.get(uid); |
| | | if (map != null) |
| | | return; |
| | | map = new UserTearcherMap(); |
| | | map.setCreateTime(new Date()); |
| | | map.setUid(uid); |
| | | map.setTearcherInfo(new TearcherInfo(tearcherId)); |
| | | userTearcherMapDao.save(map); |
| | | } |
| | | |
| | | @Override |
| | | public List<TearcherInfo> listByType(int type, int page, int count) { |
| | | return tearcherInfoDao.listByType(type, (page - 1) * count, count); |
| | | } |
| | | |
| | | @Override |
| | | public TearcherInfo selectByUid(Long uid) { |
| | | UserTearcherMap map = userTearcherMapDao.get(uid); |
| | | if (map != null) |
| | | return map.getTearcherInfo(); |
| | | else |
| | | return null; |
| | | } |
| | | |
| | | } |