コード例 #1
0
ファイル: UserInfoDal.py プロジェクト: wengzhilai/FamilyAll
    def AddUserInfoAndLogin(self, parentId, loginName, password, name,
                            level_id, sex, YEARS_TYPE, BIRTHDAY_TIME,
                            birthday_place, ICON_FILES_ID, ALIAS, AUTHORITY):
        '完善用户的基本资料以及登录账号'

        parentEnt = FaUserInfo.query.filter(FaUserInfo.ID == parentId).first()
        if parentEnt is None:
            return None, AppReturnDTO(False, "父ID有问题")
        # <- 获取添加成功后的Login实体
        loginDal = LoginDal()
        loginDal.LOGIN_NAME = loginName
        loginDal.PASSWORD = password
        loginDal.PHONE_NO = loginName
        loginEng, msg = loginDal.AddLoginName()
        if not msg.IsSuccess:
            return msg
        # ->

        # <- 更新用户信息
        userInfoEnt = FaUserInfo()
        userInfoEnt.ID = Fun.GetSeqId(FaUser)
        userInfoEnt.FATHER_ID = parentId
        userInfoEnt.LOGIN_NAME = loginDal.LOGIN_NAME
        userInfoEnt.UPDATE_TIME = datetime.datetime.now()
        userInfoEnt.NAME = name
        userInfoEnt.LEVEL_ID = level_id
        userInfoEnt.SEX = sex
        userInfoEnt.YEARS_TYPE = YEARS_TYPE
        if not Fun.IsNullOrEmpty(BIRTHDAY_TIME):
            userInfoEnt.BIRTHDAY_TIME = datetime.datetime.strptime(
                BIRTHDAY_TIME, '%Y-%m-%dT%H:%M:%SZ')
        userInfoEnt.BIRTHDAY_PLACE = birthday_place
        userInfoEnt.DIED_TIME = None
        userInfoEnt.DIED_PLACE = None
        userInfoEnt.DISTRICT_ID = parentEnt.DISTRICT_ID
        userInfoEnt.IS_LOCKED = 0
        userInfoEnt.CREATE_TIME = datetime.datetime.now()
        userInfoEnt.LEVEL_ID = 1
        userInfoEnt.STATUS = '正常'
        userInfoEnt.CREATE_USER_NAME = name
        userInfoEnt.CREATE_USER_ID = userInfoEnt.ID
        userInfoEnt.UPDATE_TIME = datetime.datetime.now()
        userInfoEnt.UPDATE_USER_NAME = name
        userInfoEnt.ICON_FILES_ID = ICON_FILES_ID
        userInfoEnt.ALIAS = ALIAS
        userInfoEnt.AUTHORITY = AUTHORITY

        db.session.add(userInfoEnt)
        return userInfoEnt, AppReturnDTO(True)
コード例 #2
0
def ApiUserInfoSingle():
    '''
    重置密码:RequestSaveModel对象,其中Data里包括VerifyCode,LoginName、NewPwd
    '''
    j_data, message = Fun.post_to_dict(request)
    if j_data is None:
        return Fun.class_to_JsonStr(message)
    in_ent = PostBaseModel(j_data)

    if Fun.IsNullOrEmpty(in_ent.Key):
        return Fun.class_to_JsonStr(AppReturnDTO(False, "参数有问题"))

    dal = UserInfoDal()
    delMode, message = dal.userInfo_single(in_ent.Key)
    if message.IsSuccess:
        message.set_data(delMode)
    return Fun.class_to_JsonStr(message)
コード例 #3
0
def ApiFamilyUserInfoRelative():

    j_data, message = Fun.post_to_dict(request)
    if j_data is None:
        return Fun.class_to_JsonStr(message)
    in_ent = PostBaseModel(j_data)
    if in_ent is None:
        return Fun.class_to_JsonStr(AppReturnDTO(False, "参数有问题"))

    dal = FamilyDal()
    # 如果没有传值,则显示当前用户的ID
    if Fun.IsNullOrEmpty(in_ent.Key):
        in_ent.Key = 1

    re_ent, message = dal.UserInfoRelative(in_ent.Key)
    if message.IsSuccess:
        message.Data = re_ent.__dict__
    return Fun.class_to_JsonStr(message)
コード例 #4
0
def UserInfo_SingleByName():
    '''
    根据用户名查询用户:RequestSaveModel对象,其中Data里包括name
    '''
    j_data, message = Fun.post_to_dict(request)
    if j_data is None:
        return Fun.class_to_JsonStr(message)

    postEnt = RequestSaveModel(j_data)
    if postEnt is None or postEnt.Data is None:
        return Fun.class_to_JsonStr(AppReturnDTO(False, "参数有问题"))

    if "name" not in postEnt.Data or Fun.IsNullOrEmpty(postEnt.Data["name"]):
        return Fun.class_to_JsonStr(AppReturnDTO(False, "没有值"))

    dal = UserInfoDal()
    re_ent, message = dal.userInfo_SingleByName(postEnt.Data["name"])
    if message.IsSuccess:
        message.set_data(re_ent)
    return json.dumps(Fun.convert_to_dict(message))
コード例 #5
0
ファイル: UserInfoDal.py プロジェクト: wengzhilai/FamilyAll
    def userInfo_register(self, _inDict):
        '''
        注册用户
        用于APP注册
        '''

        in_ent = AppRegisterModel(_inDict)

        # 检测电话号码是否合法
        if in_ent.loginName is None or in_ent.loginName == '':
            return AppReturnDTO(False, "电话号码不能为空")
        if not Fun.is_phonenum(in_ent.loginName):
            return AppReturnDTO(False, "电话号码格式不正确")
        # 验证密码复杂度
        complexity = Fun.password_complexity(in_ent.password)
        if complexity < PASSWORD_COMPLEXITY:
            return AppReturnDTO(False, "密码复杂度不够:" + str(complexity))
        # 检测短信代码
        checkOutPwd, msg = LoginDal().CheckOutVerifyCode(
            in_ent.code, in_ent.loginName)
        # 失败则退出
        if not msg.IsSuccess or not checkOutPwd:
            return msg
        if len(in_ent.parentArr) < 2:
            return AppReturnDTO(False, "添加的辈份太多了")

        userDal = UserDal()
        if userDal.user_checkLoginExist(in_ent.loginName):
            return AppReturnDTO(False, "{0}已经存在".format(in_ent.loginName))

        # 表示添加已经存在的用户,只需完善资料,并添加登录账号
        loginDal = LoginDal()
        # 添加登录账号
        if "K" in in_ent.parentArr[0] and "V" in in_ent.parentArr[0]:

            para = {
                'userId': int(in_ent.parentArr[0]["K"]),
                'loginName': in_ent.loginName,
                'password': in_ent.password,
                'name': in_ent.parentArr[0]["V"],
                'level_id': in_ent.level_id,
                'sex': in_ent.sex,
                'YEARS_TYPE': in_ent.YEARS_TYPE,
                'BIRTHDAY_TIME': in_ent.BIRTHDAY_TIME,
                'birthday_place': in_ent.birthday_place
            }
            self.FinishUserInfoAndLogin(**para)
            db.session.commit()
            return AppReturnDTO(True)

        parentId = 0
        # 如果有多个父级,都需要每一个每一个用户的添加
        for i in range(len(in_ent.parentArr) - 1, -1, -1):
            parentDict = in_ent.parentArr[i]
            # 跳过包含K的项,因为有K的项是已经存在的,有K表示是下一个的父ID
            if "K" in parentDict and not Fun.IsNullOrEmpty(parentDict["K"]):
                parentId = int(parentDict["K"])
            else:
                # 表示是需要添加的当前用户
                if i == 0:
                    para = {
                        'parentId': parentId,
                        'loginName': in_ent.loginName,
                        'password': in_ent.password,
                        'name': parentDict["V"],
                        'level_id': in_ent.level_id,
                        'sex': in_ent.sex,
                        'YEARS_TYPE': in_ent.YEARS_TYPE,
                        'BIRTHDAY_TIME': in_ent.BIRTHDAY_TIME,
                        'birthday_place': in_ent.birthday_place,
                        'ICON_FILES_ID': in_ent.ICON_FILES_ID,
                        'ALIAS': in_ent.ALIAS,
                        'AUTHORITY': in_ent.AUTHORITY
                    }
                    self.AddUserInfoAndLogin(**para)
                    db.session.commit()
                    pass
                else:  # 只添加用户名
                    parentEnt, msg = self.AddUserInfoSimple(
                        parentDict["V"], parentId)
                    if not msg.IsSuccess:  #如果失败则退出
                        return msg
                    parentId = parentEnt.ID  # 用于下次添加的时候
                    in_ent.parentArr[i]["K"] = parentId  # 用于更新,该记录是谁添加和修改的

        return AppReturnDTO(True)