|
|
@@ -21,6 +21,7 @@ import (
|
|
|
proj "dashoo.cn/micro/app/model/proj"
|
|
|
workflowModel "dashoo.cn/micro/app/model/workflow"
|
|
|
"dashoo.cn/micro/app/service"
|
|
|
+ baseService "dashoo.cn/micro/app/service/base"
|
|
|
projsrv "dashoo.cn/micro/app/service/proj"
|
|
|
worksrv "dashoo.cn/micro/app/service/work"
|
|
|
workflowService "dashoo.cn/micro/app/service/workflow"
|
|
|
@@ -656,6 +657,49 @@ func (s CtrContractService) CommitWithFile(ctx context.Context, formData *multip
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
+func (s CtrContractService) CommitWithFileUrl(ctx context.Context, req *model.CtrContractCommitWithFileUrlReq) error {
|
|
|
+ validErr := gvalid.CheckStruct(ctx, req, nil)
|
|
|
+ if validErr != nil {
|
|
|
+ return myerrors.TipsError(validErr.Current().Error())
|
|
|
+ }
|
|
|
+ fileinfoByte, err := baseService.UploadDingtalk(s.userInfo.DingtalkId, req.FileUrl, req.FileName)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ var fileinfo = []model.DingFileInfo{}
|
|
|
+ err = json.Unmarshal(fileinfoByte, &fileinfo)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ _, err = s.Commit(ctx, &model.CtrContractCommitReq{
|
|
|
+ Id: req.Id,
|
|
|
+ ContractModel: req.ContractModel,
|
|
|
+ Terms: req.Terms,
|
|
|
+ PayTerms: req.PayTerms,
|
|
|
+ File: fileinfo,
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ appendSrv, err := NewCtrContractAppendService(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ _, err = appendSrv.Add(ctx, &model.CtrContractAppendAddReq{
|
|
|
+ ContractId: req.Id,
|
|
|
+ FileName: fileinfo[0].FileName,
|
|
|
+ FileType: fileinfo[0].FileType,
|
|
|
+ FileUrl: strings.Join([]string{"dingtalk", fileinfo[0].SpaceId, fileinfo[0].FileId}, ":"),
|
|
|
+ Remark: "",
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
func (s CtrContractService) DownloadDingtalkFile(ctx context.Context, id int) (string, error) {
|
|
|
ent, err := s.AppendDao.Where("id= ?", id).One()
|
|
|
if err != nil {
|