|  | @@ -2,9 +2,9 @@ package services
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import (
 | 
	
		
			
				|  |  |  	"errors"
 | 
	
		
			
				|  |  | -	"fmt"
 | 
	
		
			
				|  |  |  	"log"
 | 
	
		
			
				|  |  |  	"strconv"
 | 
	
		
			
				|  |  | +	"time"
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	"github.com/kataras/iris/v12"
 | 
	
		
			
				|  |  |  	"go.mod/comm"
 | 
	
	
		
			
				|  | @@ -20,7 +20,9 @@ type SafeService interface {
 | 
	
		
			
				|  |  |  	Post(data models.CmSafe) error
 | 
	
		
			
				|  |  |  	Del(id int) error
 | 
	
		
			
				|  |  |  	GetDetail(id int, pid int) viewmodels.SafeDetail
 | 
	
		
			
				|  |  | +	SaveFileInfo(bid int, sid int, uid int, fileList []viewmodels.FileList) error
 | 
	
		
			
				|  |  |  	ValidRule(ctx iris.Context) (viewmodels.Safe, error)
 | 
	
		
			
				|  |  | +	ValidFile(ctx iris.Context) (viewmodels.File, error)
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // //返回service操作类
 | 
	
	
		
			
				|  | @@ -91,7 +93,7 @@ func (s *safeService) Del(id int) error {
 | 
	
		
			
				|  |  |  func (s *safeService) GetDetail(id int, pid int) viewmodels.SafeDetail {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	safeData := s.daoSafe.FindById(id)
 | 
	
		
			
				|  |  | -	fmt.Println(safeData)
 | 
	
		
			
				|  |  | +	// fmt.Println(safeData)
 | 
	
		
			
				|  |  |  	safeId, _ := comm.AesEncrypt(strconv.Itoa(safeData.Id), conf.SignSecret)
 | 
	
		
			
				|  |  |  	bid, _ := comm.AesEncrypt(strconv.Itoa(safeData.BidsectionId), conf.SignSecret)
 | 
	
		
			
				|  |  |  	data := viewmodels.SafeDetail{}
 | 
	
	
		
			
				|  | @@ -110,9 +112,35 @@ func (s *safeService) GetDetail(id int, pid int) viewmodels.SafeDetail {
 | 
	
		
			
				|  |  |  	return data
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +// 安全巡检附件数据存库
 | 
	
		
			
				|  |  | +func (s *safeService) SaveFileInfo(bid int, sid int, uid int, fileList []viewmodels.FileList) error {
 | 
	
		
			
				|  |  | +	fileData := make([]models.CmSafeFile, 0)
 | 
	
		
			
				|  |  | +	for _, file := range fileList {
 | 
	
		
			
				|  |  | +		fileVM := models.CmSafeFile{}
 | 
	
		
			
				|  |  | +		fileVM.BidsectionId = bid
 | 
	
		
			
				|  |  | +		fileVM.SafeId = sid
 | 
	
		
			
				|  |  | +		fileVM.Uid = uid
 | 
	
		
			
				|  |  | +		createTime, _ := time.Parse("2020-11-11 20:30:12", file.CreateTime)
 | 
	
		
			
				|  |  | +		fileVM.CreatedTime = createTime
 | 
	
		
			
				|  |  | +		fileVM.FileName = file.FileName
 | 
	
		
			
				|  |  | +		fileVM.FilePath = file.FilePath
 | 
	
		
			
				|  |  | +		fileData = append(fileData, fileVM)
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	err := s.daoSafeFile.InsertByList(fileData)
 | 
	
		
			
				|  |  | +	return err
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +// 校验文件规则
 | 
	
		
			
				|  |  | +func (s *safeService) ValidFile(ctx iris.Context) (viewmodels.File, error) {
 | 
	
		
			
				|  |  | +	fileValid := viewmodels.File{}
 | 
	
		
			
				|  |  | +	err := ctx.ReadJSON(&fileValid)
 | 
	
		
			
				|  |  | +	return fileValid, err
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +// 规则校验
 | 
	
		
			
				|  |  |  func (s *safeService) ValidRule(ctx iris.Context) (viewmodels.Safe, error) {
 | 
	
		
			
				|  |  |  	safeVaild := viewmodels.Safe{}
 | 
	
		
			
				|  |  | -	fmt.Println("---------------------------safeVaild", safeVaild)
 | 
	
		
			
				|  |  | +	// fmt.Println("---------------------------safeVaild", safeVaild)
 | 
	
		
			
				|  |  |  	if ctx.Method() == "GET" {
 | 
	
		
			
				|  |  |  		err := ctx.ReadForm(&safeVaild)
 | 
	
		
			
				|  |  |  		if err != nil {
 | 
	
	
		
			
				|  | @@ -136,6 +164,12 @@ func (s *safeService) ValidRule(ctx iris.Context) (viewmodels.Safe, error) {
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		err = safeVaild.ValidateCreate()
 | 
	
		
			
				|  |  |  		return safeVaild, err
 | 
	
		
			
				|  |  | +		// if ctx.Path() == s.validCreate {
 | 
	
		
			
				|  |  | +		// }
 | 
	
		
			
				|  |  | +		// if ctx.Path() == s.validFile {
 | 
	
		
			
				|  |  | +		// 	err = safeVaild.ValidateFile()
 | 
	
		
			
				|  |  | +		// 	return safeVaild, err
 | 
	
		
			
				|  |  | +		// }
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	if ctx.Method() == "PUT" {
 |