12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package service
- import (
- "context"
- "fmt"
- "strings"
- "youngee_b_api/db"
- "youngee_b_api/model/gorm_model"
- "youngee_b_api/model/http_model"
- "github.com/issue9/conv"
- "github.com/sirupsen/logrus"
- )
- var Sketch *sketch
- type sketch struct {
- }
- // ReviseOption 在上传初稿表上提交修改意见
- func (*sketch) SketchOption(ctx context.Context, request http_model.SketchOpinionRequest) (*http_model.SketchOpinionData, error) {
- Sketch := gorm_model.YounggeeSketchInfo{
- TaskID: conv.MustInt(request.TaskID),
- ReviseOpinion: request.SketchOpinion,
- }
- err := db.SketchOption(ctx, Sketch.TaskID, Sketch.ReviseOpinion)
- if err != nil {
- logrus.WithContext(ctx).Errorf("[Sketch service] call CreateSketch error,err:%+v", err)
- return nil, err
- }
- res := &http_model.SketchOpinionData{
- TaskID: int64(Sketch.TaskID),
- }
- return res, nil
- }
- // AcceptSketch 同意初稿
- func (*sketch) AcceptSketch(ctx context.Context, request http_model.AcceptSketchRequest) (*http_model.AcceptSketchData, error) {
- var TaskIDList []int
- TaskIDs := strings.Split(request.TaskIds, ",")
- for _, taskId := range TaskIDs {
- TaskIDList = append(TaskIDList, conv.MustInt(taskId))
- }
- fmt.Printf("acc request %+v", TaskIDList)
- err := db.AcceptSketch(ctx, TaskIDList)
- if err != nil {
- logrus.WithContext(ctx).Errorf("[Sketch service] call CreateSketch error,err:%+v", err)
- return nil, err
- }
- res := &http_model.AcceptSketchData{
- TaskIds: TaskIDList,
- }
- return res, nil
- }
- // FindPhoto 查找初稿图片以及视频
- func (*sketch) FindPhoto(ctx context.Context, request http_model.FindSketchPhotoRequest) ([]http_model.SketchPhoto, error) {
- var SketchPhotos []http_model.SketchPhoto
- res, err := db.FindPhoto(ctx, request.SketchID)
- if err != nil {
- logrus.WithContext(ctx).Errorf("[Sketch service] call CreateSketch error,err:%+v", err)
- return nil, err
- }
- for _, photo := range res {
- sketchPhoto := http_model.SketchPhoto{
- PhotoUrl: photo.PhotoUrl,
- PhotoUid: photo.PhotoUid,
- Symbol: conv.MustInt64(photo.Symbol),
- }
- SketchPhotos = append(SketchPhotos, sketchPhoto)
- }
- return SketchPhotos, nil
- }
|