pull/1/head
parent
9184f9129e
commit
466be363e6
|
@ -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<Formation>> list() {
|
||||
List<Formation> list = formationMapper.list();
|
||||
|
@ -22,6 +32,13 @@ public class FormationServiceImpl implements FormationService {
|
|||
|
||||
@Override
|
||||
public Result<Integer> 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);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<modules>
|
||||
<module>bwie-user</module>
|
||||
<module>bwie-health</module>
|
||||
<module>bwie-formation</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
Loading…
Reference in New Issue