Esempio n. 1
0
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)
Esempio n. 2
0
def module_save():
    j_data = request.json
    if j_data is None:
        return Fun.class_to_JsonStr(AppReturnDTO(False, "参数有误"))
    in_ent = RequestSaveModel(j_data)
    _modele = ModuleDal()
    re_ent, message = _modele.module_Save(in_dict=in_ent.Data,
                                          saveKeys=in_ent.SaveKeys)
    if message.IsSuccess:
        message.set_data(re_ent)
    return Fun.class_to_JsonStr(message)
Esempio n. 3
0
def ApiPublicGetSolarDate():
    j_data, msg = Fun.post_to_dict(request)
    if j_data is None:
        return Fun.class_to_JsonStr(msg)
    postEnt = RequestSaveModel(j_data)
    if postEnt is None or postEnt.Data is None:
        return Fun.class_to_JsonStr(AppReturnDTO(False, "参数有问题"))

    t = time.strptime(postEnt.Data["Data"], "%Y-%m-%d")
    y, m, d = t[0:3]
    reStr = iSoft.core.LunarDate.LunarDate.fromSolarDate(y, m, d)
    reStr = "{0}-{1}-{2}".format(reStr.year, reStr.month, reStr.day)
    return Fun.class_to_JsonStr(AppReturnDTO(True, reStr))
Esempio n. 4
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)
Esempio n. 5
0
def ApiPublicGetLunarDate():
    '获取阴历'
    j_data, msg = Fun.post_to_dict(request)
    if j_data is None:
        return Fun.class_to_JsonStr(msg)
    postEnt = RequestSaveModel(j_data)
    if postEnt is None or postEnt.Data is None:
        return Fun.class_to_JsonStr(AppReturnDTO(False, "参数有问题"))

    t = time.strptime(postEnt.Data["Data"], "%Y-%m-%dT%H:%M")
    y, m, d, h = t[0:4]
    converter = LunarSolarConverter()
    solar = Solar(y, m, d)
    lunar = converter.SolarToLunar(solar)
    reStr = "%d年%02d月%02d日%02d时" % (lunar.lunarYear, lunar.lunarMonth,
                                    lunar.lunarDay, h)
    return Fun.class_to_JsonStr(AppReturnDTO(True, reStr))
Esempio n. 6
0
def CheckUpdate():
    '获取最新版本'
    j_data, msg = Fun.post_to_dict(request)
    if j_data is None:
        return Fun.class_to_JsonStr(msg)
    postEnt = RequestSaveModel(j_data)

    dirpath = os.path.join(app.root_path, '../static/')
    #设置以utf-8解码模式读取文件,encoding参数必须设置,否则默认以gbk模式读取文件,当文件中包含中文时,会报错
    f = open("{0}update/wjbjp/wjbjp.json".format(dirpath), encoding='utf-8')
    setting = json.load(f)
    reJson = None
    for item in setting:
        if item["CODE"] > postEnt.Key:
            reJson = item
            print(item["CODE"])
            break
    return Fun.class_to_JsonStr(AppReturnDTO(True, "", reJson))
Esempio n. 7
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))
Esempio n. 8
0
def ApiResetPassword():
    '''
    重置密码:RequestSaveModel对象,其中Data里包括VerifyCode,LoginName、NewPwd
    '''
    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 = LoginDal()
    re_ent, message = dal.ResetPassword(postEnt.Data["VerifyCode"],
                                        postEnt.Data["LoginName"],
                                        postEnt.Data["NewPwd"])

    if message.IsSuccess:
        message.set_data(re_ent)
    return json.dumps(Fun.convert_to_dict(message))
Esempio n. 9
0
def ApiPublicSendCode():
    '''
    发送短信:RequestSaveModel对象,其中Data里包括phone
    '''
    j_data, msg = Fun.post_to_dict(request)
    if j_data is None:
        return Fun.class_to_JsonStr(msg)

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

    if "phoneNum" not in postEnt.Data or postEnt.Data[
            "phoneNum"] is None or postEnt.Data["phoneNum"] == "":
        return Fun.class_to_JsonStr(AppReturnDTO(False, "没有获取phoneNum的值"))

    # 生成随机代码
    code = random.randint(1000, 9999)
    dal = LoginDal()
    re_ent = dal.UpdateCode(postEnt.Data["phoneNum"], code)
    return json.dumps(Fun.convert_to_dict(re_ent))