yonge 4 years ago
parent
commit
62bdac5a17

+ 2 - 1
mec-auth/mec-auth-api/src/main/java/com/ym/mec/auth/api/client/SysUserFeignService.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import com.ym.mec.auth.api.client.fallback.SysUserFeignServiceFallback;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.common.config.FeignConfiguration;
+import com.ym.mec.common.entity.HttpResponseResult;
 
 @FeignClient(contextId = "sysUserFeignService", name = "auth-server", configuration = { FeignConfiguration.class }, fallback = SysUserFeignServiceFallback.class)
 public interface SysUserFeignService {
@@ -23,7 +24,7 @@ public interface SysUserFeignService {
 	public SysUser queryUserByMobile(@RequestParam("mobile") String mobile);
 
 	@PostMapping(value = "user/add", consumes = MediaType.APPLICATION_JSON_VALUE)
-	public Object addUser(SysUser user);
+	public HttpResponseResult<Integer> addUser(SysUser user);
 
 	@GetMapping(value = "queryUserInfo")
 	public SysUser queryUserInfo();

+ 3 - 2
mec-auth/mec-auth-api/src/main/java/com/ym/mec/auth/api/client/fallback/SysUserFeignServiceFallback.java

@@ -6,6 +6,7 @@ import org.springframework.stereotype.Component;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.common.entity.HttpResponseResult;
 
 @Component
 public class SysUserFeignServiceFallback implements SysUserFeignService {
@@ -25,8 +26,8 @@ public class SysUserFeignServiceFallback implements SysUserFeignService {
 		return null;
 	}
 
-	public Object addUser(SysUser user){
-		return false;
+	public HttpResponseResult<Integer> addUser(SysUser user){
+		return null;
 	}
 
 	@Override

+ 22 - 16
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/web/controller/UserController.java

@@ -1,11 +1,32 @@
 package com.ym.mec.auth.web.controller;
 
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+
+import java.util.Date;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.MediaType;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+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.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.service.SysRoleService;
 import com.ym.mec.auth.service.SysUserRoleService;
 import com.ym.mec.auth.service.SysUserService;
 import com.ym.mec.auth.web.controller.queryInfo.SysUserQueryInfo;
 import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.ImResult;
 import com.ym.mec.common.entity.ImUserModel;
 import com.ym.mec.common.exception.BizException;
@@ -18,21 +39,6 @@ import com.ym.mec.thirdparty.eseal.ESealPlugin;
 import com.ym.mec.thirdparty.user.realname.RealnameAuthenticationPluginContext;
 import com.ym.mec.thirdparty.user.realname.provider.LinkfaceRealnameAuthenticationPlugin;
 import com.ym.mec.util.date.DateUtil;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.apache.commons.beanutils.BeanUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.MediaType;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.Date;
-import java.util.Objects;
 
 @RestController()
 @RequestMapping("user")
@@ -115,7 +121,7 @@ public class UserController extends BaseController {
 	@ApiOperation(value = "新增用户")
 	@PreAuthorize("@pcs.hasPermissions('user/add')")
 	@PostMapping(value = "/add", consumes = MediaType.APPLICATION_JSON_VALUE)
-	public Object add(@RequestBody SysUser sysUser) {
+	public HttpResponseResult<Integer> add(@RequestBody SysUser sysUser) {
 		return succeed(sysUserService.add(sysUser));
 	}
 

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/StudentManageService.java

@@ -134,7 +134,7 @@ public interface StudentManageService {
      * @param sysUser
      * @return
      */
-    int studentRegister(SysUser sysUser);
+    int studentRegister(Student student);
 
     /**
      * 修改学员信息

+ 39 - 29
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentManageServiceImpl.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.service.impl;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -65,6 +66,7 @@ import com.ym.mec.biz.dal.page.StudentSignQueryInfo;
 import com.ym.mec.biz.dal.page.TeacherPaymentRecordInfo;
 import com.ym.mec.biz.service.StudentManageService;
 import com.ym.mec.biz.service.StudentService;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.ImResult;
 import com.ym.mec.common.entity.ImUserModel;
 import com.ym.mec.common.exception.BizException;
@@ -134,6 +136,10 @@ public class StudentManageServiceImpl implements StudentManageService {
 		}
 		pageInfo.setRows(dataList);
 		
+		if(dataList.size() == 0){
+			return pageInfo;
+		}
+		
         Set<Integer> userIds = dataList.stream().map(StudentManageListDto::getUserId).collect(Collectors.toSet());
 		
 		List<StudentListCourseDto> studentListCourseDtoList = studentManageDao.queryStudentRemianCourse(userIds);
@@ -455,35 +461,39 @@ public class StudentManageServiceImpl implements StudentManageService {
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public int studentRegister(SysUser sysUser) {
-        if (sysUser == null || StringUtils.isEmpty(sysUser.getPhone())) {
-            throw new BizException("参数校验失败");
-        }
-        SysUser sysUser1 = sysUserFeignService.queryUserByMobile(sysUser.getPhone());
-        if (sysUser1 != null) {
-            if (sysUser1.getUserType().contains("STUDENT")) {
-                throw new BizException("手机号已被占用");
-            } else {
-                sysUser.setId(sysUser1.getId());
-                sysUser.setUserType(sysUser1.getUserType() + ",STUDENT");
-                teacherDao.updateUser(sysUser);
-                return sysUser1.getId();
-            }
-        }
-        sysUser.setUserType("STUDENT");
-        teacherDao.addSysUser(sysUser);
-        Integer userId = sysUser.getId();
-        ImResult register = imFeignService.register(new ImUserModel(userId.toString(), sysUser.getPhone(), null));
-        sysUser.setImToken(register.getToken());
-        teacherDao.updateUser(sysUser);
-        sysUserCashAccountDao.insert(new SysUserCashAccount(userId, "CNY"));
-        Student student = new Student(userId, studentRegistrationDao.getSubjectIds(userId));
-        student.setOperatingTag(sysUser.getOperatingTag());
-        student.setServiceTag(sysUser.getServiceTag());
-        student.setTeacherId(sysUser.getTeacherId());
-        studentService.upSet(student);
-        return userId;
-    }
+	public int studentRegister(Student student) {
+		if (student == null || StringUtils.isEmpty(student.getPhone())) {
+			throw new BizException("参数校验失败");
+		}
+		Date date = new Date();
+		SysUser sysUser = sysUserFeignService.queryUserByMobile(student.getPhone());
+		if (sysUser != null) {
+			if (sysUser.getUserType().contains("STUDENT")) {
+				throw new BizException("手机号已被占用");
+			} else {
+				student.setId(sysUser.getId());
+				student.setUserType(sysUser.getUserType() + ",STUDENT");
+				student.setUpdateTime(date);
+				sysUserFeignService.updateSysUser(student);
+			}
+		} else {
+			student.setUpdateTime(date);
+			student.setCreateTime(date);
+			student.setUserType("STUDENT");
+			HttpResponseResult<Integer> result = sysUserFeignService.addUser(student);
+			student.setId(result.getData());
+
+			ImResult register = imFeignService.register(new ImUserModel(student.getId().toString(), student.getPhone(), null));
+			student.setImToken(register.getToken());
+			sysUserFeignService.updateSysUser(student);
+
+			sysUserCashAccountDao.insert(new SysUserCashAccount(student.getId(), "CNY"));
+		}
+		student.setUserId(student.getId());
+
+		studentService.upSet(student);
+		return student.getId();
+	}
 
     @Override
     @Transactional(rollbackFor = Exception.class)

+ 2 - 2
mec-web/src/main/java/com/ym/mec/web/controller/StudentManageController.java

@@ -103,8 +103,8 @@ public class StudentManageController extends BaseController {
     @ApiOperation(value = "学员注册")
     @PostMapping("/register")
     @PreAuthorize("@pcs.hasPermissions('studentManage/register')")
-    public Object studentRegister(SysUser sysUser){
-        return succeed(studentManageService.studentRegister(sysUser));
+    public Object studentRegister(Student student){
+        return succeed(studentManageService.studentRegister(student));
     }
 
     @ApiOperation(value = "修改学员信息")