Beispiel #1
0
 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>')
Beispiel #2
0
 def getVersionApksize(self):
     rs= BinMap()
     inpara= BinMap()
     inpara.put('args_id','')
     inpara.put('args_content','')
     rslist=self.model.getSelectResult(inpara, "args_id='version' or args_id='apk_size'",'args')
     for i in range(0,rslist.size()):
         rs.put(rslist.getvalue(i,'args_id'),rslist.getvalue(i,'args_content'));
     return rs;
Beispiel #3
0
    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();
Beispiel #4
0
 def testGetResult(self):
     args=BinMap()
     args.put("message", '更新成功')
     obj=ActionXml();
     obj.getResult(args)
     self.assertEqual(obj.reponse(),'<?xml version="1.0" encoding="utf-8"?><root><message>更新成功</message><code>1</code></root>')
Beispiel #5
0
 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;
Beispiel #6
0
    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;
Beispiel #7
0

    def __init__(self):
        '''
        Constructor
        '''
    def __init__(self,connstr=None,host=None,user=None,passwd=None,db=None,port=None):
        Db.__init__(self,connstr,host,user,passwd,db,port)
        
    def getCursor(self):
        if self.port is not None:
            self.conn= MySQLdb.connect(host=self.host,user=self.user,passwd=self.passwd,db=self.db,port=self.port,charset="utf8")
        else:
            self.conn= MySQLdb.connect(host=self.host,user=self.user,passwd=self.passwd,db=self.db,charset="utf8")
        self.cursor = self.conn.cursor()   
#        self.runExecute("set names 'utf8'");
        
if __name__=="__main__":
    db=MySqlModel(host='localhost', user='******',passwd='windows123',db='psdemo')
#    model=DbModel(db,"users")
    f= BinMap();
    f.put("userid","newid1")
    f.put("name","2")
#    print model.getInsertResult(f)
#    print model.getSelectResult(f)
#    
#    print model.getUpdateResult(f, "countname='newid1'")
    print (db.getSelectResult(f,'1=1','users')).getitem()

#    print model.getDeleteResult("countname='newid1'")
#    print model.getSelectResult(f)
Beispiel #8
0
            if re.search("\.", field) is not None and re.search("\s+as\s+", field) is None:
                fieldarr=field.split(".")
                if fieldarr[1]=="realstring" or fieldarr[1]=="integer":
                    rs+=fieldarr[0]+"="
                    rs+=fieldMap.getvalue(num=i)+","
                else:
                    rs+=fieldarr[0]+"="
                    rs+="'"+fieldMap.getvalue(num=i)+"',"
                
            else:
                rs+=field+"="
                rs+="'"+fieldMap.getvalue(i)+"',"
        if len(rs)>0:
            rs=rs[0:len(rs)-1]
        return rs
    
if __name__=="__main__":
#    print "id.string".index(".")
#    str="id.string"
#    
#    if re.search("\.", str) is not None and re.search("\s+as\s+", str) is None:
#        print str.split(".");
#    rs=re.search("\.", "idstring")
#    print rs
     f= BinMap();
     f.put("id.realstring","1")
     f.put("name.string","2")
     u=DbUtil();
#     print u.getSelectPart(f);
#     print u.getInsertPart(f)
     print u.getUpdatePart(f)