zk 2 lat temu
rodzic
commit
3bc8ce3d0f

+ 1 - 0
server/api/v1/autocode/enter.go

@@ -11,5 +11,6 @@ type ApiGroup struct {
 	ProblemTypeApi
 	UnitHistoryApi
 	ProblemReplyApi
+	OrganizationApi
 	// Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
 }

+ 163 - 0
server/api/v1/autocode/organization.go

@@ -0,0 +1,163 @@
+package autocode
+
+import (
+	"github.com/flipped-aurora/gin-vue-admin/server/global"
+	"github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
+	autocodeReq "github.com/flipped-aurora/gin-vue-admin/server/model/autocode/request"
+	"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
+	"github.com/flipped-aurora/gin-vue-admin/server/service"
+	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
+)
+
+type OrganizationApi struct {
+}
+
+var organizationService = service.ServiceGroupApp.AutoCodeServiceGroup.OrganizationService
+
+// CreateOrganization 创建Organization
+// @Tags Organization
+// @Summary 创建Organization
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body autocode.Organization true "创建Organization"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Router /organization/createOrganization [post]
+func (organizationApi *OrganizationApi) CreateOrganization(c *gin.Context) {
+	var organization autocode.Organization
+	_ = c.ShouldBindJSON(&organization)
+	if err := organizationService.CreateOrganization(organization); err != nil {
+		global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
+		response.FailWithMessage("创建失败", c)
+	} else {
+		response.OkWithMessage("创建成功", c)
+	}
+}
+
+// DeleteOrganization 删除Organization
+// @Tags Organization
+// @Summary 删除Organization
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body autocode.Organization true "删除Organization"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
+// @Router /organization/deleteOrganization [delete]
+func (organizationApi *OrganizationApi) DeleteOrganization(c *gin.Context) {
+	var organization autocode.Organization
+	_ = c.ShouldBindJSON(&organization)
+	if err := organizationService.DeleteOrganization(organization); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
+		response.FailWithMessage("删除失败", c)
+	} else {
+		response.OkWithMessage("删除成功", c)
+	}
+}
+
+// DeleteOrganizationByIds 批量删除Organization
+// @Tags Organization
+// @Summary 批量删除Organization
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body request.IdsReq true "批量删除Organization"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
+// @Router /organization/deleteOrganizationByIds [delete]
+func (organizationApi *OrganizationApi) DeleteOrganizationByIds(c *gin.Context) {
+	var CODES []string
+	_ = c.ShouldBindJSON(&CODES)
+	if err := organizationService.DeleteOrganizationByIds(CODES); err != nil {
+		global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
+		response.FailWithMessage("批量删除失败", c)
+	} else {
+		response.OkWithMessage("批量删除成功", c)
+	}
+}
+
+// UpdateOrganization 更新Organization
+// @Tags Organization
+// @Summary 更新Organization
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body autocode.Organization true "更新Organization"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
+// @Router /organization/updateOrganization [put]
+func (organizationApi *OrganizationApi) UpdateOrganization(c *gin.Context) {
+	var organization autocode.Organization
+	_ = c.ShouldBindJSON(&organization)
+	if err := organizationService.UpdateOrganization(organization); err != nil {
+		global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
+		response.FailWithMessage("更新失败", c)
+	} else {
+		response.OkWithMessage("更新成功", c)
+	}
+}
+
+// FindOrganization 用id查询Organization
+// @Tags Organization
+// @Summary 用id查询Organization
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data query autocode.Organization true "用id查询Organization"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
+// @Router /organization/findOrganization [get]
+func (organizationApi *OrganizationApi) FindOrganization(c *gin.Context) {
+	var organization autocode.Organization
+	_ = c.ShouldBindQuery(&organization)
+	if err, reorganization := organizationService.GetOrganization(organization.CODE); err != nil {
+		global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
+		response.FailWithMessage("查询失败", c)
+	} else {
+		response.OkWithData(gin.H{"reorganization": reorganization}, c)
+	}
+}
+
+func (organizationApi *OrganizationApi) FindOrganizationTree(c *gin.Context) {
+	code, _ := c.GetQuery("code")
+	treeMap := make(map[string][]autocode.Organization)
+	if err, reorganization := organizationService.GetOrganizationInfoLists(); err != nil {
+		response.FailWithMessage("查询失败", c)
+	} else {
+		for _, v := range reorganization {
+			treeMap[v.PARENTCODE] = append(treeMap[v.PARENTCODE], v)
+		}
+		var orgList []autocode.Organization
+		if code != "" {
+			orgList = treeMap[code]
+		} else {
+			orgList = treeMap["00"]
+		}
+		for i := 0; i < len(orgList); i++ {
+			err = organizationService.GetBaseChildrenList(&orgList[i], treeMap)
+		}
+		response.OkWithData(gin.H{"treeMap": orgList}, c)
+	}
+}
+
+// GetOrganizationList 分页获取Organization列表
+// @Tags Organization
+// @Summary 分页获取Organization列表
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data query autocodeReq.OrganizationSearch true "分页获取Organization列表"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Router /organization/getOrganizationList [get]
+func (organizationApi *OrganizationApi) GetOrganizationList(c *gin.Context) {
+	var pageInfo autocodeReq.OrganizationSearch
+	_ = c.ShouldBindQuery(&pageInfo)
+	if err, list, total := organizationService.GetOrganizationInfoList(pageInfo); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List:     list,
+			Total:    total,
+			Page:     pageInfo.Page,
+			PageSize: pageInfo.PageSize,
+		}, "获取成功", c)
+	}
+}

+ 42 - 0
server/api/v1/autocode/wechat_test.go

@@ -0,0 +1,42 @@
+package autocode
+
+import (
+	"github.com/flipped-aurora/gin-vue-admin/server/core"
+	"github.com/flipped-aurora/gin-vue-admin/server/global"
+	"github.com/flipped-aurora/gin-vue-admin/server/initialize"
+	"github.com/silenceper/wechat/v2/officialaccount/menu"
+	"testing"
+)
+
+func TestName(t *testing.T) {
+	//ssk:="4Iki42L+u5IYKcYABCDe/A=="
+	//r:="K8yfw2N2JjgdoYwxSvTq39dKEYRruSftVIZHQQEAs9Kh3XRazd1wArh0kkvWKLvxySX/xLI68p973ea9f4cevYPeMENLX/6dFEyCbxv2dcZlKh8sFSi4rqDXuPf36Hayf024ek/35EylDt8n+XqqUfKv1RZePQYZuxThsQ92yba4FB4Nh2VHC7GFoIRQEkOBCq9sTqjX0IAVrUxhs0hz092+1AMZv+pptw9hjYv144/OIzmwxV97H9svAjVvqYbeWexlIocbAp7Z6+dmyHyQILpKFFgWlUE5vVZkDQAAeh+KcV//7aShZu+l7az1er3B5AOkNQ8UJX85Ux5wyCeduxbmOzGdViycrFQVa86r0cEGVFcNWmyGElUse5jzU3H+P/XMJ9AiZZ2ybvT3NrwgdBck49iulEXoWQKjczTGBIE="
+	//vi:="gIEEvlb9cEjErJxZ5sflrw=="
+	//phone , _ := weapp.DecryptMobile(ssk, r, vi)
+	//fmt.Print(phone)
+	global.GVA_VP = core.Viper() // 初始化Viper
+	//global.GVA_LOG = core.Zap()       // 初始化zap日志库
+	//global.GVA_DB = initialize.Gorm() // gorm连接数据库
+	initialize.Redis()  //连接redis
+	initialize.Wechat() //初始化微信公众服务
+	//_, resysDictionaryDetail := dictionaryDetailService.GetSysDictionaryDetail(8)
+	//fmt.Printf("\t%v", resysDictionaryDetail)
+	var menuAA []*menu.Button
+	menuAA = append(menuAA, &menu.Button{Type: "miniprogram", Name: "小程序", URL: "http://zk1006.cn", AppID: "wx0dc3e4978f919285", PagePath: "/pages/checking"})
+	menuAA = append(menuAA, &menu.Button{Type: "view", Name: "一键授权", URL: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx66e0fbb5a735bcc4&redirect_uri=https://cc.zjkduoduo.com/api/wechat/auth&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"})
+	global.GVA_WECHAT.GetMenu().SetMenu(menuAA)
+
+	//f,_:=excelize.OpenFile("C:\\Users\\ice\\Documents\\WeChat Files\\zk1006\\FileStorage\\File\\2021-09\\21类.xlsx")
+	//files := f.GetSheetList()
+	//for _, sheet := range files {
+	//	rows,_:=f.GetRows(sheet)
+	//	fmt.Println(sheet)
+	//	for _, row := range rows {
+	//		for _, value := range row {
+	//			fmt.Printf("\t%s", strings.Replace(value, "\n", "", -1))
+	//		}
+	//		fmt.Println()
+	//	}
+	//	fmt.Println()
+	//}
+}

+ 10 - 3
server/api/v1/system/user_test.go

@@ -1,10 +1,10 @@
 package system
 
 import (
-	"fmt"
 	"github.com/flipped-aurora/gin-vue-admin/server/core"
 	"github.com/flipped-aurora/gin-vue-admin/server/global"
 	"github.com/flipped-aurora/gin-vue-admin/server/initialize"
+	"github.com/silenceper/wechat/v2/officialaccount/menu"
 	"testing"
 )
 
@@ -17,8 +17,15 @@ func TestName(t *testing.T) {
 	global.GVA_VP = core.Viper() // 初始化Viper
 	//global.GVA_LOG = core.Zap()       // 初始化zap日志库
 	global.GVA_DB = initialize.Gorm() // gorm连接数据库
-	_, resysDictionaryDetail := dictionaryDetailService.GetSysDictionaryDetail(8)
-	fmt.Printf("\t%v", resysDictionaryDetail)
+	initialize.Redis()                //连接redis
+	initialize.Wechat()               //初始化微信公众服务
+	//_, resysDictionaryDetail := dictionaryDetailService.GetSysDictionaryDetail(8)
+	//fmt.Printf("\t%v", resysDictionaryDetail)
+	var menuAA []*menu.Button
+	menuAA = append(menuAA, &menu.Button{Type: "miniprogram", Name: "小程序", URL: "http://zk1006.cn", AppID: "wx0dc3e4978f919285", PagePath: "/pages/checking"})
+	menuAA = append(menuAA, &menu.Button{Type: "view", Name: "一键授权", URL: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx66e0fbb5a735bcc4&redirect_uri=https://cc.zjkduoduo.com/api/wechat/auth&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"})
+	global.GVA_WECHAT.GetMenu().SetMenu(menuAA)
+
 	//f,_:=excelize.OpenFile("C:\\Users\\ice\\Documents\\WeChat Files\\zk1006\\FileStorage\\File\\2021-09\\21类.xlsx")
 	//files := f.GetSheetList()
 	//for _, sheet := range files {

+ 1 - 0
server/initialize/gorm.go

@@ -57,6 +57,7 @@ func MysqlTables(db *gorm.DB) {
 		autocode.ProblemType{},
 		autocode.UnitHistory{},
 		autocode.ProblemReply{},
+		autocode.Organization{},
 		// Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
 	)
 	if err != nil {

+ 9 - 7
server/initialize/router.go

@@ -42,13 +42,14 @@ func Routers() *gin.Engine {
 	autocodeRouter := router.RouterGroupApp.Autocode
 	PublicGroup := Router.Group("")
 	{
-		systemRouter.InitBaseRouter(PublicGroup)           // 注册基础功能路由 不做鉴权
-		systemRouter.InitInitRouter(PublicGroup)           // 自动初始化相关
-		autocodeRouter.InitProblemInfoPRouter(PublicGroup) // 问题详情
-		autocodeRouter.InitContentPRouter(PublicGroup)     // 内容详情
-		systemRouter.InitWechatRouter(PublicGroup)         // 微信公众号
-		autocodeRouter.InitReadCountRouter(PublicGroup)    // 查阅次数查看
-		autocodeRouter.ProblemTypePRouter(PublicGroup)     // 查阅次数查看
+		systemRouter.InitBaseRouter(PublicGroup)            // 注册基础功能路由 不做鉴权
+		systemRouter.InitInitRouter(PublicGroup)            // 自动初始化相关
+		autocodeRouter.InitProblemInfoPRouter(PublicGroup)  // 问题详情
+		autocodeRouter.InitContentPRouter(PublicGroup)      // 内容详情
+		systemRouter.InitWechatRouter(PublicGroup)          // 微信公众号
+		autocodeRouter.InitReadCountRouter(PublicGroup)     // 查阅次数查看
+		autocodeRouter.ProblemTypePRouter(PublicGroup)      // 查阅次数查看
+		autocodeRouter.InitOrganizationPRouter(PublicGroup) //地区查询
 	}
 	PrivateGroup := Router.Group("")
 	PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
@@ -77,6 +78,7 @@ func Routers() *gin.Engine {
 		autocodeRouter.InitProblemTypeRouter(PrivateGroup)
 		autocodeRouter.InitUnitHistoryRouter(PrivateGroup)
 		autocodeRouter.InitProblemReplyRouter(PrivateGroup)
+		autocodeRouter.InitOrganizationRouter(PrivateGroup)
 		// Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
 	}
 

+ 18 - 0
server/model/autocode/organization.go

@@ -0,0 +1,18 @@
+// 自动生成模板Organization
+package autocode
+
+// Organization 结构体
+// 如果含有time.Time 请自行import time包
+type Organization struct {
+	CODE       string         `json:"value" form:"CODE" gorm:"column:CODE;comment:;type:varchar(20);"`
+	NAME       string         `json:"label" form:"NAME" gorm:"column:NAME;comment:;type:varchar(50);"`
+	PARENTCODE string         `json:"parentcode" form:"PARENTCODE" gorm:"column:PARENT_CODE;comment:;type:varchar(20);"`
+	Optimistic *int           `json:"optimistic" form:"optimistic" gorm:"column:optimistic;comment:;type:int"`
+	Postition  string         `json:"postition" form:"postition" gorm:"column:postition;comment:;type:varchar(225);"`
+	Children   []Organization `json:"children" gorm:"-"`
+}
+
+// TableName Organization 表名
+func (Organization) TableName() string {
+	return "organization"
+}

+ 5 - 4
server/model/autocode/place.go

@@ -9,10 +9,11 @@ import (
 // 如果含有time.Time 请自行import time包
 type Place struct {
 	global.GVA_MODEL
-	Name     string `json:"name" form:"name" gorm:"column:name;comment:点位名称;type:varchar(255);"`
-	Position string `json:"position" form:"position" gorm:"column:position;comment:点位定位;type:varchar(255);"`
-	Type     *int   `json:"type" form:"type" gorm:"column:type;comment:点位类型;type:int;"`
-	Region   string `json:"region" form:"region" gorm:"column:region;comment:区域;type:varchar(255);"`
+	Name      string `json:"name" form:"name" gorm:"column:name;comment:点位名称;type:varchar(255);"`
+	Position  string `json:"position" form:"position" gorm:"column:position;comment:点位定位;type:varchar(255);"`
+	Type      *int   `json:"type" form:"type" gorm:"column:type;comment:点位类型;type:int;"`
+	Region    string `json:"region" form:"region" gorm:"column:region;comment:区域;type:varchar(255);"`
+	OrganCode string `json:"organCode" form:"organCode" gorm:"column:organ_code;comment:区域归属;type:varchar(255);"`
 }
 
 // TableName Place 表名

+ 11 - 0
server/model/autocode/request/organization.go

@@ -0,0 +1,11 @@
+package request
+
+import (
+	"github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
+	"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
+)
+
+type OrganizationSearch struct{
+    autocode.Organization
+    request.PageInfo
+}

+ 1 - 0
server/router/autocode/enter.go

@@ -11,5 +11,6 @@ type RouterGroup struct {
 	ProblemTypeRouter
 	UnitHistoryRouter
 	ProblemReplyRouter
+	OrganizationRouter
 	// Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
 }

+ 35 - 0
server/router/autocode/organization.go

@@ -0,0 +1,35 @@
+package autocode
+
+import (
+	"github.com/flipped-aurora/gin-vue-admin/server/api/v1"
+	"github.com/flipped-aurora/gin-vue-admin/server/middleware"
+	"github.com/gin-gonic/gin"
+)
+
+type OrganizationRouter struct {
+}
+
+// InitOrganizationRouter 初始化 Organization 路由信息
+func (s *OrganizationRouter) InitOrganizationRouter(Router *gin.RouterGroup) {
+	organizationRouter := Router.Group("organization").Use(middleware.OperationRecord())
+	var organizationApi = v1.ApiGroupApp.AutoCodeApiGroup.OrganizationApi
+	{
+		organizationRouter.POST("createOrganization", organizationApi.CreateOrganization)             // 新建Organization
+		organizationRouter.DELETE("deleteOrganization", organizationApi.DeleteOrganization)           // 删除Organization
+		organizationRouter.DELETE("deleteOrganizationByIds", organizationApi.DeleteOrganizationByIds) // 批量删除Organization
+		organizationRouter.PUT("updateOrganization", organizationApi.UpdateOrganization)              // 更新Organization
+		//organizationRouter.GET("findOrganization", organizationApi.FindOrganization)        // 根据ID获取Organization
+		//organizationRouter.GET("getOrganizationList", organizationApi.GetOrganizationList)  // 获取Organization列表
+	}
+}
+
+func (s *ContentRouter) InitOrganizationPRouter(Router *gin.RouterGroup) {
+	organizationRouter := Router.Group("organization").Use(middleware.OperationRecord())
+	var organizationApi = v1.ApiGroupApp.AutoCodeApiGroup.OrganizationApi
+	{
+		organizationRouter.GET("findOrganization", organizationApi.FindOrganization)         // 根据ID获取Organization
+		organizationRouter.GET("findOrganizationTree", organizationApi.FindOrganizationTree) // 根据ID获取Organization
+		organizationRouter.GET("getOrganizationList", organizationApi.GetOrganizationList)   // 获取Organization列表
+		//contentRouter.GET("findContent", contentApi.FindContent) // 根据ID获取Content
+	}
+}

+ 1 - 0
server/service/autocode/enter.go

@@ -11,5 +11,6 @@ type ServiceGroup struct {
 	ProblemTypeService
 	UnitHistoryService
 	ProblemReplyService
+	OrganizationService
 	// Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
 }

+ 75 - 0
server/service/autocode/organization.go

@@ -0,0 +1,75 @@
+package autocode
+
+import (
+	"github.com/flipped-aurora/gin-vue-admin/server/global"
+	"github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
+	autoCodeReq "github.com/flipped-aurora/gin-vue-admin/server/model/autocode/request"
+)
+
+type OrganizationService struct {
+}
+
+// CreateOrganization 创建Organization记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (organizationService *OrganizationService) CreateOrganization(organization autocode.Organization) (err error) {
+	err = global.GVA_DB.Create(&organization).Error
+	return err
+}
+
+// DeleteOrganization 删除Organization记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (organizationService *OrganizationService) DeleteOrganization(organization autocode.Organization) (err error) {
+	err = global.GVA_DB.Delete(&organization).Error
+	return err
+}
+
+// DeleteOrganizationByIds 批量删除Organization记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (organizationService *OrganizationService) DeleteOrganizationByIds(codes []string) (err error) {
+	err = global.GVA_DB.Delete(&[]autocode.Organization{}, "code in ?", codes).Error
+	return err
+}
+
+// UpdateOrganization 更新Organization记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (organizationService *OrganizationService) UpdateOrganization(organization autocode.Organization) (err error) {
+	err = global.GVA_DB.Save(&organization).Error
+	return err
+}
+
+// GetOrganization 根据id获取Organization记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (organizationService *OrganizationService) GetOrganization(code string) (err error, organization autocode.Organization) {
+	err = global.GVA_DB.Where("code = ?", code).First(&organization).Error
+	return
+}
+
+// GetOrganizationInfoList 分页获取Organization记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (organizationService *OrganizationService) GetOrganizationInfoList(info autoCodeReq.OrganizationSearch) (err error, list []autocode.Organization, total int64) {
+	limit := info.PageSize
+	offset := info.PageSize * (info.Page - 1)
+	// 创建db
+	db := global.GVA_DB.Model(&autocode.Organization{})
+	var organizations []autocode.Organization
+	// 如果有条件搜索 下方会自动创建搜索语句
+	err = db.Count(&total).Error
+	err = db.Limit(limit).Offset(offset).Find(&organizations).Error
+	return err, organizations, total
+}
+
+func (organizationService *OrganizationService) GetOrganizationInfoLists() (err error, list []autocode.Organization) {
+	// 创建db
+	db := global.GVA_DB.Model(&autocode.Organization{})
+	var organizations []autocode.Organization
+	err = db.Find(&organizations).Error
+	return err, organizations
+}
+
+func (organizationService *OrganizationService) GetBaseChildrenList(org *autocode.Organization, treeMap map[string][]autocode.Organization) (err error) {
+	org.Children = treeMap[org.CODE]
+	for i := 0; i < len(org.Children); i++ {
+		err = organizationService.GetBaseChildrenList(&org.Children[i], treeMap)
+	}
+	return err
+}

+ 3 - 0
server/service/autocode/place.go

@@ -55,6 +55,9 @@ func (placeService *PlaceService) GetPlaceInfoList(info autoCodeReq.PlaceSearch)
 	if info.Type != nil {
 		db.Where("type=?", info.Type)
 	}
+	if info.OrganCode != "" {
+		db.Where("organ_code=?", info.OrganCode)
+	}
 	if info.Name != "" {
 		db.Where("`name` LIKE ?", "%"+info.Name+"%")
 	}

+ 97 - 0
web/src/api/organization.js

@@ -0,0 +1,97 @@
+import service from '@/utils/request'
+
+// @Tags Organization
+// @Summary 创建Organization
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body model.Organization true "创建Organization"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Router /organization/createOrganization [post]
+export const createOrganization = (data) => {
+  return service({
+    url: '/organization/createOrganization',
+    method: 'post',
+    data
+  })
+}
+
+// @Tags Organization
+// @Summary 删除Organization
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body model.Organization true "删除Organization"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
+// @Router /organization/deleteOrganization [delete]
+export const deleteOrganization = (data) => {
+  return service({
+    url: '/organization/deleteOrganization',
+    method: 'delete',
+    data
+  })
+}
+
+// @Tags Organization
+// @Summary 删除Organization
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body request.IdsReq true "批量删除Organization"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
+// @Router /organization/deleteOrganization [delete]
+export const deleteOrganizationByIds = (data) => {
+  return service({
+    url: '/organization/deleteOrganizationByIds',
+    method: 'delete',
+    data
+  })
+}
+
+// @Tags Organization
+// @Summary 更新Organization
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body model.Organization true "更新Organization"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
+// @Router /organization/updateOrganization [put]
+export const updateOrganization = (data) => {
+  return service({
+    url: '/organization/updateOrganization',
+    method: 'put',
+    data
+  })
+}
+
+// @Tags Organization
+// @Summary 用id查询Organization
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data query model.Organization true "用id查询Organization"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
+// @Router /organization/findOrganization [get]
+export const findOrganization = (params) => {
+  return service({
+    url: '/organization/findOrganization',
+    method: 'get',
+    params
+  })
+}
+
+// @Tags Organization
+// @Summary 分页获取Organization列表
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data query request.PageInfo true "分页获取Organization列表"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Router /organization/getOrganizationList [get]
+export const getOrganizationList = (params) => {
+  return service({
+    url: '/organization/getOrganizationList',
+    method: 'get',
+    params
+  })
+}

+ 218 - 0
web/src/view/organization/organization.vue

@@ -0,0 +1,218 @@
+<template>
+  <div>
+    <div class="search-term">
+      <el-form :inline="true" :model="searchInfo" class="demo-form-inline">
+        <el-form-item>
+          <el-button size="mini" type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
+          <el-button size="mini" type="primary" icon="el-icon-plus" @click="openDialog">新增</el-button>
+          <el-popover v-model:visible="deleteVisible" placement="top" width="160">
+            <p>确定要删除吗?</p>
+            <div style="text-align: right; margin: 0">
+              <el-button size="mini" type="text" @click="deleteVisible = false">取消</el-button>
+              <el-button size="mini" type="primary" @click="onDelete">确定</el-button>
+            </div>
+            <template #reference>
+              <el-button icon="el-icon-delete" size="mini" type="danger" style="margin-left: 10px;">批量删除</el-button>
+            </template>
+          </el-popover>
+        </el-form-item>
+      </el-form>
+    </div>
+    <el-table
+      ref="multipleTable"
+      border
+      stripe
+      style="width: 100%"
+      tooltip-effect="dark"
+      :data="tableData"
+      @selection-change="handleSelectionChange"
+    >
+      <el-table-column type="selection" width="55" />
+      <el-table-column label="日期" width="180">
+        <template #default="scope">{{ formatDate(scope.row.CreatedAt) }}</template>
+      </el-table-column>
+      <el-table-column label="区域编码" prop="CODE" />
+      <el-table-column label="区域名称" prop="NAME" />
+      <el-table-column label="上级区域" prop="PARENTCODE" />
+      <el-table-column label="optimistic字段" prop="optimistic" />
+      <el-table-column label="中心点" prop="postition" />
+      <el-table-column label="按钮组">
+        <template #default="scope">
+          <el-button size="small" type="primary" icon="el-icon-edit" class="table-button" @click="updateOrganization(scope.row)">变更</el-button>
+          <el-button type="danger" icon="el-icon-delete" size="mini" @click="deleteRow(scope.row)">删除</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <el-pagination
+      layout="total, sizes, prev, pager, next, jumper"
+      :current-page="page"
+      :page-size="pageSize"
+      :page-sizes="[10, 30, 50, 100]"
+      :style="{float:'right',padding:'20px'}"
+      :total="total"
+      @current-change="handleCurrentChange"
+      @size-change="handleSizeChange"
+    />
+    <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" title="弹窗操作">
+      <el-form :model="formData" label-position="right" label-width="80px">
+        <el-form-item label="CODE字段:">
+          <el-input v-model="formData.CODE" clearable placeholder="请输入" />
+        </el-form-item>
+        <el-form-item label="NAME字段:">
+          <el-input v-model="formData.NAME" clearable placeholder="请输入" />
+        </el-form-item>
+        <el-form-item label="PARENTCODE字段:">
+          <el-input v-model="formData.PARENTCODE" clearable placeholder="请输入" />
+        </el-form-item>
+        <el-form-item label="optimistic字段:">
+          <el-input v-model.number="formData.optimistic" clearable placeholder="请输入" />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="closeDialog">取 消</el-button>
+          <el-button type="primary" @click="enterDialog">确 定</el-button>
+        </div>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import {
+  createOrganization,
+  deleteOrganization,
+  deleteOrganizationByIds,
+  updateOrganization,
+  findOrganization,
+  getOrganizationList
+} from '@/api/organization' //  此处请自行替换地址
+import infoList from '@/mixins/infoList'
+export default {
+  name: 'Organization',
+  mixins: [infoList],
+  data() {
+    return {
+      listApi: getOrganizationList,
+      dialogFormVisible: false,
+      type: '',
+      deleteVisible: false,
+      multipleSelection: [],
+      formData: {
+        CODE: '',
+        NAME: '',
+        PARENTCODE: '',
+        optimistic: 0,
+      }
+    }
+  },
+  async created() {
+    await this.getTableData()
+  },
+  methods: {
+  // 条件搜索前端看此方法
+    onSubmit() {
+      this.page = 1
+      this.pageSize = 10
+      this.getTableData()
+    },
+    handleSelectionChange(val) {
+      this.multipleSelection = val
+    },
+    deleteRow(row) {
+      this.$confirm('确定要删除吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.deleteOrganization(row)
+      })
+    },
+    async onDelete() {
+      const ids = []
+      if (this.multipleSelection.length === 0) {
+        this.$message({
+          type: 'warning',
+          message: '请选择要删除的数据'
+        })
+        return
+      }
+      this.multipleSelection &&
+        this.multipleSelection.map(item => {
+          ids.push(item.ID)
+        })
+      const res = await deleteOrganizationByIds({ ids })
+      if (res.code === 0) {
+        this.$message({
+          type: 'success',
+          message: '删除成功'
+        })
+        if (this.tableData.length === ids.length && this.page > 1) {
+          this.page--
+        }
+        this.deleteVisible = false
+        this.getTableData()
+      }
+    },
+    async updateOrganization(row) {
+      const res = await findOrganization({ ID: row.ID })
+      this.type = 'update'
+      if (res.code === 0) {
+        this.formData = res.data.reorganization
+        this.dialogFormVisible = true
+      }
+    },
+    closeDialog() {
+      this.dialogFormVisible = false
+      this.formData = {
+        CODE: '',
+        NAME: '',
+        PARENTCODE: '',
+        optimistic: 0,
+      }
+    },
+    async deleteOrganization(row) {
+      const res = await deleteOrganization({ ID: row.ID })
+      if (res.code === 0) {
+        this.$message({
+          type: 'success',
+          message: '删除成功'
+        })
+        if (this.tableData.length === 1 && this.page > 1) {
+          this.page--
+        }
+        this.getTableData()
+      }
+    },
+    async enterDialog() {
+      let res
+      switch (this.type) {
+        case 'create':
+          res = await createOrganization(this.formData)
+          break
+        case 'update':
+          res = await updateOrganization(this.formData)
+          break
+        default:
+          res = await createOrganization(this.formData)
+          break
+      }
+      if (res.code === 0) {
+        this.$message({
+          type: 'success',
+          message: '创建/更改成功'
+        })
+        this.closeDialog()
+        this.getTableData()
+      }
+    },
+    openDialog() {
+      this.type = 'create'
+      this.dialogFormVisible = true
+    }
+  },
+}
+</script>
+
+<style>
+</style>

+ 86 - 0
web/src/view/organization/organizationForm.vue

@@ -0,0 +1,86 @@
+<template>
+  <div>
+    <el-form :model="formData" label-position="right" label-width="80px">
+      <el-form-item label="CODE字段:">
+        <el-input v-model="formData.CODE" clearable placeholder="请输入" />
+      </el-form-item>
+      <el-form-item label="NAME字段:">
+        <el-input v-model="formData.NAME" clearable placeholder="请输入" />
+      </el-form-item>
+      <el-form-item label="PARENTCODE字段:">
+        <el-input v-model="formData.PARENTCODE" clearable placeholder="请输入" />
+      </el-form-item>
+      <el-form-item label="optimistic字段:">
+        <el-input v-model.number="formData.optimistic" clearable placeholder="请输入" />
+      </el-form-item>
+      <el-form-item>
+        <el-button size="mini" type="primary" @click="save">保存</el-button>
+        <el-button size="mini" type="primary" @click="back">返回</el-button>
+      </el-form-item>
+    </el-form>
+  </div>
+</template>
+
+<script>
+import {
+  createOrganization,
+  updateOrganization,
+  findOrganization
+} from '@/api/organization' //  此处请自行替换地址
+import infoList from '@/mixins/infoList'
+export default {
+  name: 'Organization',
+  mixins: [infoList],
+  data() {
+    return {
+      type: '',
+      formData: {
+        CODE: '',
+        NAME: '',
+        PARENTCODE: '',
+        optimistic: 0,
+      }
+    }
+  },
+  async created() {
+    // 建议通过url传参获取目标数据ID 调用 find方法进行查询数据操作 从而决定本页面是create还是update 以下为id作为url参数示例
+    if (this.$route.query.id) {
+      const res = await findOrganization({ ID: this.$route.query.id })
+      if (res.code === 0) {
+        this.formData = res.data.reorganization
+        this.type = 'update'
+      }
+    } else {
+      this.type = 'create'
+    }
+  },
+  methods: {
+    async save() {
+      let res
+      switch (this.type) {
+        case 'create':
+          res = await createOrganization(this.formData)
+          break
+        case 'update':
+          res = await updateOrganization(this.formData)
+          break
+        default:
+          res = await createOrganization(this.formData)
+          break
+      }
+      if (res.code === 0) {
+        this.$message({
+          type: 'success',
+          message: '创建/更改成功'
+        })
+      }
+    },
+    back() {
+      this.$router.go(-1)
+    }
+  }
+}
+</script>
+
+<style>
+</style>