| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package com.goafanti.user.service.impl;
- import java.util.Calendar;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.UUID;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.goafanti.common.dao.UserInterestMapper;
- import com.goafanti.common.model.UserInterest;
- import com.goafanti.core.mybatis.BaseMybatisDao;
- import com.goafanti.core.mybatis.page.Pagination;
- import com.goafanti.core.shiro.token.TokenManager;
- import com.goafanti.user.bo.InterestUserListBo;
- import com.goafanti.user.service.UserInterestService;
- @Service
- public class UserInterestServiceImpl extends BaseMybatisDao<UserInterestMapper> implements UserInterestService {
- @Autowired
- private UserInterestMapper userInterestMapper;
- @Override
- public UserInterest findByFromUidAndToUid(String fromUid, String toUid) {
- return userInterestMapper.findByFromUidAndToUid(fromUid, toUid);
- }
- @Override
- public String insert(String toUid) {
- UserInterest ui = new UserInterest();
- ui.setId(UUID.randomUUID().toString());
- ui.setFromUid(TokenManager.getUserId());
- ui.setToUid(toUid);
- Calendar now = Calendar.getInstance();
- now.set(Calendar.MILLISECOND, 0);
- ui.setCreateTime(now.getTime());
- userInterestMapper.insert(ui);
- return ui.getId();
- }
- @Override
- public UserInterest findByPrimaryKey(String id) {
- return userInterestMapper.selectByPrimaryKey(id);
- }
- @Override
- public int deleteByPrimaryKey(String id) {
- return userInterestMapper.deleteByPrimaryKey(id);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<InterestUserListBo> listInterestUser(Integer pageNo, Integer pageSize, Integer userType) {
- Map<String, Object> params = new HashMap<>();
- if (pageNo == null || pageNo < 0) {
- pageNo = 1;
- }
- if (pageSize == null || pageSize < 0 || pageSize > 10) {
- pageSize = 10;
- }
- if (userType != null) {
- params.put("userType", userType);
- }
- params.put("fromUid", TokenManager.getUserId());
- return (Pagination<InterestUserListBo>) findPage("findInterestUserListByPage", "findInterestUserCount", params,
- pageNo, pageSize);
- }
- @Override
- public Integer countByToUid(String toUid) {
- return userInterestMapper.countByToUid(toUid);
- }
- }
|