def ApiUserInfolist():
    j_data = request.json
    if j_data is None:
        return Fun.class_to_JsonStr(AppReturnDTO(False, "参数有误"))
    in_ent = RequestPagesModel(j_data)
    where = []
    for search in in_ent.SearchKey:
        if search["Type"] == "like":
            where.append(
                eval("FaUserInfo.%(Key)s.like('%%%(Value)s%%')" % search))
        else:
            where.append(eval("FaUserInfo.%(Key)s%(Type)s%(Value)s" % search))

    criterion = []
    for search in in_ent.OrderBy:
        search["Value"] = search["Value"].lower()
        criterion.append(eval("FaUserInfo.%(Key)s.%(Value)s()" % search))

    _modele = UserInfoDal()
    re_ent, message = _modele.userInfo_findall(in_ent.PageIndex,
                                               in_ent.PageSize, criterion,
                                               where)

    if message.IsSuccess:
        message.set_data(re_ent)
    return Fun.class_to_JsonStr(message)
def ApiUserInfoSave():

    j_data = request.json
    if j_data is None:
        return Fun.class_to_JsonStr(AppReturnDTO(False, "参数有误"))
    in_ent = RequestSaveModel(j_data)
    _modele = UserInfoDal()
    # 更新添加的用户
    if hasattr(g, "current_user"):
        # 表示添加
        if "ID" not in in_ent.Data or in_ent.Data["ID"] is None or in_ent.Data[
                "ID"] == 0:
            in_ent.Data["CREATE_USER_NAME"] = g.current_user.NAME
            if "CREATE_USER_NAME" not in in_ent.SaveKeys:
                in_ent.SaveKeys.append('CREATE_USER_NAME')

            in_ent.Data["CREATE_USER_ID"] = g.current_user.ID
            if "CREATE_USER_ID" not in in_ent.SaveKeys:
                in_ent.SaveKeys.append('CREATE_USER_ID')
    # 设置角色
    in_ent.Data["roleIdList"] = "3"
    if "roleIdList" not in in_ent.SaveKeys:
        in_ent.SaveKeys.append('roleIdList')
    re_ent, message = _modele.userInfo_Save(in_dict=in_ent.Data,
                                            saveKeys=in_ent.SaveKeys)
    if message.IsSuccess:
        message.Data = json.loads(json.dumps(re_ent, cls=AlchemyEncoder))
        # message.set_data(re_ent)
    return Fun.class_to_JsonStr(message)
Beispiel #3
0
def UserInfo_Register():
    '''
    用于手机端注册用户
    '''
    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, "参数有问题"))
    dal = UserInfoDal()
    postEnt = dal.userInfo_register(postEnt.Data)
    return Fun.class_to_JsonStr(postEnt)
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)
Beispiel #5
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))