chengqian 9 mēneši atpakaļ
vecāks
revīzija
00a080fd94

+ 52 - 14
app/file/controller/file.go

@@ -1,8 +1,8 @@
 package controller
 
 import (
-	"encoding/json"
 	"github.com/gin-gonic/gin"
+	"iot_manager_service/app/file/dao"
 	"iot_manager_service/app/file/model"
 	"iot_manager_service/app/file/service"
 	"iot_manager_service/util/cache"
@@ -13,6 +13,7 @@ import (
 	"path"
 	"path/filepath"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -20,19 +21,22 @@ var FileController = new(file)
 
 type file struct{}
 
-func (f *file) Distribute(c *gin.Context) {
-	//获取当前用户
+func (f *file) Upload(c *gin.Context) {
 	header := c.GetHeader("Authorization")
 	claims, _ := token.JwtClaims.ParseJwtToken(header)
 	nowSysUser, _ := cache.GetNowSysUser(claims.ID)
 
-	//TODO:校验签名 如果成功则上传否则不上传
+	// 获取表单字段的值
+	categoryName := c.PostForm("categoryName")
+	iv := c.PostForm("iv")
+	str := c.PostForm("authId")
+	authId := strings.Replace(str, ",", "", -1)
+
 	formFile, err := c.FormFile("file")
 	if err != nil {
 		c.JSON(http.StatusOK, common.ParamsInvalidResponse("获取文件数据失败", nil))
 		return
 	}
-
 	//获取后缀
 	sufx := path.Ext(formFile.Filename)
 	//利用时间戳生成文件名
@@ -40,22 +44,49 @@ func (f *file) Distribute(c *gin.Context) {
 	fileNameStr := strconv.FormatInt(fileNameInt, 10)
 	//新的文件名
 	newfileName := fileNameStr + sufx
-	_, err = os.Stat("uploadfiles")
+
+	currentDir, _ := os.Getwd()
+	parentDir := filepath.Dir(currentDir)
+	folderPath := filepath.Join(parentDir, "uploadfiles")
+	_, err = os.Stat(folderPath)
 	if os.IsNotExist(err) {
-		os.Mkdir("./uploadfiles", os.ModePerm)
+		os.Mkdir(folderPath, os.ModePerm)
 	}
 	//保存文件
-	filePath := filepath.Join("uploadfiles", "/", newfileName)
+	filePath := filepath.Join(folderPath, "/", newfileName)
 	c.SaveUploadedFile(formFile, filePath)
 
-	//获取另外一个参数
-	str := c.Request.FormValue("req")
-	userFile := model.ReqSysUserFile{}
-	json.Unmarshal([]byte(str), &userFile)
+	savePath := "/uploadfiles/" + newfileName
+	currentTimeValue := time.Now()
+	upload := service.FileService.Upload(dao.File{
+		OriginalName:  strings.TrimSuffix(formFile.Filename, filepath.Ext(formFile.Filename)),
+		EncryptedName: formFile.Filename,
+		SavePath:      savePath,
+		CategoryName:  categoryName,
+		AuthId:        authId,
+		SuffixName:    path.Ext(formFile.Filename),
+		UploadTime:    &currentTimeValue,
+		Uploader:      int(nowSysUser.ID),
+		Icon:          strings.TrimPrefix(path.Ext(formFile.Filename), ".") + ".png",
+		Iv:            iv,
+	})
+	c.JSON(http.StatusOK, upload)
 
-	savePath := "uploadfiles/" + newfileName
-	distribute := service.FileService.Distribute(formFile.Filename, savePath, &userFile, nowSysUser.ID)
+}
 
+func (f *file) Distribute(c *gin.Context) {
+	//获取当前用户
+	header := c.GetHeader("Authorization")
+	claims, _ := token.JwtClaims.ParseJwtToken(header)
+	nowSysUser, _ := cache.GetNowSysUser(claims.ID)
+
+	var reqUserFile model.ReqSysUserFile
+	err := c.ShouldBindJSON(&reqUserFile)
+	if err != nil {
+		c.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
+		return
+	}
+	distribute := service.FileService.Distribute(&reqUserFile, int(nowSysUser.ID))
 	c.JSON(http.StatusOK, distribute)
 }
 
@@ -91,6 +122,13 @@ func (f *file) ForwardingFile(c *gin.Context) {
 	c.JSON(http.StatusOK, forwardingFile)
 }
 
+func (f *file) GetMyUploadFiles(c *gin.Context) {
+	header := c.GetHeader("Authorization")
+	claims, _ := token.JwtClaims.ParseJwtToken(header)
+	files := service.FileService.GetMyUploadFiles(claims.ID)
+	c.JSON(http.StatusOK, files)
+}
+
 // 查看文件
 func (f *file) ViewFile(c *gin.Context) {
 	fileId := c.Query("fileId")

+ 26 - 13
app/file/dao/file.go

@@ -7,18 +7,19 @@ import (
 
 // File 文件表
 type File struct {
-	ID            int       `gorm:"primary_key;type:int" json:"id"`                     //编号
-	OriginalName  string    `gorm:"type:varchar(45)" json:"originalName"`               //文件原始名
-	EncryptedName string    `gorm:"type:varchar(45)" json:"encryptedName"`              //文件加密名
-	SavePath      string    `gorm:"type:varchar(45)" json:"savePath"`                   //保存路径
-	CategoryName  string    `gorm:"type:varchar(12)" json:"categoryName"`               //文件类别名
-	AuthId        string    `gorm:"type:varchar(12);default:'100'" json:"authId"`       //权限id
-	SuffixName    string    `gorm:"type:varchar(12)" json:"suffixName"`                 //文件后缀名
-	UploadTime    time.Time `gorm:"column:upload_time;type:datetime" json:"uploadTime"` //上传时间
-	Uploader      int       `gorm:"type:int" json:"uploader"`                           //上传者id
-	IsShowed      int       `gorm:"type:int;default:0" json:"isShowed"`                 //是否展示 0=展示,1=不展示
-	Icon          string    `gorm:"type:varchar(191)" json:"icon"`                      //文件图标
-	IsDeleted     int       `gorm:"type:int;default:0" json:"isDeleted"`                //是否删除 0=未删除,1=删除
+	ID            int        `gorm:"primary_key;type:int" json:"id"`                     //编号
+	OriginalName  string     `gorm:"type:varchar(45)" json:"originalName"`               //文件原始名
+	EncryptedName string     `gorm:"type:varchar(45)" json:"encryptedName"`              //文件加密名
+	SavePath      string     `gorm:"type:varchar(191)" json:"savePath"`                  //保存路径
+	CategoryName  string     `gorm:"type:varchar(12)" json:"categoryName"`               //文件类别名
+	AuthId        string     `gorm:"type:varchar(12);default:'100'" json:"authId"`       //权限id
+	SuffixName    string     `gorm:"type:varchar(12)" json:"suffixName"`                 //文件后缀名
+	UploadTime    *time.Time `gorm:"column:upload_time;type:datetime" json:"uploadTime"` //上传时间
+	Uploader      int        `gorm:"type:int" json:"uploader"`                           //上传者id
+	IsShowed      int        `gorm:"type:int;default:0" json:"isShowed"`                 //是否展示 0=展示,1=不展示
+	Icon          string     `gorm:"type:varchar(191)" json:"icon"`                      //文件图标
+	Iv            string     `gorm:"type:varchar(191)" json:"iv"`                        //加密文件的偏向量
+	IsDeleted     int        `gorm:"type:int;default:0" json:"isDeleted"`                //是否删除 0=未删除,1=删除
 }
 
 func (*File) TableName() string {
@@ -26,6 +27,9 @@ func (*File) TableName() string {
 }
 
 func (f *File) Create() error {
+	//if !errors.Is(Db.Model(&f).Where("encrypted_name = ?", f.EncryptedName).First(&f).Error, gorm.ErrRecordNotFound) {
+	//	return errors.New("该文件已存在")
+	//}
 	return Db.Model(&f).Save(&f).Error
 }
 
@@ -54,7 +58,7 @@ func (f *File) GetSysUserFiles(uid int, search model.SearchSysUserFiles) ([]File
 	// 执行查询并检查错误
 	err := db.Limit(limit).Offset(offset).Scan(&files).Error
 	if err != nil {
-		return files, err
+		return nil, err
 	}
 	return files, err
 }
@@ -71,3 +75,12 @@ func (f *File) GetFile(id string) (*File, error) {
 	err := Db.Model(&f).Where("id = ?", id).First(&f).Error
 	return f, err
 }
+
+func (f *File) GetMyUploadFiles(id int) ([]File, error) {
+	var files []File
+	err := Db.Model(&f).Where("uploader = ? and is_deleted = 0", id).Order("upload_time desc").Find(&files).Error
+	if err != nil {
+		return nil, err
+	}
+	return files, err
+}

+ 3 - 5
app/file/model/file.go

@@ -5,11 +5,9 @@ import (
 )
 
 type ReqSysUserFile struct {
-	OriginalName  string     `json:"originalName"`  //文件原始名
-	AuthId        string     `json:"authId"`        //权限id
-	CategoryName  string     `json:"categoryName"`  //文件类别名
-	DeptsId       []int      `json:"deptsId"`       //下发的部门id
-	EffectiveDate *time.Time `json:"effectiveDate"` //阅读的有效日期
+	ID           int        `gorm:"primarykey"` // 主键ID
+	Depts        []int      `json:"depts" gorm:"comment:下发的部门"`
+	EfectiveDate *time.Time `json:"effectiveDate" gorm:"comment:截止时间"`
 }
 
 type ReqSysUsers struct {

+ 25 - 23
app/file/service/fileService.go

@@ -9,9 +9,9 @@ import (
 	"iot_manager_service/util/common"
 	"iot_manager_service/util/websocket"
 	"net/http"
-	"path"
+	"os"
+	"path/filepath"
 	"strconv"
-	"strings"
 	"time"
 )
 
@@ -20,25 +20,19 @@ var FileService = new(fileService)
 
 type fileService struct{}
 
-func (f *fileService) Distribute(encryptedname, savepath string, requserfile *model.ReqSysUserFile, uid int) *common.Errors {
-	file := &dao.File{
-		OriginalName:  requserfile.OriginalName,
-		EncryptedName: encryptedname,
-		SavePath:      savepath,
-		CategoryName:  requserfile.CategoryName,
-		AuthId:        requserfile.AuthId,
-		SuffixName:    path.Ext(requserfile.OriginalName),
-		UploadTime:    time.Now(),
-		Uploader:      uid,
-		Icon:          strings.TrimPrefix(path.Ext(requserfile.OriginalName), ".") + ".png",
-	}
+func (f *fileService) Upload(file dao.File) *common.Errors {
 	err := file.Create()
 	if err != nil {
-		return common.FailResponse("保存文件失败", nil)
+		return common.FailResponse(err.Error(), nil)
 	}
+	return common.SuccessResponse("上传成功", nil)
+
+}
+
+func (f *fileService) Distribute(requserfile *model.ReqSysUserFile, uid int) *common.Errors {
 	//查询部门下对应的员工
 	user := &userdao.SysUser{}
-	users, err := user.GetDeptsSysUsers(requserfile.DeptsId)
+	users, err := user.GetDeptsSysUsers(requserfile.Depts)
 	if err != nil {
 		return common.FailResponse(err.Error(), nil)
 	}
@@ -47,8 +41,8 @@ func (f *fileService) Distribute(encryptedname, savepath string, requserfile *mo
 		userfile = append(userfile, dao.SysUserFile{
 			Operator:        uid,
 			Receiver:        u.ID,
-			FileID:          file.ID,
-			EffectiveDate:   requserfile.EffectiveDate,
+			FileID:          requserfile.ID,
+			EffectiveDate:   requserfile.EfectiveDate,
 			OperationStatus: "下发",
 		})
 	}
@@ -57,12 +51,10 @@ func (f *fileService) Distribute(encryptedname, savepath string, requserfile *mo
 	if err != nil {
 		return common.FailResponse(err.Error(), nil)
 	}
-
 	//下发消息
 	for _, u := range users {
 		websocket.SendMessage(strconv.Itoa(u.ID), "您有新的文件,请注意查收!")
 	}
-
 	return common.SuccessResponse("新增记录成功", nil)
 }
 
@@ -82,14 +74,24 @@ func (f *fileService) GetFile(id string, c *gin.Context) {
 	if err != nil {
 		panic(err.Error())
 	}
-	encryptedData, err := ioutil.ReadFile(file.SavePath)
+	currentDir, _ := os.Getwd()
+	parentDir := filepath.Dir(currentDir)
+	encryptedData, err := ioutil.ReadFile(parentDir + file.SavePath)
 	if err != nil {
 		panic(err.Error())
 	}
-	c.Header("Content-Disposition", "attachment;filename="+file.EncryptedName)
-	c.Header("Content-Type", "application/octet-stream")
 	c.Data(http.StatusOK, "application/octet-stream", encryptedData)
 }
+func (f *fileService) GetMyUploadFiles(id string) *common.Errors {
+	num, _ := strconv.Atoi(id)
+	filedao := &dao.File{}
+	files, err := filedao.GetMyUploadFiles(num)
+	if err != nil {
+		return common.FailResponse(err.Error(), nil)
+	}
+	return common.SuccessResponse("查询成功", gin.H{"MyUploadFiles": files})
+
+}
 
 // 转发
 func (f *fileService) ForwardingFile(uid, fileid int, users []int) *common.Errors {

+ 28 - 21
app/middleware/checkAuth.go

@@ -18,34 +18,14 @@ func CheckAuth() gin.HandlerFunc {
 	return func(c *gin.Context) {
 		header := c.GetHeader("Authorization")
 		claims, _ := token.JwtClaims.ParseJwtToken(header)
+
 		userdao := dao2.SysUser{}
 		id, _ := strconv.Atoi(claims.ID)
 		nowSysUser, err2 := userdao.GetNowSysUser(id)
 		if err2 != nil {
 			panic(err2)
 		}
-		fileid := c.Query("fileId")
-
-		filedao := &dao.File{}
-		fileInfo, err := filedao.GetFileInfo(fileid, claims.ID)
-		if err != nil {
-			c.JSON(http.StatusOK, err)
-			c.Abort()
-			return
-		}
-
-		// 将时间字符串解析为时间对象
-		targetTime, _ := time.Parse("2006-01-02 15:04:05 -0700 MST", fileInfo.EffectiveDate.String())
-		now := time.Now()
-		// 比较两个时间
-		if !now.Before(targetTime) {
-			c.JSON(http.StatusForbidden, common.StatusForbidden("访问时间已过,无权访问", nil))
-			c.Abort()
-			return
-		}
-
 		userAuth := nowSysUser.AuthId
-		fileAuth := fileInfo.AuthId
 
 		var permissionMap = map[string]struct {
 			index   string
@@ -58,6 +38,27 @@ func CheckAuth() gin.HandlerFunc {
 
 		for url, obj := range permissionMap {
 			if strings.Contains(c.Request.RequestURI, url) {
+				fileid := c.Query("fileId")
+
+				filedao := &dao.File{}
+				fileInfo, err := filedao.GetFileInfo(fileid, claims.ID)
+				if err != nil {
+					c.JSON(http.StatusOK, err)
+					c.Abort()
+					return
+				}
+
+				fileAuth := fileInfo.AuthId
+				// 将时间字符串解析为时间对象
+				targetTime, _ := time.Parse("2006-01-02 15:04:05 -0700 MST", fileInfo.EffectiveDate.String())
+				now := time.Now()
+				// 比较两个时间
+				if !now.Before(targetTime) {
+					c.JSON(http.StatusForbidden, common.StatusForbidden("访问时间已过,无权访问", nil))
+					c.Abort()
+					return
+				}
+
 				if !strings.Contains(fileAuth, obj.index) {
 					c.JSON(http.StatusForbidden, common.StatusForbidden(fmt.Sprintf("抱歉,该文件不支持【%s】操作,请联系管理员。", obj.message), nil))
 					c.Abort()
@@ -70,6 +71,12 @@ func CheckAuth() gin.HandlerFunc {
 				}
 			}
 		}
+
+		if strings.Contains(c.Request.RequestURI, "/upload") && !strings.Contains(userAuth, "4") {
+			c.JSON(http.StatusForbidden, common.StatusForbidden("您没有上传权限,请联系管理员。", nil))
+			c.Abort()
+			return
+		}
 		c.Next()
 	}
 }

+ 6 - 6
app/middleware/token.go

@@ -28,18 +28,18 @@ func AuthMiddleware() gin.HandlerFunc {
 		}
 		//解析token
 		claims, err := token.JwtClaims.ParseJwtToken(tokenString)
-		user, _ := cache.GetNowSysUser(claims.ID)
-		if user.ID == 0 {
-			c.JSON(http.StatusUnauthorized, common.StatusUnauthorized("请先登录!", nil))
-			c.Abort()
-			return
-		}
 		//过期或者无效
 		if err != nil {
 			c.JSON(http.StatusUnauthorized, common.StatusUnauthorized("登录过期,请重新登录", nil))
 			c.Abort()
 			return
 		}
+		user, _ := cache.GetNowSysUser(claims.ID)
+		if user.ID == 0 {
+			c.JSON(http.StatusUnauthorized, common.StatusUnauthorized("请先登录!", nil))
+			c.Abort()
+			return
+		}
 		c.Next()
 	}
 }

+ 18 - 7
app/user/controller/user.go

@@ -44,16 +44,18 @@ func (u *user) GetPublicKey(c *gin.Context) {
 }
 
 func (u *user) GetDeptSysUsers(c *gin.Context) {
-	depts := model.ReqDepts{}
-	err := c.ShouldBindJSON(&depts)
-	if err != nil {
-		c.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	users := service.SysUserService.GetDeptSysUsers(depts.Depts)
+	header := c.GetHeader("Authorization")
+	claims, _ := token.JwtClaims.ParseJwtToken(header)
+	uid, _ := strconv.Atoi(claims.ID)
+	users := service.SysUserService.GetDeptSysUsers(uid)
 	c.JSON(http.StatusOK, users)
 }
 
+func (u *user) GetDepts(c *gin.Context) {
+	depts := service.SysUserService.GetDepts()
+	c.JSON(http.StatusOK, depts)
+}
+
 func (u *user) GetNewTokens(c *gin.Context) {
 	header := c.GetHeader("Authorization")
 	claims, _ := token.JwtClaims.ParseJwtToken(header)
@@ -82,6 +84,15 @@ func (u *user) Logout(c *gin.Context) {
 	c.JSON(http.StatusOK, common.SuccessResponse("退出成功", nil))
 }
 
+func (u *user) GetSysUserInfo(c *gin.Context) {
+	header := c.GetHeader("Authorization")
+	claims, _ := token.JwtClaims.ParseJwtToken(header)
+	uid, _ := strconv.Atoi(claims.ID)
+	info := service.SysUserService.GetSysUserInfo(uid)
+	c.JSON(http.StatusOK, info)
+
+}
+
 func (u *user) GetSysUser(c *gin.Context) {
 	fmt.Println("demo。。。")
 }

+ 7 - 2
app/user/dao/dept.go

@@ -16,8 +16,13 @@ func (*Dept) TableName() string {
 	return "dept"
 }
 
-func (d *Dept) GetDepts(deptIDs []int) ([]Dept, error) {
+func (d *Dept) GetDepts(uid int) ([]Dept, error) {
 	var depts []Dept
-	err := Db.Model(&d).Where("id IN (?)", deptIDs).Find(&depts).Error
+	err := Db.Raw("SELECT * from dept where id != (SELECT dept_id  from sys_users where id = ?) and parent_id != 0 and is_deleted = 0 ", uid).Scan(&depts).Error
+	return depts, err
+}
+
+func (d *Dept) GetChildDepts() (depts []Dept, err error) {
+	err = Db.Model(&Dept{}).Where("parent_id != ? and is_deleted = 0", 0).Find(&depts).Error
 	return depts, err
 }

+ 19 - 0
app/user/dao/sysAuthority.go

@@ -0,0 +1,19 @@
+package dao
+
+import "time"
+
+type SysAuthority struct {
+	CreatedAt       time.Time       // 创建时间
+	UpdatedAt       time.Time       // 更新时间
+	DeletedAt       *time.Time      `sql:"index"`
+	AuthorityId     uint            `json:"authorityId" gorm:"not null;unique;primary_key;comment:角色ID;size:90"` // 角色ID
+	AuthorityName   string          `json:"authorityName" gorm:"comment:角色名"`                                    // 角色名
+	ParentId        *uint           `json:"parentId" gorm:"comment:父角色ID"`                                       // 父角色ID
+	DataAuthorityId []*SysAuthority `json:"dataAuthorityId" gorm:"many2many:sys_data_authority_id;"`
+	Children        []SysAuthority  `json:"children" gorm:"-"`
+	DefaultRouter   string          `json:"defaultRouter" gorm:"comment:默认菜单;default:dashboard"` // 默认菜单(默认dashboard)
+}
+
+func (SysAuthority) TableName() string {
+	return "sys_authorities"
+}

+ 9 - 1
app/user/dao/user.go

@@ -26,6 +26,8 @@ type SysUser struct {
 	Enable      int            `json:"enable" gorm:"default:1;comment:用户是否被冻结 1正常 2冻结"`                                      //用户是否被冻结 1正常 2冻结
 	AuthId      string         `json:"authId" gorm:"type:varchar(191);comment:权限id" `                                        //权限id
 	DeptId      int            `json:"deptId" gorm:"comment:部门id"`
+	Dept        Dept           `json:"dept" gorm:"foreignKey:DeptId;references:ID;comment:用户部门"`
+	Authority   SysAuthority   `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"`
 }
 
 func (*SysUser) TableName() string {
@@ -34,7 +36,7 @@ func (*SysUser) TableName() string {
 
 func (c *SysUser) LoginFindUserName(username string) (*SysUser, error) {
 	var user SysUser
-	err := Db.Model(&user).Debug().Where("username = ?", username).First(&user).Error
+	err := Db.Model(&user).Where("username = ?", username).First(&user).Error
 	return &user, err
 }
 
@@ -54,3 +56,9 @@ func (c *SysUser) GetDeptsSysUsers(depts []int) ([]SysUser, error) {
 	err := Db.Model(&c).Where("dept_id in ?", depts).Find(&users).Error
 	return users, err
 }
+
+func (c *SysUser) GetSysUserInfo(id int) (*SysUser, error) {
+	var user SysUser
+	err := Db.Model(&user).Preload("Dept").Preload("Authority").Where("id = ?", id).First(&user).Error
+	return &user, err
+}

+ 35 - 2
app/user/service/userService.go

@@ -58,9 +58,9 @@ func (s *userService) GetPublicKey() *common.Errors {
 	return common.SuccessResponse("获取公钥成功", gin.H{"publicKey": publicKey})
 }
 
-func (s *userService) GetDeptSysUsers(deptIDs []int) *common.Errors {
+func (s *userService) GetDeptSysUsers(id int) *common.Errors {
 	deptdao := &dao.Dept{}
-	depts, _ := deptdao.GetDepts(deptIDs)
+	depts, _ := deptdao.GetDepts(id)
 
 	userdao := &dao.SysUser{}
 	users, _ := userdao.GetSysUsers()
@@ -76,8 +76,41 @@ func (s *userService) GetDeptSysUsers(deptIDs []int) *common.Errors {
 		deptSysUsers = append(deptSysUsers, dao.Dept{
 			ID:       dept.ID,
 			DeptName: dept.DeptName,
+			ParentId: dept.ParentId,
 			SysUsers: users,
 		})
 	}
 	return common.SuccessResponse("获取成功", gin.H{"deptSysUsers": deptSysUsers})
 }
+
+func (s *userService) GetDepts() *common.Errors {
+	deptdao := &dao.Dept{}
+	depts, _ := deptdao.GetChildDepts()
+
+	userdao := &dao.SysUser{}
+	users, _ := userdao.GetSysUsers()
+
+	deptSysUsersMap := make(map[int][]dao.SysUser)
+	for _, user := range users {
+		deptSysUsersMap[user.DeptId] = append(deptSysUsersMap[user.DeptId], user)
+	}
+
+	var deptSysUsers []dao.Dept
+	for _, dept := range depts {
+		users := deptSysUsersMap[dept.ID]
+		if users != nil {
+			deptSysUsers = append(deptSysUsers, dao.Dept{
+				ID:       dept.ID,
+				DeptName: dept.DeptName,
+				ParentId: dept.ParentId,
+			})
+		}
+	}
+	return common.SuccessResponse("获取成功", gin.H{"depts": deptSysUsers})
+}
+
+func (s *userService) GetSysUserInfo(id int) *common.Errors {
+	userdao := &dao.SysUser{}
+	user, _ := userdao.GetSysUserInfo(id)
+	return common.SuccessResponse("获取成功", gin.H{"sysUser": user})
+}

+ 1 - 1
build.bat

@@ -1,3 +1,3 @@
 set GOARCH=amd64
 set GOOS=linux
-go build -o build/iot_svr ./
+go build -o build/veterans ./

+ 1 - 1
main.go

@@ -35,7 +35,7 @@ func main() {
 	engine := gin.Default()
 
 	//放行静态文件
-	engine.Static("/uploadfiles", "./uploadfiles")
+	engine.Static("/icons", "./resource/icons")
 	router.InitRouter(engine)
 
 	if cfg.Logger.DbShowLog == 1 {

BIN
resource/icons/doc.png


BIN
resource/icons/docx.png


BIN
resource/icons/ppt.png


BIN
resource/icons/pptx.png


BIN
resource/icons/txt.png


BIN
resource/icons/xls.png


BIN
resource/icons/xlsx.png


+ 11 - 1
router/router.go

@@ -30,17 +30,21 @@ func InitRouter(engine *gin.Engine) {
 		sys.POST("/logout", user.SysUserController.Logout)
 		sys.POST("/getDeptUsers", user.SysUserController.GetDeptSysUsers)
 		sys.GET("/getNewTokens", user.SysUserController.GetNewTokens)
-		sys.GET("/getUser", user.SysUserController.GetSysUser)
+		sys.GET("/getUserInfo", user.SysUserController.GetSysUserInfo)
+		sys.GET("/getDepts", user.SysUserController.GetDepts)
 	}
 
 	//文件
 	files := engine.Group("/file")
 	{
 		files.POST("/distribute", file.FileController.Distribute)
+		files.GET("/getMyUpload", file.FileController.GetMyUploadFiles)
 		files.POST("/getUserFiles", file.FileController.GetSysUserFiles)
+		files.POST("/upload", middleware.CheckAuth(), file.FileController.Upload)
 		files.GET("/viewFile", middleware.CheckAuth(), file.FileController.ViewFile)
 		files.GET("/downloadFile", middleware.CheckAuth(), file.FileController.DownloadFile)
 		files.POST("/forwardingFile", middleware.CheckAuth(), file.FileController.ForwardingFile)
+
 	}
 
 	//下发通知
@@ -50,4 +54,10 @@ func InitRouter(engine *gin.Engine) {
 		notice.GET("/websocket", websocket.HandleWebSocket)
 	}
 
+	//demo := engine.Group("/demo")
+	//{
+	//	//请求Websocket连接
+	//	//demo.POST("/shangChuan", file.FileController.ShangChuan)
+	//}
+
 }