|
1
|
package com.zhonglai.luhui.login.controller.v2;
|
1
|
package com.zhonglai.luhui.login.controller.v2;
|
|
2
|
|
2
|
|
|
|
|
3
|
+import com.ruoyi.common.constant.Constants;
|
|
3
|
import com.ruoyi.common.core.domain.AjaxResult;
|
4
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
5
|
+import com.ruoyi.common.utils.DESUtil;
|
|
4
|
import com.zhonglai.luhui.action.BaseController;
|
6
|
import com.zhonglai.luhui.action.BaseController;
|
|
5
|
import com.zhonglai.luhui.dao.service.PublicService;
|
7
|
import com.zhonglai.luhui.dao.service.PublicService;
|
|
6
|
import com.zhonglai.luhui.login.service.LoginService;
|
8
|
import com.zhonglai.luhui.login.service.LoginService;
|
|
|
|
9
|
+import com.zhonglai.luhui.security.dto.LoginToken;
|
|
7
|
import io.swagger.annotations.Api;
|
10
|
import io.swagger.annotations.Api;
|
|
|
|
11
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
12
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
8
|
import io.swagger.annotations.ApiOperation;
|
13
|
import io.swagger.annotations.ApiOperation;
|
|
9
|
import org.springframework.beans.factory.annotation.Autowired;
|
14
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
10
|
import org.springframework.web.bind.annotation.*;
|
15
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -23,73 +28,106 @@ public class ApiLoginV2Controller extends BaseController { |
|
@@ -23,73 +28,106 @@ public class ApiLoginV2Controller extends BaseController { |
|
23
|
@Autowired
|
28
|
@Autowired
|
|
24
|
private LoginService loginService;
|
29
|
private LoginService loginService;
|
|
25
|
|
30
|
|
|
26
|
-
|
|
|
|
27
|
- @ApiOperation("用户转移")
|
|
|
|
28
|
- @PostMapping("/userTransfer")
|
|
|
|
29
|
- public AjaxResult userTransfer()
|
31
|
+ @ApiOperation("账号密码登陆")
|
|
|
|
32
|
+ @ApiImplicitParams({
|
|
|
|
33
|
+ @ApiImplicitParam(value = "账号",name = "user"),
|
|
|
|
34
|
+ @ApiImplicitParam(value = "密码",name = "pass"),
|
|
|
|
35
|
+ })
|
|
|
|
36
|
+ @PostMapping("/userpassLogin")
|
|
|
|
37
|
+ public AjaxResult userpassLogin(String user,String pass)
|
|
30
|
{
|
38
|
{
|
|
31
|
- List<Map<String,Object>> list =loginService.getRuningFishUserList();
|
|
|
|
32
|
- for (Map<String,Object> runingFishuser : list)
|
39
|
+ AjaxResult ajax = AjaxResult.success();
|
|
|
|
40
|
+ //生成令牌
|
|
|
|
41
|
+ List<Map<String,Object>> list = publicService.getObjectListBySQL("SELECT * FROM `liu_yu_le`.`user_info` WHERE login_name='"+user+"' OR email='"+user+"' OR phone='"+user+"'");
|
|
|
|
42
|
+ if(null == list || list.size() == 0)
|
|
33
|
{
|
43
|
{
|
|
34
|
- List<Map<String,Object>> yu2leUserList = publicService.getObjectListBySQL("SELECT * FROM `liu_yu_le`.`user_info` where login_name='"+runingFishuser.get("login_name")+"'");
|
|
|
|
35
|
- if (null == yu2leUserList || yu2leUserList.size() == 0)
|
|
|
|
36
|
- {
|
|
|
|
37
|
- publicService.updateBySql("INSERT INTO liu_yu_le.user_info(" +
|
|
|
|
38
|
- "login_name,name,gender,phone,last_login_time,last_login_ip,create_time,last_address," +
|
|
|
|
39
|
- "nickname,province_id,city_id,county_id,province_name,city_name,county_name,address" +
|
|
|
|
40
|
- ") VALUES (" +
|
|
|
|
41
|
- "'" + runingFishuser.get("login_name") + "'," +
|
|
|
|
42
|
- "'" + runingFishuser.get("name") + "'," +
|
|
|
|
43
|
- "'" + runingFishuser.get("gender") + "'," +
|
|
|
|
44
|
- "'" + runingFishuser.get("phone") + "'," +
|
|
|
|
45
|
- (runingFishuser.get("last_login_time") == null ? "NULL" : "'" + runingFishuser.get("last_login_time") + "'") + "," +
|
|
|
|
46
|
- (runingFishuser.get("last_login_ip") == null ? "NULL" : "'" + runingFishuser.get("last_login_ip") + "'") + "," +
|
|
|
|
47
|
- "'" + runingFishuser.get("create_time") + "'," +
|
|
|
|
48
|
- (runingFishuser.get("last_address") == null ? "NULL" : "'" + runingFishuser.get("last_address") + "'") + "," +
|
|
|
|
49
|
- (runingFishuser.get("nickname") == null ? "NULL" : "'" + runingFishuser.get("nickname") + "'") + "," +
|
|
|
|
50
|
- (runingFishuser.get("province_id") == null ? "NULL" : "'" + runingFishuser.get("province_id") + "'") + "," +
|
|
|
|
51
|
- (runingFishuser.get("city_id") == null ? "NULL" : "'" + runingFishuser.get("city_id") + "'") + "," +
|
|
|
|
52
|
- (runingFishuser.get("county_id") == null ? "NULL" : "'" + runingFishuser.get("county_id") + "'") + "," +
|
|
|
|
53
|
- (runingFishuser.get("province_name") == null ? "NULL" : "'" + runingFishuser.get("province_name") + "'") + "," +
|
|
|
|
54
|
- (runingFishuser.get("city_name") == null ? "NULL" : "'" + runingFishuser.get("city_name") + "'") + "," +
|
|
|
|
55
|
- (runingFishuser.get("county_name") == null ? "NULL" : "'" + runingFishuser.get("county_name") + "'") + "," +
|
|
|
|
56
|
- (runingFishuser.get("address") == null ? "NULL" : "'" + runingFishuser.get("address") + "'") +
|
|
|
|
57
|
- ")");
|
|
|
|
58
|
-
|
|
|
|
59
|
-
|
|
|
|
60
|
- yu2leUserList = publicService.getObjectListBySQL("SELECT * FROM `liu_yu_le`.`user_info` where login_name='"+runingFishuser.get("login_name")+"'");
|
|
|
|
61
|
- Map<String,Object> runingFishUserLoginMap =loginService.getRuningFishUserLogin((Integer) runingFishuser.get("id"));
|
|
|
|
62
|
- try
|
|
|
|
63
|
- {
|
|
|
|
64
|
- publicService.updateBySql("INSERT INTO `liu_yu_le`.user_login(" +
|
|
|
|
65
|
- "`user_id`,`login_name`,`login_pass`,`user_login_pass_key`) VALUES ("+
|
|
|
|
66
|
- "'"+yu2leUserList.get(0).get("id")+"'," +
|
|
|
|
67
|
- "'"+runingFishUserLoginMap.get("login_name")+"'," +
|
|
|
|
68
|
- "'"+runingFishUserLoginMap.get("login_pass")+"'," +
|
|
|
|
69
|
- "'"+runingFishUserLoginMap.get("user_login_pass_key")+"'" +
|
|
|
|
70
|
- ")");
|
|
|
|
71
|
- }
|
|
|
|
72
|
- catch (Exception e)
|
|
|
|
73
|
- {
|
|
|
|
74
|
- logger.error("更新异常",e);
|
|
|
|
75
|
- }
|
44
|
+ return error("用户不存在");
|
|
|
|
45
|
+ }
|
|
|
|
46
|
+ Map<String,Object> userInfo = list.get(0);
|
|
|
|
47
|
+ list = publicService.getObjectListBySQL("SELECT * FROM `liu_yu_le`.`user_login` WHERE user_id="+userInfo.get("id"));
|
|
|
|
48
|
+ if(null == list || list.size() == 0)
|
|
|
|
49
|
+ {
|
|
|
|
50
|
+ return error("用户不存在");
|
|
|
|
51
|
+ }
|
|
|
|
52
|
+ Map<String,Object> userLogin = list.get(0);
|
|
|
|
53
|
+ if(!userLogin.get("login_pass").equals(DESUtil.encode(pass, (String) userLogin.get("user_login_pass_key"))))
|
|
|
|
54
|
+ {
|
|
|
|
55
|
+ return error("密码错误");
|
|
|
|
56
|
+ }
|
|
|
|
57
|
+ LoginToken loginToken = new LoginToken((Integer) userInfo.get("id"), (String) userInfo.get("login_name"), (String) userInfo.get("nickname"),"0");
|
|
|
|
58
|
+ String token = loginToken.get();
|
|
|
|
59
|
+ ajax.put(Constants.TOKEN, token);
|
|
|
|
60
|
+ return ajax;
|
|
|
|
61
|
+ }
|
|
76
|
|
62
|
|
|
77
|
|
63
|
|
|
78
|
- }
|
|
|
|
79
|
- Map<String,Object> yu2leUser = yu2leUserList.get(0);
|
|
|
|
80
|
- if(!(runingFishuser.get("id").toString()).equals(yu2leUser.get("id")+""))
|
|
|
|
81
|
- {
|
|
|
|
82
|
- //查看是否有相同用户id的用户存在
|
|
|
|
83
|
- Map<String,Object> sameRuningFishUser = loginService.getRuningFishUser((Integer) yu2leUser.get("id"));
|
|
|
|
84
|
- if (null != sameRuningFishUser) //如果有就先把旧用户id的runing_fish_user_id改为新的
|
|
|
|
85
|
- {
|
|
|
|
86
|
- loginService.updateRuningFishUserId("500"+yu2leUser.get("id"),yu2leUser.get("id")+"");
|
|
|
|
87
|
- }
|
|
|
|
88
|
|
64
|
|
|
89
|
- loginService.updateRuningFishUserId(yu2leUser.get("id")+"",runingFishuser.get("id")+"");
|
|
|
|
90
|
- }
|
|
|
|
91
|
- }
|
|
|
|
92
|
- return success();
|
|
|
|
93
|
- }
|
65
|
+// @ApiOperation("用户转移")
|
|
|
|
66
|
+// @PostMapping("/userTransfer")
|
|
|
|
67
|
+// public AjaxResult userTransfer()
|
|
|
|
68
|
+// {
|
|
|
|
69
|
+// List<Map<String,Object>> list =loginService.getRuningFishUserList();
|
|
|
|
70
|
+// for (Map<String,Object> runingFishuser : list)
|
|
|
|
71
|
+// {
|
|
|
|
72
|
+// List<Map<String,Object>> yu2leUserList = publicService.getObjectListBySQL("SELECT * FROM `liu_yu_le`.`user_info` where login_name='"+runingFishuser.get("login_name")+"'");
|
|
|
|
73
|
+// if (null == yu2leUserList || yu2leUserList.size() == 0)
|
|
|
|
74
|
+// {
|
|
|
|
75
|
+// publicService.updateBySql("INSERT INTO liu_yu_le.user_info(" +
|
|
|
|
76
|
+// "login_name,name,gender,phone,last_login_time,last_login_ip,create_time,last_address," +
|
|
|
|
77
|
+// "nickname,province_id,city_id,county_id,province_name,city_name,county_name,address" +
|
|
|
|
78
|
+// ") VALUES (" +
|
|
|
|
79
|
+// "'" + runingFishuser.get("login_name") + "'," +
|
|
|
|
80
|
+// "'" + runingFishuser.get("name") + "'," +
|
|
|
|
81
|
+// "'" + runingFishuser.get("gender") + "'," +
|
|
|
|
82
|
+// "'" + runingFishuser.get("phone") + "'," +
|
|
|
|
83
|
+// (runingFishuser.get("last_login_time") == null ? "NULL" : "'" + runingFishuser.get("last_login_time") + "'") + "," +
|
|
|
|
84
|
+// (runingFishuser.get("last_login_ip") == null ? "NULL" : "'" + runingFishuser.get("last_login_ip") + "'") + "," +
|
|
|
|
85
|
+// "'" + runingFishuser.get("create_time") + "'," +
|
|
|
|
86
|
+// (runingFishuser.get("last_address") == null ? "NULL" : "'" + runingFishuser.get("last_address") + "'") + "," +
|
|
|
|
87
|
+// (runingFishuser.get("nickname") == null ? "NULL" : "'" + runingFishuser.get("nickname") + "'") + "," +
|
|
|
|
88
|
+// (runingFishuser.get("province_id") == null ? "NULL" : "'" + runingFishuser.get("province_id") + "'") + "," +
|
|
|
|
89
|
+// (runingFishuser.get("city_id") == null ? "NULL" : "'" + runingFishuser.get("city_id") + "'") + "," +
|
|
|
|
90
|
+// (runingFishuser.get("county_id") == null ? "NULL" : "'" + runingFishuser.get("county_id") + "'") + "," +
|
|
|
|
91
|
+// (runingFishuser.get("province_name") == null ? "NULL" : "'" + runingFishuser.get("province_name") + "'") + "," +
|
|
|
|
92
|
+// (runingFishuser.get("city_name") == null ? "NULL" : "'" + runingFishuser.get("city_name") + "'") + "," +
|
|
|
|
93
|
+// (runingFishuser.get("county_name") == null ? "NULL" : "'" + runingFishuser.get("county_name") + "'") + "," +
|
|
|
|
94
|
+// (runingFishuser.get("address") == null ? "NULL" : "'" + runingFishuser.get("address") + "'") +
|
|
|
|
95
|
+// ")");
|
|
|
|
96
|
+//
|
|
|
|
97
|
+//
|
|
|
|
98
|
+// yu2leUserList = publicService.getObjectListBySQL("SELECT * FROM `liu_yu_le`.`user_info` where login_name='"+runingFishuser.get("login_name")+"'");
|
|
|
|
99
|
+// Map<String,Object> runingFishUserLoginMap =loginService.getRuningFishUserLogin((Integer) runingFishuser.get("id"));
|
|
|
|
100
|
+// try
|
|
|
|
101
|
+// {
|
|
|
|
102
|
+// publicService.updateBySql("INSERT INTO `liu_yu_le`.user_login(" +
|
|
|
|
103
|
+// "`user_id`,`login_name`,`login_pass`,`user_login_pass_key`) VALUES ("+
|
|
|
|
104
|
+// "'"+yu2leUserList.get(0).get("id")+"'," +
|
|
|
|
105
|
+// "'"+runingFishUserLoginMap.get("login_name")+"'," +
|
|
|
|
106
|
+// "'"+runingFishUserLoginMap.get("login_pass")+"'," +
|
|
|
|
107
|
+// "'"+runingFishUserLoginMap.get("user_login_pass_key")+"'" +
|
|
|
|
108
|
+// ")");
|
|
|
|
109
|
+// }
|
|
|
|
110
|
+// catch (Exception e)
|
|
|
|
111
|
+// {
|
|
|
|
112
|
+// logger.error("更新异常",e);
|
|
|
|
113
|
+// }
|
|
|
|
114
|
+//
|
|
|
|
115
|
+//
|
|
|
|
116
|
+// }
|
|
|
|
117
|
+// Map<String,Object> yu2leUser = yu2leUserList.get(0);
|
|
|
|
118
|
+// if(!(runingFishuser.get("id").toString()).equals(yu2leUser.get("id")+""))
|
|
|
|
119
|
+// {
|
|
|
|
120
|
+// //查看是否有相同用户id的用户存在
|
|
|
|
121
|
+// Map<String,Object> sameRuningFishUser = loginService.getRuningFishUser((Integer) yu2leUser.get("id"));
|
|
|
|
122
|
+// if (null != sameRuningFishUser) //如果有就先把旧用户id的runing_fish_user_id改为新的
|
|
|
|
123
|
+// {
|
|
|
|
124
|
+// loginService.updateRuningFishUserId("500"+yu2leUser.get("id"),yu2leUser.get("id")+"");
|
|
|
|
125
|
+// }
|
|
|
|
126
|
+//
|
|
|
|
127
|
+// loginService.updateRuningFishUserId(yu2leUser.get("id")+"",runingFishuser.get("id")+"");
|
|
|
|
128
|
+// }
|
|
|
|
129
|
+// }
|
|
|
|
130
|
+// return success();
|
|
|
|
131
|
+// }
|
|
94
|
|
132
|
|
|
95
|
} |
133
|
} |