package com.goafanti.user.service.impl; import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import org.apache.commons.lang3.StringUtils; 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.bo.UserIdentityBo; import com.goafanti.user.service.UserInterestService; @Service public class UserInterestServiceImpl extends BaseMybatisDao 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 listInterestUser(Integer pageNo, Integer pageSize, Integer userType) { Map 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) findPage("findInterestUserListByPage", "findInterestUserCount", params, pageNo, pageSize); } @Override public Integer countByToUid(String toUid) { return userInterestMapper.countByToUid(toUid); } @SuppressWarnings("unchecked") @Override public Pagination expertsList(String industry, Integer pNo, Integer pSize) { System.out.println(industry); if (pNo == null || pNo < 0) { pNo = 1; } if (pSize == null || pSize < 0 || pSize > 10) { pSize = 10; } Map params =new HashMap(); if (StringUtils.isNotBlank( industry)) { params.put("industry",industry); } Pagination p=(Pagination) findPage("findUserCareerListByPage", "findUserCareerCount",params, pNo, pSize); List list=(List) p.getList(); /*for (UserIdentityBo d : list) { int i=userInterestMapper.countByToUid(d.getUid()); d.setCountInterest(String.valueOf(i)); }*/ return p; } }