AppUserController.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. package com.goafanti.app.controller;
  2. import java.lang.reflect.InvocationTargetException;
  3. import java.util.ArrayList;
  4. import java.util.Date;
  5. import java.util.List;
  6. import java.util.UUID;
  7. import javax.annotation.Resource;
  8. import javax.servlet.http.HttpServletRequest;
  9. import javax.validation.Valid;
  10. import org.apache.commons.lang3.StringUtils;
  11. import org.apache.shiro.crypto.hash.SimpleHash;
  12. import org.springframework.beans.BeanUtils;
  13. import org.springframework.http.HttpMethod;
  14. import org.springframework.validation.BindingResult;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RequestMethod;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import com.alibaba.fastjson.JSONObject;
  19. import com.goafanti.achievement.bo.InputAchievement;
  20. import com.goafanti.achievement.service.AchievementInterestService;
  21. import com.goafanti.achievement.service.AchievementService;
  22. import com.goafanti.activity.service.ActivityService;
  23. import com.goafanti.banners.service.BannersService;
  24. import com.goafanti.common.bo.Result;
  25. import com.goafanti.common.constant.AFTConstants;
  26. import com.goafanti.common.constant.ErrorConstants;
  27. import com.goafanti.common.controller.BaseApiController;
  28. import com.goafanti.common.enums.AchievementFields;
  29. import com.goafanti.common.enums.AttachmentType;
  30. import com.goafanti.common.enums.DemandFields;
  31. import com.goafanti.common.model.Achievement;
  32. import com.goafanti.common.model.Demand;
  33. import com.goafanti.common.model.JpushEasemobAccount;
  34. import com.goafanti.common.model.MessageConsumer;
  35. import com.goafanti.common.model.MessageFromSystem;
  36. import com.goafanti.common.model.MessageProducer;
  37. import com.goafanti.common.model.User;
  38. import com.goafanti.common.service.FieldGlossoryService;
  39. import com.goafanti.common.utils.DateUtils;
  40. import com.goafanti.core.shiro.token.TokenManager;
  41. import com.goafanti.demand.bo.InputDemand;
  42. import com.goafanti.demand.service.DemandService;
  43. import com.goafanti.easemob.EasemobUtils;
  44. import com.goafanti.easemob.bo.EasemobInfo;
  45. import com.goafanti.message.bo.MessageBo;
  46. import com.goafanti.message.bo.MessageListBo;
  47. import com.goafanti.message.service.MessageService;
  48. import com.goafanti.news.service.NewsService;
  49. import com.goafanti.user.service.UserCareerService;
  50. import com.goafanti.user.service.UserIdentityService;
  51. import com.goafanti.user.service.UserInterestService;
  52. import com.goafanti.user.service.UserService;
  53. @RestController
  54. @RequestMapping(path = "/app/user", method = RequestMethod.GET)
  55. public class AppUserController extends BaseApiController {
  56. @Resource
  57. private UserService userServiceImpl;
  58. @Resource
  59. private MessageService messageService;
  60. @Resource
  61. private EasemobUtils easemobUtils;
  62. @Resource
  63. private BannersService bannersService;
  64. @Resource
  65. private ActivityService activityService;
  66. @Resource
  67. private NewsService newsService;
  68. @Resource
  69. private AchievementService achievementService;
  70. @Resource
  71. private DemandService demandService;
  72. @Resource
  73. private UserCareerService userCareerService;
  74. @Resource
  75. private UserInterestService userInterestService;
  76. @Resource
  77. private UserIdentityService userIdentityService;
  78. @Resource
  79. AchievementInterestService achievementInterestService;
  80. @Resource
  81. private FieldGlossoryService fieldGlossoryService;
  82. @RequestMapping(value = "/uploadImg",method = RequestMethod.POST)
  83. public Result uploadAvatar(HttpServletRequest req){
  84. Result res = new Result();
  85. String headPortraitUrl = handleFile(res, "/avatar/", false, req, "");
  86. if(TokenManager.getToken() instanceof User){
  87. User u = new User();
  88. u.setId(TokenManager.getUserId());
  89. u.setHeadPortraitUrl(headPortraitUrl);
  90. userServiceImpl.updateByPrimaryKeySelective(u);
  91. }
  92. res.setData(headPortraitUrl);
  93. return res;
  94. }
  95. @RequestMapping(value = "/updateUser",method = RequestMethod.POST)
  96. public Result updateUser(User u){
  97. Result res = new Result();
  98. if(StringUtils.isBlank(u.getNickname())){
  99. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"用户昵称不能为空"));
  100. return res;
  101. }
  102. List<User> checkData = userServiceImpl.checkExistUser(null, null, null, null, AFTConstants.USER_SOURCE_REGISTER,
  103. u.getNickname());
  104. boolean exist = false;
  105. boolean needChange = false;
  106. if (null != checkData && checkData.size() > 0) {
  107. for (User item : checkData) {
  108. if (!item.getId().equals(TokenManager.getUserId()))
  109. exist = true;
  110. }
  111. } else {
  112. needChange = true;
  113. }
  114. if (exist) {
  115. res.getError().add(buildError(ErrorConstants.USER_NICKNAME_EXIST));
  116. return res;
  117. } else if (needChange) { // 修改环信昵称
  118. JpushEasemobAccount jea = messageService.selectSynAccByUid(TokenManager.getUserId());
  119. if (null != jea && StringUtils.isNotBlank(jea.getEasemobName())) {
  120. JSONObject resultObj = new JSONObject();
  121. resultObj.put("username", jea.getEasemobName());
  122. resultObj.put("nickname", u.getNickname());
  123. easemobUtils.sendLater(
  124. new EasemobInfo().uri("/users/").data(resultObj.toJSONString()).method(HttpMethod.POST));
  125. }
  126. }
  127. u.setId(TokenManager.getUserId());
  128. userServiceImpl.updateByPrimaryKeySelective(u);
  129. return res;
  130. }
  131. @RequestMapping(value = "/logout",method = RequestMethod.GET)
  132. public Result logout(HttpServletRequest request){
  133. Result res = new Result();
  134. TokenManager.logout();
  135. return res;
  136. }
  137. @RequestMapping(value = "/userInfo",method = RequestMethod.GET)
  138. public Result userInfo(HttpServletRequest request){
  139. Result res = new Result();
  140. res.setData(userServiceImpl.selectBaseInfo());
  141. return res;
  142. }
  143. @RequestMapping(value = "/index", method = RequestMethod.GET)
  144. public Result index(){
  145. Result res = new Result();
  146. res.setData(messageService.selectMessageWithGroup());
  147. return res;
  148. }
  149. @RequestMapping(value = "/listMessage", method = RequestMethod.POST)
  150. public Result listMessage(Integer subject,Integer sourceType,Integer pageNo,Integer pageSize){
  151. Result res = new Result();
  152. if(null == subject){
  153. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "必须指定消息类型"));
  154. return res;
  155. }
  156. User u = TokenManager.getUserToken();
  157. if(u != null){
  158. List<MessageBo> boList = messageService.selectSyncMessage(u.getId());
  159. if(boList != null && boList.size()>0){
  160. List<MessageProducer> producers = new ArrayList<MessageProducer>();
  161. List<MessageConsumer> consumers = new ArrayList<MessageConsumer>();
  162. MessageProducer mp = null;
  163. MessageConsumer mc = null;
  164. Date date = new Date();
  165. for(MessageBo bo : boList){
  166. mp = new MessageProducer();
  167. mp.setId(bo.getId());
  168. mp.setSendTime(date);
  169. producers.add(mp);
  170. mc = new MessageConsumer();
  171. mc.setId(UUID.randomUUID().toString());
  172. mc.setConsumerId(TokenManager.getUserId());
  173. mc.setMessageId(bo.getMessageId());
  174. consumers.add(mc);
  175. }
  176. if(producers.size()>0)messageService.updateMessageProducer(producers);
  177. //新增 message_consumer
  178. if(consumers.size()>0)messageService.insertBatchConsumer(consumers);
  179. }
  180. }
  181. res.setData(messageService.listPersonalMessage(subject,sourceType,pageNo,pageSize));
  182. return res;
  183. }
  184. /**
  185. * 同步绑定账号
  186. * @param uuid
  187. * @param registrationId
  188. * @param userName
  189. */
  190. @RequestMapping(value = "/synBindingAccount",method = RequestMethod.POST)
  191. private Result synBindingAccount(String uuid,String registrationId,String easemobName,String easemobPass){
  192. Result res = new Result();
  193. //更新 jpush_easemob_account
  194. messageService.updateJpushEasemobAccount(uuid, registrationId, easemobName,easemobPass);
  195. return res;
  196. }
  197. /**
  198. * 读取消息
  199. * @param messageId
  200. * @throws IllegalAccessException
  201. * @throws InvocationTargetException
  202. */
  203. @RequestMapping(value = "/readMessage",method = RequestMethod.GET)
  204. private Result readMessage(String messageId){
  205. Result res = new Result();
  206. if(StringUtils.isBlank(messageId)){
  207. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"", "消息编号为空"));
  208. return res;
  209. }
  210. //读取消息详情
  211. MessageFromSystem mfs = messageService.selectSystemMessageDetail(messageId);
  212. MessageListBo bo = new MessageListBo();
  213. bo.setCreateTime(mfs.getCreateTime()==null?"":DateUtils.formatDate(mfs.getCreateTime(), AFTConstants.YYYYMMDDHHMMSS));
  214. bo.setResourceType(String.valueOf(mfs.getResourceType()));
  215. bo.setSubject(String.valueOf(mfs.getSubject()));
  216. bo.setMessageId(mfs.getId());
  217. bo.setTitle(mfs.getTitle());
  218. bo.setBody(mfs.getBody());
  219. res.setData(bo);
  220. //更新 message_consumer
  221. messageService.updateMessageConsumer(messageId);
  222. return res;
  223. }
  224. /**
  225. * 查询环信昵称和头像
  226. * @param easemobName
  227. * @return
  228. */
  229. @RequestMapping(value = "/getNicknameAndHeadPortrait",method = RequestMethod.GET)
  230. public Result getNicknameAndHeadPortrait(String easemobName){
  231. Result res = new Result();
  232. User user = userServiceImpl.selectByNumber(easemobName);
  233. JSONObject jsonObject = new JSONObject();
  234. jsonObject.put("nickName", user.getNickname());
  235. jsonObject.put("headPortraitUrl", null == user.getHeadPortraitUrl()?"":user.getHeadPortraitUrl());
  236. res.setData(jsonObject);
  237. return res;
  238. }
  239. /**
  240. * 关注功能
  241. */
  242. @RequestMapping(value = "/interestAdd", method = RequestMethod.GET)
  243. public Result Addinterest( Integer type,String objectId,String interest) {
  244. Result res = new Result();
  245. if (null==type) {
  246. res.getError().add(buildError( "分类错误!", "分类错误"));
  247. return res;
  248. }
  249. String uid=null;
  250. if (StringUtils.isNotBlank(TokenManager.getUserId())) {
  251. uid=TokenManager.getUserId();
  252. }
  253. if (Integer.valueOf(interest)==0) {
  254. res.setData(achievementInterestService.saveInterest( uid, type, objectId,interest));
  255. }else {
  256. res.setData(achievementInterestService.deleteInterest( uid, type, objectId,interest));
  257. }
  258. return res;
  259. }
  260. /**
  261. * 我的成果
  262. */
  263. @RequestMapping(value = "/achievementList", method = RequestMethod.GET)
  264. private Result achievementList(String pageNo, String pageSize) {
  265. Result res = new Result();
  266. Integer pNo = 1;
  267. Integer pSize = 10;
  268. if (StringUtils.isNumeric(pageSize)) {
  269. pSize = Integer.parseInt(pageSize);
  270. }
  271. if (StringUtils.isNumeric(pageNo)) {
  272. pNo = Integer.parseInt(pageNo);
  273. }
  274. res.setData(achievementService.listAppMyAchievement(pNo, pSize));
  275. return res;
  276. }
  277. /**
  278. * 我的需求
  279. */
  280. @RequestMapping(value = "/demandList", method = RequestMethod.GET)
  281. public Result demandList(String pageNo, String pageSize) {
  282. Result res = new Result();
  283. Integer pNo = 1;
  284. Integer pSize = 10;
  285. if (StringUtils.isNumeric(pageSize)) {
  286. pSize = Integer.parseInt(pageSize);
  287. }
  288. if (StringUtils.isNumeric(pageNo)) {
  289. pNo = Integer.parseInt(pageNo);
  290. }
  291. res.setData(demandService.listMyDemand( pNo, pSize));
  292. return res;
  293. }
  294. /**
  295. * 关注列表
  296. */
  297. @RequestMapping(value = "/interestList", method = RequestMethod.GET)
  298. public Result interestList(Integer type,String pageNo, String pageSize) {
  299. Result res = new Result();
  300. Integer pNo = 1;
  301. Integer pSize = 10;
  302. if (null==type||type<0||type>5) {
  303. res.getError().add(buildError( "类型选择错误", "类型选择错误"));
  304. }
  305. if (StringUtils.isNumeric(pageSize)) {
  306. pSize = Integer.parseInt(pageSize);
  307. }
  308. if (StringUtils.isNumeric(pageNo)) {
  309. pNo = Integer.parseInt(pageNo);
  310. }
  311. res.setData(demandService.selectinterest(type, pNo, pSize));
  312. return res;
  313. }
  314. /**
  315. * 专家详情
  316. */
  317. @RequestMapping(value = "/expertsDetail", method = RequestMethod.GET)
  318. public Result expertsDetail(String uid) {
  319. Result res = new Result();
  320. if (StringUtils.isBlank(uid)) {
  321. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"专家必须指定","专家"));
  322. return res;
  323. }
  324. res.setData(userIdentityService.expertsDetail( uid));
  325. return res;
  326. }
  327. /**
  328. * 成果详情
  329. * @param id
  330. * @return
  331. */
  332. @RequestMapping(value = "/achievementDetail", method = RequestMethod.GET)
  333. private Result userDetail(String id ) {
  334. Result res = new Result();
  335. if (StringUtils.isBlank(id)) {
  336. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"成果必须指定","成果"));
  337. return res;
  338. }
  339. res.setData(achievementService.selectAppUserOwnerDetail(id));
  340. return res;
  341. }
  342. /**
  343. * 需求详情
  344. */
  345. @RequestMapping(value = "/demandDetail", method = RequestMethod.GET)
  346. public Result DemandDetail(String id ) {
  347. Result res = new Result();
  348. if (StringUtils.isBlank(id)) {
  349. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"需求必须指定","需求"));
  350. return res;
  351. }
  352. res.setData(demandService.selectDemandDetail( id));
  353. return res;
  354. }
  355. /**
  356. * 新增成果
  357. */
  358. @RequestMapping(value = "/appAddAchievement", method = RequestMethod.POST)
  359. private Result appAddAchievement(@Valid InputAchievement ia, BindingResult bindingResult,
  360. String keyword1,String keyword2,String keyword3) {
  361. Result res = new Result();
  362. List<String> keyword=new ArrayList<>();
  363. if (!StringUtils.isBlank(keyword1)) {
  364. keyword.add(keyword1);
  365. }
  366. if (!StringUtils.isBlank(keyword2)) {
  367. keyword.add(keyword2);
  368. }
  369. if (!StringUtils.isBlank(keyword3)) {
  370. keyword.add(keyword3);
  371. }
  372. String[] keywords=(String[])keyword.toArray(new String[keyword.size()]);
  373. System.out.println(StringUtils.join(keywords,","));
  374. ia.setKeyword(StringUtils.join(keywords,","));
  375. if (bindingResult.hasErrors()) {
  376. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  377. AchievementFields.getFieldDesc(bindingResult.getFieldError().getField())));
  378. return res;
  379. }
  380. res = disposeInputAchievement(res, ia, keywords);
  381. if (!res.getError().isEmpty()) {
  382. return res;
  383. }
  384. Achievement a = new Achievement();
  385. BeanUtils.copyProperties(ia, a);
  386. res.setData(achievementService.saveAppAchievement(a, keywords));
  387. return res;
  388. }
  389. private Result disposeInputAchievement(Result res, InputAchievement ia, String[] keywords) {
  390. if (StringUtils.isBlank(ia.getName())) {
  391. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果名称", "成果名称"));
  392. return res;
  393. }
  394. if (null == ia.getCategory()) {
  395. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到数据类别", "数据类别"));
  396. return res;
  397. }
  398. if (StringUtils.isBlank(ia.getKeyword())) {
  399. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到关键词", "关键词"));
  400. return res;
  401. }
  402. if (null == keywords || keywords.length < 1) {
  403. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到关键词", "关键词"));
  404. return res;
  405. }
  406. if (null == ia.getCooperationMode()) {
  407. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到合作方式", "合作方式"));
  408. return res;
  409. }
  410. for (int i = 0; i < keywords.length; i++) {
  411. if (AFTConstants.KEYWORDLENTH < keywords[i].length()) {
  412. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "关键词长度"));
  413. return res;
  414. }
  415. }
  416. return res;
  417. }
  418. /**
  419. * 新增需求
  420. */
  421. @RequestMapping(value = "/appAddDemand", method = RequestMethod.POST)
  422. public Result appAddDemand(@Valid InputDemand demand, BindingResult bindingResult,
  423. String keyword1,String keyword2,String keyword3,
  424. String validityPeriodFormattedDate) {
  425. Result res = new Result();
  426. /*String[] keywords ;
  427. if (StringUtils.isNotEmpty(keyword3)) {
  428. keywords=new String[]{keyword1,keyword2};
  429. }else if (StringUtils.isNotEmpty(keyword2)) {
  430. keywords=new String[]{keyword1};
  431. }else {
  432. keywords=new String[]{keyword1,keyword2,keyword3};
  433. }
  434. if (null!=keywords) {
  435. demand.setKeyword(StringUtils.join(keywords,","));
  436. }*/
  437. if (bindingResult.hasErrors()) {
  438. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  439. DemandFields.getFieldDesc(bindingResult.getFieldError().getField())));
  440. return res;
  441. }
  442. res = disposeDemand(res, demand, null);
  443. if (!res.getError().isEmpty()) {
  444. return res;
  445. }
  446. Demand d = new Demand();
  447. BeanUtils.copyProperties(demand, d);
  448. if (StringUtils.isNotBlank(demand.getUrgentDays())) {
  449. d.setUrgentDays(demand.getUrgentDays());
  450. }
  451. if (StringUtils.isNotBlank(demand.getUrgentMoney())) {
  452. d.setUrgentMoney(demand.getUrgentMoney());
  453. }
  454. res.setData(demandService.saveAppUserDemand(d, validityPeriodFormattedDate, null));
  455. return res;
  456. }
  457. private Result disposeDemand(Result res, InputDemand demand, String[] keywords) {
  458. if (StringUtils.isBlank(demand.getName())) {
  459. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求名称", "需求名称"));
  460. return res;
  461. }
  462. /*if (StringUtils.isBlank(demand.getKeyword())) {
  463. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到关键词", "关键词"));
  464. return res;
  465. }
  466. if (null == keywords || keywords.length < 1) {
  467. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到关键词", "关键词"));
  468. return res;
  469. }*/
  470. if (null == demand.getIndustryCategoryA()) {
  471. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到行业类别", "行业类别"));
  472. return res;
  473. }
  474. if (null == demand.getDemandType()) {
  475. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求类型", "需求类型"));
  476. return res;
  477. }
  478. if (StringUtils.isBlank(demand.getProblemDes())) {
  479. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到问题说明", "问题说明"));
  480. return res;
  481. }
  482. /*for (int i = 0; i < keywords.length; i++) {
  483. if (AFTConstants.KEYWORDLENTH < keywords[i].length()) {
  484. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "关键词长度"));
  485. return res;
  486. }
  487. }*/
  488. return res;
  489. }
  490. /**
  491. * 成果、需求图片上传
  492. */
  493. @RequestMapping(value = "/uploadPicture", method = RequestMethod.POST)
  494. public Result uploadPicture(HttpServletRequest req, String sign) {
  495. Result res = new Result();
  496. AttachmentType attachmentType = AttachmentType.getField(sign);
  497. if (attachmentType == AttachmentType.ACHIEVEMENT_TECHNICAL_PICTURE) {
  498. res.setData(handleFiles(res, "/achievement/", false, req, sign, "achievement"));
  499. } else if (attachmentType==AttachmentType.DEMAND_PICTURE){
  500. res.setData(handleFiles(res, "/demand/", false, req, sign, "demand"));
  501. }else {
  502. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  503. }
  504. return res;
  505. }
  506. /**
  507. * 获取领域
  508. * @param pid
  509. * @param level
  510. * @return
  511. */
  512. @RequestMapping(value = "/getField", method = RequestMethod.POST)
  513. public Result getField(Integer pid, Integer level) {
  514. Result res = new Result();
  515. res.setData(fieldGlossoryService.getField(pid, level));
  516. return res;
  517. }
  518. /**
  519. * 获取环信登录账号,如果未注册则先注册
  520. */
  521. @RequestMapping(value = "/easemob", method = RequestMethod.GET)
  522. public Result getEasemob() {
  523. User u = TokenManager.getUserToken();
  524. if (u != null) {
  525. JSONObject res = easemobUtils.send(new EasemobInfo().uri("/users/" + u.getNumber()).method(HttpMethod.GET));
  526. JSONObject resultObj = new JSONObject();
  527. resultObj.put("easemobPass", new SimpleHash("md5", u.getId(), null, 1).toHex());
  528. resultObj.put("easemobName", String.valueOf(u.getNumber()));
  529. resultObj.put("nickname", StringUtils.isBlank(u.getNickname()) ? "技淘用户" + u.getNumber() : u.getNickname());
  530. if (res == null || StringUtils.equals("service_resource_not_found", (CharSequence) res.get("error"))) {
  531. easemobUtils.sendLater(
  532. new EasemobInfo().uri("/users/").data(resultObj.toJSONString()).method(HttpMethod.POST));
  533. }
  534. return res().data(resultObj);
  535. } else {
  536. return res().error(buildError("user only", "必须是登录会员才能访问。"));
  537. }
  538. }
  539. }