wangwei 7 år sedan
förälder
incheckning
49c539794f

+ 0 - 35
examcloud-core-basic-api-client/src/main/java/cn/com/qmth/examcloud/core/basic/api/client/UserCloudServiceClient.java

@@ -1,35 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.api.client;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.web.client.RestTemplate;
-
-import cn.com.qmth.examcloud.core.basic.api.UserCloudService;
-import cn.com.qmth.examcloud.core.basic.api.request.LoginReq;
-import cn.com.qmth.examcloud.core.basic.api.response.LoginResp;
-
-/**
- * user 云服务客户端
- * 
- * @author WANGWEI
- *
- */
-@Service
-public class UserCloudServiceClient extends BasicCloudClientSupport implements UserCloudService {
-
-	private static final long serialVersionUID = 5426364131505803296L;
-
-	@Autowired
-	RestTemplate restTemplate;
-
-	@Override
-	protected RestTemplate getRestTemplate() {
-		return restTemplate;
-	}
-
-	@Override
-	public LoginResp login(LoginReq req) {
-		return post("user/login", req, LoginResp.class);
-	}
-
-}

+ 0 - 169
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/UserCloudServiceProvider.java

@@ -1,169 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.api.provider;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.google.common.collect.Lists;
-
-import cn.com.qmth.examcloud.commons.base.exception.StatusException;
-import cn.com.qmth.examcloud.commons.web.security.enums.RoleMeta;
-import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
-import cn.com.qmth.examcloud.core.basic.api.UserCloudService;
-import cn.com.qmth.examcloud.core.basic.api.bean.RoleBean;
-import cn.com.qmth.examcloud.core.basic.api.bean.UserBean;
-import cn.com.qmth.examcloud.core.basic.api.request.LoginReq;
-import cn.com.qmth.examcloud.core.basic.api.response.LoginResp;
-import cn.com.qmth.examcloud.core.basic.base.enums.AccountType;
-import cn.com.qmth.examcloud.core.basic.base.enums.UserType;
-import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
-import cn.com.qmth.examcloud.core.basic.dao.StudentRepo;
-import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
-import cn.com.qmth.examcloud.core.basic.dao.entity.Org;
-import cn.com.qmth.examcloud.core.basic.dao.entity.Student;
-import cn.com.qmth.examcloud.core.basic.dao.entity.UserEntity;
-import cn.com.qmth.examcloud.core.basic.dao.entity.UserRole;
-import cn.com.qmth.examcloud.core.basic.service.UserService;
-import io.swagger.annotations.ApiOperation;
-
-/**
- * 用户服务 controller
- * 
- * @author WANGWEI
- *
- */
-@RestController
-@RequestMapping("${$rmp}" + "user")
-public class UserCloudServiceProvider extends ControllerSupport implements UserCloudService {
-
-	private static final long serialVersionUID = -5270235759913273972L;
-
-	@Autowired
-	UserService userService;
-
-	@Autowired
-	UserRepo userRepo;
-
-	@Autowired
-	OrgRepo orgRepo;
-
-	@Autowired
-	StudentRepo studentRepo;
-
-	@ApiOperation(value = "登录", notes = "")
-	@PostMapping("login")
-	@Override
-	public LoginResp login(@RequestBody LoginReq req) {
-
-		String rootOrgId = req.getRootOrgId();
-		Org rootOrg = null;
-		if (StringUtils.isBlank(rootOrgId)) {
-			if (StringUtils.isBlank(req.getDomain())) {
-				throw new StatusException("B-001001", "domain,rootOrgId 必须有一个不为空");
-			}
-
-			rootOrg = orgRepo.findFirstByParentIdAndCode(0L, req.getDomain());
-
-			if (null == rootOrg) {
-				throw new StatusException("B-001002", "机构不存在");
-			}
-
-			rootOrgId = String.valueOf(rootOrg.getId());
-
-		} else {
-			rootOrg = orgRepo.findOne(Long.valueOf(rootOrgId));
-		}
-
-		String accountType = req.getAccountType();
-		String accountValue = req.getAccountValue();
-		String password = req.getPassword();
-
-		UserBean userBean = new UserBean();
-
-		// 常规账户登录
-		if (AccountType.COMMON_LOGIN_NAME.getCode().equals(accountType)) {
-			UserEntity user = userService.getUser(Long.parseLong(rootOrgId), accountValue);
-			if (null == user) {
-				throw new StatusException("B-001004", "用户不存在");
-			}
-			String rightPassword = user.getPassword();
-			if (!rightPassword.equals(password)) {
-				throw new StatusException("B-001003", "密码错误");
-			}
-			userBean.setUserType(UserType.COMMON.getCode());
-			userBean.setUserId(user.getId());
-			userBean.setDisplayName(user.getLoginName());
-			userBean.setRootOrgId(user.getRootOrgId());
-			userBean.setRootOrgName(rootOrg != null ? rootOrg.getName() : null);
-			userBean.setOrgId(user.getOrgId());
-			List<UserRole> userRoles = user.getUserRoles();
-			ArrayList<RoleBean> roleList = Lists.newArrayList();
-
-			if (CollectionUtils.isNotEmpty(userRoles)) {
-				for (UserRole cur : userRoles) {
-					RoleBean roleBean = new RoleBean();
-					roleBean.setRoleCode(cur.getRoleCode());
-					String roleName = RoleMeta.valueOf(cur.getRoleCode()).getName();
-					roleBean.setRoleName(roleName);
-					roleList.add(roleBean);
-				}
-			}
-
-			userBean.setRoleList(roleList);
-
-		}
-		// 学生学号登录
-		else if (AccountType.STUDENT_CODE.getCode().equals(accountType)) {
-			Student student = studentRepo.findByStudentCodeAndRootOrgId(accountValue,
-					rootOrg.getId());
-			userBean = setStudentUserInfo(password, student);
-		}
-		// 学生身份证号登录
-		else if (AccountType.STUDENT_IDENTITY_NUMBER.getCode().equals(accountType)) {
-			Student student = studentRepo.findByIdentityNumberAndRootOrgId(accountValue,
-					rootOrg.getId());
-			userBean = setStudentUserInfo(password, student);
-		}
-
-		LoginResp resp = new LoginResp();
-		resp.setUserBean(userBean);
-
-		return resp;
-	}
-
-	private UserBean setStudentUserInfo(String password, Student student) {
-		UserBean userBean = new UserBean();
-		if (null == student) {
-			throw new StatusException("B-001005", "学生信息不存在");
-		}
-		UserEntity user = userRepo.findOne(student.getUser().getId());
-		String rightPassword = user.getPassword();
-		if (!rightPassword.equals(password)) {
-			throw new StatusException("B-001003", "密码错误");
-		}
-		userBean.setUserType(UserType.STUDENT.getCode());
-		userBean.setUserId(user.getId());
-		userBean.setStudentId(student.getId());
-		userBean.setDisplayName(user.getName());
-		userBean.setRootOrgId(user.getRootOrgId());
-		userBean.setOrgId(user.getOrgId());
-		userBean.setStudentCode(student.getStudentCode());
-		userBean.setIdentityNumber(student.getIdentityNumber());
-		// 设置学生角色
-		ArrayList<RoleBean> roleList = Lists.newArrayList();
-		roleList.add(new RoleBean(RoleMeta.STUDENT.name(), RoleMeta.STUDENT.getName()));
-		userBean.setRoleList(roleList);
-
-		Org org = orgRepo.findOne(user.getOrgId());
-		userBean.setOrgName(org.getName());
-		return userBean;
-	}
-
-}

+ 0 - 24
examcloud-core-basic-api/src/main/java/cn/com/qmth/examcloud/core/basic/api/UserCloudService.java

@@ -1,24 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.api;
-
-import cn.com.qmth.examcloud.commons.web.cloud.api.CloudService;
-import cn.com.qmth.examcloud.core.basic.api.request.LoginReq;
-import cn.com.qmth.examcloud.core.basic.api.response.LoginResp;
-
-/**
- * 用户云服务
- * 
- * @author WANGWEI
- *
- */
-public interface UserCloudService extends CloudService {
-
-	/**
-	 * 获取用户信息
-	 *
-	 * @author WANGWEI
-	 * @param req
-	 * @return
-	 */
-	LoginResp login(LoginReq req);
-
-}

+ 0 - 78
examcloud-core-basic-api/src/main/java/cn/com/qmth/examcloud/core/basic/api/request/LoginReq.java

@@ -1,78 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.api.request;
-
-import cn.com.qmth.examcloud.commons.web.cloud.api.BaseRequest;
-
-/**
- * @author WANGWEI
- *
- */
-public class LoginReq extends BaseRequest {
-
-	private static final long serialVersionUID = 3858312269358420299L;
-
-	/**
-	 * 顶级机构ID
-	 */
-	private String rootOrgId;
-
-	/**
-	 * 域名
-	 */
-	private String domain;
-
-	/**
-	 * 登陆账号类型
-	 */
-	private String accountType;
-
-	/**
-	 * 登陆账号值
-	 */
-	private String accountValue;
-
-	/**
-	 * 密码
-	 */
-	private String password;
-
-	public String getRootOrgId() {
-		return rootOrgId;
-	}
-
-	public void setRootOrgId(String rootOrgId) {
-		this.rootOrgId = rootOrgId;
-	}
-
-	public String getDomain() {
-		return domain;
-	}
-
-	public void setDomain(String domain) {
-		this.domain = domain;
-	}
-
-	public String getAccountType() {
-		return accountType;
-	}
-
-	public void setAccountType(String accountType) {
-		this.accountType = accountType;
-	}
-
-	public String getAccountValue() {
-		return accountValue;
-	}
-
-	public void setAccountValue(String accountValue) {
-		this.accountValue = accountValue;
-	}
-
-	public String getPassword() {
-		return password;
-	}
-
-	public void setPassword(String password) {
-		this.password = password;
-	}
-
-}

+ 0 - 20
examcloud-core-basic-api/src/main/java/cn/com/qmth/examcloud/core/basic/api/response/LoginResp.java

@@ -1,20 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.api.response;
-
-import cn.com.qmth.examcloud.commons.web.cloud.api.BaseResponse;
-import cn.com.qmth.examcloud.core.basic.api.bean.UserBean;
-
-public class LoginResp extends BaseResponse {
-
-	private static final long serialVersionUID = 1618003517901624074L;
-
-	private UserBean userBean;
-
-	public UserBean getUserBean() {
-		return userBean;
-	}
-
-	public void setUserBean(UserBean userBean) {
-		this.userBean = userBean;
-	}
-
-}