UserInterestServiceImpl.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package com.goafanti.user.service.impl;
  2. import java.util.Calendar;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import java.util.UUID;
  7. import org.apache.commons.lang3.StringUtils;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.stereotype.Service;
  10. import com.goafanti.common.dao.UserInterestMapper;
  11. import com.goafanti.common.model.UserInterest;
  12. import com.goafanti.core.mybatis.BaseMybatisDao;
  13. import com.goafanti.core.mybatis.page.Pagination;
  14. import com.goafanti.core.shiro.token.TokenManager;
  15. import com.goafanti.user.bo.InterestUserListBo;
  16. import com.goafanti.user.bo.UserIdentityBo;
  17. import com.goafanti.user.service.UserInterestService;
  18. @Service
  19. public class UserInterestServiceImpl extends BaseMybatisDao<UserInterestMapper> implements UserInterestService {
  20. @Autowired
  21. private UserInterestMapper userInterestMapper;
  22. @Override
  23. public UserInterest findByFromUidAndToUid(String fromUid, String toUid) {
  24. return userInterestMapper.findByFromUidAndToUid(fromUid, toUid);
  25. }
  26. @Override
  27. public String insert(String toUid) {
  28. UserInterest ui = new UserInterest();
  29. ui.setId(UUID.randomUUID().toString());
  30. ui.setFromUid(TokenManager.getUserId());
  31. ui.setToUid(toUid);
  32. Calendar now = Calendar.getInstance();
  33. now.set(Calendar.MILLISECOND, 0);
  34. ui.setCreateTime(now.getTime());
  35. userInterestMapper.insert(ui);
  36. return ui.getId();
  37. }
  38. @Override
  39. public UserInterest findByPrimaryKey(String id) {
  40. return userInterestMapper.selectByPrimaryKey(id);
  41. }
  42. @Override
  43. public int deleteByPrimaryKey(String id) {
  44. return userInterestMapper.deleteByPrimaryKey(id);
  45. }
  46. @SuppressWarnings("unchecked")
  47. @Override
  48. public Pagination<InterestUserListBo> listInterestUser(Integer pageNo, Integer pageSize, Integer userType) {
  49. Map<String, Object> params = new HashMap<>();
  50. if (pageNo == null || pageNo < 0) {
  51. pageNo = 1;
  52. }
  53. if (pageSize == null || pageSize < 0 || pageSize > 10) {
  54. pageSize = 10;
  55. }
  56. if (userType != null) {
  57. params.put("userType", userType);
  58. }
  59. params.put("fromUid", TokenManager.getUserId());
  60. return (Pagination<InterestUserListBo>) findPage("findInterestUserListByPage", "findInterestUserCount", params,
  61. pageNo, pageSize);
  62. }
  63. @Override
  64. public Integer countByToUid(String toUid) {
  65. return userInterestMapper.countByToUid(toUid);
  66. }
  67. @SuppressWarnings("unchecked")
  68. @Override
  69. public Pagination<UserIdentityBo> expertsList(String industry, Integer pNo, Integer pSize) {
  70. System.out.println(industry);
  71. if (pNo == null || pNo < 0) {
  72. pNo = 1;
  73. }
  74. if (pSize == null || pSize < 0 || pSize > 10) {
  75. pSize = 10;
  76. }
  77. Map<String, Object> params =new HashMap<String, Object>();
  78. if (StringUtils.isNotBlank( industry)) {
  79. params.put("industry",industry);
  80. }
  81. Pagination<UserIdentityBo> p=(Pagination<UserIdentityBo>) findPage("findUserCareerListByPage",
  82. "findUserCareerCount",params,
  83. pNo, pSize);
  84. List<UserIdentityBo> list=(List<UserIdentityBo>) p.getList();
  85. /*for (UserIdentityBo d : list) {
  86. int i=userInterestMapper.countByToUid(d.getUid());
  87. d.setCountInterest(String.valueOf(i));
  88. }*/
  89. return p;
  90. }
  91. }