CertifyApiController.java 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.goafanti.common.controller;
  2. import javax.annotation.Resource;
  3. import com.goafanti.common.bo.Result;
  4. import com.goafanti.common.constant.ErrorConstants;
  5. import com.goafanti.common.enums.UserLevel;
  6. import com.goafanti.common.model.User;
  7. import com.goafanti.core.shiro.token.TokenManager;
  8. import com.goafanti.user.service.OrganizationIdentityService;
  9. import com.goafanti.user.service.UserIdentityService;
  10. public class CertifyApiController extends BaseApiController {
  11. @Resource
  12. private OrganizationIdentityService organizationIdentityService;
  13. @Resource
  14. private UserIdentityService userIdentityService;
  15. public boolean checkCertify(Result res, User user) {
  16. if (user == null) {
  17. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户未指定", "用户"));
  18. return false;
  19. }
  20. if (UserLevel.getStatus(user.getLvl()).equals(UserLevel.GENERAL)) {
  21. res.getError().add(buildError(ErrorConstants.NON_CERTIFIED, "未通过实名认证,无法操作!"));
  22. return false;
  23. }
  24. return true;
  25. }
  26. public boolean checkAdminLogin(Result res) {
  27. if (TokenManager.getAdminToken() == null) {
  28. res.getError().add(buildError(ErrorConstants.NON_LOGIN, "找不到登录信息"));
  29. return false;
  30. }
  31. return true;
  32. }
  33. public boolean checkUserLogin(Result res) {
  34. if (TokenManager.getUserToken() == null) {
  35. res.getError().add(buildError(ErrorConstants.NON_LOGIN, "找不到登录信息"));
  36. return false;
  37. }
  38. return true;
  39. }
  40. }