// Package logic ----------------------------- // @file : artistinfo_artwork.go // @author : JJXu // @contact : wavingbear@163.com // @time : 2023/2/24 22:26 // ------------------------------------------- package logic import ( "errors" "github.com/fonchain/fonchain-artistinfo/cmd/internal/dao" "github.com/fonchain/fonchain-artistinfo/cmd/model" "github.com/fonchain/fonchain-artistinfo/pb/artistInfoArtwork" "github.com/fonchain/fonchain-artistinfo/pkg/m" ) type IArtistInfoArtwork interface { CreateArtworkLockRecord(req *artistInfoArtwork.CreateArtworkLockRecordReq) (res *artistInfoArtwork.ArtworkCommonNoParams, err error) ArtworkLockAction(req *artistInfoArtwork.ArtworkLockActionRequest) (res *artistInfoArtwork.ArtworkCommonNoParams, err error) GetArtworkLockRecords(req *artistInfoArtwork.GetArtworkLockRecordsRequest) (res *artistInfoArtwork.ArtworkLockList, err error) DeleteArtworkRecord(req *artistInfoArtwork.DeleteArtworkRecordRequest) (res *artistInfoArtwork.ArtworkCommonNoParams, err error) } var _ IArtistInfoArtwork = new(ArtistInfoArtworkLogic) type ArtistInfoArtworkLogic struct{} func (ArtistInfoArtworkLogic) CreateArtworkLockRecord(req *artistInfoArtwork.CreateArtworkLockRecordReq) (res *artistInfoArtwork.ArtworkCommonNoParams, err error) { err = dao.CreateArtworkLockRecord(&model.ArtworkLockRecord{ ArtistUid: req.ArtistUid, ArtworkUid: req.ArtworkUid, Status: req.Status, LockTime: req.LockTime, }) return } func (ArtistInfoArtworkLogic) ArtworkLockAction(req *artistInfoArtwork.ArtworkLockActionRequest) (res *artistInfoArtwork.ArtworkCommonNoParams, err error) { switch req.Lock { case 2: err = dao.BatchLockArtworks(req.ArtistUid) case 3: err = dao.BatchUnlockArtworks(req.ArtistUid) default: err = errors.New("lock值错误") } return } func (ArtistInfoArtworkLogic) GetArtworkLockRecords(req *artistInfoArtwork.GetArtworkLockRecordsRequest) (res *artistInfoArtwork.ArtworkLockList, err error) { res = &artistInfoArtwork.ArtworkLockList{} res, err = dao.GetArtworkLockRecords(req) return } func (ArtistInfoArtworkLogic) DeleteArtworkRecord(req *artistInfoArtwork.DeleteArtworkRecordRequest) (res *artistInfoArtwork.ArtworkCommonNoParams, err error) { //检查画作锁定情况 for _, v := range req.ArtworkUids { if dao.HasBeenLocked(v) { return nil, errors.New(m.ERROR_ISLOCK) } } err = dao.DeletedArtworkLockRecord(req.ArtworkUids...) return }