Browse Source

Merge remote-tracking branch 'origin/master'

Joburgess 5 years ago
parent
commit
e38c74e05a

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

@@ -110,4 +110,18 @@ public interface StudentManageService {
      * @return
      */
     PageInfo<StudentManageVipGroupClassDto> findStudentVipGroupClass(StudentManageVipClassQueryInfo queryInfo);
+
+    /**
+     * 后台注册学员
+     * @param sysUser
+     * @return
+     */
+    int studentRegister(SysUser sysUser);
+
+    /**
+     * 修改学员信息
+     * @param sysUser
+     * @return
+     */
+    int studentUpdate(SysUser sysUser);
 }

+ 0 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ContractServiceImpl.java

@@ -42,7 +42,6 @@ import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
 import com.ym.mec.biz.service.ContractService;
 import com.ym.mec.biz.service.GoodsService;
 import com.ym.mec.biz.service.MusicGroupService;
-import com.ym.mec.biz.service.MusicGroupSubjectGoodsGroupService;
 import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
 import com.ym.mec.biz.service.StudentPaymentOrderService;
 import com.ym.mec.biz.service.StudentRegistrationService;

+ 1 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/EmployeeServiceImpl.java

@@ -90,8 +90,7 @@ public class EmployeeServiceImpl extends BaseServiceImpl<Integer, Employee>  imp
 		employeeDao.batchAddEmployeeRole(employee.getId(),employee.getRoleIds());
 		//添加用户现金账户
 		sysUserCashAccountDao.insert(new SysUserCashAccount(employee.getId(),"CNY"));
-		ImResult imResult = imFeignService.register(new ImUserModel(employee.getId().toString(), employee.getUsername(),
-				StringUtils.isEmpty(employee.getAvatar())?sysConfigDao.findConfigValue(SysConfigService.USER_DEFAULT_HEAD_URL):employee.getAvatar()));
+		ImResult imResult = imFeignService.register(new ImUserModel(employee.getId().toString(), employee.getUsername(),null));
 		employee.setImToken(imResult.getToken());
 		teacherDao.updateUser(employee);
 	}

+ 9 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SchoolServiceImpl.java

@@ -1,5 +1,14 @@
 package com.ym.mec.biz.service.impl;
 
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
 import com.ym.mec.biz.dal.dao.OrganizationDao;
 import com.ym.mec.biz.dal.dao.SchoolDao;
 import com.ym.mec.biz.dal.entity.School;
@@ -9,15 +18,6 @@ import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
 
 @Service
 public class SchoolServiceImpl extends BaseServiceImpl<Integer, School>  implements SchoolService {

+ 47 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentManageServiceImpl.java

@@ -1,6 +1,8 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.auth.api.enums.SysUserType;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.MusicGroup;
@@ -8,9 +10,12 @@ import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.entity.SysUserCashAccount;
 import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.biz.service.StudentManageService;
+import com.ym.mec.common.entity.ImResult;
+import com.ym.mec.common.entity.ImUserModel;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.QueryInfo;
+import com.ym.mec.im.ImFeignService;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.http.HttpUtil;
 import org.apache.commons.collections.MapUtils;
@@ -38,6 +43,10 @@ public class StudentManageServiceImpl implements StudentManageService {
     @Autowired
     private StudentRegistrationDao studentRegistrationDao;
     @Autowired
+    private ImFeignService imFeignService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+    @Autowired
     private ClassGroupDao classGroupDao;
     @Autowired
     private StudentPaymentOrderDao studentPaymentOrderDao;
@@ -275,4 +284,42 @@ public class StudentManageServiceImpl implements StudentManageService {
         pageInfo.setRows(dataList);
         return pageInfo;
     }
+
+    @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){
+            throw new BizException("手机号已被占用");
+        }
+        sysUser.setUserType(SysUserType.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"));
+        return userId;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int studentUpdate(SysUser sysUser) {
+        Integer userId = sysUser.getId();
+        if(userId == null || StringUtils.isEmpty(sysUser.getPhone())){
+            throw new BizException("参数校验失败");
+        }
+        SysUser sysUser1 = sysUserFeignService.queryUserByMobile(sysUser.getPhone());
+        if(sysUser1 == null){
+            throw new BizException("用户不存在");
+        }
+        if(!userId.equals(sysUser1.getId())){
+            throw new BizException("手机号已被占用");
+        }
+        teacherDao.updateUser(sysUser);
+        return userId;
+    }
 }

+ 4 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -511,10 +511,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 //添加用户电子签章账户
 //                contractService.register(userId, sysUser.getRealName(), sysUser.getIdCardNo(), sysUser.getPhone());
                 //注册到融云
-                if (StringUtils.isEmpty(sysUser.getAvatar())) {
-                    sysUser.setAvatar(sysConfigDao.findConfigValue(SysConfigService.USER_DEFAULT_HEAD_URL));
-                }
-                ImResult register = imFeignService.register(new ImUserModel(userId.toString(), sysUser.getUsername(), sysUser.getAvatar()));
+//                if (StringUtils.isEmpty(sysUser.getAvatar())) {
+//                    sysUser.setAvatar(sysConfigDao.findConfigValue(SysConfigService.USER_DEFAULT_HEAD_URL));
+//                }
+                ImResult register = imFeignService.register(new ImUserModel(userId.toString(), sysUser.getUsername(), null));
                 sysUser.setImToken(register.getToken());
                 teacherDao.updateUser(sysUser);
             } else {

+ 2 - 14
mec-biz/src/main/resources/config/mybatis/SchoolMapper.xml

@@ -122,7 +122,7 @@
     <select id="queryByOrganId" resultMap="School">
         SELECT * FROM school
         <where>
-            del_flag_ != 1
+            del_flag_ != 1 and user_id_ is null
             <if test="organId != null">
                 AND FIND_IN_SET(organ_id_,#{organId})
             </if>
@@ -136,18 +136,6 @@
         select * from school where del_flag_ != 1 and user_id_ = #{userId}
     </select>
     <select id="findVipSchoolByUserId" resultMap="School">
-        SELECT
-            *
-        FROM
-            school
-        WHERE
-            del_flag_ != 1
-            AND organ_id_=#{organId}
-            <if test="isDefault == null">
-                AND ( user_id_ IS NULL OR user_id_ = #{userId} )
-            </if>
-            <if test="isDefault != null">
-                AND user_id_ = #{userId}
-            </if>
+        SELECT * FROM school WHERE del_flag_ != 1 AND (FIND_IN_SET(organ_id_,#{organId}) and user_id_ is NULL) or user_id_ = #{userId}
     </select>
 </mapper>

+ 12 - 1
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherSchoolController.java

@@ -7,9 +7,12 @@ import com.ym.mec.biz.dal.entity.School;
 import com.ym.mec.biz.dal.entity.Teacher;
 import com.ym.mec.biz.service.SchoolService;
 import com.ym.mec.common.controller.BaseController;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -72,6 +75,14 @@ public class TeacherSchoolController extends BaseController {
         if(sysUser == null){
             return failed(HttpStatus.FORBIDDEN,"请登录");
         }
-        return succeed(schoolService.findVipSchoolByTeacher(sysUser.getId(),sysUser.getOrganId(),isDefault));
+        Teacher teacher = teacherDao.get(sysUser.getId());
+        if(teacher == null){
+        	return failed("非法访问");
+		}
+		String organIdList = teacher.getOrganId();
+		if (StringUtils.isNoneBlank(teacher.getFlowOrganRange())) {
+			organIdList = organIdList + "," + teacher.getFlowOrganRange();
+		}
+        return succeed(schoolService.findVipSchoolByTeacher(sysUser.getId(),organIdList,isDefault));
     }
 }

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

@@ -115,10 +115,11 @@ public class SchoolController extends BaseController {
     @ApiOperation(value = "获取教师vip课教学点")
     @GetMapping("/findVipSchoolByTeacher")
     public Object findVipSchoolByTeacher(@ApiParam(value = "教师编号", required = true) Integer userId){
-        SysUser sysUser = sysUserFeignService.queryUserById(userId);
+    	SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (sysUser == null) {
             return failed("用户信息获取失败");
         }
-        return succeed(schoolService.findVipSchoolByTeacher(userId,sysUser.getOrganId(),null));
+        String organidList = sysUser.getOrganId();
+        return succeed(schoolService.findVipSchoolByTeacher(userId,organidList,null));
     }
 }

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

@@ -16,10 +16,12 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 
 @Api(tags = "学生管理")
@@ -60,6 +62,27 @@ public class StudentManageController extends BaseController {
         return succeed(studentManageService.findStudentsByOrganId(queryInfo));
     }
 
+    @ApiOperation(value = "学员注册")
+    @PostMapping("/register")
+    @PreAuthorize("@pcs.hasPermissions('studentManage/register')")
+    public Object studentRegister(SysUser sysUser){
+        return succeed(studentManageService.studentRegister(sysUser));
+    }
+
+    @ApiOperation(value = "修改学员信息")
+    @PostMapping("/studentUpdate")
+    @PreAuthorize("@pcs.hasPermissions('studentManage/studentUpdate')")
+    public Object studentUpdate(Integer id, String phone, String username, Integer gender, String realName, Date birthdate){
+        SysUser sysUser = new SysUser();
+        sysUser.setId(id);
+        sysUser.setPhone(phone);
+        sysUser.setUsername(username);
+        sysUser.setGender(gender);
+        sysUser.setRealName(realName);
+        sysUser.setBirthdate(birthdate);
+        return succeed(studentManageService.studentUpdate(sysUser));
+    }
+
     @ApiOperation(value = "乐团管理--乐团详情--获取学员列表")
     @GetMapping("/queryMusicGroupStudent")
     @PreAuthorize("@pcs.hasPermissions('studentManage/queryMusicGroupStudent')")