分类,提交
This commit is contained in:
parent
593bf218f8
commit
484cc1684c
79
api/v1/businesses/classifu_statuse.go
Normal file
79
api/v1/businesses/classifu_statuse.go
Normal file
@ -0,0 +1,79 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成api操作代码。
|
||||
// 生成日期:2025-08-07 14:57:37
|
||||
// 生成路径: api/v1/businesses/classify_statuse.go
|
||||
// 生成人:gfast
|
||||
// desc:分类地位相关参数
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package businesses
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
commonApi "github.com/tiger1103/gfast/v3/api/v1/common"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/model"
|
||||
)
|
||||
|
||||
// ClassifyStatuseSearchReq 分页请求参数
|
||||
type ClassifyStatuseSearchReq struct {
|
||||
g.Meta `path:"/list" tags:"分类地位" method:"get" summary:"分类地位列表"`
|
||||
commonApi.Author
|
||||
model.ClassifyStatuseSearchReq
|
||||
}
|
||||
|
||||
// ClassifyStatuseSearchRes 列表返回结果
|
||||
type ClassifyStatuseSearchRes struct {
|
||||
g.Meta `mime:"application/json"`
|
||||
*model.ClassifyStatuseSearchRes
|
||||
}
|
||||
|
||||
// ClassifyStatuseAddReq 添加操作请求参数
|
||||
type ClassifyStatuseAddReq struct {
|
||||
g.Meta `path:"/add" tags:"分类地位" method:"post" summary:"分类地位添加"`
|
||||
commonApi.Author
|
||||
*model.ClassifyStatuseAddReq
|
||||
}
|
||||
|
||||
// ClassifyStatuseAddRes 添加操作返回结果
|
||||
type ClassifyStatuseAddRes struct {
|
||||
commonApi.EmptyRes
|
||||
}
|
||||
|
||||
// ClassifyStatuseEditReq 修改操作请求参数
|
||||
type ClassifyStatuseEditReq struct {
|
||||
g.Meta `path:"/edit" tags:"分类地位" method:"put" summary:"分类地位修改"`
|
||||
commonApi.Author
|
||||
*model.ClassifyStatuseEditReq
|
||||
}
|
||||
|
||||
// ClassifyStatuseEditRes 修改操作返回结果
|
||||
type ClassifyStatuseEditRes struct {
|
||||
commonApi.EmptyRes
|
||||
}
|
||||
|
||||
// ClassifyStatuseGetReq 获取一条数据请求
|
||||
type ClassifyStatuseGetReq struct {
|
||||
g.Meta `path:"/get" tags:"分类地位" method:"get" summary:"获取分类地位信息"`
|
||||
commonApi.Author
|
||||
Id int `p:"id" v:"required#主键必须"` //通过主键获取
|
||||
}
|
||||
|
||||
// ClassifyStatuseGetRes 获取一条数据结果
|
||||
type ClassifyStatuseGetRes struct {
|
||||
g.Meta `mime:"application/json"`
|
||||
*model.ClassifyStatuseInfoRes
|
||||
}
|
||||
|
||||
// ClassifyStatuseDeleteReq 删除数据请求
|
||||
type ClassifyStatuseDeleteReq struct {
|
||||
g.Meta `path:"/delete" tags:"分类地位" method:"delete" summary:"删除分类地位"`
|
||||
commonApi.Author
|
||||
Ids []int `p:"ids" v:"required#主键必须"` //通过主键删除
|
||||
Version []int `p:"version"`
|
||||
}
|
||||
|
||||
// ClassifyStatuseDeleteRes 删除数据返回
|
||||
type ClassifyStatuseDeleteRes struct {
|
||||
commonApi.EmptyRes
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成api操作代码。
|
||||
// 生成日期:2025-08-06 11:24:51
|
||||
// 生成路径: api/v1/demo/species_name.go
|
||||
// 生成日期:2025-08-07 10:19:19
|
||||
// 生成路径: api/v1/businesses/species_name.go
|
||||
// 生成人:gfast
|
||||
// desc:相关参数
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package demo
|
||||
package businesses
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
@ -69,7 +69,8 @@ type SpeciesNameGetRes struct {
|
||||
type SpeciesNameDeleteReq struct {
|
||||
g.Meta `path:"/delete" tags:"" method:"delete" summary:"删除"`
|
||||
commonApi.Author
|
||||
Ids []int `p:"ids" v:"required#主键必须"` //通过主键删除
|
||||
Ids []int `p:"ids" v:"required#主键必须"` //通过主键删除
|
||||
Versions []int `p:"version"`
|
||||
}
|
||||
|
||||
// SpeciesNameDeleteRes 删除数据返回
|
||||
|
76
internal/app/businesses/common/audit.go
Normal file
76
internal/app/businesses/common/audit.go
Normal file
@ -0,0 +1,76 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/lock"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/system/service"
|
||||
)
|
||||
|
||||
type audit struct{}
|
||||
|
||||
var Audit = new(audit)
|
||||
|
||||
type AuditReq struct {
|
||||
Id int `p:"id" v:"required#主键ID不能为空"`
|
||||
AuditStatus int `p:"auditStatus"`
|
||||
AuditView string `p:"auditView"`
|
||||
AuditUser uint64 `p:"auditUser"`
|
||||
AuditDate *gtime.Time `p:"auditDate"`
|
||||
AuditDept string `p:"auditDept"`
|
||||
Status int `p:"status"`
|
||||
Version int `p:"version"`
|
||||
}
|
||||
|
||||
// Audit 审核逻辑(通用方法)
|
||||
// 参数说明:
|
||||
// - ctx: 请求上下文
|
||||
// - model: 数据表操作对象(如 dao.YourModel.Ctx(ctx))
|
||||
// - req: 审核请求结构体(包含 id, version, 审核状态等)
|
||||
// - save: 实际保存函数,由业务层传入
|
||||
func (c *audit) Audit(
|
||||
ctx context.Context,
|
||||
model *gdb.Model,
|
||||
req *AuditReq,
|
||||
save func(ctx context.Context, req *AuditReq) error,
|
||||
) error {
|
||||
if req.Id == 0 || req.Version == 0 {
|
||||
return errors.New("缺少 ID 或版本号")
|
||||
}
|
||||
if req.AuditStatus == 0 {
|
||||
return errors.New("审核状态不能为空")
|
||||
}
|
||||
|
||||
// 执行乐观锁检查与 version 自增
|
||||
newVersion, err := lock.TryOptimisticLock(ctx, model, "id", req.Id, req.Version)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 填充审核人、时间、新版本号
|
||||
req.Version = newVersion
|
||||
if req.AuditDate == nil {
|
||||
req.AuditDate = gtime.Now()
|
||||
}
|
||||
if req.AuditUser == 0 {
|
||||
req.AuditUser = service.Context().GetUserId(ctx)
|
||||
}
|
||||
// 执行业务 save
|
||||
return save(ctx, req)
|
||||
}
|
||||
func (c *audit) SaveAudit(model *gdb.Model, req *AuditReq) error {
|
||||
_, err := model.Data(g.Map{
|
||||
"audit_status": req.AuditStatus,
|
||||
"audit_user": req.AuditUser,
|
||||
"audit_date": req.AuditDate,
|
||||
"version": req.Version,
|
||||
"audit_view": req.AuditView,
|
||||
"audit_dept": req.AuditDept,
|
||||
"status": req.Status,
|
||||
}).Where("id", req.Id).Update()
|
||||
return err
|
||||
}
|
84
internal/app/businesses/controller/classifu_statuse.go
Normal file
84
internal/app/businesses/controller/classifu_statuse.go
Normal file
@ -0,0 +1,84 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成controller操作代码。
|
||||
// 生成日期:2025-08-07 14:57:37
|
||||
// 生成路径: internal/app/businesses/controller/classify_statuse.go
|
||||
// 生成人:gfast
|
||||
// desc:分类地位
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/tiger1103/gfast/v3/api/v1/businesses"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/common"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/dao"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/service"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/lock"
|
||||
systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
|
||||
)
|
||||
|
||||
type classifyStatuseController struct {
|
||||
systemController.BaseController
|
||||
}
|
||||
|
||||
var ClassifyStatuse = new(classifyStatuseController)
|
||||
|
||||
// List 列表
|
||||
func (c *classifyStatuseController) List(ctx context.Context, req *businesses.ClassifyStatuseSearchReq) (res *businesses.ClassifyStatuseSearchRes, err error) {
|
||||
res = new(businesses.ClassifyStatuseSearchRes)
|
||||
res.ClassifyStatuseSearchRes, err = service.ClassifyStatuse().List(ctx, &req.ClassifyStatuseSearchReq)
|
||||
return
|
||||
}
|
||||
|
||||
// Get 获取分类地位
|
||||
func (c *classifyStatuseController) Get(ctx context.Context, req *businesses.ClassifyStatuseGetReq) (res *businesses.ClassifyStatuseGetRes, err error) {
|
||||
res = new(businesses.ClassifyStatuseGetRes)
|
||||
res.ClassifyStatuseInfoRes, err = service.ClassifyStatuse().GetBySpeciesCode(ctx, req.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// Add 添加分类地位
|
||||
func (c *classifyStatuseController) Add(ctx context.Context, req *businesses.ClassifyStatuseAddReq) (res *businesses.ClassifyStatuseAddRes, err error) {
|
||||
err = service.ClassifyStatuse().Add(ctx, req.ClassifyStatuseAddReq)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改分类地位
|
||||
func (c *classifyStatuseController) Edit(ctx context.Context, req *businesses.ClassifyStatuseEditReq) (res *businesses.ClassifyStatuseEditRes, err error) {
|
||||
newVersion, err := lock.TryOptimisticLock(ctx, dao.ClassifyStatuse.Ctx(ctx), "id", req.Id, req.Version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Version = newVersion
|
||||
err = service.ClassifyStatuse().Edit(ctx, req.ClassifyStatuseEditReq)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除分类地位
|
||||
func (c *classifyStatuseController) Delete(ctx context.Context, req *businesses.ClassifyStatuseDeleteReq) (res *businesses.ClassifyStatuseDeleteRes, err error) {
|
||||
for i, id := range req.Ids {
|
||||
_, err = lock.TryOptimisticLock(ctx, dao.ClassifyStatuse.Ctx(ctx), "id", id, req.Version[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
err = service.ClassifyStatuse().Delete(ctx, req.Ids)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *classifyStatuseController) Audit(ctx context.Context, req *common.AuditReq) (res *g.Map, err error) {
|
||||
err = common.Audit.Audit(ctx, dao.ClassifyStatuse.Ctx(ctx), req, func(ctx context.Context, req *common.AuditReq) error {
|
||||
return common.Audit.SaveAudit(dao.ClassifyStatuse.Ctx(ctx), req)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &g.Map{
|
||||
"msg": "审核成功",
|
||||
"newVersion": req.Version,
|
||||
}, nil
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成controller操作代码。
|
||||
// 生成日期:2025-08-06 11:24:51
|
||||
// 生成路径: internal/app/demo/controller/species_name.go
|
||||
// 生成日期:2025-08-07 10:25:50
|
||||
// 生成路径: internal/app/businesses/controller/species_name.go
|
||||
// 生成人:gfast
|
||||
// desc:
|
||||
// company:云南奇讯科技有限公司
|
||||
@ -12,8 +12,12 @@ package controller
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/tiger1103/gfast/v3/api/v1/businesses"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/common"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/dao"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/service"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/lock"
|
||||
systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
|
||||
)
|
||||
|
||||
@ -24,33 +28,57 @@ type speciesNameController struct {
|
||||
var SpeciesName = new(speciesNameController)
|
||||
|
||||
// List 列表
|
||||
func (c *speciesNameController) List(ctx context.Context, req *demo.SpeciesNameSearchReq) (res *demo.SpeciesNameSearchRes, err error) {
|
||||
res = new(demo.SpeciesNameSearchRes)
|
||||
func (c *speciesNameController) List(ctx context.Context, req *businesses.SpeciesNameSearchReq) (res *businesses.SpeciesNameSearchRes, err error) {
|
||||
res = new(businesses.SpeciesNameSearchRes)
|
||||
res.SpeciesNameSearchRes, err = service.SpeciesName().List(ctx, &req.SpeciesNameSearchReq)
|
||||
return
|
||||
}
|
||||
|
||||
// Get 获取
|
||||
func (c *speciesNameController) Get(ctx context.Context, req *demo.SpeciesNameGetReq) (res *demo.SpeciesNameGetRes, err error) {
|
||||
res = new(demo.SpeciesNameGetRes)
|
||||
func (c *speciesNameController) Get(ctx context.Context, req *businesses.SpeciesNameGetReq) (res *businesses.SpeciesNameGetRes, err error) {
|
||||
res = new(businesses.SpeciesNameGetRes)
|
||||
res.SpeciesNameInfoRes, err = service.SpeciesName().GetById(ctx, req.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// Add 添加
|
||||
func (c *speciesNameController) Add(ctx context.Context, req *demo.SpeciesNameAddReq) (res *demo.SpeciesNameAddRes, err error) {
|
||||
func (c *speciesNameController) Add(ctx context.Context, req *businesses.SpeciesNameAddReq) (res *businesses.SpeciesNameAddRes, err error) {
|
||||
err = service.SpeciesName().Add(ctx, req.SpeciesNameAddReq)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改
|
||||
func (c *speciesNameController) Edit(ctx context.Context, req *demo.SpeciesNameEditReq) (res *demo.SpeciesNameEditRes, err error) {
|
||||
func (c *speciesNameController) Edit(ctx context.Context, req *businesses.SpeciesNameEditReq) (res *businesses.SpeciesNameEditRes, err error) {
|
||||
newVersion, err := lock.TryOptimisticLock(ctx, dao.SpeciesName.Ctx(ctx), "id", req.Id, req.Version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Version = newVersion
|
||||
err = service.SpeciesName().Edit(ctx, req.SpeciesNameEditReq)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (c *speciesNameController) Delete(ctx context.Context, req *demo.SpeciesNameDeleteReq) (res *demo.SpeciesNameDeleteRes, err error) {
|
||||
func (c *speciesNameController) Delete(ctx context.Context, req *businesses.SpeciesNameDeleteReq) (res *businesses.SpeciesNameDeleteRes, err error) {
|
||||
for i, id := range req.Ids {
|
||||
_, err = lock.TryOptimisticLock(ctx, dao.SpeciesName.Ctx(ctx), "id", id, req.Versions[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
err = service.SpeciesName().Delete(ctx, req.Ids)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *speciesNameController) Audit(ctx context.Context, req *common.AuditReq) (res *g.Map, err error) {
|
||||
err = common.Audit.Audit(ctx, dao.SpeciesName.Ctx(ctx), req, func(ctx context.Context, req *common.AuditReq) error {
|
||||
return common.Audit.SaveAudit(dao.SpeciesName.Ctx(ctx), req)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &g.Map{
|
||||
"msg": "审核成功",
|
||||
"newVersion": req.Version,
|
||||
}, nil
|
||||
}
|
||||
|
29
internal/app/businesses/dao/classifu_statuse.go
Normal file
29
internal/app/businesses/dao/classifu_statuse.go
Normal file
@ -0,0 +1,29 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成dao操作代码。
|
||||
// 生成日期:2025-08-07 14:57:37
|
||||
// 生成路径: internal/app/businesses/dao/classify_statuse.go
|
||||
// 生成人:gfast
|
||||
// desc:分类地位
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/dao/internal"
|
||||
)
|
||||
|
||||
// classifyStatuseDao is the manager for logic model data accessing and custom defined data operations functions management.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type classifyStatuseDao struct {
|
||||
*internal.ClassifyStatuseDao
|
||||
}
|
||||
|
||||
var (
|
||||
// ClassifyStatuse is globally public accessible object for table tools_gen_table operations.
|
||||
ClassifyStatuse = classifyStatuseDao{
|
||||
internal.NewClassifyStatuseDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Fill with you ideas below.
|
133
internal/app/businesses/dao/internal/classifu_statuse.go
Normal file
133
internal/app/businesses/dao/internal/classifu_statuse.go
Normal file
@ -0,0 +1,133 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成dao internal操作代码。
|
||||
// 生成日期:2025-08-07 14:57:37
|
||||
// 生成路径: internal/app/businesses/dao/internal/classify_statuse.go
|
||||
// 生成人:gfast
|
||||
// desc:分类地位
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// ClassifyStatuseDao is the manager for logic model data accessing and custom defined data operations functions management.
|
||||
type ClassifyStatuseDao struct {
|
||||
table string // Table is the underlying table name of the DAO.
|
||||
group string // Group is the database configuration group name of current DAO.
|
||||
columns ClassifyStatuseColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// ClassifyStatuseColumns defines and stores column names for table classify_statuse.
|
||||
type ClassifyStatuseColumns struct {
|
||||
Id string //
|
||||
SpeciesCode string // 物种编码
|
||||
Jie string // 界
|
||||
Kingdom string // Kingdom
|
||||
Men string // 门
|
||||
Phylum string // Phylum
|
||||
Gang string // 纲
|
||||
ClassTitle string // Class
|
||||
Mu string // 目
|
||||
OrderTitle string // Order
|
||||
Ke string // 科
|
||||
Family string // Family
|
||||
Shu string // 属
|
||||
Genus string // Genus
|
||||
Zhong string // Genus
|
||||
Species string // Species
|
||||
OtherInfo string // 其他分类信息
|
||||
SourcesData string // 数据来源
|
||||
CreateUser string // 数据采集人
|
||||
CreateDate string // 数据采集日期
|
||||
AuditUser string // 数据核查人
|
||||
AuditDate string // 数据核查日期
|
||||
AuditStatus string // 核查
|
||||
AuditView string // 核查意见
|
||||
Remark string // 备注
|
||||
Version string // 版本
|
||||
CreatedAt string //
|
||||
UpdatedAt string //
|
||||
DeletedAt string //
|
||||
}
|
||||
|
||||
var classifyStatuseColumns = ClassifyStatuseColumns{
|
||||
Id: "id",
|
||||
SpeciesCode: "species_code",
|
||||
Jie: "jie",
|
||||
Kingdom: "kingdom",
|
||||
Men: "men",
|
||||
Phylum: "phylum",
|
||||
Gang: "gang",
|
||||
ClassTitle: "class_title",
|
||||
Mu: "mu",
|
||||
OrderTitle: "order_title",
|
||||
Ke: "ke",
|
||||
Family: "family",
|
||||
Shu: "shu",
|
||||
Genus: "genus",
|
||||
Zhong: "zhong",
|
||||
Species: "species",
|
||||
OtherInfo: "other_info",
|
||||
SourcesData: "sources_data",
|
||||
CreateUser: "create_user",
|
||||
CreateDate: "create_date",
|
||||
AuditUser: "audit_user",
|
||||
AuditDate: "audit_date",
|
||||
AuditStatus: "audit_status",
|
||||
AuditView: "audit_view",
|
||||
Remark: "remark",
|
||||
Version: "version",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewClassifyStatuseDao creates and returns a new DAO object for table data access.
|
||||
func NewClassifyStatuseDao() *ClassifyStatuseDao {
|
||||
return &ClassifyStatuseDao{
|
||||
group: "default",
|
||||
table: "classify_statuse",
|
||||
columns: classifyStatuseColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *ClassifyStatuseDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *ClassifyStatuseDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *ClassifyStatuseDao) Columns() ClassifyStatuseColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *ClassifyStatuseDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *ClassifyStatuseDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
|
||||
// It commits the transaction and returns nil if function f returns nil.
|
||||
//
|
||||
// Note that, you should not Commit or Rollback the transaction in function f
|
||||
// as it is automatically handled by this function.
|
||||
func (dao *ClassifyStatuseDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成dao internal操作代码。
|
||||
// 生成日期:2025-08-06 11:24:51
|
||||
// 生成路径: internal/app/demo/dao/internal/species_name.go
|
||||
// 生成日期:2025-08-07 10:19:19
|
||||
// 生成路径: internal/app/businesses/dao/internal/species_name.go
|
||||
// 生成人:gfast
|
||||
// desc:
|
||||
// company:云南奇讯科技有限公司
|
||||
@ -11,6 +11,7 @@ package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
@ -34,6 +35,12 @@ type SpeciesNameColumns struct {
|
||||
AuditUser string // 数据核查人
|
||||
AuditDate string // 数据核查日期
|
||||
Remark string // 备注
|
||||
AuditStatus string //
|
||||
AuditView string //
|
||||
Version string //
|
||||
CreatedAt string //
|
||||
UpdatedAt string //
|
||||
DeletedAt string //
|
||||
}
|
||||
|
||||
var speciesNameColumns = SpeciesNameColumns{
|
||||
@ -47,6 +54,12 @@ var speciesNameColumns = SpeciesNameColumns{
|
||||
AuditUser: "audit_user",
|
||||
AuditDate: "audit_date",
|
||||
Remark: "remark",
|
||||
AuditStatus: "audit_status",
|
||||
AuditView: "audit_view",
|
||||
Version: "version",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewSpeciesNameDao creates and returns a new DAO object for table data access.
|
||||
|
@ -1,6 +1,17 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成dao操作代码。
|
||||
// 生成日期:2025-08-07 10:19:19
|
||||
// 生成路径: internal/app/businesses/dao/species_name.go
|
||||
// 生成人:gfast
|
||||
// desc:
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import "github.com/tiger1103/gfast/v3/internal/app/businesses/dao/internal"
|
||||
import (
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/dao/internal"
|
||||
)
|
||||
|
||||
// speciesNameDao is the manager for logic model data accessing and custom defined data operations functions management.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
|
241
internal/app/businesses/logic/classifu_statuse.go
Normal file
241
internal/app/businesses/logic/classifu_statuse.go
Normal file
@ -0,0 +1,241 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/dao"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/model"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/model/do"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/service"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/system/consts"
|
||||
"github.com/tiger1103/gfast/v3/library/liberr"
|
||||
)
|
||||
|
||||
func init() {
|
||||
service.RegisterClassifyStatuse(NewClassifyStatuse())
|
||||
}
|
||||
|
||||
func NewClassifyStatuse() service.IClassifyStatuse {
|
||||
return &sClassifyStatuse{}
|
||||
}
|
||||
|
||||
type sClassifyStatuse struct{}
|
||||
|
||||
func (s *sClassifyStatuse) List(ctx context.Context, req *model.ClassifyStatuseSearchReq) (listRes *model.ClassifyStatuseSearchRes, err error) {
|
||||
listRes = new(model.ClassifyStatuseSearchRes)
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
m := dao.ClassifyStatuse.Ctx(ctx).WithAll()
|
||||
if req.Id != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().Id+" = ?", req.Id)
|
||||
}
|
||||
if req.SpeciesCode != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().SpeciesCode+" like ?", "%"+req.SpeciesCode+"%")
|
||||
}
|
||||
if req.Jie != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().Jie+" like ?", "%"+req.Jie+"%")
|
||||
}
|
||||
if req.Kingdom != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().Kingdom+" like ?", "%"+req.Kingdom+"%")
|
||||
}
|
||||
if req.Men != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().Men+" like ?", "%"+req.Men+"%")
|
||||
}
|
||||
if req.Phylum != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().Phylum+" like ?", "%"+req.Phylum+"%")
|
||||
}
|
||||
if req.Gang != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().Gang+" like ?", "%"+req.Gang+"%")
|
||||
}
|
||||
if req.ClassTitle != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().ClassTitle+" like ?", "%"+req.ClassTitle+"%")
|
||||
}
|
||||
if req.Mu != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().Mu+" like ?", "%"+req.Mu+"%")
|
||||
}
|
||||
if req.OrderTitle != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().OrderTitle+" like ?", "%"+req.OrderTitle+"%")
|
||||
}
|
||||
if req.Ke != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().Ke+" like ?", "%"+req.Ke+"%")
|
||||
}
|
||||
if req.Family != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().Family+" like ?", "%"+req.Family+"%")
|
||||
}
|
||||
if req.Shu != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().Shu+" like ?", "%"+req.Shu+"%")
|
||||
}
|
||||
if req.Genus != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().Genus+" like ?", "%"+req.Genus+"%")
|
||||
}
|
||||
if req.Zhong != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().Zhong+" like ?", "%"+req.Zhong+"%")
|
||||
}
|
||||
if req.Species != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().Species+" like ?", "%"+req.Species+"%")
|
||||
}
|
||||
if req.SourcesData != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().SourcesData+" like ?", "%"+req.SourcesData+"%")
|
||||
}
|
||||
if req.CreateUser != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().CreateUser+" = ?", gconv.Int(req.CreateUser))
|
||||
}
|
||||
if req.CreateDate != nil {
|
||||
start := req.CreateDate[0]
|
||||
end := req.CreateDate[1]
|
||||
if start != nil && end != nil {
|
||||
m = m.Where(
|
||||
dao.ClassifyStatuse.Columns().CreateDate+" >= ? AND "+
|
||||
dao.ClassifyStatuse.Columns().CreateDate+" <= ?",
|
||||
start,
|
||||
end,
|
||||
)
|
||||
}
|
||||
}
|
||||
if req.AuditUser != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().AuditUser+" = ?", gconv.Int(req.AuditUser))
|
||||
}
|
||||
if req.AuditDate != nil {
|
||||
start := req.AuditDate[0]
|
||||
end := req.AuditDate[1]
|
||||
if start != nil && end != nil {
|
||||
m = m.Where(
|
||||
dao.ClassifyStatuse.Columns().AuditDate+" >= ? AND "+
|
||||
dao.ClassifyStatuse.Columns().AuditDate+" <= ?",
|
||||
start,
|
||||
end,
|
||||
)
|
||||
}
|
||||
}
|
||||
if req.AuditStatus != "" {
|
||||
m = m.Where(dao.ClassifyStatuse.Columns().AuditStatus+" = ?", gconv.Int(req.AuditStatus))
|
||||
}
|
||||
listRes.Total, err = m.Count()
|
||||
liberr.ErrIsNil(ctx, err, "获取总行数失败")
|
||||
if req.PageNum == 0 {
|
||||
req.PageNum = 1
|
||||
}
|
||||
listRes.CurrentPage = req.PageNum
|
||||
if req.PageSize == 0 {
|
||||
req.PageSize = consts.PageSize
|
||||
}
|
||||
order := "id asc"
|
||||
if req.OrderBy != "" {
|
||||
order = req.OrderBy
|
||||
}
|
||||
var res []*model.ClassifyStatuseListRes
|
||||
err = m.Page(req.PageNum, req.PageSize).Order(order).Scan(&res)
|
||||
liberr.ErrIsNil(ctx, err, "获取数据失败")
|
||||
listRes.List = make([]*model.ClassifyStatuseListRes, len(res))
|
||||
for k, v := range res {
|
||||
listRes.List[k] = &model.ClassifyStatuseListRes{
|
||||
Id: v.Id,
|
||||
SpeciesCode: v.SpeciesCode,
|
||||
Jie: v.Jie,
|
||||
Kingdom: v.Kingdom,
|
||||
Men: v.Men,
|
||||
Phylum: v.Phylum,
|
||||
Gang: v.Gang,
|
||||
ClassTitle: v.ClassTitle,
|
||||
Mu: v.Mu,
|
||||
OrderTitle: v.OrderTitle,
|
||||
Ke: v.Ke,
|
||||
Family: v.Family,
|
||||
Shu: v.Shu,
|
||||
Genus: v.Genus,
|
||||
Zhong: v.Zhong,
|
||||
Species: v.Species,
|
||||
OtherInfo: v.OtherInfo,
|
||||
SourcesData: v.SourcesData,
|
||||
CreateUser: v.CreateUser,
|
||||
CreateDate: v.CreateDate,
|
||||
AuditUser: v.AuditUser,
|
||||
AuditDate: v.AuditDate,
|
||||
AuditStatus: v.AuditStatus,
|
||||
AuditView: v.AuditView,
|
||||
Remark: v.Remark,
|
||||
Version: v.Version,
|
||||
CreatedAt: v.CreatedAt,
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sClassifyStatuse) GetBySpeciesCode(ctx context.Context, id int) (res *model.ClassifyStatuseInfoRes, err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
err = dao.ClassifyStatuse.Ctx(ctx).WithAll().Where(dao.ClassifyStatuse.Columns().SpeciesCode, id).Scan(&res)
|
||||
liberr.ErrIsNil(ctx, err, "获取信息失败")
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sClassifyStatuse) Add(ctx context.Context, req *model.ClassifyStatuseAddReq) (err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
_, err = dao.ClassifyStatuse.Ctx(ctx).Insert(do.ClassifyStatuse{
|
||||
Id: req.Id,
|
||||
Jie: req.Jie,
|
||||
Kingdom: req.Kingdom,
|
||||
Men: req.Men,
|
||||
Phylum: req.Phylum,
|
||||
Gang: req.Gang,
|
||||
ClassTitle: req.ClassTitle,
|
||||
Mu: req.Mu,
|
||||
OrderTitle: req.OrderTitle,
|
||||
Ke: req.Ke,
|
||||
Family: req.Family,
|
||||
Shu: req.Shu,
|
||||
Genus: req.Genus,
|
||||
Zhong: req.Zhong,
|
||||
Species: req.Species,
|
||||
OtherInfo: req.OtherInfo,
|
||||
SourcesData: req.SourcesData,
|
||||
CreateUser: req.CreateUser,
|
||||
CreateDate: req.CreateDate,
|
||||
AuditStatus: req.AuditStatus,
|
||||
Remark: req.Remark,
|
||||
SpeciesCode: req.SpeciesCode,
|
||||
})
|
||||
liberr.ErrIsNil(ctx, err, "添加失败")
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sClassifyStatuse) Edit(ctx context.Context, req *model.ClassifyStatuseEditReq) (err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
_, err = dao.ClassifyStatuse.Ctx(ctx).WherePri(req.Id).Update(do.ClassifyStatuse{
|
||||
Jie: req.Jie,
|
||||
Kingdom: req.Kingdom,
|
||||
SpeciesCode: req.SpeciesCode,
|
||||
Men: req.Men,
|
||||
Phylum: req.Phylum,
|
||||
Gang: req.Gang,
|
||||
ClassTitle: req.ClassTitle,
|
||||
Mu: req.Mu,
|
||||
OrderTitle: req.OrderTitle,
|
||||
Ke: req.Ke,
|
||||
Family: req.Family,
|
||||
Shu: req.Shu,
|
||||
Genus: req.Genus,
|
||||
Zhong: req.Zhong,
|
||||
Species: req.Species,
|
||||
OtherInfo: req.OtherInfo,
|
||||
SourcesData: req.SourcesData,
|
||||
CreateUser: req.CreateUser,
|
||||
CreateDate: req.CreateDate,
|
||||
Remark: req.Remark,
|
||||
Version: req.Version,
|
||||
})
|
||||
liberr.ErrIsNil(ctx, err, "修改失败")
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sClassifyStatuse) Delete(ctx context.Context, ids []int) (err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
_, err = dao.ClassifyStatuse.Ctx(ctx).Delete(dao.ClassifyStatuse.Columns().Id+" in (?)", ids)
|
||||
liberr.ErrIsNil(ctx, err, "删除失败")
|
||||
})
|
||||
return
|
||||
}
|
@ -14,10 +14,10 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
service.RegisterSpeciesName(New())
|
||||
service.RegisterSpeciesName(NewSpeciesName())
|
||||
}
|
||||
|
||||
func New() service.ISpeciesName {
|
||||
func NewSpeciesName() service.ISpeciesName {
|
||||
return &sSpeciesName{}
|
||||
}
|
||||
|
||||
@ -31,28 +31,46 @@ func (s *sSpeciesName) List(ctx context.Context, req *model.SpeciesNameSearchReq
|
||||
m = m.Where(dao.SpeciesName.Columns().Id+" = ?", req.Id)
|
||||
}
|
||||
if req.SpeciesCode != "" {
|
||||
m = m.Where(dao.SpeciesName.Columns().SpeciesCode+" = ?", req.SpeciesCode)
|
||||
m = m.Where(dao.SpeciesName.Columns().SpeciesCode+" like ?", "%"+req.SpeciesCode+"%")
|
||||
}
|
||||
if req.Name != "" {
|
||||
m = m.Where(dao.SpeciesName.Columns().Name+" like ?", "%"+req.Name+"%")
|
||||
}
|
||||
if req.Content != "" {
|
||||
m = m.Where(dao.SpeciesName.Columns().Content+" = ?", req.Content)
|
||||
}
|
||||
if req.SourcesData != "" {
|
||||
m = m.Where(dao.SpeciesName.Columns().SourcesData+" = ?", req.SourcesData)
|
||||
m = m.Where(dao.SpeciesName.Columns().SourcesData+" like ?", "%"+req.SourcesData+"%")
|
||||
}
|
||||
if req.CreateUser != "" {
|
||||
m = m.Where(dao.SpeciesName.Columns().CreateUser+" = ?", gconv.Int(req.CreateUser))
|
||||
}
|
||||
if req.CreateDate != "" {
|
||||
m = m.Where(dao.SpeciesName.Columns().CreateDate+" = ?", gconv.Time(req.CreateDate))
|
||||
if req.CreateDate != nil {
|
||||
start := req.CreateDate[0]
|
||||
end := req.CreateDate[1]
|
||||
if start != nil && end != nil {
|
||||
m = m.Where(
|
||||
dao.SpeciesName.Columns().CreateDate+" >= ? AND "+
|
||||
dao.SpeciesName.Columns().CreateDate+" <= ?",
|
||||
start,
|
||||
end,
|
||||
)
|
||||
}
|
||||
}
|
||||
if req.AuditUser != "" {
|
||||
m = m.Where(dao.SpeciesName.Columns().AuditUser+" = ?", gconv.Int(req.AuditUser))
|
||||
}
|
||||
if req.AuditDate != "" {
|
||||
m = m.Where(dao.SpeciesName.Columns().AuditDate+" = ?", gconv.Time(req.AuditDate))
|
||||
if req.AuditDate != nil {
|
||||
start := req.AuditDate[0]
|
||||
end := req.AuditDate[1]
|
||||
if start != nil && end != nil {
|
||||
m = m.Where(
|
||||
dao.SpeciesName.Columns().AuditDate+" >= ? AND "+
|
||||
dao.SpeciesName.Columns().AuditDate+" <= ?",
|
||||
start,
|
||||
end,
|
||||
)
|
||||
}
|
||||
}
|
||||
if req.AuditStatus != "" {
|
||||
m = m.Where(dao.SpeciesName.Columns().AuditStatus+" = ?", gconv.Int(req.AuditStatus))
|
||||
}
|
||||
listRes.Total, err = m.Count()
|
||||
liberr.ErrIsNil(ctx, err, "获取总行数失败")
|
||||
@ -83,6 +101,10 @@ func (s *sSpeciesName) List(ctx context.Context, req *model.SpeciesNameSearchReq
|
||||
AuditUser: v.AuditUser,
|
||||
AuditDate: v.AuditDate,
|
||||
Remark: v.Remark,
|
||||
AuditStatus: v.AuditStatus,
|
||||
AuditView: v.AuditView,
|
||||
Version: v.Version,
|
||||
CreatedAt: v.CreatedAt,
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -127,6 +149,9 @@ func (s *sSpeciesName) Edit(ctx context.Context, req *model.SpeciesNameEditReq)
|
||||
AuditUser: req.AuditUser,
|
||||
AuditDate: req.AuditDate,
|
||||
Remark: req.Remark,
|
||||
AuditStatus: req.AuditStatus,
|
||||
AuditView: req.AuditView,
|
||||
Version: req.Version,
|
||||
})
|
||||
liberr.ErrIsNil(ctx, err, "修改失败")
|
||||
})
|
||||
|
174
internal/app/businesses/model/classifu_statuse.go
Normal file
174
internal/app/businesses/model/classifu_statuse.go
Normal file
@ -0,0 +1,174 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成model操作代码。
|
||||
// 生成日期:2025-08-07 14:57:37
|
||||
// 生成路径: internal/app/businesses/model/classify_statuse.go
|
||||
// 生成人:gfast
|
||||
// desc:分类地位
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gmeta"
|
||||
comModel "github.com/tiger1103/gfast/v3/internal/app/common/model"
|
||||
)
|
||||
|
||||
// ClassifyStatuseInfoRes is the golang structure for table classify_statuse.
|
||||
type ClassifyStatuseInfoRes struct {
|
||||
gmeta.Meta `orm:"table:classify_statuse"`
|
||||
Id int `orm:"id,primary" json:"id" dc:""` //
|
||||
SpeciesCode string `orm:"species_code,primary" json:"speciesCode" dc:"物种编码"` // 物种编码
|
||||
Jie string `orm:"jie" json:"jie" dc:"界"` // 界
|
||||
Kingdom string `orm:"kingdom" json:"kingdom" dc:"Kingdom"` // Kingdom
|
||||
Men string `orm:"men" json:"men" dc:"门"` // 门
|
||||
Phylum string `orm:"phylum" json:"phylum" dc:"Phylum"` // Phylum
|
||||
Gang string `orm:"gang" json:"gang" dc:"纲"` // 纲
|
||||
ClassTitle string `orm:"class_title" json:"classTitle" dc:"Class"` // Class
|
||||
Mu string `orm:"mu" json:"mu" dc:"目"` // 目
|
||||
OrderTitle string `orm:"order_title" json:"orderTitle" dc:"Order"` // Order
|
||||
Ke string `orm:"ke" json:"ke" dc:"科"` // 科
|
||||
Family string `orm:"family" json:"family" dc:"Family"` // Family
|
||||
Shu string `orm:"shu" json:"shu" dc:"属"` // 属
|
||||
Genus string `orm:"genus" json:"genus" dc:"Genus"` // Genus
|
||||
Zhong string `orm:"zhong" json:"zhong" dc:"Genus"` // Genus
|
||||
Species string `orm:"species" json:"species" dc:"Species"` // Species
|
||||
OtherInfo string `orm:"other_info" json:"otherInfo" dc:"其他分类信息"` // 其他分类信息
|
||||
SourcesData string `orm:"sources_data" json:"sourcesData" dc:"数据来源"` // 数据来源
|
||||
CreateUser int `orm:"create_user" json:"createUser" dc:"数据采集人"` // 数据采集人
|
||||
CreateDate *gtime.Time `orm:"create_date" json:"createDate" dc:"数据采集日期"` // 数据采集日期
|
||||
AuditUser int `orm:"audit_user" json:"auditUser" dc:"数据核查人"` // 数据核查人
|
||||
AuditDate *gtime.Time `orm:"audit_date" json:"auditDate" dc:"数据核查日期"` // 数据核查日期
|
||||
AuditStatus int `orm:"audit_status" json:"auditStatus" dc:"核查"` // 核查
|
||||
AuditView string `orm:"audit_view" json:"auditView" dc:"核查意见"` // 核查意见
|
||||
Remark string `orm:"remark" json:"remark" dc:"备注"` // 备注
|
||||
Version int `orm:"version" json:"version" dc:"版本"` // 版本
|
||||
CreatedAt *gtime.Time `orm:"created_at" json:"createdAt" dc:""` //
|
||||
UpdatedAt *gtime.Time `orm:"updated_at" json:"updatedAt" dc:""` //
|
||||
DeletedAt *gtime.Time `orm:"deleted_at" json:"deletedAt" dc:""` //
|
||||
}
|
||||
|
||||
type ClassifyStatuseListRes struct {
|
||||
Id int `json:"id" dc:""`
|
||||
SpeciesCode string `json:"speciesCode" dc:"物种编码"`
|
||||
Jie string `json:"jie" dc:"界"`
|
||||
Kingdom string `json:"kingdom" dc:"Kingdom"`
|
||||
Men string `json:"men" dc:"门"`
|
||||
Phylum string `json:"phylum" dc:"Phylum"`
|
||||
Gang string `json:"gang" dc:"纲"`
|
||||
ClassTitle string `json:"classTitle" dc:"Class"`
|
||||
Mu string `json:"mu" dc:"目"`
|
||||
OrderTitle string `json:"orderTitle" dc:"Order"`
|
||||
Ke string `json:"ke" dc:"科"`
|
||||
Family string `json:"family" dc:"Family"`
|
||||
Shu string `json:"shu" dc:"属"`
|
||||
Genus string `json:"genus" dc:"Genus"`
|
||||
Zhong string `json:"zhong" dc:"Genus"`
|
||||
Species string `json:"species" dc:"Species"`
|
||||
OtherInfo string `json:"otherInfo" dc:"其他分类信息"`
|
||||
SourcesData string `json:"sourcesData" dc:"数据来源"`
|
||||
CreateUser int `json:"createUser" dc:"数据采集人"`
|
||||
CreateDate *gtime.Time `json:"createDate" dc:"数据采集日期"`
|
||||
AuditUser int `json:"auditUser" dc:"数据核查人"`
|
||||
AuditDate *gtime.Time `json:"auditDate" dc:"数据核查日期"`
|
||||
AuditStatus int `json:"auditStatus" dc:"核查"`
|
||||
AuditView string `json:"auditView" dc:"核查意见"`
|
||||
Remark string `json:"remark" dc:"备注"`
|
||||
Version int `json:"version" dc:"版本"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:""`
|
||||
}
|
||||
|
||||
// ClassifyStatuseSearchReq 分页请求参数
|
||||
type ClassifyStatuseSearchReq struct {
|
||||
comModel.PageReq
|
||||
Id string `p:"id" dc:""` //
|
||||
SpeciesCode string `p:"speciesCode" dc:"物种编码"` //物种编码
|
||||
Jie string `p:"jie" dc:"界"` //界
|
||||
Kingdom string `p:"kingdom" dc:"Kingdom"` //Kingdom
|
||||
Men string `p:"men" dc:"门"` //门
|
||||
Phylum string `p:"phylum" dc:"Phylum"` //Phylum
|
||||
Gang string `p:"gang" dc:"纲"` //纲
|
||||
ClassTitle string `p:"classTitle" dc:"Class"` //Class
|
||||
Mu string `p:"mu" dc:"目"` //目
|
||||
OrderTitle string `p:"orderTitle" dc:"Order"` //Order
|
||||
Ke string `p:"ke" dc:"科"` //科
|
||||
Family string `p:"family" dc:"Family"` //Family
|
||||
Shu string `p:"shu" dc:"属"` //属
|
||||
Genus string `p:"genus" dc:"Genus"` //Genus
|
||||
Zhong string `p:"zhong" dc:"Genus"` //Genus
|
||||
Species string `p:"species" dc:"Species"` //Species
|
||||
SourcesData string `p:"sourcesData" dc:"数据来源"` //数据来源
|
||||
CreateUser string `p:"createUser" dc:"数据采集人"` //数据采集人
|
||||
CreateDate []*gtime.Time `p:"createDate" dc:"数据采集日期"` //数据采集日期
|
||||
AuditUser string `p:"auditUser" dc:"数据核查人"` //数据核查人
|
||||
AuditDate []*gtime.Time `p:"auditDate" dc:"数据核查日期"` //数据核查日期
|
||||
AuditStatus string `p:"auditStatus" dc:"核查"` //核查
|
||||
}
|
||||
|
||||
// ClassifyStatuseSearchRes 列表返回结果
|
||||
type ClassifyStatuseSearchRes struct {
|
||||
comModel.ListRes
|
||||
List []*ClassifyStatuseListRes `json:"list"`
|
||||
}
|
||||
|
||||
// ClassifyStatuseAddReq 添加操作请求参数
|
||||
type ClassifyStatuseAddReq struct {
|
||||
Id int `p:"id" `
|
||||
SpeciesCode string `p:"speciesCode" dc:"物种编码"` //物种编码
|
||||
Jie string `p:"jie" dc:"界"`
|
||||
Kingdom string `p:"kingdom" dc:"Kingdom"`
|
||||
Men string `p:"men" dc:"门"`
|
||||
Phylum string `p:"phylum" dc:"Phylum"`
|
||||
Gang string `p:"gang" dc:"纲"`
|
||||
ClassTitle string `p:"classTitle" dc:"Class"`
|
||||
Mu string `p:"mu" dc:"目"`
|
||||
OrderTitle string `p:"orderTitle" dc:"Order"`
|
||||
Ke string `p:"ke" dc:"科"`
|
||||
Family string `p:"family" dc:"Family"`
|
||||
Shu string `p:"shu" dc:"属"`
|
||||
Genus string `p:"genus" dc:"Genus"`
|
||||
Zhong string `p:"zhong" dc:"Genus"`
|
||||
Species string `p:"species" dc:"Species"`
|
||||
OtherInfo string `p:"otherInfo" dc:"其他分类信息"`
|
||||
SourcesData string `p:"sourcesData" dc:"数据来源"`
|
||||
CreateUser int `p:"createUser" dc:"数据采集人"`
|
||||
CreateDate *gtime.Time `p:"createDate" dc:"数据采集日期"`
|
||||
//AuditUser int `p:"auditUser" dc:"数据核查人"`
|
||||
//AuditDate *gtime.Time `p:"auditDate" dc:"数据核查日期"`
|
||||
AuditStatus int `p:"auditStatus"`
|
||||
//AuditView string `p:"auditView" dc:"核查意见"`
|
||||
Remark string `p:"remark" dc:"备注"`
|
||||
//Version int `p:"version" dc:"版本"`
|
||||
}
|
||||
|
||||
// ClassifyStatuseEditReq 修改操作请求参数
|
||||
type ClassifyStatuseEditReq struct {
|
||||
Id int `p:"id" v:"required#主键ID不能为空" dc:""`
|
||||
SpeciesCode string `p:"speciesCode" dc:"物种编码"` //物种编码
|
||||
|
||||
Jie string `p:"jie" dc:"界"`
|
||||
Kingdom string `p:"kingdom" dc:"Kingdom"`
|
||||
Men string `p:"men" dc:"门"`
|
||||
Phylum string `p:"phylum" dc:"Phylum"`
|
||||
Gang string `p:"gang" dc:"纲"`
|
||||
ClassTitle string `p:"classTitle" dc:"Class"`
|
||||
Mu string `p:"mu" dc:"目"`
|
||||
OrderTitle string `p:"orderTitle" dc:"Order"`
|
||||
Ke string `p:"ke" dc:"科"`
|
||||
Family string `p:"family" dc:"Family"`
|
||||
Shu string `p:"shu" dc:"属"`
|
||||
Genus string `p:"genus" dc:"Genus"`
|
||||
Zhong string `p:"zhong" dc:"Genus"`
|
||||
Species string `p:"species" dc:"Species"`
|
||||
OtherInfo string `p:"otherInfo" dc:"其他分类信息"`
|
||||
SourcesData string `p:"sourcesData" dc:"数据来源"`
|
||||
CreateUser int `p:"createUser" dc:"数据采集人"`
|
||||
CreateDate *gtime.Time `p:"createDate" dc:"数据采集日期"`
|
||||
//AuditUser int `p:"auditUser" dc:"数据核查人"`
|
||||
//AuditDate *gtime.Time `p:"auditDate" dc:"数据核查日期"`
|
||||
//AuditStatus int `p:"auditStatus" v:"required#核查不能为空" dc:"核查"`
|
||||
//AuditView string `p:"auditView" dc:"核查意见"`
|
||||
Remark string `p:"remark" dc:"备注"`
|
||||
Version int `p:"version" dc:"版本"`
|
||||
}
|
49
internal/app/businesses/model/do/classifu_statuse.go
Normal file
49
internal/app/businesses/model/do/classifu_statuse.go
Normal file
@ -0,0 +1,49 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成model entity操作代码。
|
||||
// 生成日期:2025-08-07 14:57:37
|
||||
// 生成路径: internal/app/businesses/model/entity/classify_statuse.go
|
||||
// 生成人:gfast
|
||||
// desc:分类地位
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package do
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gmeta"
|
||||
)
|
||||
|
||||
// ClassifyStatuse is the golang structure for table classify_statuse.
|
||||
type ClassifyStatuse struct {
|
||||
gmeta.Meta `orm:"table:classify_statuse, do:true"`
|
||||
Id interface{} `orm:"id,primary" json:"id"` //
|
||||
SpeciesCode interface{} `orm:"species_code,primary" json:"speciesCode"` // 物种编码
|
||||
Jie interface{} `orm:"jie" json:"jie"` // 界
|
||||
Kingdom interface{} `orm:"kingdom" json:"kingdom"` // Kingdom
|
||||
Men interface{} `orm:"men" json:"men"` // 门
|
||||
Phylum interface{} `orm:"phylum" json:"phylum"` // Phylum
|
||||
Gang interface{} `orm:"gang" json:"gang"` // 纲
|
||||
ClassTitle interface{} `orm:"class_title" json:"classTitle"` // Class
|
||||
Mu interface{} `orm:"mu" json:"mu"` // 目
|
||||
OrderTitle interface{} `orm:"order_title" json:"orderTitle"` // Order
|
||||
Ke interface{} `orm:"ke" json:"ke"` // 科
|
||||
Family interface{} `orm:"family" json:"family"` // Family
|
||||
Shu interface{} `orm:"shu" json:"shu"` // 属
|
||||
Genus interface{} `orm:"genus" json:"genus"` // Genus
|
||||
Zhong interface{} `orm:"zhong" json:"zhong"` // Genus
|
||||
Species interface{} `orm:"species" json:"species"` // Species
|
||||
OtherInfo interface{} `orm:"other_info" json:"otherInfo"` // 其他分类信息
|
||||
SourcesData interface{} `orm:"sources_data" json:"sourcesData"` // 数据来源
|
||||
CreateUser interface{} `orm:"create_user" json:"createUser"` // 数据采集人
|
||||
CreateDate *gtime.Time `orm:"create_date" json:"createDate"` // 数据采集日期
|
||||
AuditUser interface{} `orm:"audit_user" json:"auditUser"` // 数据核查人
|
||||
AuditDate *gtime.Time `orm:"audit_date" json:"auditDate"` // 数据核查日期
|
||||
AuditStatus interface{} `orm:"audit_status" json:"auditStatus"` // 核查
|
||||
AuditView interface{} `orm:"audit_view" json:"auditView"` // 核查意见
|
||||
Remark interface{} `orm:"remark" json:"remark"` // 备注
|
||||
Version interface{} `orm:"version" json:"version"` // 版本
|
||||
CreatedAt *gtime.Time `orm:"created_at" json:"createdAt"` //
|
||||
UpdatedAt *gtime.Time `orm:"updated_at" json:"updatedAt"` //
|
||||
DeletedAt *gtime.Time `orm:"deleted_at" json:"deletedAt"` //
|
||||
}
|
@ -1,3 +1,12 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成model entity操作代码。
|
||||
// 生成日期:2025-08-07 10:19:19
|
||||
// 生成路径: internal/app/businesses/model/entity/species_name.go
|
||||
// 生成人:gfast
|
||||
// desc:
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package do
|
||||
|
||||
import (
|
||||
@ -18,4 +27,10 @@ type SpeciesName struct {
|
||||
AuditUser interface{} `orm:"audit_user" json:"auditUser"` // 数据核查人
|
||||
AuditDate *gtime.Time `orm:"audit_date" json:"auditDate"` // 数据核查日期
|
||||
Remark interface{} `orm:"remark" json:"remark"` // 备注
|
||||
AuditStatus interface{} `orm:"audit_status" json:"auditStatus"` //
|
||||
AuditView interface{} `orm:"audit_view" json:"auditView"` //
|
||||
Version interface{} `orm:"version" json:"version"` //
|
||||
CreatedAt *gtime.Time `orm:"created_at" json:"createdAt"` //
|
||||
UpdatedAt *gtime.Time `orm:"updated_at" json:"updatedAt"` //
|
||||
DeletedAt *gtime.Time `orm:"deleted_at" json:"deletedAt"` //
|
||||
}
|
||||
|
49
internal/app/businesses/model/entity/classifu_statuse.go
Normal file
49
internal/app/businesses/model/entity/classifu_statuse.go
Normal file
@ -0,0 +1,49 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成model entity操作代码。
|
||||
// 生成日期:2025-08-07 14:57:37
|
||||
// 生成路径: internal/app/businesses/model/entity/classify_statuse.go
|
||||
// 生成人:gfast
|
||||
// desc:分类地位
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package entity
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gmeta"
|
||||
)
|
||||
|
||||
// ClassifyStatuse is the golang structure for table classify_statuse.
|
||||
type ClassifyStatuse struct {
|
||||
gmeta.Meta `orm:"table:classify_statuse"`
|
||||
Id int `orm:"id,primary" json:"id"` //
|
||||
SpeciesCode string `orm:"species_code,primary" json:"speciesCode"` // 物种编码
|
||||
Jie string `orm:"jie" json:"jie"` // 界
|
||||
Kingdom string `orm:"kingdom" json:"kingdom"` // Kingdom
|
||||
Men string `orm:"men" json:"men"` // 门
|
||||
Phylum string `orm:"phylum" json:"phylum"` // Phylum
|
||||
Gang string `orm:"gang" json:"gang"` // 纲
|
||||
ClassTitle string `orm:"class_title" json:"classTitle"` // Class
|
||||
Mu string `orm:"mu" json:"mu"` // 目
|
||||
OrderTitle string `orm:"order_title" json:"orderTitle"` // Order
|
||||
Ke string `orm:"ke" json:"ke"` // 科
|
||||
Family string `orm:"family" json:"family"` // Family
|
||||
Shu string `orm:"shu" json:"shu"` // 属
|
||||
Genus string `orm:"genus" json:"genus"` // Genus
|
||||
Zhong string `orm:"zhong" json:"zhong"` // Genus
|
||||
Species string `orm:"species" json:"species"` // Species
|
||||
OtherInfo string `orm:"other_info" json:"otherInfo"` // 其他分类信息
|
||||
SourcesData string `orm:"sources_data" json:"sourcesData"` // 数据来源
|
||||
CreateUser int `orm:"create_user" json:"createUser"` // 数据采集人
|
||||
CreateDate *gtime.Time `orm:"create_date" json:"createDate"` // 数据采集日期
|
||||
AuditUser int `orm:"audit_user" json:"auditUser"` // 数据核查人
|
||||
AuditDate *gtime.Time `orm:"audit_date" json:"auditDate"` // 数据核查日期
|
||||
AuditStatus int `orm:"audit_status" json:"auditStatus"` // 核查
|
||||
AuditView string `orm:"audit_view" json:"auditView"` // 核查意见
|
||||
Remark string `orm:"remark" json:"remark"` // 备注
|
||||
Version int `orm:"version" json:"version"` // 版本
|
||||
CreatedAt *gtime.Time `orm:"created_at" json:"createdAt"` //
|
||||
UpdatedAt *gtime.Time `orm:"updated_at" json:"updatedAt"` //
|
||||
DeletedAt *gtime.Time `orm:"deleted_at" json:"deletedAt"` //
|
||||
}
|
@ -1,3 +1,12 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成model entity操作代码。
|
||||
// 生成日期:2025-08-07 10:19:19
|
||||
// 生成路径: internal/app/businesses/model/entity/species_name.go
|
||||
// 生成人:gfast
|
||||
// desc:
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package entity
|
||||
|
||||
import (
|
||||
@ -18,4 +27,10 @@ type SpeciesName struct {
|
||||
AuditUser int `orm:"audit_user" json:"auditUser"` // 数据核查人
|
||||
AuditDate *gtime.Time `orm:"audit_date" json:"auditDate"` // 数据核查日期
|
||||
Remark string `orm:"remark" json:"remark"` // 备注
|
||||
AuditStatus int `orm:"audit_status" json:"auditStatus"` //
|
||||
AuditView string `orm:"audit_view" json:"auditView"` //
|
||||
Version int `orm:"version" json:"version"` //
|
||||
CreatedAt *gtime.Time `orm:"created_at" json:"createdAt"` //
|
||||
UpdatedAt *gtime.Time `orm:"updated_at" json:"updatedAt"` //
|
||||
DeletedAt *gtime.Time `orm:"deleted_at" json:"deletedAt"` //
|
||||
}
|
||||
|
@ -1,3 +1,12 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成model操作代码。
|
||||
// 生成日期:2025-08-07 10:19:19
|
||||
// 生成路径: internal/app/businesses/model/species_name.go
|
||||
// 生成人:gfast
|
||||
// desc:
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
@ -19,6 +28,12 @@ type SpeciesNameInfoRes struct {
|
||||
AuditUser int `orm:"audit_user" json:"auditUser" dc:"数据核查人"` // 数据核查人
|
||||
AuditDate *gtime.Time `orm:"audit_date" json:"auditDate" dc:"数据核查日期"` // 数据核查日期
|
||||
Remark string `orm:"remark" json:"remark" dc:"备注"` // 备注
|
||||
AuditStatus int `orm:"audit_status" json:"auditStatus" dc:""` //
|
||||
AuditView string `orm:"audit_view" json:"auditView" dc:""` //
|
||||
Version int `orm:"version" json:"version" dc:""` //
|
||||
CreatedAt *gtime.Time `orm:"created_at" json:"createdAt" dc:""` //
|
||||
UpdatedAt *gtime.Time `orm:"updated_at" json:"updatedAt" dc:""` //
|
||||
DeletedAt *gtime.Time `orm:"deleted_at" json:"deletedAt" dc:""` //
|
||||
}
|
||||
|
||||
type SpeciesNameListRes struct {
|
||||
@ -32,20 +47,26 @@ type SpeciesNameListRes struct {
|
||||
AuditUser int `json:"auditUser" dc:"数据核查人"`
|
||||
AuditDate *gtime.Time `json:"auditDate" dc:"数据核查日期"`
|
||||
Remark string `json:"remark" dc:"备注"`
|
||||
AuditStatus int `json:"auditStatus" dc:""`
|
||||
AuditView string `json:"auditView" dc:""`
|
||||
Version int `json:"version" dc:""`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:""`
|
||||
}
|
||||
|
||||
// SpeciesNameSearchReq 分页请求参数
|
||||
type SpeciesNameSearchReq struct {
|
||||
comModel.PageReq
|
||||
Id string `p:"id" dc:"主键"` //主键
|
||||
SpeciesCode string `p:"speciesCode" dc:"物种编号"` //物种编号
|
||||
Name string `p:"name" dc:"物种名称"` //物种名称
|
||||
Content string `p:"content" dc:"物种名称内容"` //物种名称内容
|
||||
SourcesData string `p:"sourcesData" dc:"数据来源"` //数据来源
|
||||
CreateUser string `p:"createUser" v:"createUser@integer#数据采集人需为整数" dc:"数据采集人"` //数据采集人
|
||||
CreateDate string `p:"createDate" v:"createDate@datetime#数据采集信息需为YYYY-MM-DD hh:mm:ss格式" dc:"数据采集信息"` //数据采集信息
|
||||
AuditUser string `p:"auditUser" v:"auditUser@integer#数据核查人需为整数" dc:"数据核查人"` //数据核查人
|
||||
AuditDate string `p:"auditDate" v:"auditDate@datetime#数据核查日期需为YYYY-MM-DD hh:mm:ss格式" dc:"数据核查日期"` //数据核查日期
|
||||
Id string `p:"id" dc:"主键"` //主键
|
||||
SpeciesCode string `p:"speciesCode" dc:"物种编号"` //物种编号
|
||||
Name string `p:"name" dc:"物种名称"` //物种名称
|
||||
Content string `p:"content" dc:"物种名称内容"` //物种名称内容
|
||||
SourcesData string `p:"sourcesData" dc:"数据来源"` //数据来源
|
||||
CreateUser string `p:"createUser" v:"createUser@integer#数据采集人需为整数" dc:"数据采集人"` //数据采集人
|
||||
CreateDate []*gtime.Time `p:"createDate"` //数据采集信息
|
||||
AuditUser string `p:"auditUser" v:"auditUser@integer#数据核查人需为整数" dc:"数据核查人"` //数据核查人
|
||||
AuditDate []*gtime.Time `p:"auditDate"` //数据核查日期
|
||||
AuditStatus string `p:"auditStatus" v:"auditStatus@integer#需为整数" dc:""` //
|
||||
AuditView string `p:"auditView" dc:""` //
|
||||
}
|
||||
|
||||
// SpeciesNameSearchRes 列表返回结果
|
||||
@ -65,6 +86,9 @@ type SpeciesNameAddReq struct {
|
||||
AuditUser int `p:"auditUser" dc:"数据核查人"`
|
||||
AuditDate *gtime.Time `p:"auditDate" dc:"数据核查日期"`
|
||||
Remark string `p:"remark" dc:"备注"`
|
||||
//AuditStatus int `p:"auditStatus" v:"required#不能为空" dc:""`
|
||||
//AuditView string `p:"auditView" dc:""`
|
||||
//Version int `p:"version" dc:""`
|
||||
}
|
||||
|
||||
// SpeciesNameEditReq 修改操作请求参数
|
||||
@ -79,4 +103,7 @@ type SpeciesNameEditReq struct {
|
||||
AuditUser int `p:"auditUser" dc:"数据核查人"`
|
||||
AuditDate *gtime.Time `p:"auditDate" dc:"数据核查日期"`
|
||||
Remark string `p:"remark" dc:"备注"`
|
||||
AuditStatus int `p:"auditStatus" v:"required#不能为空" dc:""`
|
||||
AuditView string `p:"auditView" dc:""`
|
||||
Version int `p:"version" dc:""`
|
||||
}
|
||||
|
16
internal/app/businesses/router/classifu_statuse.go
Normal file
16
internal/app/businesses/router/classifu_statuse.go
Normal file
@ -0,0 +1,16 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/controller"
|
||||
)
|
||||
|
||||
func (router *Router) BindClassifyStatuseController(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
group.Group("/classifyStatuse", func(group *ghttp.RouterGroup) {
|
||||
group.Bind(
|
||||
controller.ClassifyStatuse,
|
||||
)
|
||||
})
|
||||
}
|
28
internal/app/businesses/service/classifu_statuse.go
Normal file
28
internal/app/businesses/service/classifu_statuse.go
Normal file
@ -0,0 +1,28 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/model"
|
||||
)
|
||||
|
||||
type IClassifyStatuse interface {
|
||||
List(ctx context.Context, req *model.ClassifyStatuseSearchReq) (res *model.ClassifyStatuseSearchRes, err error)
|
||||
GetBySpeciesCode(ctx context.Context, Id int) (res *model.ClassifyStatuseInfoRes, err error)
|
||||
Add(ctx context.Context, req *model.ClassifyStatuseAddReq) (err error)
|
||||
Edit(ctx context.Context, req *model.ClassifyStatuseEditReq) (err error)
|
||||
Delete(ctx context.Context, Id []int) (err error)
|
||||
}
|
||||
|
||||
var localClassifyStatuse IClassifyStatuse
|
||||
|
||||
func ClassifyStatuse() IClassifyStatuse {
|
||||
if localClassifyStatuse == nil {
|
||||
panic("implement not found for interface IClassifyStatuse, forgot register?")
|
||||
}
|
||||
return localClassifyStatuse
|
||||
}
|
||||
|
||||
func RegisterClassifyStatuse(i IClassifyStatuse) {
|
||||
localClassifyStatuse = i
|
||||
}
|
@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/tiger1103/gfast/v3/internal/app/businesses/model"
|
||||
)
|
||||
|
||||
@ -11,6 +12,7 @@ type ISpeciesName interface {
|
||||
Add(ctx context.Context, req *model.SpeciesNameAddReq) (err error)
|
||||
Edit(ctx context.Context, req *model.SpeciesNameEditReq) (err error)
|
||||
Delete(ctx context.Context, Id []int) (err error)
|
||||
//Audit(ctx context.Context, req *common.AuditReq)
|
||||
}
|
||||
|
||||
var localSpeciesName ISpeciesName
|
||||
|
40
internal/app/lock/lock.go
Normal file
40
internal/app/lock/lock.go
Normal file
@ -0,0 +1,40 @@
|
||||
package lock
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
// TryOptimisticLock 乐观锁通用方法(基于 version 字段)
|
||||
// 参数说明:
|
||||
// - ctx: 请求上下文
|
||||
// - model: 对应表的 gdb.Model,如 dao.User.Ctx(ctx)
|
||||
// - idKey: 主键名,通常是 "id"
|
||||
// - idVal: 主键值
|
||||
// - clientVersion: 前端传来的 version 值
|
||||
// 返回:新的 version,如果冲突返回错误
|
||||
func TryOptimisticLock(ctx context.Context, model *gdb.Model, idKey string, idVal any, clientVersion int) (newVersion int, err error) {
|
||||
if idVal == 0 || clientVersion == 0 {
|
||||
return 0, gerror.New("缺少 ID 或版本号参数")
|
||||
}
|
||||
|
||||
// 尝试根据 version 进行原子更新
|
||||
result, err := model.
|
||||
Where(idKey, idVal).
|
||||
Where("version", clientVersion).
|
||||
Increment("version", 1)
|
||||
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// 检查是否真的更新成功
|
||||
rows, _ := result.RowsAffected()
|
||||
if rows == 0 {
|
||||
return 0, gerror.New("数据版本冲突,请刷新后重试")
|
||||
}
|
||||
|
||||
return clientVersion + 1, nil
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user