コード例 #1
0
ファイル: operategw.py プロジェクト: sailorhdx/taurusxr
 def userModify(self, wsbody):
     formdata = Storage()
     formdata.customer_id = self.get_ws_attr(wsbody, 'userCode')
     formdata.realname = self.get_ws_attr(wsbody, 'realName')
     formdata.install_address = self.get_ws_attr(wsbody, 'installAddress')
     formdata.ip_address = self.get_ws_attr(wsbody, 'ipAddress')
     formdata.mobile = self.get_ws_attr(wsbody, 'mobile')
     formdata.idcard = self.get_ws_attr(wsbody, 'idcard')
     account = self.db.query(models.TrAccount).filter_by(
         customer_id=formdata.customer_id).first()
     if not account:
         return self.send_wsresp('userModify',
                                 code=Codes.ERROR_NOT_EXIST,
                                 error=u'用户不存在')
     formdata.account_number = account.account_number
     formdata.user_concur_number = account.user_concur_number
     formdata.bind_vlan = account.bind_vlan
     formdata.bind_mac = account.bind_mac
     formdata.account_desc = account.account_desc
     customer = self.db.query(models.TrCustomer).get(formdata.customer_id)
     customer.realname = formdata.realname
     customer.address = formdata.install_address
     customer.mobile = formdata.mobile
     customer.idcard = formdata.idcard
     manager = AccountService(self.db, self.aes)
     ret = manager.update(formdata)
     if not ret:
         self.send_wsresp('userModify',
                          code=Codes.ERROR_UNKNOWN,
                          error=manager.last_error)
     else:
         self.send_wsresp('userModify', code=Codes.SUCCESS)
コード例 #2
0
ファイル: operategw.py プロジェクト: sailorhdx/taurusxr
 def insertProduct(self, wsbody):
     formdata = Storage()
     formdata.product_id = self.get_ws_attr(wsbody,
                                            'productCode',
                                            notnull=True)
     formdata.product_name = self.get_ws_attr(wsbody,
                                              'productName',
                                              notnull=True)
     formdata.bind_mac = self.get_ws_attr(wsbody, 'bindMac', defval=0)
     formdata.bind_vlan = self.get_ws_attr(wsbody, 'bindVlan', defval=0)
     formdata.concur_number = self.get_ws_attr(wsbody,
                                               'concurNumber',
                                               defval=0)
     formdata.bandwidthCode = self.get_ws_attr(wsbody,
                                               'bandwidthCode',
                                               defval='')
     formdata.input_max_limit = utils.bb2mb(
         self.get_ws_attr(wsbody, 'inputMaxLimit', defval=0))
     formdata.output_max_limit = utils.bb2mb(
         self.get_ws_attr(wsbody, 'outputMaxLimit', defval=0))
     formdata.fee_months = self.get_ws_attr(wsbody, 'feeNum', defval=0)
     formdata.fee_price = self.get_ws_attr(wsbody, 'feePrice', defval=0)
     formdata.product_policy = BOMonth
     formdata.fee_times = 0
     formdata.fee_flows = 0
     formdata.product_charges = None
     formdata.free_auth = 0
     formdata.free_auth_uprate = 0
     formdata.free_auth_downrate = 0
     pkg = self.db.query(models.TrProduct).get(formdata.product_id)
     if pkg:
         return self.send_wsresp('insertProduct',
                                 code=Codes.ERROR_ALREADY_EXIST,
                                 error=u'套餐已经存在')
     else:
         manager = ProductService(self.db, self.aes)
         ret = manager.add(formdata)
         if not ret:
             self.send_wsresp('insertProduct',
                              code=Codes.ERROR_UNKNOWN,
                              error=manager.last_error)
         else:
             self.send_wsresp('insertProduct', code=Codes.SUCCESS)
         return
コード例 #3
0
ファイル: operategw.py プロジェクト: sailorhdx/taurusxr
 def updatePolicy(self, wsbody):
     formdata = Storage()
     formdata.customer_id = self.get_ws_attr(wsbody, 'userCode')
     formdata.domain = self.get_ws_attr(wsbody, 'domainCode')
     formdata.bind_mac = self.get_ws_attr(wsbody, 'bindMac')
     formdata.bind_vlan = self.get_ws_attr(wsbody, 'bindVlan')
     formdata.user_concur_number = self.get_ws_attr(wsbody, 'concurNumber')
     account = self.db.query(models.TrAccount).filter_by(
         customer_id=formdata.customer_id).first()
     if not account:
         return self.send_wsresp('updatePolicy',
                                 code=Codes.ERROR_NOT_EXIST,
                                 error=u'用户不存在')
     formdata.account_number = account.account_number
     manager = AccountService(self.db, self.aes)
     ret = manager.update(formdata)
     if not ret:
         self.send_wsresp('updatePolicy',
                          code=Codes.ERROR_UNKNOWN,
                          error=manager.last_error)
     else:
         self.send_wsresp('updatePolicy', code=Codes.SUCCESS)