Browse Source

修复区域更新,新增站点附带问题

zk 2 years ago
parent
commit
a9af2203fc

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

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

+ 142 - 0
server/api/v1/autocode/place_pro.go

@@ -0,0 +1,142 @@
+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/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 PlaceProApi struct {
+}
+
+var placeProService = service.ServiceGroupApp.AutoCodeServiceGroup.PlaceProService
+
+// CreatePlacePro 创建PlacePro
+// @Tags PlacePro
+// @Summary 创建PlacePro
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body autocode.PlacePro true "创建PlacePro"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Router /placePro/createPlacePro [post]
+func (placeProApi *PlaceProApi) CreatePlacePro(c *gin.Context) {
+	var placePro autocode.PlacePro
+	_ = c.ShouldBindJSON(&placePro)
+	if err := placeProService.CreatePlacePro(placePro); err != nil {
+		global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
+		response.FailWithMessage("创建失败", c)
+	} else {
+		response.OkWithMessage("创建成功", c)
+	}
+}
+
+// DeletePlacePro 删除PlacePro
+// @Tags PlacePro
+// @Summary 删除PlacePro
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body autocode.PlacePro true "删除PlacePro"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
+// @Router /placePro/deletePlacePro [delete]
+func (placeProApi *PlaceProApi) DeletePlacePro(c *gin.Context) {
+	var placePro autocode.PlacePro
+	_ = c.ShouldBindJSON(&placePro)
+	if err := placeProService.DeletePlacePro(placePro); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
+		response.FailWithMessage("删除失败", c)
+	} else {
+		response.OkWithMessage("删除成功", c)
+	}
+}
+
+// DeletePlaceProByIds 批量删除PlacePro
+// @Tags PlacePro
+// @Summary 批量删除PlacePro
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body request.IdsReq true "批量删除PlacePro"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
+// @Router /placePro/deletePlaceProByIds [delete]
+func (placeProApi *PlaceProApi) DeletePlaceProByIds(c *gin.Context) {
+	var IDS request.IdsReq
+	_ = c.ShouldBindJSON(&IDS)
+	if err := placeProService.DeletePlaceProByIds(IDS); err != nil {
+		global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
+		response.FailWithMessage("批量删除失败", c)
+	} else {
+		response.OkWithMessage("批量删除成功", c)
+	}
+}
+
+// UpdatePlacePro 更新PlacePro
+// @Tags PlacePro
+// @Summary 更新PlacePro
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body autocode.PlacePro true "更新PlacePro"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
+// @Router /placePro/updatePlacePro [put]
+func (placeProApi *PlaceProApi) UpdatePlacePro(c *gin.Context) {
+	var placePro autocode.PlacePro
+	_ = c.ShouldBindJSON(&placePro)
+	if err := placeProService.UpdatePlacePro(placePro); err != nil {
+		global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
+		response.FailWithMessage("更新失败", c)
+	} else {
+		response.OkWithMessage("更新成功", c)
+	}
+}
+
+// FindPlacePro 用id查询PlacePro
+// @Tags PlacePro
+// @Summary 用id查询PlacePro
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data query autocode.PlacePro true "用id查询PlacePro"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
+// @Router /placePro/findPlacePro [get]
+func (placeProApi *PlaceProApi) FindPlacePro(c *gin.Context) {
+	var placePro autocode.PlacePro
+	_ = c.ShouldBindQuery(&placePro)
+	if err, replacePro := placeProService.GetPlacePro(placePro.ID); err != nil {
+		global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
+		response.FailWithMessage("查询失败", c)
+	} else {
+		response.OkWithData(gin.H{"replacePro": replacePro}, c)
+	}
+}
+
+// GetPlaceProList 分页获取PlacePro列表
+// @Tags PlacePro
+// @Summary 分页获取PlacePro列表
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data query autocodeReq.PlaceProSearch true "分页获取PlacePro列表"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Router /placePro/getPlaceProList [get]
+func (placeProApi *PlaceProApi) GetPlaceProList(c *gin.Context) {
+	var pageInfo autocodeReq.PlaceProSearch
+	_ = c.ShouldBindQuery(&pageInfo)
+	if err, list, total := placeProService.GetPlaceProInfoList(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)
+	}
+}

+ 1 - 0
server/initialize/gorm.go

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

+ 1 - 0
server/initialize/router.go

@@ -79,6 +79,7 @@ func Routers() *gin.Engine {
 		autocodeRouter.InitUnitHistoryRouter(PrivateGroup)
 		autocodeRouter.InitUnitHistoryRouter(PrivateGroup)
 		autocodeRouter.InitProblemReplyRouter(PrivateGroup)
 		autocodeRouter.InitProblemReplyRouter(PrivateGroup)
 		autocodeRouter.InitOrganizationRouter(PrivateGroup)
 		autocodeRouter.InitOrganizationRouter(PrivateGroup)
+		autocodeRouter.InitPlaceProRouter(PrivateGroup)
 		// Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
 		// Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
 	}
 	}
 
 

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

@@ -1,6 +1,8 @@
 // 自动生成模板Organization
 // 自动生成模板Organization
 package autocode
 package autocode
 
 
+import "gorm.io/gorm"
+
 // Organization 结构体
 // Organization 结构体
 // 如果含有time.Time 请自行import time包
 // 如果含有time.Time 请自行import time包
 type Organization struct {
 type Organization struct {
@@ -10,6 +12,7 @@ type Organization struct {
 	Optimistic *int           `json:"optimistic" form:"optimistic" gorm:"column:optimistic;comment:;type:int"`
 	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);"`
 	Postition  string         `json:"postition" form:"postition" gorm:"column:postition;comment:;type:varchar(225);"`
 	Children   []Organization `json:"children" gorm:"-"`
 	Children   []Organization `json:"children" gorm:"-"`
+	DeletedAt  gorm.DeletedAt `gorm:"index" json:"-"` // 删除时间
 }
 }
 
 
 // TableName Organization 表名
 // TableName Organization 表名

+ 19 - 0
server/model/autocode/place_pro.go

@@ -0,0 +1,19 @@
+// 自动生成模板PlacePro
+package autocode
+
+import (
+	"github.com/flipped-aurora/gin-vue-admin/server/global"
+)
+
+// PlacePro 结构体
+// 如果含有time.Time 请自行import time包
+type PlacePro struct {
+	global.GVA_MODEL
+	PlaceId      *int   `json:"placeId" form:"placeId" gorm:"column:place_id;comment:站点id;type:bigint"`
+	PlaceProText string `json:"placeProText" form:"placeProText" gorm:"column:place_pro_text;comment:站点问题;type:varchar(500);"`
+}
+
+// TableName PlacePro 表名
+func (PlacePro) TableName() string {
+	return "place_pro"
+}

+ 11 - 0
server/model/autocode/request/place_pro.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 PlaceProSearch struct {
+	autocode.PlacePro
+	request.PageInfo
+}

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

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

+ 24 - 0
server/router/autocode/place_pro.go

@@ -0,0 +1,24 @@
+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 PlaceProRouter struct {
+}
+
+// InitPlaceProRouter 初始化 PlacePro 路由信息
+func (s *PlaceProRouter) InitPlaceProRouter(Router *gin.RouterGroup) {
+	placeProRouter := Router.Group("placePro").Use(middleware.OperationRecord())
+	var placeProApi = v1.ApiGroupApp.AutoCodeApiGroup.PlaceProApi
+	{
+		placeProRouter.POST("createPlacePro", placeProApi.CreatePlacePro)             // 新建PlacePro
+		placeProRouter.DELETE("deletePlacePro", placeProApi.DeletePlacePro)           // 删除PlacePro
+		placeProRouter.DELETE("deletePlaceProByIds", placeProApi.DeletePlaceProByIds) // 批量删除PlacePro
+		placeProRouter.PUT("updatePlacePro", placeProApi.UpdatePlacePro)              // 更新PlacePro
+		placeProRouter.GET("findPlacePro", placeProApi.FindPlacePro)                  // 根据ID获取PlacePro
+		placeProRouter.GET("getPlaceProList", placeProApi.GetPlaceProList)            // 获取PlacePro列表
+	}
+}

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

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

+ 2 - 2
server/service/autocode/organization.go

@@ -19,7 +19,7 @@ func (organizationService *OrganizationService) CreateOrganization(organization
 // DeleteOrganization 删除Organization记录
 // DeleteOrganization 删除Organization记录
 // Author [piexlmax](https://github.com/piexlmax)
 // Author [piexlmax](https://github.com/piexlmax)
 func (organizationService *OrganizationService) DeleteOrganization(organization autocode.Organization) (err error) {
 func (organizationService *OrganizationService) DeleteOrganization(organization autocode.Organization) (err error) {
-	err = global.GVA_DB.Delete(&organization).Error
+	err = global.GVA_DB.Model(organization).Delete("code = ?", organization.CODE).Error
 	return err
 	return err
 }
 }
 
 
@@ -33,7 +33,7 @@ func (organizationService *OrganizationService) DeleteOrganizationByIds(codes []
 // UpdateOrganization 更新Organization记录
 // UpdateOrganization 更新Organization记录
 // Author [piexlmax](https://github.com/piexlmax)
 // Author [piexlmax](https://github.com/piexlmax)
 func (organizationService *OrganizationService) UpdateOrganization(organization autocode.Organization) (err error) {
 func (organizationService *OrganizationService) UpdateOrganization(organization autocode.Organization) (err error) {
-	err = global.GVA_DB.Save(&organization).Error
+	err = global.GVA_DB.Model(organization).Where("code = ?", organization.CODE).Updates(&organization).Error
 	return err
 	return err
 }
 }
 
 

+ 60 - 0
server/service/autocode/place_pro.go

@@ -0,0 +1,60 @@
+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/request"
+)
+
+type PlaceProService struct {
+}
+
+// CreatePlacePro 创建PlacePro记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (placeProService *PlaceProService) CreatePlacePro(placePro autocode.PlacePro) (err error) {
+	err = global.GVA_DB.Create(&placePro).Error
+	return err
+}
+
+// DeletePlacePro 删除PlacePro记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (placeProService *PlaceProService) DeletePlacePro(placePro autocode.PlacePro) (err error) {
+	err = global.GVA_DB.Delete(&placePro).Error
+	return err
+}
+
+// DeletePlaceProByIds 批量删除PlacePro记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (placeProService *PlaceProService) DeletePlaceProByIds(ids request.IdsReq) (err error) {
+	err = global.GVA_DB.Delete(&[]autocode.PlacePro{}, "id in ?", ids.Ids).Error
+	return err
+}
+
+// UpdatePlacePro 更新PlacePro记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (placeProService *PlaceProService) UpdatePlacePro(placePro autocode.PlacePro) (err error) {
+	err = global.GVA_DB.Save(&placePro).Error
+	return err
+}
+
+// GetPlacePro 根据id获取PlacePro记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (placeProService *PlaceProService) GetPlacePro(id uint) (err error, placePro autocode.PlacePro) {
+	err = global.GVA_DB.Where("id = ?", id).First(&placePro).Error
+	return
+}
+
+// GetPlaceProInfoList 分页获取PlacePro记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (placeProService *PlaceProService) GetPlaceProInfoList(info autoCodeReq.PlaceProSearch) (err error, list interface{}, total int64) {
+	limit := info.PageSize
+	offset := info.PageSize * (info.Page - 1)
+	// 创建db
+	db := global.GVA_DB.Model(&autocode.PlacePro{})
+	var placePros []autocode.PlacePro
+	// 如果有条件搜索 下方会自动创建搜索语句
+	err = db.Count(&total).Error
+	err = db.Limit(limit).Offset(offset).Find(&placePros).Error
+	return err, placePros, total
+}