...
|
...
|
@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.synthesize_energy.common.domain.BusinessException;
|
|
|
import com.synthesize_energy.common.domain.CommonErrorCode;
|
|
|
import com.synthesize_energy.item.entity.CompanyData;
|
|
|
import com.synthesize_energy.item.entity.SmsCode;
|
|
|
import com.synthesize_energy.item.entity.User;
|
|
|
import com.synthesize_energy.item.mapper.CompanyDataMapper;
|
|
|
import com.synthesize_energy.item.mapper.SmsCodeMapper;
|
|
|
import com.synthesize_energy.item.mapper.UserMapper;
|
|
|
import com.synthesize_energy.item.utils.JwtUtil;
|
...
|
...
|
@@ -32,6 +34,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us |
|
|
private UserMapper userMapper;
|
|
|
@Autowired
|
|
|
private SmsCodeMapper smsCodeMapper;
|
|
|
@Autowired
|
|
|
private CompanyDataMapper companyDataMapper;
|
|
|
|
|
|
/**
|
|
|
* 登录接口
|
...
|
...
|
@@ -41,8 +45,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us |
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public Map<String,Object> login(String phone, String code) {
|
|
|
Map<String,Object> map = new HashMap<>(2);
|
|
|
public Map<String, Object> login(String phone, String code) {
|
|
|
Map<String, Object> map = new HashMap<>(2);
|
|
|
QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
|
|
|
userQueryWrapper.lambda().eq(User::getPhone, phone);
|
|
|
User user = userMapper.selectOne(userQueryWrapper);
|
...
|
...
|
@@ -53,12 +57,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us |
|
|
if (StringUtils.isEmpty(smsCode) || !code.equals(smsCode.getCode())) {
|
|
|
throw new BusinessException(CommonErrorCode.E_100102);
|
|
|
}
|
|
|
CompanyData com = companyDataMapper.selectById(user.getCompanyId());
|
|
|
String sign = JwtUtil.sign(user);
|
|
|
map.put("token",sign);
|
|
|
map.put("state",user.getStatus());
|
|
|
map.put("userName",user.getName());
|
|
|
map.put("companyName",user.getCompanyName());
|
|
|
map.put("department",user.getDepartment());
|
|
|
map.put("token", sign);
|
|
|
map.put("state", user.getStatus());
|
|
|
map.put("userName", user.getName());
|
|
|
map.put("companyName", com == null ? "" : com.getName());
|
|
|
map.put("department", user.getDepartment());
|
|
|
return map;
|
|
|
}
|
|
|
} |
...
|
...
|
|