def verfiyUser(self,user_id,user_pwd,imei,imsi): rs= BinMap() inpara= BinMap() inpara.put('user_id','') inpara.put('user_pwd','') inpara.put('imei','') inpara.put('imsi','') rslist= BinList() rslist=self.model.getSelectResult(inpara, "user_id='"+user_id+"' and user_pwd='"+user_pwd+"'",'users') if rslist.size()==1: if (rslist.getvalue(0,'imei')=="" and rslist.getvalue(0,'imsi')=="") or (rslist.getvalue(0,'imei')==None and rslist.getvalue(0,'imsi')==None): inpara.clear() inpara.put('imei',imei) inpara.put('imsi',imsi) print inpara.getitem() self.model.getUpdateResult(inpara, "user_id='"+user_id+"' and user_pwd='"+user_pwd+"'",'users') rs.put('code','1') rs.put('message','登录成功') elif rslist.getvalue(0,'imei')==imei and rslist.getvalue(0,'imsi')==imsi: rs.put('code','1') rs.put('message','登录成功') else: rs.put('code','0') rs.put('message','手机已经绑定,违法终端') else: rs.put('code','0') rs.put('message','用户名或密码错误') return rs;
def changPassWord(self,user_id,oldpwd,newpwd): inpara= BinMap() inpara.put('user_id','') inpara.put('user_pwd','') inpara.put('imei','') inpara.put('imsi','') rslist= BinList() rs= BinMap() rslist=self.model.getSelectResult(inpara, "user_id='"+user_id+"' and user_pwd='"+oldpwd+"'",'users') if rslist.size()==1: inpara.clear() inpara.put('user_pwd',newpwd) self.model.getUpdateResult(inpara, "user_id='"+user_id+"'",'users') rs.put('code','1') rs.put('message','修改成功') else: rs.put('code','0') rs.put('message','用户名或密码错误') return rs;
def testGetList(self): data=BinList(); data.put(0,'name','张三'); data.put(0, 'sex', '男'); data.put(0, 'id', '1'); data.put(1,'name','李四'); data.put(1, 'sex', '女'); data.put(1, 'id', '2'); para=BinMap(); para.put("text", '[name],[sex]'); para.put('id','[id]'); obj=ActionXml(); obj.getList(data, para, None); self.assertEqual(obj.reponse(),'<?xml version="1.0" encoding="utf-8"?><root><message>数据下载成功</message><code>1</code><count>2</count><data><row><text>张三,男</text><id>1</id></row><row><text>李四,女</text><id>2</id></row></data></root>')
def testGetInfo(self): data=BinList(); data.put(0,'name','张三'); data.put(0, 'sex', '男'); data.put(0, 'id', '1'); data.put(1,'name','李四'); data.put(1, 'sex', '女'); data.put(1, 'id', '2'); items=BinMap(); items.put("name", "姓名"); items.put("sex", "性别"); items.put("id", "编号"); args=BinMap(); args.put("message", '更新'); obj=ActionXml(); obj.getInfo(data, items, args); # self.assertAlmostEqual(obj.reponse(),'<?xml version="1.0" encoding="utf-8"?><root><message>更新</message><code>1</code><count>2</count><data><row>【编号】1\n【姓名】张三\n【性别】男</row><row>【编号】2\n【姓名】李四\n【性别】女</row></data></root>') print obj.reponse();