'commit'
continuous-integration/drone/push Build is passing Details

master
黄海 4 years ago
parent af460b0e16
commit 137c67c8a8

@ -7,10 +7,9 @@
<list default="true" id="19c8c37d-a056-451c-a29d-fb612b9a3e2f" name="Default Changelist" comment="commit">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Business/FileRelate/FileRelateController/FileReleateController.go" beforeDir="false" afterPath="$PROJECT_DIR$/Business/FileRelate/FileRelateController/FileReleateController.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/docs/docs.go" beforeDir="false" afterPath="$PROJECT_DIR$/docs/docs.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/docs/swagger.json" beforeDir="false" afterPath="$PROJECT_DIR$/docs/swagger.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/docs/swagger.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/docs/swagger.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Business/FileRelate/FileRelateDao/FileReleateDao.go" beforeDir="false" afterPath="$PROJECT_DIR$/Business/FileRelate/FileRelateDao/FileReleateDao.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/main.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/models/t_zhxy_file.go" beforeDir="false" afterPath="$PROJECT_DIR$/models/t_zhxy_file.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

@ -41,7 +41,7 @@ func Routers(r *gin.RouterGroup) {
// @Param target_person_id formData string true "目标人ID"
// @Success 200 {object} Model.Res
// @Router /dsSzxy/fileRelate/fileUpload [post]
// @X-IntRangeLimit [{"identity_id":"5"},{"person_id":"1,999999999999"},{"target_group_id":"1,999999999999"},{"target_identity_id":"5"},{"target_person_id":"1,999999999999"},{"system_id":"1,20"}]
// @X-IntRangeLimit [{"identity_id":"5"},{"person_id":"1,999999999999"},{"target_group_id":"-1,999999999999"},{"target_identity_id":"5"},{"target_person_id":"1,999999999999"},{"system_id":"1,20"}]
// @X-TableName ["t_zhxy_file"]
func fileUpload(c *gin.Context) {
file, err := c.FormFile("file")
@ -170,3 +170,41 @@ func fileUpdate(c *gin.Context) {
"message": `修改成功!`,
})
}
// @Summary 文件复制,一般用于文件转发
// @Description 文件复制,一般用于文件转发
// @Tags 文件系统管理
// @Accept application/x-www-form-urlencoded
// @Produce json
// @Param file_id formData string true "文件ID"
// @Param source_identity_id formData string true "原文件所有人身份ID"
// @Param source_person_id formData string true "原文件所有人ID"
// @Param target_identity_id formData string true "接收文件所有人身份ID"
// @Param target_person_id formData string true "接收文件所有人ID"
// @Param target_group_id formData string true "接收文件群组ID"
// @Success 200 {object} Model.Res
// @X-EmptyLimit ["file_id"]
// @Router /dsSzxy/fileRelate/FileCopy [post]
// @X-IntRangeLimit [{"source_identity_id":"5"},{"source_person_id":"1,999999999999"},{"target_group_id":"-1,999999999999"},{"target_identity_id":"5"},{"target_person_id":"1,999999999999"}]
// @X-TableName ["t_zhxy_file"]
func FileCopy(c *gin.Context) {
fileId := c.PostForm("file_id")
sourceIdentityId := CommonUtil.ConvertStringToInt32(c.PostForm("source_identity_id"))
sourcePersonId := CommonUtil.ConvertStringToInt32(c.PostForm("source_person_id"))
targetIdentityId := CommonUtil.ConvertStringToInt32(c.PostForm("target_identity_id"))
targetPersonId := CommonUtil.ConvertStringToInt32(c.PostForm("target_person_id"))
targetGroupId := CommonUtil.ConvertStringToInt32(c.PostForm("target_group_id"))
//文件复制
success, err := FileRelateDao.FileCopy(fileId, sourceIdentityId, sourcePersonId, targetIdentityId, targetPersonId, targetGroupId)
if err != nil {
c.JSON(200, gin.H{
"success": success,
"message": `复制成功!`,
})
} else {
c.JSON(200, gin.H{
"success": success,
"message": err.Error(),
})
}
}

@ -5,6 +5,7 @@ import (
"dsSzxy/Utils/ConfigUtil"
"dsSzxy/Utils/DbUtil"
"dsSzxy/models"
"errors"
"fmt"
"github.com/xormplus/builder"
"net/url"
@ -35,9 +36,9 @@ func FileRecord(fileName string, indentityId int32, personId int32, targetGroupI
model.TargetGroupId = targetGroupId
model.TargetIdentityId = tIdentityId
model.TargetPersonId = tPersonId
model.UploadIndentityId = indentityId
model.UploadPersonId = personId
model.UploadTime = time.Now()
model.SourceIndentityId = indentityId
model.SourcePersonId = personId
model.RecordTime = time.Now()
c, err := GetFileTypeByExtName(extName)
if err == nil {
model.TypeId = int32(c)
@ -56,7 +57,39 @@ func FileUpdate(fileId string, fileName string) {
var myBuilder = builder.Dialect(builder.MYSQL).Update(builder.Eq{"file_name": fileName}).
From(`t_zhxy_file`).Where(builder.Eq{"file_id": fileId})
sql, _ := myBuilder.ToBoundSQL()
db.SQL(sql).Execute()
_, err := db.SQL(sql).Execute()
if err != nil {
fmt.Println(err.Error())
}
}
//复制文件记录
func FileCopy(fileId string, sIdentityId int32, sPersonId int32, tIdentityId int32, tPersonId int32, tGroudpId int32) (bool, error) {
//1、查询这个文件原来是谁的
modelArray := make([]models.TZhxyFile, 0)
err := db.Where("file_id = ?", fileId).Limit(1, 1).Find(&modelArray)
if err != nil {
fmt.Println("在检索时发生错误:", err.Error())
return false, err
}
//2、拷贝一份
if len(modelArray) == 0 {
return false, errors.New("没有找到指定的file_id")
}
model := modelArray[0]
model.FileId = CommonUtil.GetUUID()
model.SourceIndentityId = sIdentityId
model.SourcePersonId = sPersonId
model.TargetIdentityId = tIdentityId
model.TargetPersonId = tPersonId
model.TargetGroupId = tGroudpId
model.RecordTime = time.Now()
_, err = db.Insert(model)
if err != nil {
fmt.Println(err.Error())
return false, errors.New("写入数据库时发生错误")
}
return true, nil
}
/**

@ -19,7 +19,7 @@ import (
// @title 智慧校园API
// @version 1.0
// @description 分布式,大并发,高可用
// @description 物联网,大数据,人工智能
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io

@ -9,9 +9,9 @@ type TZhxyFile struct {
FileName string `xorm:"not null comment('文件名称') VARCHAR(255)"`
ExtName string `xorm:"not null comment('扩展名') VARCHAR(10)"`
TypeId int32 `xorm:"not null comment('文件、视频、图片') index INT(11)"`
UploadTime time.Time `xorm:"not null comment('上传时间') DATETIME"`
UploadIndentityId int32 `xorm:"not null comment('上传人身份') INT(11)"`
UploadPersonId int32 `xorm:"not null comment('上传人ID') INT(11)"`
RecordTime time.Time `xorm:"not null comment('上传时间') DATETIME"`
SourceIndentityId int32 `xorm:"not null comment('上传人身份') INT(11)"`
SourcePersonId int32 `xorm:"not null comment('上传人ID') INT(11)"`
TargetIdentityId int32 `xorm:"not null comment('接收方身份ID如果对方是群组标识-1') INT(11)"`
TargetPersonId int32 `xorm:"not null comment('接收人ID如果对方是群组标识-1') INT(11)"`
TargetGroupId int32 `xorm:"not null comment('接收群组ID如果对方是具体的员标识-1') INT(11)"`

Loading…
Cancel
Save