发表于: 2017-05-13 23:55:15
3 1185
今天完成的事情:
@RequestMapping(value = "/a/login", method = RequestMethod.POST)
public String login(HttpServletRequest request, HttpServletResponse response, ModelMap model, String name, String pwd) {
log.info(" welcome to manager login ");
try {
List<Long> managerIds = this.managerService.getManagerIdsByName(name, 0, Integer.MAX_VALUE);
log.info(name+" get managerIDs "+managerIds);
if (managerIds==null || managerIds.isEmpty() || managerIds.size()>1) {
log.info(name +" not get any user ");
model.addAttribute("code", -5003);
} else {
log.info(name +" get user "+ managerIds.get(0));
Manager manager = this.managerService.getObjectById(managerIds.get(0));
if (PasswordUtils.authenticatePassword(manager.getPwd(), pwd) && manager.getStatus().equals(Manager.STATUS_USING)) {
log.info(managerIds.get(0)+" login ");
Map<String,String> maps=new HashMap();
maps.put(CookieConstant.Cookie_WEB_ManagerName, manager.getName());
//maps.put(CookieConstant.Cookie_WEB_PuserPublicsHash, manager.getPublicsHash());
//maps.put(CookieConstant.Cookie_WEB_PuserPublicsHash, "-2042484612");
maps.put(CookieUtil.USER_ID, manager.getId() + "");//map用来存储键和值
cookieUtil.setIdentity(request, response, maps, manager.getId());
Role role = roleService.getObjectById(manager.getRoleID());
if(role==null){
log.error("not get any role " + manager.getRoleID());
model.addAttribute("code", -7001);
return "/data/json";
}
model.addAttribute("code", 0);
model.addAttribute("manager", manager);
model.addAttribute("role",role);
log.info(managerIds.get(0)+" login over ");
} else {
log.info(managerIds.get(0)+" has wrong pwd ");
model.addAttribute("code", -5004);
model.addAttribute("result", null);
}
}
} catch (Throwable t) {
log.error(t.getMessage());
log.error("manager login error,name is " + name);
model.addAttribute("code", -5002);
model.addAttribute("result", null);
}
return "/data/login";
}
项目里面都是查ID,现在还没搞懂:
一个登陆过程:
请求Post方法,将Name和ID放入List中,判断如果ID为null或为空或id数多于1个,则向前端返回负值code,定义Map,将ID和Name Put进cookie。
明天计划的事情:
梳理萝卜多方案
遇到的问题:
暂无
收获:
听老大讲了一波scallop负载均衡和Dal
Scallop:
1.Spring RMI 只调用一个services,不能管理services
2.services1、services2、services3 存在List里,随机访问
3.由scallop中的home表管理services服务
Dal缓存:
提高命中率:
1.通过ID找到Object
2.通过Key-value 找到Object
评论