yuanliang пре 1 година
родитељ
комит
21590e3b19

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

@@ -390,7 +390,7 @@ public class UserController extends BaseController {
         }
 
         // 新密码规则:clx+手机号后四位
-        String newPassword = MessageFormat.format("klx{0}", sysUser.getPhone().substring(7));
+        String newPassword = MessageFormat.format("klxjg{0}", sysUser.getPhone().substring(7));
 
         // 生成重置默认密码
         String password = new BCryptPasswordEncoder().encode(newPassword);

+ 3 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/TenantStaff.java

@@ -3,11 +3,10 @@ package com.yonge.cooleshow.biz.dal.entity;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.IdType;
-import lombok.Data;
-
+import com.yonge.cooleshow.common.enums.UserLockFlag;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -68,7 +67,7 @@ public class TenantStaff implements Serializable {
 
     @ApiModelProperty("帐号状态(注销,冻结,激活)") 
 	@TableField(value = "status_")
-    private String status;
+    private UserLockFlag status;
 
     @ApiModelProperty("更新时间") 
 	@TableField(value = "update_time_")

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/StudentServiceImpl.java

@@ -425,7 +425,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
             sysUser.setUserType("STUDENT");
             sysUser.setBirthdate(studentInfo.getBirthdate());
 
-            String newPassword = MessageFormat.format("klx{0}", studentInfo.getPhone().substring(7));
+            String newPassword = MessageFormat.format("klxjg{0}", studentInfo.getPhone().substring(7));
             String password = new BCryptPasswordEncoder().encode(newPassword);
             sysUser.setPassword(password);
             sysUserMapper.insert(sysUser);

+ 55 - 32
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantInfoServiceImpl.java

@@ -1,35 +1,42 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
-import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.cooleshow.biz.dal.entity.SysArea;
 import com.yonge.cooleshow.biz.dal.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
 import com.yonge.cooleshow.biz.dal.entity.TenantStaff;
 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.SysAreaService;
 import com.yonge.cooleshow.biz.dal.service.SysConfigService;
+import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
+import com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper;
 import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.cooleshow.common.enums.SysUserType;
+import com.yonge.cooleshow.common.enums.UserLockFlag;
 import com.yonge.toolset.base.exception.BizException;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Service;
-import lombok.extern.slf4j.Slf4j;
-import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
-import com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper;
-import com.yonge.cooleshow.biz.dal.mapper.TenantInfoMapper;
-import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.text.MessageFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -88,7 +95,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
         for (int i = 0; i < tenantInfos.size(); i++) {
             TenantInfoWrapper.TenantInfo info = tenantInfos.get(i);
             long id = info.getId();
-            listId.add(i,(int)id);
+            listId.add(i, (int) id);
         }
         //查询对应机构的老师数量
         List<Integer> listTeacher = new ArrayList<>();
@@ -117,7 +124,6 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
     }
 
 
-
     /**
      * 添加
      *
@@ -126,7 +132,16 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
      */
     @Override
     public Boolean add(TenantInfo tenantInfo) {
-        getOrCreateAccount(tenantInfo);
+        SysUser sysUser = getOrCreateAccount(tenantInfo);
+
+        TenantStaff tenantStaff = new TenantStaff();
+        tenantStaff.setTenantId(tenantStaff.getTenantId());
+        tenantStaff.setUserId(sysUser.getId());
+        tenantStaff.setAvatar(sysUser.getAvatar());
+        tenantStaff.setNickname(tenantInfo.getUsername());
+        tenantStaff.setStatus(UserLockFlag.NORMAL);
+        tenantStaffMapper.insert(tenantStaff);
+
         tenantInfo.setEnableFlag(true);
         tenantInfoMapper.insert(tenantInfo);
         return true;
@@ -140,7 +155,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
         //若存在信息
         if (!sysUsers.isEmpty()) {
             sysUser = sysUsers.get(0);
-            TenantStaff tenantStaff = tenantStaffMapper.getByPhone(tenantInfo.getPhone());
+            TenantStaff tenantStaff = tenantStaffMapper.selectById(sysUser.getId());
             if (tenantStaff != null) {
                 throw new BizException("手机号已经注册机构账号");
             }
@@ -156,8 +171,6 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
 
             //更新当前账号的用户名
             sysUser.setUsername(tenantInfo.getUsername());
-            //更新当前账号的手机号
-            sysUser.setPhone(tenantInfo.getPhone());
 
             sysUserMapper.updateById(sysUser);
         } else {
@@ -170,17 +183,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
             String password = new BCryptPasswordEncoder().encode(newPassword);
             sysUser.setPassword(password);
             sysUserMapper.insert(sysUser);
-
-
         }
-
-        TenantStaff tenantStaff = new TenantStaff();
-        tenantStaff.setTenantId(tenantStaff.getTenantId());
-        tenantStaff.setUserId(sysUser.getId());
-        tenantStaff.setAvatar(sysUser.getAvatar());
-        tenantStaff.setNickname(tenantInfo.getUsername());
-        tenantStaff.setStatus("ACTIVE");
-        tenantStaffMapper.insert(tenantStaff);
         return sysUser;
     }
 	
@@ -259,7 +262,6 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
     }
 
 
-
     /**
      * 更新
      *
@@ -268,20 +270,37 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
      */
     @Override
     public Boolean updateTenantInfo(TenantInfo info) {
-        getOrCreateAccount(info);
-        Boolean bool = tenantInfoMapper.updateInfo(info);
-        return bool;
+        SysUser sysUser = getOrCreateAccount(info);
+
+        TenantInfo oldTenantInfo = this.getById(info.getId());
+        tenantStaffMapper.update(null, Wrappers.<TenantStaff>lambdaUpdate()
+                .set(TenantStaff::getUserId, sysUser.getId())
+                .set(TenantStaff::getNickname, info.getUsername())
+                .eq(TenantStaff::getUserId, oldTenantInfo.getUserId())
+        );
+
+        tenantInfoMapper.update(null, Wrappers.<TenantInfo>lambdaUpdate()
+                .set(TenantInfo::getName, info.getName())
+                .set(TenantInfo::getLogo, info.getLogo())
+                .set(TenantInfo::getBriefIntroduction, info.getBriefIntroduction())
+                .set(TenantInfo::getProvinceCode, info.getProvinceCode())
+                .set(TenantInfo::getCityCode, info.getCityCode())
+                .set(TenantInfo::getRegionCode, info.getRegionCode())
+                .eq(TenantInfo::getId, info.getId())
+        );
+        return true;
     }
 
 
-
     /**
      * 机构申请分页查询
+     *
      * @param query
      * @return
      */
     @Override
-    public IPage<TenantInfoWrapper.TenantInfo> applyPage(IPage<TenantInfoWrapper.TenantInfo> page, TenantInfoWrapper.TenantInfoQuery query) {
+    public IPage<TenantInfoWrapper.TenantInfo> applyPage(IPage<TenantInfoWrapper.TenantInfo> page,
+                                                         TenantInfoWrapper.TenantInfoQuery query) {
         //分页查询
         List<TenantInfoWrapper.TenantInfo> tenantInfos = baseMapper.selectApplyPage(page, query);
         List<TenantInfoWrapper.TenantInfo> infos = queryArea(tenantInfos);
@@ -291,11 +310,13 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
 
     /**
      * 机构入驻审核历史记录查询
+     *
      * @param query
      * @return
      */
     @Override
-    public IPage<TenantInfoWrapper.TenantInfo> historyPage(IPage<TenantInfoWrapper.TenantInfo> page, TenantInfoWrapper.TenantInfoQuery query) {
+    public IPage<TenantInfoWrapper.TenantInfo> historyPage(IPage<TenantInfoWrapper.TenantInfo> page,
+                                                           TenantInfoWrapper.TenantInfoQuery query) {
         long id = query.getId();
         //分页查询
         List<TenantInfoWrapper.TenantInfo> tenantInfos = baseMapper.selectHistoryPage(page, id);
@@ -307,6 +328,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
 
     /**
      * 机构入驻审核本次提交查询
+     *
      * @param query
      * @return
      */
@@ -341,7 +363,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
     public Boolean entry(TenantInfoWrapper.TenantInfoQuery query) {
         Integer pass = query.getIfPass();
         //审核通过
-        if (pass == 1){
+        if (pass == 1) {
             //查询本次提交记录,并插入审核表
             TenantInfoWrapper.TenantInfo info = queryNow(query);
             tenantInfoMapper.insertNow(info);
@@ -359,6 +381,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
 
     /**
      * 匹配地区码与省市区
+     *
      * @param tenantInfos
      * @return
      */

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

@@ -22,8 +22,8 @@
         SELECT
         <include refid="baseColumns"/>, ta.purchase_cycle_ as purchaseCycle, su.username_ as activationUserName
         FROM tenant_activation_code t
-        LEFT JOIN tenant_album ta on t.tenant_album_id_ = ta.id_
-        LEFT JOIN sys_user su on t.active_user_id = su.id_
+        LEFT JOIN tenant_album_purchase ta on t.tenant_album_id_ = ta.id_
+        LEFT JOIN sys_user su on t.activation_user_id_ = su.id_
         <where>
             <if test="param.keyword != null and param.keyword.trim() != ''">
                 AND (

+ 3 - 1
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/TenantActivationCodeController.java

@@ -23,6 +23,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+
 
 @Slf4j
 @Validated
@@ -34,7 +36,7 @@ public class TenantActivationCodeController extends BaseController {
     @Autowired
     private TenantActivationCodeService tenantActivationCodeService;
 
-    @Autowired
+    @Resource
     private SysUserFeignService sysUserFeignService;
 
     @Autowired