发表于: 2017-10-24 23:45:56
2 762
今天完成的事情:
1、将“积分新平台”的以map形式返回的数据删除,更改为在jsp中定义字段,用MyListUtil提前查询好map。
2、回顾了一遍逗你学登录注册找回密码的相关接口 a/register
verifyType = "register"
参数校验 account pwd verify
======== 1、校验验证码 ========== (地区码)
verifyResult = verifyMobileCode(account, verify_type, verify);
verifyResult == false 返回 -2005
========= 2、校验 account 类型 ==========
userId = userService.getUserIdByMail(account);
或
userId= userService.getUserIdByMobile(account);
user = userService.getObjectById(userId);
分支①
user 有无密码?
有密码直接中断返回错误码 2005。
尚未有密码则 带上密码 update user。
如果入参带有 openid
DataUtils.isNotNullOrEmpty(openid)
insert 一条 UserOpenidRelation(),
relation.setType("'web"); relation.setUid(userId); relation.setOpenId(openId);
分支②
user是null
========== 3、 =============
正常注册
2、测试了 MyListUtil 的更多的方法。
①convert2Map 这个方法被重载了3次。
项目中最常用到的是 convert2Map(Field keyField, Field valueField, List datas);
目标是将入参的 keyField 与 valueField 互相成为键值对,返回一个相关的map。
②MyListUtil.convert2Map(Field f, List keys, List datas) 有 3 个入参,
该方法目标为针对 传入集合(datas) 筛选某个字段(f)的值在目标集合(keys)中的值。
List<Long> periodIds = periodService.getPeriodIds(0, Integer.MAX_VALUE);
List<Period> periodList = periodService.getObjectsByIds(periodIds);
List keys = new ArrayList();
keys.add(31597L);
keys.add(31598L);
keys.add(31599L);
// 按目标id集合 取到 值
Map periodId_pClass = MyListUtil.convert2Map(Period.class.getDeclaredField("id"), keys, periodList);
我们先查出了所有的课程Id(periodId),通过课程Id查到了课程列表periodList。
然后造一个list,存入31567L 31598L 31599L 三个Long值(是要筛选出的目标课程Id的值)。
此时调用 convert2Map 方法,会发现返回的 period_pClass 刚好就是 id 为目标id 的三个课程对象。
③MyMapUtil 的 lookUpValueByKey(Map map, Object key, Class clazz) 方法
这个方法是通过入参的key查找 map 中指定的值,比如我传入 31597L 这个id值,就会返回id为31597L的 课程对象。
Object o = MyMapUtil.lookUpValueByKey(periodId_pClass, 31597L, Period.class);
System.out.println(o);
public static <K, V, T extends V> V lookUpValueByKey(Map<K, V> map, K key, Class<T> tClazz)
明天计划的事情:
遇到的问题:
收获:
评论