You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.6 KiB

from entity.ChannelEntity import Channel
from common.Utils import getSession
class ChannelService:
# 新增一个channel
def insertOneByValues(channelId, channelTitle, channelLanguage, region, channelReptileTime=None):
session = getSession()
channel = Channel(channelId=channelId, channelTitle=channelTitle,
channelLanguage=channelLanguage, region=region)
if channelReptileTime:
channel.channelReptileTime = channelReptileTime
session.add(channel)
session.commit()
session.close()
def queryOneById(id):
session = getSession()
channel = session.query(Channel).filter(Channel.id == id).first()
session.close()
return channel
def queryOneByChannelId(channelId):
session = getSession()
channel = session.query(Channel).filter(
Channel.channelId == channelId).first()
session.close()
return channel
def updtaByChannel(channelId, channelTitle=None, channelLanguage=None, channelReptileTime=None, region=None):
session = getSession()
update_channel = session.query(Channel).filter(
Channel.channelId == channelId).first()
if update_channel:
if channelTitle:
update_channel.channelTitle = channelTitle
if channelLanguage:
update_channel.channelLanguage = channelLanguage
if channelReptileTime:
update_channel.channelReptileTime = channelReptileTime
if region:
update_channel.region = region
session.commit()
session.close()