def add_group(group_name, group_de): session = baseDao.get_session() g = Group() g.group_uuid = uuid.uuid4() g.group_name = group_name g.group_de = group_de g.created_ts = datetime.now() g.private_fl = False g.group_type_cd = 'SP' return groupDao.add_group(session, g)
def test_add_group(self): session = baseDao.get_session() g = Group() g.group_uuid = uuid.uuid4() g.group_name = "Group_" + randomUtil.random_string(10, 10) g.group_de = "Group Description: " + randomUtil.random_string(10, 10) g.group_type_cd = 'SP' g.created_ts = datetime.now() g.private_fl = False new_group = groupDao.add_group(session, g) self.assertTrue(new_group.group_id > 0)
def create_group(): jsonData = request.get_json() with db.auto_commit(): group = Group() group.group_name = jsonData['group_name'] group.league_id = jsonData['league_id'] db.session.add(group) for gt in jsonData['group_team']: db.session.flush() group_team = Group_team() group_team.group_id = group.group_id group_team.league_id = jsonData['league_id'] group_team.team_id = gt['team_id'] db.session.add(group_team) return Success(msg='新增小组成功')