curry пре 9 месеци
родитељ
комит
7985617d55

+ 113 - 0
server/api/v1/admin/department.go

@@ -0,0 +1,113 @@
+package admin
+
+import (
+	"github.com/gin-gonic/gin"
+	"server/dao"
+	"server/global"
+	"server/model/common/request"
+	"server/model/common/response"
+	"strconv"
+)
+
+type DepartmentApi struct {
+}
+
+func (da *DepartmentApi) QueryAllDep(c *gin.Context) {
+	deps, err := departmentService.QueryAllDep()
+	if err != nil {
+		response.FailWithMessage("查询失败", c)
+		global.GVA_LOG.Error("QueryAllDep ==" + err.Error())
+		return
+	}
+	response.OkWithData(deps, c)
+}
+
+func (da *DepartmentApi) QueryDepByStart(c *gin.Context) {
+	deps, err := departmentService.QueryDepByStart()
+	if err != nil {
+		response.FailWithMessage("查询失败", c)
+		global.GVA_LOG.Error("QueryDepByStart ==" + err.Error())
+		return
+	}
+	response.OkWithData(deps, c)
+}
+
+func (da *DepartmentApi) CreateDep(c *gin.Context) {
+	department := dao.Department{}
+	err := c.ShouldBindJSON(&department)
+	if err != nil {
+		global.GVA_LOG.Error("CreateDep ==" + err.Error())
+		response.FailWithMessage("错误", c)
+		return
+	}
+	err = departmentService.CreateDep(department)
+	if err != nil {
+		global.GVA_LOG.Error("CreateDep ==" + err.Error())
+		response.FailWithMessage("错误", c)
+		return
+	}
+	response.OkWithMessage("创建成功", c)
+}
+
+func (da *DepartmentApi) UpdateDep(c *gin.Context) {
+	department := dao.Department{}
+	err := c.ShouldBindJSON(&department)
+	if err != nil {
+		global.GVA_LOG.Error("UpdateDep ==" + err.Error())
+		response.FailWithMessage("错误", c)
+		return
+	}
+	err = departmentService.UpdateDep(department)
+	if err != nil {
+		global.GVA_LOG.Error("UpdateDep ==" + err.Error())
+		response.FailWithMessage("错误", c)
+		return
+	}
+	response.OkWithMessage("更新成功", c)
+}
+
+func (da *DepartmentApi) UpdateDepStatus(c *gin.Context) {
+	department := dao.Department{}
+	err := c.ShouldBindJSON(&department)
+	if err != nil {
+		global.GVA_LOG.Error("UpdateDepStatus ==" + err.Error())
+		response.FailWithMessage("错误", c)
+		return
+	}
+	err = departmentService.UpdateDepStatus(department.Id, department.IsStart)
+	if err != nil {
+		global.GVA_LOG.Error("UpdateDepStatus ==" + err.Error())
+		response.FailWithMessage("错误", c)
+		return
+	}
+	response.OkWithMessage("更新成功", c)
+}
+
+func (da *DepartmentApi) UpdateUserDep(c *gin.Context) {
+	ids := request.Ids{}
+	err := c.ShouldBindJSON(&ids)
+	if err != nil {
+		global.GVA_LOG.Error("UpdateUserDep ==" + err.Error())
+		response.FailWithMessage("错误", c)
+		return
+	}
+	err = departmentService.UpdateUserDep(ids.Ids, ids.Id)
+	if err != nil {
+		global.GVA_LOG.Error("UpdateUserDep ==" + err.Error())
+		response.FailWithMessage("错误", c)
+		return
+	}
+	response.OkWithMessage("更新成功", c)
+}
+
+func (da *DepartmentApi) DeleteDep(c *gin.Context) {
+	id := c.Param("depId")
+	depId, _ := strconv.Atoi(id)
+	err := departmentService.DeleteDep(depId)
+	if err != nil {
+		global.GVA_LOG.Error("DeleteDep ==" + err.Error())
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	response.OkWithMessage("删除成功", c)
+}

+ 11 - 0
server/api/v1/admin/enter.go

@@ -0,0 +1,11 @@
+package admin
+
+import "server/service"
+
+type ApiGroup struct {
+	DepartmentApi
+}
+
+var (
+	departmentService = service.ServiceGroupApp.AdminServiceGroup.DepartmentService
+)

+ 2 - 0
server/api/v1/enter.go

@@ -1,6 +1,7 @@
 package v1
 
 import (
+	"server/api/v1/admin"
 	"server/api/v1/example"
 	"server/api/v1/system"
 )
@@ -8,6 +9,7 @@ import (
 type ApiGroup struct {
 	SystemApiGroup  system.ApiGroup
 	ExampleApiGroup example.ApiGroup
+	AdminApiGroup   admin.ApiGroup
 }
 
 var ApiGroupApp = new(ApiGroup)

+ 11 - 0
server/api/v1/system/sys_user.go

@@ -471,3 +471,14 @@ func (b *BaseApi) ResetPassword(c *gin.Context) {
 	}
 	response.OkWithMessage("重置成功", c)
 }
+
+// QueryAllUsers 查询所有用户
+func (b *BaseApi) QueryAllUsers(c *gin.Context) {
+	users, err := userService.QueryAllUsers()
+	if err != nil {
+		global.GVA_LOG.Error("查询失败!", zap.Error(err))
+		response.FailWithMessage("查询失败", c)
+		return
+	}
+	response.OkWithDetailed(users, "查询成功", c)
+}

+ 63 - 0
server/dao/department.go

@@ -0,0 +1,63 @@
+package dao
+
+import "server/global"
+
+type Department struct {
+	Id            int       `gorm:"primarykey" from:"id" json:"ID"`
+	Name          string    `json:"name" from:"name" gorm:"comment:部门名称"`
+	Desc          string    `json:"desc" from:"desc" gorm:"comment:部门描述"`
+	PrincipalId   int       `json:"principalId" from:"principal_id" gorm:"comment:负责人id"`
+	PrincipalName string    `json:"principalName" from:"principal_name" gorm:"comment:负责人姓名"`
+	Users         []SysUser `json:"users" gorm:"-"`
+	IsStart       bool      `json:"isStart" from:"is_start" gorm:"comment:是否启用"`
+}
+
+func (Department) TableName() string {
+	return "department"
+}
+
+// TODO:部门查询
+
+// QueryAllDep 查询所有部门
+func QueryAllDep() (deps []Department, err error) {
+	err = global.GVA_DB.Model(&Department{}).Find(&deps).Error
+	return deps, err
+}
+
+// QueryDepByStart 查询启用部门
+func QueryDepByStart() (deps []Department, err error) {
+	err = global.GVA_DB.Model(&Department{}).Where("is_start = ?", true).Find(&deps).Error
+	return deps, err
+}
+
+// QueryUsersByDepId 查询部门下的用户
+func QueryUsersByDepId(depId int) (users []SysUser, err error) {
+	err = global.GVA_DB.Model(&SysUser{}).Where("department_id =?", depId).Find(&users).Error
+	return users, err
+}
+
+// TODO:部门新增
+
+// CreateDep 创建部门
+func (d Department) CreateDep() error {
+	return global.GVA_DB.Create(&d).Error
+}
+
+// TODO:部门修改
+
+// UpdateDep 修改部门
+func (d Department) UpdateDep() error {
+	return global.GVA_DB.Model(&d).Updates(d).Error
+}
+
+// UpdateDepStatus 修改部门状态
+func UpdateDepStatus(depId int, isStart bool) error {
+	return global.GVA_DB.Model(&Department{}).Where("id = ?", depId).Update("is_start", isStart).Error
+}
+
+// TODO:部门删除
+
+// DeleteDep 删除部门
+func DeleteDep(depId int) error {
+	return global.GVA_DB.Where("id = ?", depId).Delete(&Department{}).Error
+}

+ 1 - 3
server/dao/sys_base_menu.go

@@ -85,7 +85,6 @@ func (bm SysBaseMenu) CreateBaseMenu() error {
 
 func (bm SysBaseMenu) UpdateBaseMenu() (err error) {
 	var oldMenu SysBaseMenu
-
 	err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
 		tx.Where("id = ?", bm.ID).Find(&oldMenu)
 		if oldMenu.Name != bm.Name {
@@ -125,8 +124,7 @@ func (bm SysBaseMenu) UpdateBaseMenu() (err error) {
 				return txErr
 			}
 		}
-
-		txErr = tx.Model(&oldMenu).Updates(bm).Error
+		txErr = tx.Model(&oldMenu).Select("*").Updates(bm).Error
 		if txErr != nil {
 			global.GVA_LOG.Debug(txErr.Error())
 			return txErr

+ 27 - 13
server/dao/sys_user.go

@@ -9,19 +9,20 @@ import (
 
 type SysUser struct {
 	global.GVA_MODEL
-	UUID        uuid.UUID    `json:"uuid" gorm:"index;comment:用户UUID"`                                                     // 用户UUID
-	Username    string       `json:"userName" gorm:"index;comment:用户登录名"`                                                  // 用户登录名
-	Password    string       `json:"-"  gorm:"comment:用户登录密码"`                                                             // 用户登录密码
-	NickName    string       `json:"nickName" gorm:"default:系统用户;comment:用户昵称"`                                            // 用户昵称
-	SideMode    string       `json:"sideMode" gorm:"default:dark;comment:用户侧边主题"`                                          // 用户侧边主题
-	HeaderImg   string       `json:"headerImg" gorm:"default:https://qmplusimg.henrongyi.top/gva_header.jpg;comment:用户头像"` // 用户头像
-	BaseColor   string       `json:"baseColor" gorm:"default:#fff;comment:基础颜色"`                                           // 基础颜色
-	ActiveColor string       `json:"activeColor" gorm:"default:#1890ff;comment:活跃颜色"`                                      // 活跃颜色
-	AuthorityId uint         `json:"authorityId" gorm:"default:888;comment:用户角色ID"`                                        // 用户角色ID
-	Authority   SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"`
-	Phone       string       `json:"phone"  gorm:"comment:用户手机号"`                     // 用户手机号
-	Email       string       `json:"email"  gorm:"comment:用户邮箱"`                      // 用户邮箱
-	Enable      int          `json:"enable" gorm:"default:1;comment:用户是否被冻结 1正常 2冻结"` //用户是否被冻结 1正常 2冻结
+	UUID         uuid.UUID    `json:"uuid" gorm:"index;comment:用户UUID"`                                                     // 用户UUID
+	Username     string       `json:"userName" gorm:"index;comment:用户登录名"`                                                  // 用户登录名
+	Password     string       `json:"-"  gorm:"comment:用户登录密码"`                                                             // 用户登录密码
+	NickName     string       `json:"nickName" gorm:"default:系统用户;comment:用户昵称"`                                            // 用户昵称
+	SideMode     string       `json:"sideMode" gorm:"default:dark;comment:用户侧边主题"`                                          // 用户侧边主题
+	HeaderImg    string       `json:"headerImg" gorm:"default:https://qmplusimg.henrongyi.top/gva_header.jpg;comment:用户头像"` // 用户头像
+	BaseColor    string       `json:"baseColor" gorm:"default:#fff;comment:基础颜色"`                                           // 基础颜色
+	ActiveColor  string       `json:"activeColor" gorm:"default:#1890ff;comment:活跃颜色"`                                      // 活跃颜色
+	AuthorityId  uint         `json:"authorityId" gorm:"default:888;comment:用户角色ID"`                                        // 用户角色ID
+	Authority    SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"`
+	Phone        string       `json:"phone"  gorm:"comment:用户手机号"`                     // 用户手机号
+	Email        string       `json:"email"  gorm:"comment:用户邮箱"`                      // 用户邮箱
+	Enable       int          `json:"enable" gorm:"default:1;comment:用户是否被冻结 1正常 2冻结"` //用户是否被冻结 1正常 2冻结
+	DepartmentId int          `json:"departmentId" gorm:"comment:部门id"`
 }
 
 func (SysUser) TableName() string {
@@ -78,6 +79,12 @@ func GetUserInfoByUUID(uuid uuid.UUID) (user SysUser, err error) {
 	return user, err
 }
 
+// QueryAllUsers 查询所有用户
+func QueryAllUsers() (users []SysUser, err error) {
+	err = global.GVA_DB.Model(&SysUser{}).Find(&users).Error
+	return users, err
+}
+
 // TODO: 用户新增
 
 // CreateUser 创建用户
@@ -139,6 +146,13 @@ func (u SysUser) SetUserInfoById() error {
 		Updates(&u).Error
 }
 
+// UpdateUserDep 修改用户部门
+func UpdateUserDep(ids []int, depId int) error {
+	return global.GVA_DB.Model(&SysUser{}).
+		Where("id in (?)", ids).
+		Update("department_id", depId).Error
+}
+
 // TODO: 用户删除
 
 // DeleteUser 删除用户

+ 4 - 12
server/go.mod

@@ -7,6 +7,7 @@ require (
 	github.com/aws/aws-sdk-go v1.44.307
 	github.com/casbin/casbin/v2 v2.87.1
 	github.com/casbin/gorm-adapter/v3 v3.18.0
+	github.com/flipped-aurora/gin-vue-admin/server v0.0.0-20240703013134-eebd8771bdd1
 	github.com/flipped-aurora/ws v1.0.2
 	github.com/fsnotify/fsnotify v1.6.0
 	github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6
@@ -15,11 +16,9 @@ require (
 	github.com/go-sql-driver/mysql v1.7.1
 	github.com/gofrs/uuid/v5 v5.0.0
 	github.com/golang-jwt/jwt/v4 v4.5.0
-	github.com/gookit/color v1.5.4
 	github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.8+incompatible
 	github.com/jordan-wright/email v0.0.0-20200824153738-3f5bafa1cd84
 	github.com/mojocn/base64Captcha v1.3.6
-	github.com/otiai10/copy v1.7.0
 	github.com/pkg/errors v0.9.1
 	github.com/qiniu/api.v7/v7 v7.4.1
 	github.com/qiniu/qmgo v1.1.8
@@ -34,7 +33,6 @@ require (
 	github.com/swaggo/swag v1.16.2
 	github.com/tencentyun/cos-go-sdk-v5 v0.7.42
 	github.com/unrolled/secure v1.13.0
-	github.com/xuri/excelize/v2 v2.8.0
 	go.mongodb.org/mongo-driver v1.12.1
 	go.uber.org/automaxprocs v1.5.3
 	go.uber.org/zap v1.24.0
@@ -44,7 +42,7 @@ require (
 	gorm.io/driver/mysql v1.5.6
 	gorm.io/driver/postgres v1.5.7
 	gorm.io/driver/sqlserver v1.5.1
-	gorm.io/gorm v1.25.9
+	gorm.io/gorm v1.25.10
 	nhooyr.io/websocket v1.8.7
 )
 
@@ -73,7 +71,7 @@ require (
 	github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
 	github.com/golang-sql/sqlexp v0.1.0 // indirect
 	github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
-	github.com/golang/snappy v0.0.1 // indirect
+	github.com/golang/snappy v0.0.4 // indirect
 	github.com/google/go-querystring v1.0.0 // indirect
 	github.com/google/uuid v1.3.0 // indirect
 	github.com/hashicorp/hcl v1.0.0 // indirect
@@ -86,7 +84,7 @@ require (
 	github.com/jmespath/go-jmespath v0.4.0 // indirect
 	github.com/josharian/intern v1.0.0 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
-	github.com/klauspost/compress v1.13.6 // indirect
+	github.com/klauspost/compress v1.15.9 // indirect
 	github.com/klauspost/cpuid/v2 v2.2.4 // indirect
 	github.com/leodido/go-urn v1.2.4 // indirect
 	github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
@@ -97,15 +95,12 @@ require (
 	github.com/mitchellh/mapstructure v1.5.0 // indirect
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
-	github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
 	github.com/montanaflynn/stats v0.7.0 // indirect
 	github.com/mozillazg/go-httpheader v0.2.1 // indirect
 	github.com/pelletier/go-toml/v2 v2.0.8 // indirect
 	github.com/pmezard/go-difflib v1.0.0 // indirect
 	github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
 	github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
-	github.com/richardlehane/mscfb v1.0.4 // indirect
-	github.com/richardlehane/msoleps v1.0.3 // indirect
 	github.com/shoenig/go-m1cpu v0.1.6 // indirect
 	github.com/spf13/afero v1.9.5 // indirect
 	github.com/spf13/cast v1.5.1 // indirect
@@ -119,9 +114,6 @@ require (
 	github.com/xdg-go/pbkdf2 v1.0.0 // indirect
 	github.com/xdg-go/scram v1.1.2 // indirect
 	github.com/xdg-go/stringprep v1.0.4 // indirect
-	github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
-	github.com/xuri/efp v0.0.0-20230802181842-ad255f2331ca // indirect
-	github.com/xuri/nfp v0.0.0-20230819163627-dc951e3ffe1a // indirect
 	github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
 	github.com/yusufpapurcu/wmi v1.2.3 // indirect
 	go.uber.org/atomic v1.9.0 // indirect

+ 8 - 34
server/go.sum

@@ -95,6 +95,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
 github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
 github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
 github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
+github.com/flipped-aurora/gin-vue-admin/server v0.0.0-20240703013134-eebd8771bdd1 h1:tc9cWlmEfoKaBBlYzMiFyrZFV5UyEI6Lfbv/vpNJ5q8=
+github.com/flipped-aurora/gin-vue-admin/server v0.0.0-20240703013134-eebd8771bdd1/go.mod h1:DuaB1rq2m1vKjcOCBpuVjqppGOXSCbmPndxSRNSgqPQ=
 github.com/flipped-aurora/ws v1.0.2 h1:oEUz7sgrbPENvgli7Q4QpC0NIEbJucgR4yjcDMg/AjY=
 github.com/flipped-aurora/ws v1.0.2/go.mod h1:RdyM2Fnvxx7f7A6WSmU1aAhDrQIAVW7LS/0LsAUE5mE=
 github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
@@ -193,8 +195,9 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
 github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
 github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
 github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
-github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
 github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
+github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
 github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
 github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
 github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
@@ -235,8 +238,6 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
 github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
 github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
 github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
-github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
-github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
 github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
 github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
 github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
@@ -285,8 +286,9 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
 github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
 github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
 github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
-github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
 github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
+github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
+github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
 github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
 github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
 github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
@@ -325,8 +327,6 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
 github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
 github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
 github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
-github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
-github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
 github.com/mojocn/base64Captcha v1.3.6 h1:gZEKu1nsKpttuIAQgWHO+4Mhhls8cAKyiV2Ew03H+Tw=
 github.com/mojocn/base64Captcha v1.3.6/go.mod h1:i5CtHvm+oMbj1UzEPXaA8IH/xHFZ3DGY3Wh3dBpZ28E=
 github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
@@ -334,13 +334,6 @@ github.com/montanaflynn/stats v0.7.0 h1:r3y12KyNxj/Sb/iOE46ws+3mS1+MZca1wlHQFPsY
 github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
 github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ=
 github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60=
-github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE=
-github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U=
-github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
-github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
-github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
-github.com/otiai10/mint v1.3.3 h1:7JgpsBaN0uMkyju4tbYHu0mnM55hNKVYLsXmwr15NQI=
-github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
 github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
 github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
@@ -364,11 +357,6 @@ github.com/redis/go-redis/v9 v9.0.5/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDO
 github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
-github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
-github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
-github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
-github.com/richardlehane/msoleps v1.0.3 h1:aznSZzrwYRl3rLKRT3gUk9am7T/mLNSnJINvN0AQoVM=
-github.com/richardlehane/msoleps v1.0.3/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
 github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
 github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
 github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
@@ -442,14 +430,6 @@ github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3k
 github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
 github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
 github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
-github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
-github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
-github.com/xuri/efp v0.0.0-20230802181842-ad255f2331ca h1:uvPMDVyP7PXMMioYdyPH+0O+Ta/UO1WFfNYMO3Wz0eg=
-github.com/xuri/efp v0.0.0-20230802181842-ad255f2331ca/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
-github.com/xuri/excelize/v2 v2.8.0 h1:Vd4Qy809fupgp1v7X+nCS/MioeQmYVVzi495UCTqB7U=
-github.com/xuri/excelize/v2 v2.8.0/go.mod h1:6iA2edBTKxKbZAa7X5bDhcCg51xdOn1Ar5sfoXRGrQg=
-github.com/xuri/nfp v0.0.0-20230819163627-dc951e3ffe1a h1:Mw2VNrNNNjDtw68VsEj2+st+oCSn4Uz7vZw6TbhcV1o=
-github.com/xuri/nfp v0.0.0-20230819163627-dc951e3ffe1a/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
 github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
 github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
 github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -498,7 +478,6 @@ golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0
 golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
 golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
 golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
-golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
 golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
 golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
 golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@@ -513,7 +492,6 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH
 golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
 golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
 golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
-golang.org/x/image v0.11.0/go.mod h1:bglhjqbqVuEb9e9+eNR45Jfu7D+T4Qan+NhQk8Ck2P8=
 golang.org/x/image v0.13.0/go.mod h1:6mmbMOeV28HuMTgA6OSRkdXKYw/t5W9Uwn2Yv1r3Yxk=
 golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
 golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
@@ -580,7 +558,6 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
 golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
 golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
 golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
-golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
 golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
 golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@@ -656,7 +633,6 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
 golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
@@ -665,7 +641,6 @@ golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
 golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
 golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
-golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -679,7 +654,6 @@ golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
 golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
 golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
 golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
-golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
 golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
 golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
 golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
@@ -864,8 +838,8 @@ gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
 gorm.io/gorm v1.24.3/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
 gorm.io/gorm v1.25.1/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
 gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
-gorm.io/gorm v1.25.9 h1:wct0gxZIELDk8+ZqF/MVnHLkA1rvYlBWUMv2EdsK1g8=
-gorm.io/gorm v1.25.9/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
+gorm.io/gorm v1.25.10 h1:dQpO+33KalOA+aFYGlK+EfxcI5MbO7EP2yYygwh9h+s=
+gorm.io/gorm v1.25.10/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
 gorm.io/plugin/dbresolver v1.4.1 h1:Ug4LcoPhrvqq71UhxtF346f+skTYoCa/nEsdjvHwEzk=
 gorm.io/plugin/dbresolver v1.4.1/go.mod h1:CTbCtMWhsjXSiJqiW2R8POvJ2cq18RVOl4WGyT5nhNc=
 honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

+ 1 - 0
server/initialize/gorm.go

@@ -46,6 +46,7 @@ func RegisterTables() {
 		example.ExaFile{},
 		example.ExaFileChunk{},
 		dao.ExaFileUploadAndDownload{},
+		dao.Department{},
 	)
 	if err != nil {
 		global.GVA_LOG.Error("register table failed", zap.Error(err))

+ 4 - 1
server/initialize/router.go

@@ -42,6 +42,7 @@ func Routers() *gin.Engine {
 	InstallPlugin(Router) // 安装插件
 	systemRouter := router.RouterGroupApp.System
 	exampleRouter := router.RouterGroupApp.Example
+	adminRouter := router.RouterGroupApp.Admin
 	// 如果想要不使用nginx代理前端网页,可以修改 web/.env.production 下的
 	// VUE_APP_BASE_API = /
 	// VUE_APP_BASE_PATH = http://localhost
@@ -75,7 +76,7 @@ func Routers() *gin.Engine {
 	{
 		systemRouter.InitApiRouter(PrivateGroup, PublicGroup)    // 注册功能api路由
 		systemRouter.InitJwtRouter(PrivateGroup)                 // jwt相关路由
-		systemRouter.InitUserRouter(PrivateGroup)                // 注册用户路由
+		systemRouter.InitUserRouter(PrivateGroup, PublicGroup)   // 注册用户路由
 		systemRouter.InitMenuRouter(PrivateGroup)                // 注册menu路由
 		systemRouter.InitCasbinRouter(PrivateGroup)              // 权限相关路由
 		systemRouter.InitAuthorityRouter(PrivateGroup)           // 注册角色路由
@@ -85,6 +86,8 @@ func Routers() *gin.Engine {
 		systemRouter.InitAuthorityBtnRouterRouter(PrivateGroup)  // 字典详情管理
 
 		exampleRouter.InitFileUploadAndDownloadRouter(PrivateGroup)
+
+		adminRouter.InitDepartmentRouter(PublicGroup)
 	}
 
 	global.GVA_LOG.Info("router register success")

+ 5 - 0
server/model/common/request/common.go

@@ -25,4 +25,9 @@ type GetAuthorityId struct {
 	AuthorityId uint `json:"authorityId" form:"authorityId"` // 角色ID
 }
 
+type Ids struct {
+	Ids []int `json:"ids" form:"ids"`
+	Id  int   `json:"id" form:"id"`
+}
+
 type Empty struct{}

+ 27 - 0
server/router/admin/department.go

@@ -0,0 +1,27 @@
+package admin
+
+import (
+	"github.com/gin-gonic/gin"
+	v1 "server/api/v1"
+	"server/middleware"
+)
+
+type DepartmentRouter struct{}
+
+func (s *DepartmentRouter) InitDepartmentRouter(Router *gin.RouterGroup) {
+	departmentRouter := Router.Group("department").Use(middleware.OperationRecord())
+	departmentRouterWithoutRecord := Router.Group("department")
+
+	departmentApi := v1.ApiGroupApp.AdminApiGroup.DepartmentApi
+	{
+		departmentRouter.POST("createDep", departmentApi.CreateDep)
+		departmentRouter.PUT("updateDep", departmentApi.UpdateDep)
+		departmentRouter.PUT("updateDepStatus", departmentApi.UpdateDepStatus)
+		departmentRouter.PUT("updateUserDep", departmentApi.UpdateUserDep)
+		departmentRouter.DELETE("deleteDep/:depId", departmentApi.DeleteDep)
+	}
+	{
+		departmentRouterWithoutRecord.GET("queryAllDep", departmentApi.QueryAllDep)
+		departmentRouterWithoutRecord.GET("queryDepByStart", departmentApi.QueryDepByStart)
+	}
+}

+ 5 - 0
server/router/admin/enter.go

@@ -0,0 +1,5 @@
+package admin
+
+type RouterGroup struct {
+	DepartmentRouter
+}

+ 2 - 0
server/router/enter.go

@@ -1,6 +1,7 @@
 package router
 
 import (
+	"server/router/admin"
 	"server/router/example"
 	"server/router/system"
 )
@@ -8,6 +9,7 @@ import (
 type RouterGroup struct {
 	System  system.RouterGroup
 	Example example.RouterGroup
+	Admin   admin.RouterGroup
 }
 
 var RouterGroupApp = new(RouterGroup)

+ 11 - 9
server/router/system/sys_user.go

@@ -8,19 +8,21 @@ import (
 
 type UserRouter struct{}
 
-func (s *UserRouter) InitUserRouter(Router *gin.RouterGroup) {
+func (s *UserRouter) InitUserRouter(Router *gin.RouterGroup, RouterPub *gin.RouterGroup) {
 	userRouter := Router.Group("user").Use(middleware.OperationRecord())
 	userRouterWithoutRecord := Router.Group("user")
+	userPublicRouterWithoutRecord := RouterPub.Group("user")
 	baseApi := v1.ApiGroupApp.SystemApiGroup.BaseApi
 	{
-		userRouter.POST("admin_register", baseApi.Register)               // 管理员注册账号
-		userRouter.POST("changePassword", baseApi.ChangePassword)         // 用户修改密码
-		userRouter.POST("setUserAuthority", baseApi.SetUserAuthority)     // 设置用户权限
-		userRouter.DELETE("deleteUser", baseApi.DeleteUser)               // 删除用户
-		userRouter.PUT("setUserInfo", baseApi.SetUserInfo)                // 设置用户信息
-		userRouter.PUT("setSelfInfo", baseApi.SetSelfInfo)                // 设置自身信息
-		userRouter.POST("setUserAuthorities", baseApi.SetUserAuthorities) // 设置用户权限组
-		userRouter.POST("resetPassword", baseApi.ResetPassword)           // 设置用户权限组
+		userRouter.POST("admin_register", baseApi.Register)                       // 管理员注册账号
+		userRouter.POST("changePassword", baseApi.ChangePassword)                 // 用户修改密码
+		userRouter.POST("setUserAuthority", baseApi.SetUserAuthority)             // 设置用户权限
+		userRouter.DELETE("deleteUser", baseApi.DeleteUser)                       // 删除用户
+		userRouter.PUT("setUserInfo", baseApi.SetUserInfo)                        // 设置用户信息
+		userRouter.PUT("setSelfInfo", baseApi.SetSelfInfo)                        // 设置自身信息
+		userRouter.POST("setUserAuthorities", baseApi.SetUserAuthorities)         // 设置用户权限组
+		userRouter.POST("resetPassword", baseApi.ResetPassword)                   // 设置用户权限组
+		userPublicRouterWithoutRecord.GET("queryAllUsers", baseApi.QueryAllUsers) //查询所有用户
 	}
 	{
 		userRouterWithoutRecord.POST("getUserList", baseApi.GetUserList) // 分页获取用户列表

+ 62 - 0
server/service/admin/department.go

@@ -0,0 +1,62 @@
+package admin
+
+import (
+	"errors"
+	"server/dao"
+)
+
+type DepartmentService struct {
+}
+
+func (ds *DepartmentService) QueryAllDep() ([]dao.Department, error) {
+	deps, err := dao.QueryAllDep()
+	if err != nil {
+		return nil, err
+	}
+	for i, dep := range deps {
+		users, err := dao.QueryUsersByDepId(dep.Id)
+		if err != nil {
+			return nil, err
+		}
+		deps[i].Users = users
+	}
+
+	return deps, nil
+}
+
+func (ds *DepartmentService) QueryDepByStart() ([]dao.Department, error) {
+	deps, err := dao.QueryDepByStart()
+	if err != nil {
+		return nil, err
+	}
+	return deps, nil
+}
+
+func (ds *DepartmentService) CreateDep(department dao.Department) error {
+	user, _ := dao.QueryUserByUserId(uint(department.PrincipalId))
+	department.PrincipalName = user.NickName
+	return department.CreateDep()
+}
+
+func (ds *DepartmentService) UpdateDep(department dao.Department) error {
+	return department.UpdateDep()
+}
+
+func (ds *DepartmentService) UpdateDepStatus(depId int, isStart bool) error {
+	return dao.UpdateDepStatus(depId, isStart)
+}
+
+func (ds *DepartmentService) UpdateUserDep(userIds []int, depId int) error {
+	return dao.UpdateUserDep(userIds, depId)
+}
+
+func (ds *DepartmentService) DeleteDep(depId int) error {
+	users, err := dao.QueryUsersByDepId(depId)
+	if err != nil {
+		return err
+	}
+	if len(users) > 0 {
+		return errors.New("当前部门下存在用户")
+	}
+	return dao.DeleteDep(depId)
+}

+ 5 - 0
server/service/admin/enter.go

@@ -0,0 +1,5 @@
+package admin
+
+type ServiceGroup struct {
+	DepartmentService
+}

+ 2 - 0
server/service/enter.go

@@ -1,6 +1,7 @@
 package service
 
 import (
+	"server/service/admin"
 	"server/service/example"
 	"server/service/system"
 )
@@ -8,6 +9,7 @@ import (
 type ServiceGroup struct {
 	SystemServiceGroup  system.ServiceGroup
 	ExampleServiceGroup example.ServiceGroup
+	AdminServiceGroup   admin.ServiceGroup
 }
 
 var ServiceGroupApp = new(ServiceGroup)

+ 6 - 0
server/service/system/sys_user.go

@@ -210,3 +210,9 @@ func (userService *UserService) ResetPassword(ID uint) error {
 		Password: utils.BcryptHash("123456"),
 	}.SetUserInfoById()
 }
+
+// QueryAllUsers 查询所有用户
+func (userService *UserService) QueryAllUsers() (userList []dao.SysUser, err error) {
+	userList, err = dao.QueryAllUsers()
+	return userList, err
+}

+ 54 - 0
web/src/api/department.js

@@ -0,0 +1,54 @@
+import service from '@/utils/request'
+
+export const getAllDep = () => {
+  return service({
+    url: '/department/queryAllDep',
+    method: 'get'
+  })
+}
+
+export const getDepByStart = () => {
+  return service({
+    url: '/department/queryDepByStart',
+    method: 'get'
+  })
+}
+
+export const createDep = (data) => {
+  return service({
+    url: '/department/createDep',
+    method: 'post',
+    data
+  })
+}
+
+export const updateDep = (data) => {
+  return service({
+    url: '/department/updateDep',
+    method: 'put',
+    data
+  })
+}
+
+export const updateDepStatus = (data) => {
+  return service({
+    url: '/department/updateDepStatus',
+    method: 'put',
+    data
+  })
+}
+
+export const updateUserDep = (data) => {
+  return service({
+    url: '/department/updateUserDep',
+    method: 'put',
+    data
+  })
+}
+
+export const deleteDep = (data) => {
+  return service({
+    url: '/department/deleteDep/' + data,
+    method: 'delete'
+  })
+}

+ 0 - 5
web/src/router/index.js

@@ -4,11 +4,6 @@ const routes = [{
   path: '/',
   redirect: '/login'
 },
-{
-  path: '/init',
-  name: 'Init',
-  component: () => import('@/view/init/index.vue')
-},
 {
   path: '/login',
   name: 'Login',

+ 423 - 0
web/src/view/department/department.vue

@@ -0,0 +1,423 @@
+<template>
+  <el-container class="gva-table-box">
+    <el-header>
+      <el-row>
+        <el-col :span="2">
+          <el-button
+            type="primary"
+            @click="centerDialogVisible = true"
+          >
+            添加部门
+          </el-button>
+        </el-col>
+        <el-col :span="2">
+          <el-button
+            type="primary"
+            @click="handleDistributionDep"
+          >
+            分配部门
+          </el-button>
+        </el-col>
+      </el-row>
+    </el-header>
+    <el-main>
+      <el-table :data="depTableData">
+        <el-table-column
+          prop="name"
+          label="部门名称"
+        />
+        <el-table-column
+          prop="desc"
+          label="部门描述"
+        />
+        <el-table-column
+          prop="principalName"
+          label="部门负责人"
+        />
+        <el-table-column
+          prop="isStart"
+          label="是否启用"
+        >
+          <template #default="scope">
+            <el-switch
+              v-model="scope.row.isStart"
+              style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
+              @change="handleSwitchChange(scope.row)"
+            />
+          </template>
+        </el-table-column>
+        <el-table-column label="操作">
+          <template #default="scope">
+            <el-button
+              icon="edit"
+
+              type="primary"
+              link
+              @click="handleEditDep(scope.row)"
+            >
+              编辑
+            </el-button>
+            <el-button
+              icon="delete"
+
+              type="primary"
+              link
+              @click="handleDeleteDep(scope.row)"
+            >
+              删除
+            </el-button>
+          </template>
+        </el-table-column>
+        <el-table-column
+          label="展开"
+          width="100px"
+          type="expand"
+        >
+          <template #default="props">
+            <el-table
+              :data="props.row.users"
+              @selection-change="handleSelectionChange"
+            >
+              <el-table-column
+                type="selection"
+                width="55"
+              />
+              <el-table-column
+                prop="ID"
+                label="编号"
+                align="center"
+              />
+              <el-table-column
+                label="头像"
+                align="center"
+              >
+                <template #default="scope">
+                  <CustomPic
+                    style="margin-top:8px"
+                    :pic-src="scope.row.headerImg"
+                  />
+                </template>
+              </el-table-column>
+              <el-table-column
+                prop="userName"
+                label="用户名"
+                align="center"
+              />
+              <el-table-column
+                prop="nickName"
+                label="昵称"
+                align="center"
+              />
+              <el-table-column
+                prop="email"
+                label="邮箱"
+                align="center"
+              />
+              <el-table-column
+                label="操作"
+                align="center"
+              >
+                <template #default="scope">
+                  <el-button
+                    icon="edit"
+                    type="primary"
+                    link
+                    @click="handleDistributionDep(scope.row)"
+                  >分配</el-button>
+                </template>
+              </el-table-column>
+            </el-table>
+          </template>
+        </el-table-column>
+      </el-table>
+    </el-main>
+    <!--    新增-->
+    <el-dialog
+      v-model="centerDialogVisible"
+      title="新增部门"
+      width="500"
+      align-center
+    >
+      <el-form
+        :model="depFromData"
+        label-width="auto"
+        style="max-width: 600px"
+      >
+        <el-form-item label="部门名称">
+          <el-input
+            v-model="depFromData.name"
+            style="width: 240px"
+          />
+        </el-form-item>
+        <el-form-item label="部门描述">
+          <el-input
+            v-model="depFromData.desc"
+            style="width: 240px"
+          />
+        </el-form-item>
+        <el-form-item label="部门负责人">
+          <el-select
+            v-model.number="depFromData.principalId"
+            style="width: 240px"
+          >
+            <el-option
+              v-for="item in userOptions"
+              :key="item.ID"
+              :label="item.nickName"
+              :value="item.ID"
+            />
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="centerDialogVisible = false">取消</el-button>
+          <el-button
+            type="primary"
+            @click="handleAddDep"
+          >
+            确定
+          </el-button>
+        </div>
+      </template>
+    </el-dialog>
+    <!--    修改-->
+    <el-dialog
+      v-model="updateDialogVisible"
+      title="修改部门"
+      width="500"
+      align-center
+    >
+      <el-form
+        :model="updateDepFromData"
+        label-width="auto"
+        style="max-width: 600px"
+      >
+        <el-form-item label="部门名称">
+          <el-input
+            v-model="updateDepFromData.name"
+            style="width: 240px"
+          />
+        </el-form-item>
+        <el-form-item label="部门描述">
+          <el-input
+            v-model="updateDepFromData.desc"
+            style="width: 240px"
+          />
+        </el-form-item>
+        <el-form-item label="部门负责人">
+          <el-select
+            v-model.number="updateDepFromData.principalId"
+            style="width: 240px"
+          >
+            <el-option
+              v-for="item in userOptions"
+              :key="item.ID"
+              :label="item.nickName"
+              :value="item.ID"
+            />
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="updateDialogVisible = false">取消</el-button>
+          <el-button
+            type="primary"
+            @click="handleUpdateDep"
+          >
+            确定
+          </el-button>
+        </div>
+      </template>
+    </el-dialog>
+    <!--    分配-->
+    <el-dialog
+      v-model="distributionDialogVisible"
+      title="分配"
+      width="500"
+      align-center
+    >
+      <warning-bar title="注:只提供开启了的部门" />
+      <el-select
+        v-model.number="distributionDepData.id"
+        style="width: 240px"
+      >
+        <el-option
+          v-for="item in depOptions"
+          :key="item.ID"
+          :label="item.name"
+          :value="item.ID"
+        />
+      </el-select>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="distributionDialogVisible = false">取消</el-button>
+          <el-button
+            type="primary"
+            @click="distributionDep"
+          >
+            确定
+          </el-button>
+        </div>
+      </template>
+    </el-dialog>
+  </el-container>
+</template>
+
+<script setup>
+import { ref, onMounted } from 'vue'
+import {
+  createDep,
+  deleteDep,
+  getAllDep,
+  getDepByStart,
+  updateDep,
+  updateDepStatus,
+  updateUserDep
+} from '@/api/department'
+import CustomPic from '@/components/customPic/index.vue'
+import WarningBar from '@/components/warningBar/warningBar.vue'
+import { getAllUsers } from '@/api/user'
+import { ElMessage, ElMessageBox } from 'element-plus'
+
+const depTableData = ref([])
+
+const queryData = async() => {
+  await getAllDep().then(res => {
+    depTableData.value = res.data
+  })
+  await getAllUsers().then(res => {
+    userOptions.value = res.data
+    depFromData.value.principalId = res.data[0].ID
+  })
+  await getDepByStart().then(res => {
+    depOptions.value = res.data
+    distributionDepData.value.id = res.data[0].ID
+  })
+}
+
+// 部门是否启用
+const handleSwitchChange = async(row) => {
+  await updateDepStatus(row).then(res => {
+    if (res.code === 0) {
+      ElMessage.success('更新成功')
+    }
+  })
+}
+
+// 修改
+const updateDialogVisible = ref(false)
+
+const updateDepFromData = ref({
+  id: 0,
+  name: '',
+  desc: '',
+  principalId: 0
+})
+const handleEditDep = (row) => {
+  updateDepFromData.value.id = row.ID
+  updateDepFromData.value.name = row.name
+  updateDepFromData.value.desc = row.desc
+  updateDepFromData.value.principalId = row.principalId
+  updateDialogVisible.value = true
+}
+
+const handleUpdateDep = async() => {
+  await updateDep(updateDepFromData.value).then(res => {
+    console.log(res)
+  })
+  updateDialogVisible.value = false
+}
+
+const handleDeleteDep = (row) => {
+  ElMessageBox.confirm(
+    '确定删除吗?',
+    '删除',
+    {
+      confirmButtonText: '确定',
+      cancelButtonText: '取消',
+      type: 'warning',
+    }
+  )
+    .then(async() => {
+      await deleteDep(row.ID).then(res => {
+        console.log(res)
+      })
+      await queryData()
+    })
+    .catch(() => {
+      ElMessage({
+        type: 'info',
+        message: '取消删除',
+      })
+    })
+}
+
+// 分配
+const depOptions = ref()
+
+const distributionDialogVisible = ref(false)
+
+const distributionDepData = ref({
+  ids: [],
+  id: 0
+})
+
+const handleDistributionDep = (row) => {
+  if (row.ID !== undefined) {
+    distributionDepData.value.ids = []
+    distributionDepData.value.ids[0] = row.ID
+  }
+  distributionDialogVisible.value = true
+}
+
+const handleSelectionChange = async(val) => {
+  distributionDepData.value.ids = []
+  for (const key in val) {
+    console.log(val[key].ID)
+    distributionDepData.value.ids.push(val[key].ID)
+  }
+}
+const distributionDep = async() => {
+  if (distributionDepData.value.ids.length === 0) {
+    ElMessage.error('请选择用户')
+    return false
+  }
+  await updateUserDep(distributionDepData.value).then(res => {
+    console.log(res)
+  })
+  await queryData()
+  distributionDialogVisible.value = false
+}
+
+// 新增部门
+const userOptions = ref()
+
+const depFromData = ref({
+  name: '',
+  desc: '',
+  principalId: 0
+})
+
+const centerDialogVisible = ref(false)
+const handleAddDep = async() => {
+  if (depFromData.value.name === '') {
+    ElMessage.error('请输入部门名称')
+    return false
+  }
+  await createDep(depFromData.value).then(res => {
+    console.log(res)
+  })
+  await queryData()
+  centerDialogVisible.value = false
+}
+
+onMounted(() => {
+  queryData()
+})
+</script>
+
+<style scoped>
+
+</style>

+ 0 - 2
web/src/view/superAdmin/authority/authority.vue

@@ -144,7 +144,6 @@ import {
   deleteAuthority,
   createAuthority,
   updateAuthority,
-  copyAuthority
 } from '@/api/authority'
 
 import Menus from '@/view/superAdmin/authority/components/menus.vue'
@@ -179,7 +178,6 @@ const activeRow = ref({})
 const dialogTitle = ref('新增角色')
 const dialogFormVisible = ref(false)
 const apiDialogFlag = ref(false)
-const copyForm = ref({})
 
 const form = ref({
   authorityId: 0,