def titleComposeSave(admin_id, title, var1, var2, var3, var4, var5, task_id, config_id): try: title_option = { "title_info": title, 'keyword_var1': var1, 'keyword_var2': var2, 'keyword_var3': var3, 'keyword_var4': var4, 'keyword_var5': var5 } info = titleComposeData(admin_id, task_id, 'title_compose', config_id) # print(info) if len(info) > 0: cursor = config.config_online() content = json.dumps(title_option) content = content.replace("\\", "\\\\") sql = "UPDATE {} SET option_value = '{}' WHERE admin_id = {} and option_name = 'title_compose' and task_id = {} and config_id = {}".format( table, content, admin_id, task_id, config_id) # print(content) cursor.execute(sql) result = cursor.fetchall() else: cursor = config.config_online() content = json.dumps(title_option) content = content.replace("\\", "\\\\") sql = "INSERT INTO {} (option_name, option_value,admin_id,task_id,config_id) VALUES ('title_compose','{}','{}','{}','{}')".format( table, content, admin_id, task_id, config_id) print(sql) cursor.execute(sql) except Exception as e: print(e) return []
def setDuanTypeSave(admin_id, option_value, task_id, config_id): try: info = titleComposeData(admin_id, task_id, 'duanType', config_id) print(info) content = json.dumps(option_value) content = content.replace("\\", "\\\\") if not info is None: try: if len(info) == 0: cursor = config.config_online() sql = "INSERT INTO {} (option_name, option_value,admin_id,task_id,config_id) VALUES ('duanType','{}','{}','{}','{}')".format( table, content, admin_id, task_id, config_id) print(sql) cursor.execute(sql) return except Exception as e: pass cursor = config.config_online() sql = "UPDATE {} SET option_value = '{}' WHERE admin_id = {} and option_name = 'duanType' and task_id = {} and config_id = {}".format( table, content, admin_id, task_id, config_id) cursor.execute(sql) except Exception as e: print(e) return []
def getSelectedDataProCity(city, is_pro, is_city, is_xian, is_regionsp): city_all = [] for name in city: sql = "SELECT `name`,`id` FROM {} WHERE `name` = '%s' ".format(table) data = (name) cursor = config.config_online() cursor.execute(sql % data) # print(cursor.fetchall()) for row_p in cursor: sql = "SELECT `name`,`id` FROM {} WHERE `parent_id` = '%s' ".format( table) data = (row_p[1]) cursor = config.config_online() cursor.execute(sql % data) for row_c in cursor: proname = row_p[0] cityname = row_c[0] if is_pro == 1: if '省' in proname[-1]: proname = proname[:-1] if is_city == 1: if '市' in cityname[-1]: cityname = cityname[:-1] city_all.append(proname + cityname) return clearData(city_all, is_pro, is_city, is_xian, is_regionsp)
def getSelectedDataProXian(city, is_pro, is_city, is_xian, is_regionsp): city_all = [] for name in city: sql = "SELECT `name`,`id` FROM {} WHERE `name` = '%s' ".format(table) data = (name) cursor = config.config_online() cursor.execute(sql % data) # print(cursor.fetchall()) for row_p in cursor: sql = "SELECT `name`,`id` FROM {} WHERE `parent_id` = '%s' ".format( table) data = (row_p[1]) cursor = config.config_online() cursor.execute(sql % data) for row_c in cursor: sql = "SELECT `name`,`id` FROM {} WHERE `parent_id` = '%s' ".format( table) data = (row_c[1]) cursor = config.config_online() cursor.execute(sql % data) for row_x in cursor: try: newname = row_x[0] if len(newname) > 2: if is_xian == 1: if '县' in newname[-1]: newname = newname[:-1] # newname = newname.replace('县', '') if is_regionsp == 1: newname = newname.replace('自治区', '') newname = newname.replace('自治县', '') newname = newname.replace('自治州', '') newname = newname.replace('自治乡', '') if '区' in newname[-1]: newname = newname[:-1] # newname = newname.replace('区', '') proname = row_p[0] if is_pro == 1: if '省' in proname[-1]: proname = proname[:-1] city_all.append(proname + newname) except Exception as e: print(e) return clearData(city_all, is_pro, is_city, is_xian, is_regionsp)
def getTaskInfo(admin_id, name): try: cursor = config.config_online() sql = "SELECT * FROM {} WHERE `admin_id` = '{}' and `name` = '{}' and status = 1".format( table, admin_id, name) # print(sql) cursor.execute(sql) result = cursor.fetchall() info = { 'id': result[0][0], 'name': result[0][1], 'speed': result[0][2], 'type': result[0][3], 'website': result[0][4], 'admin_id': result[0][5], 'username': str(result[0][6]), 'password': str(result[0][7]), 'is_start': result[0][9], 'shop_id': result[0][12], 'token': str(result[0][8]), 'config_id': str(result[0][11]) } return info except Exception as e: print(e) return []
def addPageInfo(admin_id,name,task_id,config_id): cursor = config.config_online() sql = "INSERT INTO {} (name, admin_id,task_id,config_id) VALUES ( '{}', '{}','{}','{}')".format(table_pag, name,admin_id,task_id,config_id) # print(sql) cursor.execute(sql) for info in cursor: return info[0]
def getSendSenPag(task_id,config_id,pagList): # if len(notWhere) > 0: # notWhere = 'id not in ({}) and'.format(notWhere[:-1]) sql = "select pag_id,content from {} where task_id = {} and config_id = {}".format(table, task_id, config_id) print(sql) cursor = config.config_online() commit = config.config_Commit() try: # 先删 # data = '' data = [] cursor.execute(sql) i = 0 for info2 in pagList: for info in cursor: print(info) if info2['id'] == info[0]: pagList[i]['data'].append(info) i += 1 return pagList except Exception as e: print(12313123) print(e) return ['error']
def deleteAllDuan(admin_id,task_id,pag_id,config_id): try: cursor = config.config_online() sql = "DELETE FROM {} WHERE admin_id = '{}' and task_id = '{}' and pag_id = '{}' and config_id = '{}'".format(table,admin_id,task_id,pag_id,config_id) cursor.execute(sql) except Exception as e: print(e)
def titleDataAll(admin_id, task_id, status, config_id): try: sqlDel = "SELECT * FROM {} WHERE admin_id = {} and task_id = '{}' and status = '{}' and config_id = '{}' order by `send_time`".format( table, admin_id, task_id, status, config_id) print(sqlDel) cursor = config.config_online() except Exception as e: print(e) # commit = config.config_Commit() try: # 先删 data = [] # # print(sqlDel) cursor.execute(sqlDel) for info in cursor: data.append({ "id": info[0], "title": info[1], 'status': info[4], 'desc': info[5], 'send_time': info[6] }) return data except Exception as e: print(e)
def getListTaskCount(admin_id, search=''): sql = "SELECT count(`id`) FROM {} WHERE `admin_id` = '{}' and status = 1 and `name` like '%{}%'".format( table, admin_id, search) # print(sql) cursor = config.config_online() cursor.execute(sql) result = cursor.fetchall() return result[0][0]
def login(username, password): sql = "SELECT `username`,`id` FROM {} WHERE `username` = '%s' and `password` = '%s' and type = 1".format( table) data = (username, password) cursor = config.config_online() cursor.execute(sql % data) result = cursor.fetchall() return result[0]
def addAlbumInfo(admin_id, name, task_id, config_id): cursor = config.config_online() try: sql = "INSERT INTO {} (name, admin_id,task_id,config_id) VALUES ( '{}', '{}','{}','{}')".format( table, name, admin_id, task_id, config_id) cursor.execute(sql) result = cursor.fetchall() except Exception as e: print(e)
def setOptionStatus(task_id,config_id,status): try: cursor = config.config_online() sql = "UPDATE {} SET status= '{}' WHERE task_id = {} and config_id = {}".format(table,status, task_id,config_id) print(sql) cursor.execute(sql) except Exception as e: print(e) return []
def delAlbumImg(idList): cursor = config.config_online() commit = config.config_Commit() try: for id in idList: sqlDel = "DELETE FROM {} WHERE id = '{}'".format(table_img, id) cursor.execute(sqlDel) except Exception as e: print(e)
def delAlbumImgClear(type, admin_id, task_id, album_id, config_id): cursor = config.config_online() commit = config.config_Commit() try: sqlDel = "DELETE FROM {} WHERE type = '{}' and admin_id = '{}' and task_id = '{}' and album_id = '{}' and config_id = '{}'".format( table_img, type, admin_id, task_id, album_id, config_id) cursor.execute(sqlDel) except Exception as e: print(e)
def deleteList(admin_id, task_id, status, config_id): try: cursor = config.config_online() sql = "DELETE FROM {} WHERE admin_id = {} and task_id = {} and status = {} and config_id = {}".format( table, admin_id, task_id, status, config_id) # print(sql) cursor.execute(sql) except Exception as e: print(e) return []
def deleteInfo(admin_id, name, task_id, config_id): cursor = config.config_online() commit = config.config_Commit() try: sqlDel = 'DELETE FROM {} WHERE admin_id = "{}" and name = "{}" and task_id = {} and config_id = {}'.format( table, admin_id, name, task_id, config_id) print(sqlDel) cursor.execute(sqlDel) except Exception as e: print(e)
def getProvince(): sql = "SELECT `name` FROM {} WHERE `level` = '%s' ".format(table) data = (Level_Province) cursor = config.config_online() cursor.execute(sql % data) city_list = [] # print(cursor.fetchall()) for row in cursor: city_list.append(row[0]) return city_list
def updateStart(admin_id, username, is_start): try: cursor = config.config_online() sql = "UPDATE {} SET is_start = '{}' WHERE admin_id = {} and username = '******'".format( table, is_start, admin_id, username) cursor.execute(sql) result = cursor.fetchall() except Exception as e: print(e) return ''
def delUserInfo(task_id): try: cursor = config.config_online() sql = "UPDATE {} SET status = 0 WHERE id = {}".format(table, task_id) # print(sql) cursor.execute(sql) result = cursor.fetchall() except Exception as e: print(e) return []
def titleDataCount(admin_id, task_id, status, config_id): try: sqlDel = "SELECT count(`id`) FROM {} WHERE admin_id = {} and task_id = '{}' and status = '{}' and config_id = '{}'".format( table, admin_id, task_id, status, config_id) cursor = config.config_online() cursor.execute(sqlDel) for info in cursor: return info[0] except Exception as e: print(e)
def titleData(admin_id, task_id, config_id): cursor = config.config_online() sql = "SELECT type,keyword FROM {} WHERE admin_id = '%s' and task_id = '{}' and config_id = {}".format( table, task_id, config_id) data = (admin_id) cursor.execute(sql % data) data = [] for info in cursor: data.append(info) return data
def deleteOne(admin_id, task_id, id, config_id): try: cursor = config.config_online() sql = "DELETE FROM {} WHERE admin_id = {} and task_id = {} and id = {} and config_id = {}".format( table, admin_id, task_id, id, config_id) # print(sql) cursor.execute(sql) result = cursor.fetchall() except Exception as e: print(e) return []
def getDataContent(id, task_id, config_id): try: cursor = config.config_online() sql = "SELECT content FROM {} WHERE id = '%s' and task_id = '{}' and config_id = '{}'".format( table, task_id, config_id) data = (id) cursor.execute(sql % data) for info in cursor: return info[0] except Exception as e: print(e)
def updateSend(config_id, send): try: cursor = config.config_online() sql = "UPDATE {} SET is_send = {} WHERE id = '{}'".format( table, send, config_id) print(sql) cursor.execute(sql) result = cursor.fetchall() except Exception as e: print(e) return []
def getDataName(name, task_id): try: cursor = config.config_online() sql = 'SELECT id FROM {} WHERE name = "{}" and task_id = "{}" and status = 1'.format( table, name, task_id) cursor.execute(sql) for info in cursor: return info except Exception as e: # print('没有这个模板') return []
def getTaskId(admin_id, username): try: cursor = config.config_online() sql = "SELECT `id` FROM {} WHERE `admin_id` = '{}' and `name` = '{}'".format( table, admin_id, username) cursor.execute(sql) result = cursor.fetchall() return result[0][0] except Exception as e: print(e) return ''
def updateConfig(task_id, config_id): try: cursor = config.config_online() sql = "UPDATE {} SET config_id = '{}' WHERE id = '{}'".format( table, config_id, task_id) print(sql) cursor.execute(sql) result = cursor.fetchall() except Exception as e: print(e) return ''
def updateUserInfo(username, password, task_id, token, config_id): try: cursor = config.config_online() sql = "UPDATE {} SET username = '******',password= '******',token='{}' WHERE task_id = {} and config_id = {}".format( table, username, password, token, task_id, config_id) print(sql) cursor.execute(sql) result = cursor.fetchall() except Exception as e: print(e) return []
def setOption(admin_id,task_id,config_id,info): try: sendinfo = getOption(admin_id,task_id,config_id) print(222222222222) print(sendinfo) print(3333333333) if sendinfo is not None: cursor = config.config_online() sql = "UPDATE {} SET hour = '{}',minute = '{}',status= '{}',send_hour='{}',send_min='{}',count_num='{}' WHERE task_id = {} and config_id = {}".format( table, info['hour'], info['minute'], info['status'], info['send_hour'], info['send_min'], info['count_num'], task_id,config_id) print(sql) cursor.execute(sql) else: cursor = config.config_online() sql = "INSERT INTO {} (task_id, admin_id,hour,minute,status,config_id,send_hour,send_min,count_num) VALUES ('{}','{}','{}','{}','{}','{}','{}','{}','{}')".format(table, task_id, admin_id,info['hour'],info['minute'],info['status'],config_id,info['send_hour'],info['send_min'],info['count_num']) print(sql) cursor.execute(sql) except Exception as e: print(e) return []