def post(self): ''' firstname,lastname,phone,email :return: ''' id = self.get_argument('id') firstname = self.get_argument('firstname') lastname = self.get_argument('lastname') phone = self.get_argument('phone') email = self.get_argument('email') user_service = UserService() user_service.update_user_by_id(id, firstname, lastname, phone, email) ret = { 'errorMsg': False, 'row': { 'id': id, 'firstname': firstname, 'lastname': lastname, 'phone': phone, 'email': email } } self.write(json.dumps(ret))
def post(self, *args, **kwargs): user_service = UserService() user_list = user_service.get_user_list() print user_list self.write(json.dumps(user_list))
def post(self): from Model.User import UserService from Repository.UserRepository import UserRepository service = UserService() #依赖注入已自动把UserRepository()传递进去 obj = service.check_login(user=None, email=None, pwd=None) print(obj.username) print(obj.vip_obj.caption) print(obj.vip_obj.nid)
def post(self): ''' firstname,lastname,phone,email :return: ''' id = self.get_argument('id') user_service = UserService() user_service.delete_user_by_id(id) ret = {'success': True} self.write(json.dumps(ret))
def post(self, *args, **kwargs): username = self.get_argument("username", None) email = self.get_argument("email", None) pwd = self.get_argument("pwd", None) code = self.get_argument("checkcode", None) service = UserService() result = service.check_login(user=username, email=email, pwd=pwd) #obj封装了所有的用户信息,UserModel对象 if result and code.upper() == self.session["CheckCode"].upper(): self.session['username'] = result.username self.redirect("/ProvinceManager.html") else: self.write("alert('error')")
def post(self): ''' firstname,lastname,phone,email :return: ''' ''' :return: ''' firstname = self.get_argument('firstname') lastname = self.get_argument('lastname') phone = self.get_argument('phone') email = self.get_argument('email') user_service = UserService() user_service.insert_into_user(firstname, lastname, phone, email) ret = {'errorMsg': False} self.write(json.dumps(ret))
def post(self): page = self.get_argument('page') rows = self.get_argument('rows') if page: user_service = UserService() user_list = user_service.get_user_list_by_page(page, rows) count = user_service.get_user_count() ret = {'total': count['count'], 'rows': user_list} self.write(json.dumps(ret)) else: user_service = UserService() user_list = user_service.get_user_list() self.write(json.dumps(user_list))
def __init__(self): self.nid = IntegerField( required=False, widget=Widget.InputText(attributes={'class': 'hide'})) self.name = StringField() self.domain = StringField() self.business_mobile = StringField() self.business_phone = StringField() self.qq = StringField() self.address = StringField(widget=Widget.TextArea( attributes={'class': 'address'})) self.backend_mobile = StringField() self.backend_phone = StringField() self.user_id = IntegerField(widget=Widget.Select( attributes={}, choices=UserService(UserRepository()).get_user_to_select())) self.province_id = IntegerField( widget=Widget.Select(attributes={'id': 'province'}, choices=[{ 'value': 0, 'text': '请选择省份' }])) self.city_id = IntegerField(widget=Widget.Select( attributes={'id': 'city'}, choices=[{ 'value': 0, 'text': '请选择市' }])) self.county_id = IntegerField( widget=Widget.Select(attributes={'id': 'county'}, choices=[{ 'value': 0, 'text': '请选择县(区)' }])) super(MerchantForm, self).__init__()
def __init__(self): self.nid = IntegerField( required=False, widget=Widget.InputText(attributes={"class": "hide"})) self.name = StringField(custom_error_dict={ "required": "名称不能为空", "valid": "名称格式错误" }) self.domain = StringField(custom_error_dict={ "required": "域名不能为空", "valid": "域名格式错误" }) self.business_mobile = StringField(custom_error_dict={ "required": "业务电话不能为空", "valid": "业务电话格式错误" }) self.business_phone = StringField(custom_error_dict={ "required": "业务手机不能为空", "valid": "业务手机格式错误" }) self.qq = StringField(custom_error_dict={ "required": "QQ不能为空", "valid": "QQ格式错误" }) self.address = StringField( widget=Widget.TextArea(attributes={"class": "address"}), custom_error_dict={ "required": "地址信息不能为空", "valid": "地址格式错误" }) self.backend_mobile = StringField(custom_error_dict={ "required": "负责人电话不能为空", "valid": "负责人电话格式错误" }) self.backend_phone = StringField(custom_error_dict={ "required": "负责人电话不能为空", "valid": "负责人电话格式错误" }) self.user_id = IntegerField(widget=Widget.Select( attributes={}, choices=UserService().get_user_to_select()), custom_error_dict={ "required": "请选择登录用户", "valid": "选择登录用户错误" }) self.province_id = IntegerField(widget=Widget.Select( attributes={"id": "my_province"}, choices=[{ "value": 0, "text": "请选择省份" }]), custom_error_dict={ "required": "请选择省", "valid": "省选择错误" }) self.city_id = IntegerField(widget=Widget.Select( attributes={"id": "my_city"}, choices=[{ "value": 0, "text": "请选择市" }]), custom_error_dict={ "required": "请选择市", "valid": "市选择错误" }) self.country_id = IntegerField(widget=Widget.Select( attributes={"id": "my_country"}, choices=[{ "value": 0, "text": "请选择县(区)" }]), custom_error_dict={ "required": "请选择县(区)", "valid": "县(区)选择错误" }) super(MerchantForm, self).__init__()
def __init__(self): self.response = Response() self.userService = UserService() self.model = None
class User_Service: def __init__(self): self.response = Response() self.userService = UserService() self.model = None def fetch_oen_message(self, email): self.model = self.userService.fetch_one_message(email) try: if self.model: model_view = User_Model_View( id=self.model.id, email=self.model.password, password=self.model.password, login_time=self.model.login_time, jiachangcai=self.model.jiachangcai, xiafancai=self.model.xiafancai, sucai=self.model.sucai, dayudarou=self.model.dayudarou, tanggeng=self.model.tanggeng, liangcai=self.model.liangcai, suiji_caidan=self.model.suiji_caidan) self.response.model_view = model_view except Exception as e: self.response.status = False self.response.message = str(e) return self.response def check_email(self, email): result = self.userService.check_email(email) try: if result: raise Exception('邮箱已注册!!!') except Exception as e: self.response.status = False self.response.message = str(e) return self.response def check_email_password(self, email, password): self.model = self.userService.check_eamil_password(email, password) try: if self.model: model_view = User_Model_View( id=self.model.id, email=self.model.password, password=self.model.password, login_time=self.model.login_time, jiachangcai=self.model.jiachangcai, xiafancai=self.model.xiafancai, sucai=self.model.sucai, dayudarou=self.model.dayudarou, tanggeng=self.model.tanggeng, liangcai=self.model.liangcai, suiji_caidan=self.model.suiji_caidan) self.response.model_view = model_view else: raise Exception('邮箱密码不匹配') except Exception as e: self.response.status = False self.response.message = str(e) return self.response def update_password(self, email, password): try: self.userService.update_password(email, password) except Exception as e: self.response.status = False self.response.message = '更新密码出错,稍后修改' return self.response def update_dish(self, handler): user = handler.get_argument('user', None) jiachangcai = handler.get_argument('jiachangcai', None) if jiachangcai: jiachangcai = ' '.join(set(jiachangcai.split(' '))) xiafancai = handler.get_argument('xiafancai', None) if xiafancai: xiafancai = ' '.join(set(xiafancai.split(' '))) sucai = handler.get_argument('sucai', None) if sucai: sucai = ' '.join(set(sucai.split(' '))) dayudarou = handler.get_argument('dayudarou', None) if dayudarou: dayudarou = ' '.join(set(dayudarou.split(' '))) tanggeng = handler.get_argument('tanggeng', None) if tanggeng: tanggeng = ' '.join(set(tanggeng.split(' '))) liangcai = handler.get_argument('liangcai', None) if liangcai: liangcai = ' '.join(set(liangcai.split(' '))) try: self.userService.update_dish(user, jiachangcai, xiafancai, sucai, dayudarou, tanggeng, liangcai) except Exception as e: self.response.status = False self.response.message = str(e) return self.response def update_suiji_caidan(self, email, suijicaidan): pass def update_last_login(self, email): import datetime current_time = datetime.datetime.now() try: self.userService.update_last_login(email, current_time) except Exception as e: self.response.status = False self.response.message = '数据库错误,更新登入时间失败' return self.response def add_email_password(self, email, password): try: self.userService.add_email_password(email, password) except Exception as e: self.response.status = False self.response.message = str(e) return self.response
def get(self): id = self.get_argument('id') user_service = UserService() user_obj = user_service.get_user_by_id(id) print user_obj, 111111111111111111 self.write(json.dumps(user_obj))
def get(self): user_service = UserService() user_list = user_service.get_user_list() self.write(json.dumps(user_list))