wangwei 6 년 전
부모
커밋
5a9be76cd4

+ 46 - 2
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/StudentController.java

@@ -1,6 +1,7 @@
 package cn.com.qmth.examcloud.core.basic.api.controller;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -27,11 +28,15 @@ 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.helpers.page.PageInfo;
 import cn.com.qmth.examcloud.commons.web.security.bean.User;
 import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
+import cn.com.qmth.examcloud.core.basic.api.controller.bean.StudentDomain;
 import cn.com.qmth.examcloud.core.basic.base.constants.BasicConsts;
+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.OrgEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.StudentEntity;
 import cn.com.qmth.examcloud.core.basic.service.StudentService;
 import cn.com.qmth.examcloud.core.basic.service.bean.StudentInfo;
@@ -54,6 +59,9 @@ public class StudentController extends ControllerSupport {
 	@Autowired
 	UserRepo userRepo;
 
+	@Autowired
+	OrgRepo orgRepo;
+
 	/**
 	 * 方法注释
 	 *
@@ -67,7 +75,7 @@ public class StudentController extends ControllerSupport {
 	 */
 	@ApiOperation(value = "查询学生分页数据", notes = "分页")
 	@GetMapping("studentPage/{curPage}/{pageSize}")
-	public Page<StudentEntity> getStudentPage(@PathVariable Integer curPage,
+	public PageInfo<StudentDomain> getStudentPage(@PathVariable Integer curPage,
 			@PathVariable Integer pageSize, @RequestParam String name,
 			@RequestParam String studentCode, @RequestParam String identityNumber,
 			@RequestParam(required = false) Long rootOrgId) {
@@ -102,7 +110,43 @@ public class StudentController extends ControllerSupport {
 				new Sort(Direction.DESC, "updateTime"));
 
 		Page<StudentEntity> studentList = studentRepo.findAll(specification, pageRequest);
-		return studentList;
+
+		Iterator<StudentEntity> iterator = studentList.iterator();
+
+		List<StudentDomain> studentDomainList = Lists.newArrayList();
+
+		while (iterator.hasNext()) {
+			StudentEntity next = iterator.next();
+			StudentDomain bean = new StudentDomain();
+			bean.setId(next.getId());
+			bean.setName(next.getName());
+			bean.setRootOrgId(next.getRootOrgId());
+			bean.setUpdateTime(next.getUpdateTime());
+			bean.setCreationTime(next.getCreationTime());
+			bean.setEnable(next.getEnable());
+			bean.setStudentCode(next.getStudentCode());
+			bean.setIdentityNumber(next.getIdentityNumber());
+			bean.setPhotoPath(next.getPhotoPath());
+			bean.setPhoneNumber(next.getPhoneNumber());
+			bean.setSecurityPhone(next.getSecurityPhone());
+			bean.setRemark(next.getRemark());
+
+			bean.setOrgId(next.getOrgId());
+			if (null != bean.getOrgId()) {
+				OrgEntity org = orgRepo.findOne(Long.valueOf(bean.getOrgId()));
+				if (null != org) {
+					bean.setOrgName(org.getName());
+				}
+			}
+
+			studentDomainList.add(bean);
+		}
+
+		PageInfo<StudentDomain> ret = new PageInfo<StudentDomain>();
+		ret.setList(studentDomainList);
+		ret.setTotal(studentList.getTotalElements());
+		return ret;
+
 	}
 
 	/**

+ 168 - 0
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/bean/StudentDomain.java

@@ -0,0 +1,168 @@
+package cn.com.qmth.examcloud.core.basic.api.controller.bean;
+
+import java.util.Date;
+
+import cn.com.qmth.examcloud.commons.web.cloud.api.JsonSerializable;
+
+/**
+ * 类注释
+ *
+ * @author WANGWEI
+ * @date 2018年8月22日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+public class StudentDomain implements JsonSerializable {
+
+	private static final long serialVersionUID = 757531976286006550L;
+
+	private Long id;
+
+	private String name;
+
+	private String password;
+
+	private String studentCode;
+
+	private String identityNumber;
+
+	private String photoPath;
+
+	private String remark;
+
+	private Boolean enable;
+
+	private Long orgId;
+
+	private String orgName;
+
+	private Long rootOrgId;
+
+	private String phoneNumber;
+
+	private String securityPhone;
+
+	private Date updateTime;
+
+	private Date creationTime;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getPassword() {
+		return password;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	public String getStudentCode() {
+		return studentCode;
+	}
+
+	public void setStudentCode(String studentCode) {
+		this.studentCode = studentCode;
+	}
+
+	public String getIdentityNumber() {
+		return identityNumber;
+	}
+
+	public void setIdentityNumber(String identityNumber) {
+		this.identityNumber = identityNumber;
+	}
+
+	public String getPhotoPath() {
+		return photoPath;
+	}
+
+	public void setPhotoPath(String photoPath) {
+		this.photoPath = photoPath;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public Boolean getEnable() {
+		return enable;
+	}
+
+	public void setEnable(Boolean enable) {
+		this.enable = enable;
+	}
+
+	public Long getOrgId() {
+		return orgId;
+	}
+
+	public void setOrgId(Long orgId) {
+		this.orgId = orgId;
+	}
+
+	public String getOrgName() {
+		return orgName;
+	}
+
+	public void setOrgName(String orgName) {
+		this.orgName = orgName;
+	}
+
+	public Long getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
+
+	public String getPhoneNumber() {
+		return phoneNumber;
+	}
+
+	public void setPhoneNumber(String phoneNumber) {
+		this.phoneNumber = phoneNumber;
+	}
+
+	public String getSecurityPhone() {
+		return securityPhone;
+	}
+
+	public void setSecurityPhone(String securityPhone) {
+		this.securityPhone = securityPhone;
+	}
+
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public Date getCreationTime() {
+		return creationTime;
+	}
+
+	public void setCreationTime(Date creationTime) {
+		this.creationTime = creationTime;
+	}
+
+}