|
@@ -1,17 +1,21 @@
|
|
|
package com.huimv.mobile.service.impl;
|
|
|
|
|
|
import com.huimv.mobile.domain.MobileApi;
|
|
|
+import com.huimv.mobile.domain.MobileUnit;
|
|
|
import com.huimv.mobile.domain.MobileUser;
|
|
|
import com.huimv.mobile.repo.MobileApiRepository;
|
|
|
+import com.huimv.mobile.repo.MobileUnitRepository;
|
|
|
import com.huimv.mobile.repo.MobileUserRepository;
|
|
|
import com.huimv.mobile.result.Result;
|
|
|
import com.huimv.mobile.service.MobileUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.DigestUtils;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* @Project : huimv.shiwan
|
|
@@ -27,33 +31,37 @@ public class MobileUserServiceImpl implements MobileUserService {
|
|
|
private MobileUserRepository userRepository;
|
|
|
|
|
|
@Autowired
|
|
|
- private MobileApiRepository mobileApiRepository;
|
|
|
+ private MobileUnitRepository mobileUnitRepository;
|
|
|
|
|
|
@Override
|
|
|
- public Result register(String account, String password) {
|
|
|
+ public Result login(String account, String password) {
|
|
|
|
|
|
+ password = DigestUtils.md5DigestAsHex(password.getBytes());
|
|
|
MobileUser mobileUser = userRepository.findByAccountAndPassword(account, password);
|
|
|
|
|
|
if (mobileUser == null){
|
|
|
return new Result(10001,"用户名或密码错误");
|
|
|
}
|
|
|
+ if (mobileUser.getStatus() == 0){
|
|
|
+ return new Result(10001,"该账号已停冻结");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
Map endMap = new HashMap();
|
|
|
Integer grant = mobileUser.getGrantClass();
|
|
|
if (grant != 3){
|
|
|
- List<MobileApi> all = mobileApiRepository.findAll();
|
|
|
+ List<MobileUnit> all = mobileUnitRepository.findAll();
|
|
|
endMap.put("url",all);
|
|
|
endMap.put("userName",mobileUser.getUserName());
|
|
|
endMap.put("userId",mobileUser.getId());
|
|
|
endMap.put("unit",mobileUser.getUnit());
|
|
|
endMap.put("grant",grant);
|
|
|
}
|
|
|
- if (grant == 1 || grant == 2 ){
|
|
|
+ if (grant == 3){
|
|
|
|
|
|
- MobileApi api = mobileApiRepository.findByFarmId(mobileUser.getUnitId());
|
|
|
- endMap.put("url",api.getUrl());
|
|
|
+ String api = mobileUnitRepository.findById(mobileUser.getUnitId()).get().getApi();
|
|
|
+ endMap.put("url",api);
|
|
|
endMap.put("userName",mobileUser.getUserName());
|
|
|
endMap.put("userId",mobileUser.getId());
|
|
|
endMap.put("unit",mobileUser.getUnit());
|