mirror of
https://github.com/Teamlinker/Teamlinker.git
synced 2025-06-03 03:00:17 +00:00
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { getMysqlInstance } from '../../common/db/mysql';
|
|
import { DComponent } from "../../common/decorate/component";
|
|
import { DEventListener } from "../../common/event/event";
|
|
import { EServer_Common_Event_Types } from "../../common/event/types";
|
|
import { generateUpdateSql } from '../../common/util/sql';
|
|
import { fileModel } from './../../../common/model/file';
|
|
@DComponent
|
|
class FileEvents {
|
|
@DEventListener(EServer_Common_Event_Types.File.REF)
|
|
async refFile(fileId:string){
|
|
let mysql=getMysqlInstance()
|
|
await mysql.execute(generateUpdateSql(fileModel,{
|
|
ref:{
|
|
exp:"+",
|
|
value:1
|
|
}
|
|
},{
|
|
id:fileId
|
|
}))
|
|
}
|
|
@DEventListener(EServer_Common_Event_Types.File.UNREF)
|
|
async unrefFile(fileId:string){
|
|
let mysql=getMysqlInstance()
|
|
await mysql.execute(generateUpdateSql(fileModel,{
|
|
ref:{
|
|
exp:"-",
|
|
value:1
|
|
}
|
|
},{
|
|
id:fileId
|
|
}))
|
|
}
|
|
}
|