NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.ge.controller.playWeb.loginWeb;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;

import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.commons.lang3.StringUtils;
import org.n3r.ecaop.client.EcAopClient;
import org.n3r.ecaop.client.EcAopMethod;
import org.n3r.ecaop.client.EcAopResult;
import org.n3r.ecaop.client.SignAlgorithm;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSON;
import com.ge.common.Config;
import com.ge.common.DataUtil;
import com.ge.common.DateUtil;
import com.ge.common.StaticMap;
import com.ge.common.getInfo.ECSInfo;
import com.ge.common.netInterface.CheckNetType;
import com.ge.entity.client.baseUser.BaseUserPo;
import com.ge.service.client.baseUser.IBaseUserService;


/**
* @Title OlyprizecongfigWebController
* @Package com.ge.controller.playWeb.olyprizecongfigWeb
* @Description
* @author wangpeng
* @date 2016-07-27 11:26:25
* @version 1.0
*/

@Controller
@RequestMapping("loginWeb")
@Scope("prototype")
public class LoginWebController{

@Resource
private IBaseUserService baseUserService;


/**
*
* @param request
* @param response
* @param classRequestMapping
* @param index
* @return
* @throws Exception
*/

@RequestMapping(value="{classRequestMapping:\w+}-{index:\w+}/xxxx")
public ModelAndView notlogin(HttpServletRequest request,HttpServletResponse response,
@PathVariable(value="classRequestMapping") String classRequestMapping,
@PathVariable(value="index") String index) throws Exception {
ModelAndView mv = null;
BaseUserPo baseUser=new BaseUserPo();
Map<String, Object> hm = new HashMap<String, Object>();
DataUtil du = new DataUtil();
String [] desmobileArr = request.getParameterValues("desmobile");
String playSign = classRequestMapping+"-"+index;

if(desmobileArr!=null&&desmobileArr.length>0
&& du.isUnicomMobile(String.valueOf(desmobileArr[0]))){

baseUser = getLoginBaseUser(du.getReturnLong(desmobileArr[0]),playSign,request);

hm.put("user", baseUser);
hm.put("mapping", classRequestMapping);
hm.put("index", index);
mv = sucForWord(hm,request);
}else{
mv = noLogin(classRequestMapping, index,request);
}
return mv;
}
@RequestMapping(value="{classRequestMapping:\w+}-{index:\w+}/yyyy")
public ModelAndView notloginYY(HttpServletRequest request,HttpServletResponse response,
@PathVariable(value="classRequestMapping") String classRequestMapping,
@PathVariable(value="index") String index) throws Exception {
ModelAndView mv = null;
BaseUserPo baseUser=new BaseUserPo();
Map<String, Object> hm = new HashMap<String, Object>();

String ticket = request.getParameter("ticket");
String playSign = classRequestMapping+"-"+index;

if(StringUtils.isNotEmpty(ticket) && !ticket.equals("null")){
baseUser = getLoginBaseUser(ticket, playSign,request);
if(baseUser!=null){
hm.put("user", baseUser);
hm.put("mapping", classRequestMapping);
hm.put("index", index);
mv = sucForWord(hm,request);
}else{
mv=new ModelAndView();
mv.setViewName("close");
}
}else{
mv = noLogin(classRequestMapping, index,request);
}
return mv;
}


@RequestMapping(value="{classRequestMapping:\w+}-{index:\w+}/noLogin")
public ModelAndView noLogin(@PathVariable(value="classRequestMapping") String classRequestMapping,@PathVariable(value="index") String index,HttpServletRequest request) throws Exception {
ModelAndView mv = new ModelAndView();
// BaseUserPo baseUser = getBaseUser();
BaseUserPo baseUser = (BaseUserPo)request.getSession().getAttribute("baseUser");
mv.addObject("baseUser",baseUser);
mv.addObject("backUrl",classRequestMapping+"-"+index);
mv.setViewName("playWeb/loginWeb/noLogin");
return mv;
}
//================================================================================================================


/**
*
* @param request
* @param response
* @param classRequestMapping
* @param index
* @param param
* @return
* @throws Exception
*/
@RequestMapping(value="{classRequestMapping:\w+}-{index:\w+}-{param}/xxxx")
public ModelAndView notlogin(HttpServletRequest request,HttpServletResponse response,
@PathVariable(value="classRequestMapping") String classRequestMapping,
@PathVariable(value="index") String index,
@PathVariable("param") String param) throws Exception {

ModelAndView mv = new ModelAndView();
BaseUserPo baseUser=new BaseUserPo();
DataUtil du = new DataUtil();
String playSign = classRequestMapping+"-"+index+"-"+param;
Map<String, Object> hm = new HashMap<String, Object>();

String [] desmobileArr = request.getParameterValues("desmobile");

if(desmobileArr!=null&&desmobileArr.length>0
&& du.isUnicomMobile(String.valueOf(desmobileArr[0]))){
baseUser = getLoginBaseUser(du.getReturnLong(desmobileArr[0]),playSign,request);

hm.put("user", baseUser);
hm.put("mapping", classRequestMapping);
hm.put("index", index);
hm.put("param", param);

mv = sucForWord(hm,request);
}else{
mv = noLogin(classRequestMapping, index, param,request);
}
return mv;
}
@RequestMapping(value="{classRequestMapping:\w+}-{index:\w+}-{param}/yyyy")
public ModelAndView loginYY(HttpServletRequest request,HttpServletResponse response,
@PathVariable(value="classRequestMapping") String classRequestMapping,
@PathVariable(value="index") String index,
@PathVariable("param") String param) throws Exception {
BaseUserPo baseUser=new BaseUserPo();
ModelAndView mv = new ModelAndView();
Map<String, Object> hm = new HashMap<String, Object>();

String playSign = classRequestMapping+"-"+index+"-"+param;
String ticket = request.getParameter("ticket");

if(StringUtils.isNotEmpty(ticket) && !ticket.equals("null")){
baseUser = getLoginBaseUser(ticket, playSign,request);
if(baseUser!=null){
hm.put("user", baseUser);
hm.put("mapping", classRequestMapping);
hm.put("index", index);
hm.put("param", param);

mv = sucForWord(hm,request);
}else{
mv=new ModelAndView();
mv.setViewName("close");
}
}else{
mv = noLogin(classRequestMapping, index, param,request);
}
request.getSession().setAttribute("code", baseUser.getCode());
return mv;
}

@RequestMapping(value="{classRequestMapping:\w+}-{index:\w+}-{param}/noLogin")
public ModelAndView noLogin(
@PathVariable(value="classRequestMapping") String classRequestMapping,
@PathVariable(value="index") String index,
@PathVariable("param") String param,
HttpServletRequest request) throws Exception {
ModelAndView mv = new ModelAndView();
// BaseUserPo baseUser = getBaseUser();
BaseUserPo baseUser = (BaseUserPo)request.getSession().getAttribute("baseUser");
mv.addObject("baseUser",baseUser);
mv.addObject("backUrl",classRequestMapping+"-"+index+"-"+param);
mv.setViewName("playWeb/loginWeb/noLogin");
return mv;
}




/**
* 通过开放平台获得用户信息
* @param ticket //手厅参数
* @param planSign //活动标识
* @return
* @throws Exception
*/
public BaseUserPo getLoginBaseUser(String ticket, String planSign,HttpServletRequest request) throws Exception {
//获取登陆信息
BaseUserPo baseUser=null;
ECSInfo einfo=null;
for(int i=0;i<3;i++){
try {
JSONObject json=einfo.getInfo(ticket);
String refreshtoken=(String) json.get("refreshtoken");
String usercustid=(String) json.get("usercustid");
baseUser=einfo.getUser(refreshtoken,usercustid);
einfo=new ECSInfo();
baseUser=einfo.getUser(ticket);
if(baseUser==null){
continue;
}else{
break;
}
} catch (Exception e) {
// TODO: handle exception
continue;
}
}
if(baseUser!=null){
baseUser.setSign(planSign);
//判断网别 ==如果开发
if(null!=baseUser.getNettype() && (baseUser.getNettype().equals("01")
||baseUser.getNettype().equals("02"))){
baseUser.setNettypeCode(baseUser.getNettype());
baseUser.setNettype("23g");
} else if(null!=baseUser.getNettype() && (baseUser.getNettype().equals("11"))) {
baseUser.setNettypeCode(baseUser.getNettype());
baseUser.setNettype("4g");
}


return setBaseUser(baseUser,request);
}else{
return baseUser;
}
}

/**
* 通过本身的数据库获得用户信息
* @param phone //手机号
* @param planSign //活动标识
* @return
*/
public BaseUserPo getLoginBaseUser(Long phone, String planSign,HttpServletRequest request) {
DataUtil du = new DataUtil();
BaseUserPo baseUser = new BaseUserPo();
baseUser.setPhone(phone);
baseUser.setCode(du.getNoNull(du.getSequence()));
baseUser.setSign(planSign);

//判断网别
// CheckNetType netType=new CheckNetType();
// JSONObject json=netType.checkType(phone);
// if(null!=json.get("nettype") && (json.get("nettype").equals("10")
// ||json.get("nettype").equals("16")
// ||json.get("nettype").equals("17")
// ||json.get("nettype").equals("33"))){
// baseUser.setNettype("23g");
// } else if(null!=json.get("nettype") && (json.get("nettype").equals("50")
// ||json.get("nettype").equals("19") ||json.get("nettype").equals(""))) {
// }
baseUser.setNettype("4g");
// baseUser.setCitycode(StaticMap.getCityCodeMap().get(json.get("city").toString()));
baseUser.setCitycode("沈阳");
return setBaseUser(baseUser,request);
}

public BaseUserPo setBaseUser(BaseUserPo baseUser,HttpServletRequest request) {
DataUtil du = new DataUtil();
BaseUserPo temp = new BaseUserPo();
temp.setPhone(baseUser.getPhone());
temp=baseUserService.byNoGetBaseUser(temp);

//登陆
if(temp!=null) {
baseUser.setNo(temp.getNo());
baseUser.setUpdateName(baseUser.getPhone());
baseUserService.updBaseUser(baseUser);
} else {
baseUser.setNo(du.getSequence());
baseUser.setInputName(baseUser.getPhone());
baseUserService.addBaseUser(baseUser);
}

//设置IP
baseUser.setIpaddress(request.getRemoteAddr());

return baseUser;
}

/**
* 成功跳转
* @return
*/
private ModelAndView sucForWord(Map<String, Object> hm,HttpServletRequest request) {
DataUtil du = new DataUtil();
String mapping = du.getNoNull(hm.get("mapping"));
String index = du.getNoNull(hm.get("index"));
String param = du.getNoNull(hm.get("param"));

ModelAndView mv=new ModelAndView();
String redirect = "redirect:/playWeb/"+mapping+'/'+index+".do";
if(!"".equals(param)) {
redirect = redirect + "?param="+param;
}

mv.setViewName(redirect);
request.getSession().setAttribute("baseUser", (BaseUserPo)hm.get("user"));
return mv;
}


@RequestMapping("xxxx")
public ModelAndView autologin(HttpServletRequest request,HttpServletResponse response,String param) {

// ModelAndView mv = new ModelAndView();
// mv.setViewName("playWeb/loginWeb/temp");
// return mv;
ModelAndView mv = new ModelAndView();
TreeMap<String, String> hm = new TreeMap<String, String>();
/*
内网:http://10.40.32.13:9200/openservlet
外网:http://211.94.67.94:8001/openservlet
Dcn 地址:http://132.38.0.86:9200/openservlet"
_uop_id
*/

Cookie[] cookies = request.getCookies();
HttpSession session = request.getSession();
String ticket=request.getParameter("ticket");

// ECSInfo ecs=new ECSInfo();
// BaseUserPo baseuser=new BaseUserPo();
// JSONObject json=ecs.getInfo(ticket);
// json=ecs.getInfoRefresh(json.get("refreshtoken").toString(),json.get("usercustid").toString());
// System.out.println(json);
//获取登陆信息
EcAopClient client = new EcAopClient(Config.getCommonLabel("ECSInfo", "DCNURL"), Config.getCommonLabel("ECSInfo", "PHONECODE"),Config.getCommonLabel("ECSInfo", "PHONEHETY"));
client.setSignAlgorithm(SignAlgorithm.HmacMD5);

EcAopMethod method = client.createEcAopMethod(Config.getCommonLabel("ECSInfo", "GETINFO"), Map.class);
hm.put("type", "02");
hm.put("queryvalue", ticket);
String strID = UUID.randomUUID().toString();
hm.put("apptx", strID);
EcAopResult res = method.exec(hm);


JSONObject jsonResult = JSONObject.fromObject(res.getResponse());
System.out.println(jsonResult);
String refreshtoken=(String) jsonResult.get("refreshtoken");
String usercustid=(String) jsonResult.get("usercustid");

//用户登录信息刷新接口
method = client.createEcAopMethod(Config.getCommonLabel("ECSInfo", "REFRESH"), Map.class);
hm.clear();
hm.put("refreshtoken", refreshtoken);
hm.put("usercustid", usercustid);
strID = UUID.randomUUID().toString();
hm.put("apptx", strID);
res = method.exec(hm);
// EcAopClientLogBean a = new EcAopClientLogBean(method,hm,res);

JSONObject json = JSONObject.fromObject(res.getResponse());
String accesstoken=(String) json.get("accesstoken");
System.out.println(json);
//获取登陆账号信息
method = client.createEcAopMethod(Config.getCommonLabel("ECSInfo", "GETACCOUNTINFO"), Map.class);
hm.clear();
hm.put("granttype", "userinfo");
hm.put("accesstoken", accesstoken);
strID = UUID.randomUUID().toString();
hm.put("apptx", strID);
res = method.exec(hm);
// a = new EcAopClientLogBean(method,hm,res);

json = JSONObject.fromObject(res.getResponse());
JSONArray jsonArray = JSONArray.fromObject(json.get("productlist"));
json = JSONObject.fromObject(jsonArray.get(0));
System.out.println(json);
String businumber=json.get("productid").toString();
String provincecode=json.get("provincecode").toString();
String citycode=json.get("citycode").toString();
String nettype=json.get("nettype").toString();
String paytype=json.get("paytype").toString();
String lastvisitip=json.get("lastvisitip").toString();
//根据accesstoken生成ticket
method = client.createEcAopMethod(Config.getCommonLabel("ECSInfo", "TICKET"), Map.class);
hm.clear();
hm.put("accesstoken", accesstoken);
strID = UUID.randomUUID().toString();
hm.put("apptx", strID);
res = method.exec(hm);

//非支付类订单同步接口
DateUtil du=new DateUtil();
method = client.createEcAopMethod(Config.getCommonLabel("ECSInfo", "NOPAY"), Map.class);
hm.clear();
hm.put("access_token", accesstoken);
hm.put("customid", usercustid);
hm.put("nettype", nettype);
hm.put("paytype", paytype);
hm.put("usernumber", businumber);

hm.put("businumber", businumber);
hm.put("orderid", "091"+du.getFormatDate14()+"00007");
hm.put("busicode", "1034");
hm.put("busitype", "02");
hm.put("createtime", du.getFormatDate14());
hm.put("ipaddress", request.getRemoteAddr());
hm.put("provincecode", provincecode);
hm.put("citycode", citycode);

Map<String, String> subMap = new HashMap<String, String>();
subMap.put("acceptbusinesstype", "0002");
subMap.put("accepttype", "01");
subMap.put("effecttype", "01");
subMap.put("orderstatus", "01");
subMap.put("ordererrordesc", "test");
String JSONStr = JSON.toJSONString(subMap);

hm.put("handleinfo", JSONStr);
strID = UUID.randomUUID().toString();
hm.put("apptx", strID);
res = method.exec(hm);

json = JSONObject.fromObject(res.getResponse());
System.out.println(json);
//mv.setViewName("playWeb/loginWeb/temp");
return mv;
}
//================================================================================================================


public static void main(String [] args){
TreeMap<String, String> hm = new TreeMap<String, String>();
// EcAopClient client = new EcAopClient("http://open.10010.com/openservlet", Config.getCommonLabel("ECSInfo", "PHONECODE"),Config.getCommonLabel("ECSInfo", "PHONEHETY"));
// client.setSignAlgorithm(SignAlgorithm.HmacMD5);
//
// EcAopMethod method = client.createEcAopMethod("com.aop.method.realnamecheckqry", Map.class);
// hm.put("usernumber", "18624008361");
//
// String strID = UUID.randomUUID().toString();
// hm.put("apptx", strID);
// EcAopResult res = method.exec(hm);
//
//
// JSONObject jsonResult = JSONObject.fromObject(res.getResponse());
// System.out.println(jsonResult);
hm.put("usernumber", "18624008361");
ECSInfo ecs=new ECSInfo();
ecs.realnamecheckqry(hm);
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.