import type { ChatLogItem } from '@shared/model/chat' ; import { hpack , hunpack } from '@shared/utils/json-helper' ; import { request } from '@shared/utils/request' ; import _isNil from 'lodash/isNil' ; import _isEmpty from 'lodash/isEmpty' ; export interface GameReport { uuid : string ; title : string ; cast : any ; groupUUID : string ; content : { playerUUID : string ; logs : ReportLogItem [ ] ; } ; } export type GameReportSimple = Pick < GameReport , 'uuid' | 'title' | 'groupUUID' > ; export const reportLogRequireKey = [ 'uuid' , 'sender_uuid' , 'message' , 'type' , 'date' , 'data' , 'revoke' , ] as const ; export type ReportLogItem = Pick < ChatLogItem , typeof reportLogRequireKey [ number ] > ; export interface EditLogItem extends ReportLogItem { selected : boolean ; } export interface DetailLogItem extends ReportLogItem { isShow : boolean ; } param title param playerUUID param groupUUID param logs export const createTRPGGameReport = async ( title , playerUUID , groupUUID , logs ) : Promise < string > => { const { data } = await request . post ( '/trpg/game-report/create' , { title , groupUUID , content : { playerUUID , logs : hpack ( logs ) } , } ) ; return data . uuid ; } ; param groupUUID export async function fetchGroupReport ( groupUUID ) { const { data } = await request . get ( `/trpg/game-report/group/${ groupUUID }/list` ) ; return data . list ; } param reportUUID param groupUUID export async function deleteGroupReport ( reportUUID , groupUUID ) { await request . post ( '/trpg/game-report/delete' , { reportUUID , groupUUID , } ) ; } param uuid export async function fetchTRPGGameReport ( uuid ) { const { data } = await request . get ( `/trpg/game-report/${ uuid }` ) ; const report = data . report ; if ( ! _isNil ( report . content ) ) { report . content . logs = hunpack ( report . content . logs ) ; } return report ; } /**
 * 获取自己的战报
 */ export const fetchOwnReport = async ( ) : Promise < GameReport [ ] > => { const { data } = await request . get ( '/trpg/game-report/list' ) ; const reports = data . reports ; return reports ; } ; export type RecruitPlatform = 'trpgengine' | 'qq' | 'other' ; export type RecruitContactType = 'user' | 'group' ; export interface RecruitItemType { uuid : string ; title : string ; author : string ; content : string ; platform : RecruitPlatform ; contact_type : RecruitContactType ; contact_content : string ; updatedAt : string ; completed : boolean ; } /**
 * 值与显示的映射
 */ export const recruitPlatformMap = { trpgengine : 'TRPG Engine' , qq : 'QQ' , other : '其他' , } ; export const recruitContactTypeMap = { user : '用户' , group : '群组' , } ; param title param content param platform param contactType param contactContent export const createRecruit = async ( title , content , platform , contactType , contactContent ) : Promise < void > => { if ( _isEmpty ( title ) || _isEmpty ( content ) ) { throw new Error ( '缺少必要字段' ) ; } await request . post ( `/trpg/recruit/create` , { title , content , platform , contactType , contactContent , } ) ; } ; /**
 * 获取所有招募列表
 */ export async function fetchAllRecruitList ( ) { const { data } = await request . get ( '/trpg/recruit/list/all' ) ; const list = data . list ; return list ; } /**
 * 获取用户招募列表
 */ export async function fetchUserRecruitList ( ) { const { data } = await request . get ( '/trpg/recruit/list/user' ) ; const list = data . list ; return list ; } param recruitUUID export async function setRecruitCompleted ( recruitUUID ) { await request . post ( `/trpg/recruit/${ recruitUUID }/complete` ) ; } param recruitUUID export async function fetchUserRecruitDetail ( recruitUUID ) { const { data } = await request . get ( `/trpg/recruit/${ recruitUUID }` ) ; const recruit = data . recruit ; return recruit ; }