|
|
|
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()
|