作者 kgy

Merge remote-tracking branch 'kgy/master' into master

@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5 import com.synthesize_energy.common.domain.BusinessException; 5 import com.synthesize_energy.common.domain.BusinessException;
6 import com.synthesize_energy.common.domain.CommonErrorCode; 6 import com.synthesize_energy.common.domain.CommonErrorCode;
  7 +import com.synthesize_energy.item.entity.CompanyData;
7 import com.synthesize_energy.item.entity.SmsCode; 8 import com.synthesize_energy.item.entity.SmsCode;
8 import com.synthesize_energy.item.entity.User; 9 import com.synthesize_energy.item.entity.User;
  10 +import com.synthesize_energy.item.mapper.CompanyDataMapper;
9 import com.synthesize_energy.item.mapper.SmsCodeMapper; 11 import com.synthesize_energy.item.mapper.SmsCodeMapper;
10 import com.synthesize_energy.item.mapper.UserMapper; 12 import com.synthesize_energy.item.mapper.UserMapper;
11 import com.synthesize_energy.item.utils.JwtUtil; 13 import com.synthesize_energy.item.utils.JwtUtil;
@@ -32,6 +34,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us @@ -32,6 +34,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
32 private UserMapper userMapper; 34 private UserMapper userMapper;
33 @Autowired 35 @Autowired
34 private SmsCodeMapper smsCodeMapper; 36 private SmsCodeMapper smsCodeMapper;
  37 + @Autowired
  38 + private CompanyDataMapper companyDataMapper;
35 39
36 /** 40 /**
37 * 登录接口 41 * 登录接口
@@ -41,8 +45,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us @@ -41,8 +45,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
41 * @return 45 * @return
42 */ 46 */
43 @Override 47 @Override
44 - public Map<String,Object> login(String phone, String code) {  
45 - Map<String,Object> map = new HashMap<>(2); 48 + public Map<String, Object> login(String phone, String code) {
  49 + Map<String, Object> map = new HashMap<>(2);
46 QueryWrapper<User> userQueryWrapper = new QueryWrapper<>(); 50 QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
47 userQueryWrapper.lambda().eq(User::getPhone, phone); 51 userQueryWrapper.lambda().eq(User::getPhone, phone);
48 User user = userMapper.selectOne(userQueryWrapper); 52 User user = userMapper.selectOne(userQueryWrapper);
@@ -53,12 +57,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us @@ -53,12 +57,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
53 if (StringUtils.isEmpty(smsCode) || !code.equals(smsCode.getCode())) { 57 if (StringUtils.isEmpty(smsCode) || !code.equals(smsCode.getCode())) {
54 throw new BusinessException(CommonErrorCode.E_100102); 58 throw new BusinessException(CommonErrorCode.E_100102);
55 } 59 }
  60 + CompanyData com = companyDataMapper.selectById(user.getCompanyId());
56 String sign = JwtUtil.sign(user); 61 String sign = JwtUtil.sign(user);
57 - map.put("token",sign);  
58 - map.put("state",user.getStatus());  
59 - map.put("userName",user.getName());  
60 - map.put("companyName",user.getCompanyName());  
61 - map.put("department",user.getDepartment()); 62 + map.put("token", sign);
  63 + map.put("state", user.getStatus());
  64 + map.put("userName", user.getName());
  65 + map.put("companyName", com == null ? "" : com.getName());
  66 + map.put("department", user.getDepartment());
62 return map; 67 return map;
63 } 68 }
64 } 69 }