From 466be363e6940db96b1e08b8320fd1855f498b0c Mon Sep 17 00:00:00 2001 From: 31353 <31353751672@qq.com> Date: Sun, 17 Dec 2023 11:16:08 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=9D=E6=A3=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/FormationServiceImpl.java | 17 +++++++++++++++++ bwie-modules/pom.xml | 1 + 2 files changed, 18 insertions(+) diff --git a/bwie-modules/bwie-formation/src/main/java/com/bwie/formaiton/service/impl/FormationServiceImpl.java b/bwie-modules/bwie-formation/src/main/java/com/bwie/formaiton/service/impl/FormationServiceImpl.java index da7a267..67735a8 100644 --- a/bwie-modules/bwie-formation/src/main/java/com/bwie/formaiton/service/impl/FormationServiceImpl.java +++ b/bwie-modules/bwie-formation/src/main/java/com/bwie/formaiton/service/impl/FormationServiceImpl.java @@ -1,12 +1,18 @@ package com.bwie.formaiton.service.impl; +import com.alibaba.fastjson.JSON; +import com.bwie.common.constants.TokenConstants; import com.bwie.common.domain.Formation; +import com.bwie.common.domain.User; import com.bwie.common.result.Result; +import com.bwie.common.utils.JwtUtils; import com.bwie.formaiton.mapper.FormationMapper; import com.bwie.formaiton.service.FormationService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; +import javax.servlet.http.HttpServletRequest; import java.util.List; @Service @@ -14,6 +20,10 @@ public class FormationServiceImpl implements FormationService { @Autowired private FormationMapper formationMapper; + @Autowired + private StringRedisTemplate redisTemplate; + @Autowired + private HttpServletRequest request; @Override public Result> list() { List list = formationMapper.list(); @@ -22,6 +32,13 @@ public class FormationServiceImpl implements FormationService { @Override public Result insert(Formation formation) { + String token = request.getHeader(TokenConstants.TOKEN); + String userKey = JwtUtils.getUserKey(token); + String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey); + User user = JSON.parseObject(s, User.class); + formation.setUserId(user.getId()); + formation.setUserName(user.getUsername()); + formation.setUserPwd(user.getPassword()); Integer i = formationMapper.insert(formation); return Result.success(i); } diff --git a/bwie-modules/pom.xml b/bwie-modules/pom.xml index d59054f..483b8a9 100644 --- a/bwie-modules/pom.xml +++ b/bwie-modules/pom.xml @@ -14,6 +14,7 @@ bwie-user bwie-health + bwie-formation