Просмотр исходного кода

[update] message:1.小程序登录后返回token字段

kelei 6 месяцев назад
Родитель
Сommit
393881cfe9

+ 8 - 1
admin/src/main/java/com/flyer/foster/service/impl/AppUserServiceImpl.java

@@ -12,10 +12,12 @@ import com.flyer.foster.pojo.StpAppUtil;
 import com.flyer.foster.service.IAppUserService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.flyer.foster.util.WeChatApiUtil;
+import org.etsi.uri.x01903.v13.ResponderIDType;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.expression.spel.ast.OpInc;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
 import java.util.Map;
 
 /**
@@ -50,6 +52,7 @@ public class AppUserServiceImpl extends ServiceImpl<IAppUserMapper, AppUser> imp
         String openid = code2Session.getOpenid();
         // 查找用户信息,存在更新,不存在新增
         AppUser appUser = iAppUserService.lambdaQuery().eq(AppUser::getOpenId, openid).one();
+        StpAppUtil.login(openid, LoginDevice.APP);
         if (appUser == null) {
             // 存入用户信息
             appUser = new AppUser();
@@ -57,11 +60,15 @@ public class AppUserServiceImpl extends ServiceImpl<IAppUserMapper, AppUser> imp
             appUser.setOpenId(code2Session.getOpenid());
             appUser.setName(DEFAUT_NAME);
             appUser.setIcon(DEFAULT_ICON);
+            appUser.setCreatedBy("kelei");
+            appUser.setCreatedTime(LocalDateTime.now());
+            appUser.setUpdatedBy("kelei");
+            appUser.setUpdatedTime(LocalDateTime.now());
             this.save(appUser);
         }
         AppUserRespDTO respDTO = new AppUserRespDTO();
         BeanUtil.copyProperties(appUser, respDTO);
-        StpAppUtil.login(respDTO.getOpenId(), LoginDevice.APP);
+        respDTO.setToken(StpAppUtil.getTokenValue());
         return respDTO;
     }
 }