UserServiceImpl.java 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. package com.goafanti.user.service.impl;
  2. import java.text.ParseException;
  3. import java.util.Date;
  4. import java.util.HashMap;
  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.OrganizationIdentityMapper;
  11. import com.goafanti.common.dao.OrganizationInfoMapper;
  12. import com.goafanti.common.dao.PatentCostMapper;
  13. import com.goafanti.common.dao.UserMapper;
  14. import com.goafanti.common.model.OrganizationIdentity;
  15. import com.goafanti.common.model.OrganizationInfo;
  16. import com.goafanti.common.model.User;
  17. import com.goafanti.common.utils.DateUtils;
  18. import com.goafanti.core.mybatis.BaseMybatisDao;
  19. import com.goafanti.core.mybatis.page.Pagination;
  20. import com.goafanti.user.bo.OrgListBo;
  21. import com.goafanti.user.bo.UserDownLoadBo;
  22. import com.goafanti.user.bo.UserListBo;
  23. import com.goafanti.user.bo.UserPageHomeBo;
  24. import com.goafanti.user.service.UserService;
  25. @Service
  26. public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserService {
  27. @Autowired
  28. UserMapper userMapper;
  29. @Autowired
  30. OrganizationInfoMapper organizationInfoMapper;
  31. @Autowired
  32. OrganizationIdentityMapper organizationIdentityMapper;
  33. @Override
  34. public User insertRegister(User user,String contacts,String companyName,String uid) {
  35. userMapper.insert(user);
  36. if (1 == user.getType()){
  37. if (!StringUtils.isBlank(companyName)){
  38. OrganizationInfo organizationInfo = new OrganizationInfo();
  39. organizationInfo.setUid(uid);
  40. organizationInfo.setCompanyName(companyName);
  41. organizationInfo.setId(UUID.randomUUID().toString());
  42. organizationInfoMapper.insert(organizationInfo);
  43. }
  44. if (!StringUtils.isBlank(contacts)){
  45. OrganizationIdentity organizationIdentity = new OrganizationIdentity();
  46. organizationIdentity.setUid(uid);
  47. organizationIdentity.setId(UUID.randomUUID().toString());
  48. organizationIdentity.setContacts(contacts);
  49. organizationIdentityMapper.insert(organizationIdentity);
  50. }
  51. }
  52. return user;
  53. }
  54. @Override
  55. public User selectByMobieAndType(java.lang.String mobile, Integer type) {
  56. return userMapper.selectByMobieAndType(mobile,type);
  57. }
  58. @Override
  59. public User selectByPrimaryKey(String id) {
  60. return userMapper.selectByPrimaryKey(id);
  61. }
  62. @Override
  63. public int updateByPrimaryKeySelective(User u) {
  64. return userMapper.updateByPrimaryKeySelective(u);
  65. }
  66. @Override
  67. public User insert(User user) {
  68. userMapper.insert(user);
  69. return user;
  70. }
  71. @Override
  72. public int updateByPrimaryKey(User u) {
  73. return userMapper.updateByPrimaryKey(u);
  74. }
  75. @Override
  76. public UserPageHomeBo selectUserPageHomeBoByUserId(String uid) {
  77. return userMapper.selectUserPageHomeBoByUserId(uid);
  78. }
  79. @Override
  80. public UserDownLoadBo selectUserDownLoadBoByUserId(String id) {
  81. return userMapper.selectUserDownLoadBoByUserId(id);
  82. }
  83. @SuppressWarnings("unchecked")
  84. @Override
  85. public Pagination<UserListBo> listUser(String mobile, String email, String[] pDate, Integer number,
  86. String aftUsername, Integer auditStatus, Integer pageNo, Integer pageSize) throws ParseException {
  87. Map<String, Object> params = new HashMap<>();
  88. Date pStart = null;
  89. Date pEnd = null;
  90. if (null != pDate ){
  91. pStart = DateUtils.parseDate(pDate[0], "yyyy-MM-dd");
  92. if (pDate.length == 2){
  93. pEnd = DateUtils.addDays(DateUtils.parseDate(pDate[1], "yyyy-MM-dd"), 1);
  94. }
  95. }
  96. if (null != pStart){
  97. params.put("pStart", pStart);
  98. }
  99. if (null != pEnd){
  100. params.put("pEnd", pEnd);
  101. }
  102. if (!StringUtils.isBlank(mobile)){
  103. params.put("mobile", mobile);
  104. }
  105. if (!StringUtils.isBlank(email)){
  106. params.put("email", email);
  107. }
  108. if (null != number ){
  109. params.put("number", number);
  110. }
  111. if (!StringUtils.isBlank(aftUsername)){
  112. params.put("aftUsername", aftUsername);
  113. }
  114. if (null != auditStatus){
  115. params.put("auditStatus", auditStatus);
  116. }
  117. if (pageNo == null || pageNo < 0) {
  118. pageNo = 1;
  119. }
  120. if (pageSize == null || pageSize < 0) {
  121. pageSize = 10;
  122. }
  123. return (Pagination<UserListBo>) findPage("findUserListByPage","findUserCount", params, pageNo,
  124. pageSize);
  125. }
  126. @SuppressWarnings("unchecked")
  127. @Override
  128. public Pagination<OrgListBo> listOrg(String mobile, String email, String[] pDate, Integer number,
  129. String aftUsername, Integer auditStatus, Integer pageNo, Integer pageSize) throws ParseException {
  130. Map<String, Object> params = new HashMap<>();
  131. Date pStart = null;
  132. Date pEnd = null;
  133. if (null != pDate ){
  134. pStart = DateUtils.parseDate(pDate[0], "yyyy-MM-dd");
  135. if (pDate.length == 2){
  136. pEnd = DateUtils.addDays(DateUtils.parseDate(pDate[1], "yyyy-MM-dd"), 1);
  137. }
  138. }
  139. if (null != pStart){
  140. params.put("pStart", pStart);
  141. }
  142. if (null != pEnd){
  143. params.put("pEnd", pEnd);
  144. }
  145. if (!StringUtils.isBlank(mobile)){
  146. params.put("mobile", mobile);
  147. }
  148. if (!StringUtils.isBlank(email)){
  149. params.put("email", email);
  150. }
  151. if (null != number ){
  152. params.put("number", number);
  153. }
  154. if (!StringUtils.isBlank(aftUsername)){
  155. params.put("aftUsername", aftUsername);
  156. }
  157. if (null != auditStatus){
  158. params.put("auditStatus", auditStatus);
  159. }
  160. if (pageNo == null || pageNo < 0) {
  161. pageNo = 1;
  162. }
  163. if (pageSize == null || pageSize < 0) {
  164. pageSize = 10;
  165. }
  166. return (Pagination<OrgListBo>) findPage("findOrgListByPage","findOrgCount", params, pageNo,
  167. pageSize);
  168. }
  169. }