Browse Source

Merge branch 'develop' of http://git.dayaedu.com/yonge/cooleshow

# Conflicts:
#	scripts/install.sh
zouxuan 1 year ago
parent
commit
4b0624fb00

+ 1 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/student/controller/SysMusicCompareRecordController.java

@@ -46,6 +46,7 @@ public class SysMusicCompareRecordController extends BaseController {
         }
         record.setUserId(sysUser.getId());
         record.setClientId("student");
+        record.setTenantId(sysUser.getTenantId());
         return succeed(sysMusicCompareRecordService.insert(record));
     }
 

+ 1 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/SysMusicCompareRecordController.java

@@ -48,6 +48,7 @@ public class SysMusicCompareRecordController extends BaseController {
         }
         record.setUserId(sysUser.getId());
         record.setClientId(ClientEnum.TEACHER.name().toLowerCase());
+        record.setTenantId(sysUser.getTenantId());
         return succeed(sysMusicCompareRecordService.insert(record));
     }
 

+ 53 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/open/OpenClient.java

@@ -0,0 +1,53 @@
+package com.yonge.cooleshow.teacher.controller.open;
+
+import com.microsvc.toolkit.middleware.oss.wrapper.OssWrapper;
+import com.yonge.cooleshow.biz.dal.service.UploadFileService;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.toolset.thirdparty.entity.UploadSign;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+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.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+
+@RestController
+@RequestMapping("${app-config.url.teacher:}/open")
+@Api(value = "开放权限接口", tags = "开放权限接口")
+public class OpenClient extends BaseController {
+
+    @Autowired
+    private UploadFileService uploadFileService;
+
+
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "bucketName", dataType = "String", value = "为空时默认使用daya"),
+            @ApiImplicitParam(name = "fileName", dataType = "String", value = "要上传的文件名称,不包含路径信息"),
+            @ApiImplicitParam(name = "postData", dataType = "Map", value = "1.如果使用js sdk上传的时候设置了ACL请设置,例\"acl\":\"public-read\"值要与SDK中一致,没有则删除该项</br>" +
+                    "2.提供js sdk中的key值,例\"key\":\"20150115/中文/${filename}\""),
+            @ApiImplicitParam(name = "unknowValueField", dataType = "List", value = "对于用户无法确定表单值的放在unknownValueField中(比如有的上传控件会添加一些表单项,但表单项的值可能是随机的)"),
+            @ApiImplicitParam(name = "pluginName", dataType = "String", value = "插件名称,默认ks3,可选值:ks3,aliyun,tencent"),
+    })
+    @ApiOperation(value = "获取上传文件签名", notes = "{\n" +
+            "    \"bucketName\":\"\",\n" +
+            "    \"filename\":\"test.png\",\n" +
+            "    \"postData\":{\n" +
+            "        \"acl\":\"public-read\",\n" +
+            "        \"key\":\"20150115/中文/${filename}\"\n" +
+            "    },\n" +
+            "    \"unknowValueField\":[\"test\"]\n" +
+            "}")
+    @PostMapping("/getUploadSign")
+    public HttpResponseResult<OssWrapper.ResponseSign> getUploadSign(@RequestParam(defaultValue = "ks3") String pluginName,
+                                                                     @RequestBody UploadSign uploadSign) {
+        // 设置默认文件存储服务方
+        uploadSign.setPluginName(pluginName);
+        return succeed(uploadFileService.getUploadSign(uploadSign));
+    }
+}

+ 1 - 1
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/SysUserFeignService.java

@@ -58,7 +58,7 @@ public interface SysUserFeignService {
 										   @RequestParam("clientId")String clientId,
 										   @RequestParam("clientSecret")String clientSecret);
 
-	@PostMapping(value = "user/getTenantByClient")
+	@GetMapping(value = "user/getTenantByClient")
 	@ApiOperation(value = "获取机构编号")
 	HttpResponseResult<Long> getTenantByClient(@RequestParam("userId")Long userId,@RequestParam("clientId")String clientId);
 

+ 5 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysUser.java

@@ -1,5 +1,6 @@
 package com.yonge.cooleshow.auth.api.entity;
 
+import com.alibaba.fastjson.JSON;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
@@ -119,4 +120,8 @@ public class SysUser implements Serializable{
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);
 	}
+
+	public String jsonString() {
+		return JSON.toJSONString(this);
+	}
 }

+ 3 - 9
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/UserController.java

@@ -40,13 +40,7 @@ import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.authentication.BadCredentialsException;
 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.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
 import java.text.MessageFormat;
@@ -135,8 +129,8 @@ public class UserController extends BaseController {
         return sysUserService.get(userId);
     }
 
-    @PostMapping(value = "/getTenantByClient", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
-    public HttpResponseResult<Long> getTenantByClient(Long userId,String clientId) {
+    @GetMapping(value = "/getTenantByClient")
+    public HttpResponseResult<Long> getTenantByClient(@RequestParam("userId")Long userId, @RequestParam("clientId")String clientId) {
         return HttpResponseResult.succeed(sysUserService.getTenantByClient(userId,clientId));
     }
 

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/TenantInfoMapper.java

@@ -65,4 +65,6 @@ public interface TenantInfoMapper extends BaseMapper<TenantInfo> {
 	String queryStudentCount(@Param("id") Long id);
 
 	String queryTeacherCount(@Param("id") Long id);
+
+    void updateIdPhone(@Param("newId") Long newId, @Param("phone") String phone, @Param("oldId") Long oldId);
 }

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/TenantStaffMapper.java

@@ -27,4 +27,6 @@ public interface TenantStaffMapper extends BaseMapper<TenantStaff> {
     TenantStaff getByPhone(@Param("phone") String phone);
 
     TenantStaff selectByUserId(@Param("id") Long id);
+
+    void updateUserId(@Param("newId") Long newId, @Param("oldId") Long oldId, @Param("username") String username, @Param("avatar") String avatar);
 }

+ 9 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantActivationCodeServiceImpl.java

@@ -333,14 +333,19 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
             Integer rowIndex = next.getRowIndex();
             TenantActivationCodeWrapper.ImportTemplate code = next.getClazz();
 
+            String acCode = code.getCode();
+            if (StringUtils.isEmpty(acCode)) {
+                continue;
+            }
+
             int msgRowNo = rowIndex + 1;
             code.checkIsIllegal().forEach(err -> errMsg.add(String.format(errTemplate, msgRowNo, err)));
             if (codeRowMap.containsKey(code.getCode())) {
                 errMsg.add(String.format(errTemplate, msgRowNo, "激活码重复"));
             }
-            codeRowMap.put(code.getCode().trim(), msgRowNo);
+            codeRowMap.put(acCode, msgRowNo);
             if (StringUtils.isNotEmpty(code.getPhone())) {
-                codePhoneMap.put(code.getCode().trim(), code.getPhone().trim());
+                codePhoneMap.put(acCode.trim(), code.getPhone().trim());
             }
 
             if (errMsg.size() > 100) {
@@ -373,9 +378,9 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
                                 TenantActivationCode::getActivationStatus));
                 for (String code : codes) {
                     if (!codeStatusMap.containsKey(code)) {
-                        errMsg.add(String.format(errTemplate, codeRowMap.get(code), "验证码无效"));
+                        errMsg.add(String.format(errTemplate, codeRowMap.get(code), "激活码无效"));
                     } else if (Boolean.TRUE.equals(codeStatusMap.get(code))) {
-                        errMsg.add(String.format(errTemplate, codeRowMap.get(code), "验证码已经激活"));
+                        errMsg.add(String.format(errTemplate, codeRowMap.get(code), "激活码已经激活"));
                     }
                 }
             }

+ 3 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantInfoMapper.xml

@@ -80,6 +80,9 @@
       set status_ = 'UNPASS'
       where  id_ =#{id}
     </update>
+    <update id="updateIdPhone">
+        update tenant_info set user_id_ = #{newId} and phone_ =#{phone}  where user_id_ = #{oldId}
+    </update>
 
     <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper$TenantInfo">
         SELECT

+ 8 - 2
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantStaffMapper.xml

@@ -20,8 +20,14 @@
         , t.status_ AS status
         , t.update_time_ AS updateTime
         , t.create_time_ AS createTime
-        </sql> 
-    
+        </sql>
+    <update id="updateUserId">
+        update Tenant_staff set  user_id_ = #{newId}
+        <where>
+        </where>
+
+    </update>
+
     <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.entity.TenantStaff">
 		SELECT         
         	<include refid="baseColumns" />

+ 53 - 28
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/TenantInfoController.java

@@ -9,6 +9,9 @@ import com.yonge.cooleshow.biz.dal.entity.TenantAlbumPurchase;
 import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
 import com.yonge.cooleshow.biz.dal.entity.TenantStaff;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
+import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
+import com.yonge.cooleshow.biz.dal.mapper.TenantInfoMapper;
+import com.yonge.cooleshow.biz.dal.mapper.TenantStaffMapper;
 import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper;
 import com.yonge.cooleshow.common.constant.SysConfigConstant;
@@ -31,6 +34,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * @Author:haonan
@@ -57,6 +61,15 @@ public class TenantInfoController extends BaseController {
     @Autowired
     private SysConfigService sysConfigService;
 
+    @Autowired
+    private SysUserMapper sysUserMapper;
+
+    @Autowired
+    private TenantStaffMapper tenantStaffMapper;
+
+    @Autowired
+    private TenantInfoMapper tenantInfoMapper;
+
     @ApiOperation(value = "发送登录短信验证码")
     @ApiImplicitParams({@ApiImplicitParam(name = "mobile", value = "手机号", required = true, dataType = "String"),
             @ApiImplicitParam(name = "type", value = "类型(PASSWD:修改密码,LOGIN:登录或注册,BANK:绑定银行卡,PHONE:修改手机号)", required =
@@ -155,40 +168,50 @@ public class TenantInfoController extends BaseController {
         if (StringUtils.isNotBlank(phone)){
             boolean re = smsCodeService.verifyValidCode(phone, code, "PHONE");
             if (re){
-                SysUser user = sysUserFeignService.queryUserInfo();
-                tenantInfoService.updateSysUser(sysUser1, user.getId());
-
-                //设置默认头像
-                if (StringUtils.isEmpty(sysUser.getAvatar())) {
-                    sysUser.setAvatar(sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD));
-                }
-
-                //判断更改的手机所属的机构信息
-
-                String oldPhone = user.getPhone();
-                //查看原机构信息
-                List<TenantInfo> list = tenantInfoService.lambdaQuery().eq(TenantInfo::getPhone, oldPhone).list();
-                if (CollectionUtils.isNotEmpty(list)){
-                    TenantInfo info = list.get(0);
-                    if (ObjectUtil.isEmpty(info)) {
-                        //更新tennatInfo
-                        info.setPhone(phone);
-                        tenantInfoService.updateById(info);
+                //查询输入的手机号  是否存在于sysUser表中
+                SysUser user = sysUserMapper.findUserByPhone(phone);
+                if (Objects.nonNull(user)){
+                    //如果存在 判断是否为机构员工
+                    TenantStaff tenantStaff = tenantStaffService.getByUserId(user.getId());
+                    if (!ObjectUtil.isEmpty(tenantStaff)){
+                        throw new BizException("该手机号已绑定机构");
                     }
-                }
-
-                //更新员工表
-                Long id = user.getId();
-                TenantStaff staff = tenantStaffService.getByUserId(id);
-                if (staff != null){
-                    staff.setNickname(sysUser.getUsername());
-                    staff.setAvatar(sysUser.getAvatar());
-                    tenantStaffService.updateById(staff);
+                } else {
+                    //没有存在于sysUser表
+                    SysUser newUser = new SysUser();
+
+                    //查询当前登录账号
+                    SysUser OldUser = sysUserFeignService.queryUserInfo();
+
+                    //给新账户赋值
+                    newUser = JSON.parseObject(OldUser.jsonString(), SysUser.class);
+                    com.yonge.cooleshow.biz.dal.entity.SysUser sysUser2 = JSON.parseObject(newUser.jsonString(), com.yonge.cooleshow.biz.dal.entity.SysUser.class);
+                    sysUser2.setUsername(sysUser.getUsername());
+                    //设置默认头像
+                    if (StringUtils.isEmpty(sysUser.getAvatar())) {
+                        sysUser.setAvatar(sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD));
+                    } else {
+                        sysUser2.setAvatar(sysUser.getAvatar());
+                    }
+                    sysUserMapper.insert(sysUser2);
+                    //查询当前登录用户的userId
+                    Long oldId = OldUser.getId();
+                    //查询新用户的userId
+                    Long newId = sysUser2.getId();
+
+                    //staff 更新userId
+                    tenantStaffMapper.updateUserId(newId,oldId, sysUser2.getUsername(),sysUser2.getAvatar());
+                    //tennatinfo  更新userId  和 phone
+                    tenantInfoMapper.updateIdPhone(newId,phone,oldId);
                 }
             } else {
                 throw new BizException("手机号校验有误");
             }
         }  else {
+            //更新当前用户的staff表
+
+
+
             SysUser user = sysUserFeignService.queryUserInfo();
             tenantInfoService.updateSysUser(sysUser1, user.getId());
 
@@ -205,6 +228,8 @@ public class TenantInfoController extends BaseController {
                 staff.setAvatar(sysUser.getAvatar());
                 tenantStaffService.updateById(staff);
             }
+
+            //更新tenantInfo的username
         }
             return HttpResponseResult.succeed(true);
         }

+ 1 - 1
scripts/install.sh

@@ -6,7 +6,7 @@ PROJECT_NAME="cooleshow"
 PROJECT_LIBS="libs"
 
 GIT_URL="http://10.206.0.11/yonge/cooleshow.git"
-GIT_BRANCH="develop"
+GIT_BRANCH="master"
 
 # 删除旧的项目
 rm -rf ${PROJECT_NAME}