from entity.ChannelEntity import Channel from common.Utils import getSession class ChannelService: # 新增一个channel def insertOneByValues(channelId, channelTitle, channelLanguage, region): session = getSession() channel = Channel(channelId=channelId, channelTitle=channelTitle, channelLanguage=channelLanguage, region=region) 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