def check_song_record(song_name, singer=None): """校验去重""" if singer: sql = "SELECT COUNT(*) AS number FROM cc_song song,cc_singer singer WHERE song.singer_id=singer.id \ AND song.song_name= %s AND singer.name = %s" result = db.get_one(sql, song_name, singer) else: sql = f"SELECT COUNT(*) AS number FROM cc_song WHERE song_name=%s" result = db.get_one(sql, song_name) count = result.get("number") return True if count == 0 else False
def select_song_record_by_id(song_id): """获取一条歌曲数据""" sql = """SELECT cs.id,(SELECT `name` FROM cc_singer WHERE id=cs.singer_id) as singer, \ (SELECT `name` FROM cc_song_kind WHERE id=cs.song_kind_id) as song_kind,\ cs.song_name,cs.size \ FROM cc_song cs WHERE `id`=%s AND del_status ='false'""" result = db.get_one(sql, song_id) return result
def select_host_server_record_by_id(id): sql = """SELECT `id`,`server_ip`,`server_name`,`memory`, `cpu`,`remark`,`create_time`,update_time, CASE WHEN `status`='0' THEN "有效" ELSE "无效" END as sys_status, CASE WHEN `effect`='0' THEN "开发" WHEN `effect`='1' THEN "测试" WHEN `effect`='2' THEN "预生产" ELSE "生产" END as sys_effect, CASE WHEN `sys_check`='0' THEN "逻辑服务器" ELSE "网关服务器" END as checks FROM sys_host_server WHERE `id`=%s """ result = db.get_one(sql, id) return result
def select_content_dir_record(*args): """获取目录名称""" sql = "SELECT `name` FROM cocoa.cc_content_type WHERE `filetype`=%s AND `suffix`=%s" result = db.get_one(sql, *args) return result
def check_record(*args): """文件类型校验去重""" sql = "SELECT COUNT(*) as number FROM cocoa.cc_content_type WHERE `filetype`=%s AND `suffix`=%s" result = db.get_one(sql, *args) count = result.get("number") return True if count == 0 else False
def select_record_by_id(cid): """查询具体文件类型""" sql = "SELECT `id`,`filetype`,`name`,`suffix` FROM cocoa.cc_content_type WHERE `id`=%s" result = db.get_one(sql, cid) return result
def check_host_server_record(name, ip): """文件类型校验去重""" sql = "SELECT COUNT(*) as number FROM sys_host_server WHERE `server_name`=%s AND `server_ip`=%s" result = db.get_one(sql, name, ip) count = result.get("number") return True if count == 0 else False
def get_singer_in_song(_id): sql = "SELECT `singer_id` FROM cc_song WHERE id=%s" info = db.get_one(sql, _id) singer_id = info.get("singer_id") return singer_id if singer_id else {}