|
|
|
package com.zhonglai.luhui.login.controller.v2;
|
|
|
|
|
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.utils.DESUtil;
|
|
|
|
import com.zhonglai.luhui.action.BaseController;
|
|
|
|
import com.zhonglai.luhui.dao.service.PublicService;
|
|
|
|
import com.zhonglai.luhui.login.service.LoginService;
|
|
|
|
import com.zhonglai.luhui.security.dto.LoginToken;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
...
|
...
|
@@ -23,73 +28,106 @@ public class ApiLoginV2Controller extends BaseController { |
|
|
|
@Autowired
|
|
|
|
private LoginService loginService;
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("用户转移")
|
|
|
|
@PostMapping("/userTransfer")
|
|
|
|
public AjaxResult userTransfer()
|
|
|
|
{
|
|
|
|
List<Map<String,Object>> list =loginService.getRuningFishUserList();
|
|
|
|
for (Map<String,Object> runingFishuser : list)
|
|
|
|
@ApiOperation("账号密码登陆")
|
|
|
|
@ApiImplicitParams({
|
|
|
|
@ApiImplicitParam(value = "账号",name = "user"),
|
|
|
|
@ApiImplicitParam(value = "密码",name = "pass"),
|
|
|
|
})
|
|
|
|
@PostMapping("/userpassLogin")
|
|
|
|
public AjaxResult userpassLogin(String user,String pass)
|
|
|
|
{
|
|
|
|
List<Map<String,Object>> yu2leUserList = publicService.getObjectListBySQL("SELECT * FROM `liu_yu_le`.`user_info` where login_name='"+runingFishuser.get("login_name")+"'");
|
|
|
|
if (null == yu2leUserList || yu2leUserList.size() == 0)
|
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
|
//生成令牌
|
|
|
|
List<Map<String,Object>> list = publicService.getObjectListBySQL("SELECT * FROM `liu_yu_le`.`user_info` WHERE login_name='"+user+"' OR email='"+user+"' OR phone='"+user+"'");
|
|
|
|
if(null == list || list.size() == 0)
|
|
|
|
{
|
|
|
|
publicService.updateBySql("INSERT INTO liu_yu_le.user_info(" +
|
|
|
|
"login_name,name,gender,phone,last_login_time,last_login_ip,create_time,last_address," +
|
|
|
|
"nickname,province_id,city_id,county_id,province_name,city_name,county_name,address" +
|
|
|
|
") VALUES (" +
|
|
|
|
"'" + runingFishuser.get("login_name") + "'," +
|
|
|
|
"'" + runingFishuser.get("name") + "'," +
|
|
|
|
"'" + runingFishuser.get("gender") + "'," +
|
|
|
|
"'" + runingFishuser.get("phone") + "'," +
|
|
|
|
(runingFishuser.get("last_login_time") == null ? "NULL" : "'" + runingFishuser.get("last_login_time") + "'") + "," +
|
|
|
|
(runingFishuser.get("last_login_ip") == null ? "NULL" : "'" + runingFishuser.get("last_login_ip") + "'") + "," +
|
|
|
|
"'" + runingFishuser.get("create_time") + "'," +
|
|
|
|
(runingFishuser.get("last_address") == null ? "NULL" : "'" + runingFishuser.get("last_address") + "'") + "," +
|
|
|
|
(runingFishuser.get("nickname") == null ? "NULL" : "'" + runingFishuser.get("nickname") + "'") + "," +
|
|
|
|
(runingFishuser.get("province_id") == null ? "NULL" : "'" + runingFishuser.get("province_id") + "'") + "," +
|
|
|
|
(runingFishuser.get("city_id") == null ? "NULL" : "'" + runingFishuser.get("city_id") + "'") + "," +
|
|
|
|
(runingFishuser.get("county_id") == null ? "NULL" : "'" + runingFishuser.get("county_id") + "'") + "," +
|
|
|
|
(runingFishuser.get("province_name") == null ? "NULL" : "'" + runingFishuser.get("province_name") + "'") + "," +
|
|
|
|
(runingFishuser.get("city_name") == null ? "NULL" : "'" + runingFishuser.get("city_name") + "'") + "," +
|
|
|
|
(runingFishuser.get("county_name") == null ? "NULL" : "'" + runingFishuser.get("county_name") + "'") + "," +
|
|
|
|
(runingFishuser.get("address") == null ? "NULL" : "'" + runingFishuser.get("address") + "'") +
|
|
|
|
")");
|
|
|
|
|
|
|
|
|
|
|
|
yu2leUserList = publicService.getObjectListBySQL("SELECT * FROM `liu_yu_le`.`user_info` where login_name='"+runingFishuser.get("login_name")+"'");
|
|
|
|
Map<String,Object> runingFishUserLoginMap =loginService.getRuningFishUserLogin((Integer) runingFishuser.get("id"));
|
|
|
|
try
|
|
|
|
return error("用户不存在");
|
|
|
|
}
|
|
|
|
Map<String,Object> userInfo = list.get(0);
|
|
|
|
list = publicService.getObjectListBySQL("SELECT * FROM `liu_yu_le`.`user_login` WHERE user_id="+userInfo.get("id"));
|
|
|
|
if(null == list || list.size() == 0)
|
|
|
|
{
|
|
|
|
publicService.updateBySql("INSERT INTO `liu_yu_le`.user_login(" +
|
|
|
|
"`user_id`,`login_name`,`login_pass`,`user_login_pass_key`) VALUES ("+
|
|
|
|
"'"+yu2leUserList.get(0).get("id")+"'," +
|
|
|
|
"'"+runingFishUserLoginMap.get("login_name")+"'," +
|
|
|
|
"'"+runingFishUserLoginMap.get("login_pass")+"'," +
|
|
|
|
"'"+runingFishUserLoginMap.get("user_login_pass_key")+"'" +
|
|
|
|
")");
|
|
|
|
return error("用户不存在");
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
Map<String,Object> userLogin = list.get(0);
|
|
|
|
if(!userLogin.get("login_pass").equals(DESUtil.encode(pass, (String) userLogin.get("user_login_pass_key"))))
|
|
|
|
{
|
|
|
|
logger.error("更新异常",e);
|
|
|
|
return error("密码错误");
|
|
|
|
}
|
|
|
|
LoginToken loginToken = new LoginToken((Integer) userInfo.get("id"), (String) userInfo.get("login_name"), (String) userInfo.get("nickname"),"0");
|
|
|
|
String token = loginToken.get();
|
|
|
|
ajax.put(Constants.TOKEN, token);
|
|
|
|
return ajax;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
Map<String,Object> yu2leUser = yu2leUserList.get(0);
|
|
|
|
if(!(runingFishuser.get("id").toString()).equals(yu2leUser.get("id")+""))
|
|
|
|
{
|
|
|
|
//查看是否有相同用户id的用户存在
|
|
|
|
Map<String,Object> sameRuningFishUser = loginService.getRuningFishUser((Integer) yu2leUser.get("id"));
|
|
|
|
if (null != sameRuningFishUser) //如果有就先把旧用户id的runing_fish_user_id改为新的
|
|
|
|
{
|
|
|
|
loginService.updateRuningFishUserId("500"+yu2leUser.get("id"),yu2leUser.get("id")+"");
|
|
|
|
}
|
|
|
|
|
|
|
|
loginService.updateRuningFishUserId(yu2leUser.get("id")+"",runingFishuser.get("id")+"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
// @ApiOperation("用户转移")
|
|
|
|
// @PostMapping("/userTransfer")
|
|
|
|
// public AjaxResult userTransfer()
|
|
|
|
// {
|
|
|
|
// List<Map<String,Object>> list =loginService.getRuningFishUserList();
|
|
|
|
// for (Map<String,Object> runingFishuser : list)
|
|
|
|
// {
|
|
|
|
// List<Map<String,Object>> yu2leUserList = publicService.getObjectListBySQL("SELECT * FROM `liu_yu_le`.`user_info` where login_name='"+runingFishuser.get("login_name")+"'");
|
|
|
|
// if (null == yu2leUserList || yu2leUserList.size() == 0)
|
|
|
|
// {
|
|
|
|
// publicService.updateBySql("INSERT INTO liu_yu_le.user_info(" +
|
|
|
|
// "login_name,name,gender,phone,last_login_time,last_login_ip,create_time,last_address," +
|
|
|
|
// "nickname,province_id,city_id,county_id,province_name,city_name,county_name,address" +
|
|
|
|
// ") VALUES (" +
|
|
|
|
// "'" + runingFishuser.get("login_name") + "'," +
|
|
|
|
// "'" + runingFishuser.get("name") + "'," +
|
|
|
|
// "'" + runingFishuser.get("gender") + "'," +
|
|
|
|
// "'" + runingFishuser.get("phone") + "'," +
|
|
|
|
// (runingFishuser.get("last_login_time") == null ? "NULL" : "'" + runingFishuser.get("last_login_time") + "'") + "," +
|
|
|
|
// (runingFishuser.get("last_login_ip") == null ? "NULL" : "'" + runingFishuser.get("last_login_ip") + "'") + "," +
|
|
|
|
// "'" + runingFishuser.get("create_time") + "'," +
|
|
|
|
// (runingFishuser.get("last_address") == null ? "NULL" : "'" + runingFishuser.get("last_address") + "'") + "," +
|
|
|
|
// (runingFishuser.get("nickname") == null ? "NULL" : "'" + runingFishuser.get("nickname") + "'") + "," +
|
|
|
|
// (runingFishuser.get("province_id") == null ? "NULL" : "'" + runingFishuser.get("province_id") + "'") + "," +
|
|
|
|
// (runingFishuser.get("city_id") == null ? "NULL" : "'" + runingFishuser.get("city_id") + "'") + "," +
|
|
|
|
// (runingFishuser.get("county_id") == null ? "NULL" : "'" + runingFishuser.get("county_id") + "'") + "," +
|
|
|
|
// (runingFishuser.get("province_name") == null ? "NULL" : "'" + runingFishuser.get("province_name") + "'") + "," +
|
|
|
|
// (runingFishuser.get("city_name") == null ? "NULL" : "'" + runingFishuser.get("city_name") + "'") + "," +
|
|
|
|
// (runingFishuser.get("county_name") == null ? "NULL" : "'" + runingFishuser.get("county_name") + "'") + "," +
|
|
|
|
// (runingFishuser.get("address") == null ? "NULL" : "'" + runingFishuser.get("address") + "'") +
|
|
|
|
// ")");
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// yu2leUserList = publicService.getObjectListBySQL("SELECT * FROM `liu_yu_le`.`user_info` where login_name='"+runingFishuser.get("login_name")+"'");
|
|
|
|
// Map<String,Object> runingFishUserLoginMap =loginService.getRuningFishUserLogin((Integer) runingFishuser.get("id"));
|
|
|
|
// try
|
|
|
|
// {
|
|
|
|
// publicService.updateBySql("INSERT INTO `liu_yu_le`.user_login(" +
|
|
|
|
// "`user_id`,`login_name`,`login_pass`,`user_login_pass_key`) VALUES ("+
|
|
|
|
// "'"+yu2leUserList.get(0).get("id")+"'," +
|
|
|
|
// "'"+runingFishUserLoginMap.get("login_name")+"'," +
|
|
|
|
// "'"+runingFishUserLoginMap.get("login_pass")+"'," +
|
|
|
|
// "'"+runingFishUserLoginMap.get("user_login_pass_key")+"'" +
|
|
|
|
// ")");
|
|
|
|
// }
|
|
|
|
// catch (Exception e)
|
|
|
|
// {
|
|
|
|
// logger.error("更新异常",e);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// Map<String,Object> yu2leUser = yu2leUserList.get(0);
|
|
|
|
// if(!(runingFishuser.get("id").toString()).equals(yu2leUser.get("id")+""))
|
|
|
|
// {
|
|
|
|
// //查看是否有相同用户id的用户存在
|
|
|
|
// Map<String,Object> sameRuningFishUser = loginService.getRuningFishUser((Integer) yu2leUser.get("id"));
|
|
|
|
// if (null != sameRuningFishUser) //如果有就先把旧用户id的runing_fish_user_id改为新的
|
|
|
|
// {
|
|
|
|
// loginService.updateRuningFishUserId("500"+yu2leUser.get("id"),yu2leUser.get("id")+"");
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// loginService.updateRuningFishUserId(yu2leUser.get("id")+"",runingFishuser.get("id")+"");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return success();
|
|
|
|
// }
|
|
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|