Преглед изворни кода

feat:系统首页配置功能。

Cheng Jian пре 3 година
родитељ
комит
69b3c589d8

+ 428 - 0
opms_parent/app/dao/plat/internal/plat_user_config.go

@@ -0,0 +1,428 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"context"
+	model "dashoo.cn/micro/app/model/plat"
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/frame/gmvc"
+	"time"
+)
+
+// PlatUserConfigDao is the manager for logic model data accessing
+// and custom defined data operations functions management.
+type PlatUserConfigDao struct {
+	gmvc.M
+	DB      gdb.DB
+	Table   string
+	Columns platUserConfigColumns
+}
+
+// PlatUserConfigColumns defines and stores column names for table plat_user_config.
+type platUserConfigColumns struct {
+	Id          string // 主键
+	UserId      string // 用户ID
+	ModuleCode  string // 模块代码
+	ConfigInfo  string // 配置信息
+	Remark      string // 备注
+	CreatedBy   string // 创建者
+	CreatedName string // 创建人
+	CreatedTime string // 创建时间
+	UpdatedBy   string // 更新者
+	UpdatedName string // 更新人
+	UpdatedTime string // 更新时间
+	DeletedTime string // 删除时间
+}
+
+var (
+	// PlatUserConfig is globally public accessible object for table plat_user_config operations.
+	PlatUserConfig = PlatUserConfigDao{
+		M:     g.DB("default").Model("plat_user_config").Safe(),
+		DB:    g.DB("default"),
+		Table: "plat_user_config",
+		Columns: platUserConfigColumns{
+			Id:          "id",
+			UserId:      "user_id",
+			ModuleCode:  "module_code",
+			ConfigInfo:  "config_info",
+			Remark:      "remark",
+			CreatedBy:   "created_by",
+			CreatedName: "created_name",
+			CreatedTime: "created_time",
+			UpdatedBy:   "updated_by",
+			UpdatedName: "updated_name",
+			UpdatedTime: "updated_time",
+			DeletedTime: "deleted_time",
+		},
+	}
+)
+
+func NewPlatUserConfigDao(tenant string) PlatUserConfigDao {
+	var dao PlatUserConfigDao
+	dao = PlatUserConfigDao{
+		M:     g.DB(tenant).Model("plat_user_config").Safe(),
+		DB:    g.DB(tenant),
+		Table: "plat_user_config",
+		Columns: platUserConfigColumns{
+			Id:          "id",
+			UserId:      "user_id",
+			ModuleCode:  "module_code",
+			ConfigInfo:  "config_info",
+			Remark:      "remark",
+			CreatedBy:   "created_by",
+			CreatedName: "created_name",
+			CreatedTime: "created_time",
+			UpdatedBy:   "updated_by",
+			UpdatedName: "updated_name",
+			UpdatedTime: "updated_time",
+			DeletedTime: "deleted_time",
+		},
+	}
+	return dao
+}
+
+// Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
+// of current DB object and with given context in it.
+// Note that this returned DB object can be used only once, so do not assign it to
+// a global or package variable for long using.
+func (d *PlatUserConfigDao) Ctx(ctx context.Context) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Ctx(ctx)}
+}
+
+// As sets an alias name for current table.
+func (d *PlatUserConfigDao) As(as string) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (d *PlatUserConfigDao) TX(tx *gdb.TX) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (d *PlatUserConfigDao) Master() *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Master()}
+}
+
+// Slave marks the following operation on slave node.
+// Note that it makes sense only if there's any slave node configured.
+func (d *PlatUserConfigDao) Slave() *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Slave()}
+}
+
+// Args sets custom arguments for model operation.
+func (d *PlatUserConfigDao) Args(args ...interface{}) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Args(args...)}
+}
+
+// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *PlatUserConfigDao) LeftJoin(table ...string) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.LeftJoin(table...)}
+}
+
+// RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *PlatUserConfigDao) RightJoin(table ...string) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.RightJoin(table...)}
+}
+
+// InnerJoin does "INNER JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *PlatUserConfigDao) InnerJoin(table ...string) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.InnerJoin(table...)}
+}
+
+// Fields sets the operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *PlatUserConfigDao) Fields(fieldNamesOrMapStruct ...interface{}) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
+}
+
+// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *PlatUserConfigDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
+}
+
+// Option sets the extra operation option for the model.
+func (d *PlatUserConfigDao) Option(option int) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Option(option)}
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (d *PlatUserConfigDao) OmitEmpty() *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (d *PlatUserConfigDao) Filter() *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Filter()}
+}
+
+// Where sets the condition statement for the model. The parameter <where> can be type of
+// string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
+// multiple conditions will be joined into where statement using "AND".
+// Eg:
+// Where("uid=10000")
+// Where("uid", 10000)
+// Where("money>? AND name like ?", 99999, "vip_%")
+// Where("uid", 1).Where("name", "john")
+// Where("status IN (?)", g.Slice{1,2,3})
+// Where("age IN(?,?)", 18, 50)
+// Where(User{ Id : 1, UserName : "john"})
+func (d *PlatUserConfigDao) Where(where interface{}, args ...interface{}) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Where(where, args...)}
+}
+
+// WherePri does the same logic as M.Where except that if the parameter <where>
+// is a single condition like int/string/float/slice, it treats the condition as the primary
+// key value. That is, if primary key is "id" and given <where> parameter as "123", the
+// WherePri function treats the condition as "id=123", but M.Where treats the condition
+// as string "123".
+func (d *PlatUserConfigDao) WherePri(where interface{}, args ...interface{}) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.WherePri(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (d *PlatUserConfigDao) And(where interface{}, args ...interface{}) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (d *PlatUserConfigDao) Or(where interface{}, args ...interface{}) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (d *PlatUserConfigDao) Group(groupBy string) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (d *PlatUserConfigDao) Order(orderBy ...string) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Order(orderBy...)}
+}
+
+// Limit sets the "LIMIT" statement for the model.
+// The parameter <limit> can be either one or two number, if passed two number is passed,
+// it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
+// statement.
+func (d *PlatUserConfigDao) Limit(limit ...int) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Limit(limit...)}
+}
+
+// Offset sets the "OFFSET" statement for the model.
+// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
+func (d *PlatUserConfigDao) Offset(offset int) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Offset(offset)}
+}
+
+// Page sets the paging number for the model.
+// The parameter <page> is started from 1 for paging.
+// Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
+func (d *PlatUserConfigDao) Page(page, limit int) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (d *PlatUserConfigDao) Batch(batch int) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Batch(batch)}
+}
+
+// Cache sets the cache feature for the model. It caches the result of the sql, which means
+// if there's another same sql request, it just reads and returns the result from cache, it
+// but not committed and executed into the database.
+//
+// If the parameter <duration> < 0, which means it clear the cache with given <name>.
+// If the parameter <duration> = 0, which means it never expires.
+// If the parameter <duration> > 0, which means it expires after <duration>.
+//
+// The optional parameter <name> is used to bind a name to the cache, which means you can later
+// control the cache like changing the <duration> or clearing the cache with specified <name>.
+//
+// Note that, the cache feature is disabled if the model is operating on a transaction.
+func (d *PlatUserConfigDao) Cache(duration time.Duration, name ...string) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Cache(duration, name...)}
+}
+
+// Data sets the operation data for the model.
+// The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
+// Eg:
+// Data("uid=10000")
+// Data("uid", 10000)
+// Data(g.Map{"uid": 10000, "name":"john"})
+// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
+func (d *PlatUserConfigDao) Data(data ...interface{}) *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Data(data...)}
+}
+
+// All does "SELECT FROM ..." statement for the model.
+// It retrieves the records from table and returns the result as []*model.PlatUserConfig.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *PlatUserConfigDao) All(where ...interface{}) ([]*model.PlatUserConfig, error) {
+	all, err := d.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.PlatUserConfig
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// One retrieves one record from table and returns the result as *model.PlatUserConfig.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *PlatUserConfigDao) One(where ...interface{}) (*model.PlatUserConfig, error) {
+	one, err := d.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.PlatUserConfig
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindOne retrieves and returns a single Record by M.WherePri and M.One.
+// Also see M.WherePri and M.One.
+func (d *PlatUserConfigDao) FindOne(where ...interface{}) (*model.PlatUserConfig, error) {
+	one, err := d.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.PlatUserConfig
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindAll retrieves and returns Result by by M.WherePri and M.All.
+// Also see M.WherePri and M.All.
+func (d *PlatUserConfigDao) FindAll(where ...interface{}) ([]*model.PlatUserConfig, error) {
+	all, err := d.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.PlatUserConfig
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// Struct retrieves one record from table and converts it into given struct.
+// The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
+// it can create the struct internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not nil.
+//
+// Eg:
+// user := new(User)
+// err  := dao.User.Where("id", 1).Struct(user)
+//
+// user := (*User)(nil)
+// err  := dao.User.Where("id", 1).Struct(&user)
+func (d *PlatUserConfigDao) Struct(pointer interface{}, where ...interface{}) error {
+	return d.M.Struct(pointer, where...)
+}
+
+// Structs retrieves records from table and converts them into given struct slice.
+// The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
+// slice internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not empty.
+//
+// Eg:
+// users := ([]User)(nil)
+// err   := dao.User.Structs(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Structs(&users)
+func (d *PlatUserConfigDao) Structs(pointer interface{}, where ...interface{}) error {
+	return d.M.Structs(pointer, where...)
+}
+
+// Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
+// It calls function Struct if <pointer> is type of *struct/**struct.
+// It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
+//
+// Eg:
+// user  := new(User)
+// err   := dao.User.Where("id", 1).Scan(user)
+//
+// user  := (*User)(nil)
+// err   := dao.User.Where("id", 1).Scan(&user)
+//
+// users := ([]User)(nil)
+// err   := dao.User.Scan(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Scan(&users)
+func (d *PlatUserConfigDao) Scan(pointer interface{}, where ...interface{}) error {
+	return d.M.Scan(pointer, where...)
+}
+
+// Chunk iterates the table with given size and callback function.
+func (d *PlatUserConfigDao) Chunk(limit int, callback func(entities []*model.PlatUserConfig, err error) bool) {
+	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*model.PlatUserConfig
+		err = result.Structs(&entities)
+		if err == sql.ErrNoRows {
+			return false
+		}
+		return callback(entities, err)
+	})
+}
+
+// LockUpdate sets the lock for update for current operation.
+func (d *PlatUserConfigDao) LockUpdate() *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.LockUpdate()}
+}
+
+// LockShared sets the lock in share mode for current operation.
+func (d *PlatUserConfigDao) LockShared() *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.LockShared()}
+}
+
+// Unscoped enables/disables the soft deleting feature.
+func (d *PlatUserConfigDao) Unscoped() *PlatUserConfigDao {
+	return &PlatUserConfigDao{M: d.M.Unscoped()}
+}

+ 36 - 0
opms_parent/app/dao/plat/plat_user_config.go

@@ -0,0 +1,36 @@
+// ============================================================================
+// This is auto-generated by gf cli tool only once. Fill this file as you wish.
+// ============================================================================
+
+package plat
+
+import (
+	"dashoo.cn/micro/app/dao/plat/internal"
+)
+
+// platUserConfigDao is the manager for logic model data accessing
+// and custom defined data operations functions management. You can define
+// methods on it to extend its functionality as you wish.
+type platUserConfigDao struct {
+	internal.PlatUserConfigDao
+}
+
+var (
+	// PlatUserConfig is globally public accessible object for table plat_user_config operations.
+	PlatUserConfig = platUserConfigDao{
+		internal.PlatUserConfig,
+	}
+)
+
+type PlatUserConfigDao struct {
+	internal.PlatUserConfigDao
+}
+
+func NewPlatUserConfigDao(tenant string) *PlatUserConfigDao {
+	dao := internal.NewPlatUserConfigDao(tenant)
+	return &PlatUserConfigDao{
+		dao,
+	}
+}
+
+// Fill with you ideas below.

+ 74 - 0
opms_parent/app/handler/home/home.go

@@ -0,0 +1,74 @@
+package home
+
+import (
+	"context"
+	"dashoo.cn/common_definition/comm_def"
+	model "dashoo.cn/micro/app/model/home"
+	service "dashoo.cn/micro/app/service/home"
+)
+
+type HomeHandler struct{}
+
+// SetUpHomeConfig 设置个人首页配置
+// Swagger:Home 首页 设置个人首页配置
+func (h *HomeHandler) SetUpHomeConfig(ctx context.Context, req *model.SetUpHomeConfig, rsp *comm_def.CommonMsg) error {
+	svc, err := service.NewHomeService(ctx)
+	if err != nil {
+		return err
+	}
+	err = svc.SetUpHomeReportConfig(req)
+	if err != nil {
+		return err
+	}
+	rsp.Code = 200
+	rsp.Msg = "保存成功"
+	return nil
+}
+
+// GetHomeConfig 获取首页报表配置
+// Swagger:Home 首页 获取首页报表配置
+func (h *HomeHandler) GetHomeConfig(ctx context.Context, req *model.SearchHomeConfig, rsp *comm_def.CommonMsg) error {
+	svc, err := service.NewHomeService(ctx)
+	if err != nil {
+		return err
+	}
+	config, err := svc.QueryHomeReportConfig(req.ModuleCode)
+	rsp.Code = 200
+	rsp.Msg = "查询成功"
+	rsp.Data = config
+	return nil
+}
+
+// GetHomeNumReportData 获取首页个人看板数据
+// Swagger:Home 首页 获取首页个人看板数据
+func (h *HomeHandler) GetHomeNumReportData(ctx context.Context, req *model.SearchNumReportData, rsp *comm_def.CommonMsg) error {
+	svc, err := service.NewHomeService(ctx)
+	if err != nil {
+		return err
+	}
+	resp, err := svc.QueryHomeNumReportData(req)
+	if err != nil {
+		return err
+	}
+	rsp.Code = 200
+	rsp.Msg = "查询成功"
+	rsp.Data = resp
+	return nil
+}
+
+// GetHomeDataReportData 获取首页数据报表数据
+// Swagger:Home 首页 获取首页数据报表数据
+func (h *HomeHandler) GetHomeDataReportData(ctx context.Context, req *model.SearchDataReportData, rsp *comm_def.CommonMsg) error {
+	svc, err := service.NewHomeService(ctx)
+	if err != nil {
+		return err
+	}
+	resp, err := svc.QueryHomeDataReportData(req)
+	if err != nil {
+		return err
+	}
+	rsp.Code = 200
+	rsp.Msg = "查询成功"
+	rsp.Data = resp
+	return nil
+}

+ 55 - 0
opms_parent/app/model/home/home.go

@@ -0,0 +1,55 @@
+package home
+
+type SetUpHomeConfig struct {
+	ModuleCode       string              `json:"module_code"`
+	NumReportConfig  []*NumReportConfig  `json:"num_report_config"`
+	DataReportConfig []*DataReportConfig `json:"data_report_config"`
+}
+
+type SearchHomeConfig struct {
+	ModuleCode string `json:"module_code"`
+}
+
+type SearchNumReportData struct {
+	ReportId []int64 `json:"ids"`
+}
+
+type SearchDataReportData struct {
+	ReportId int64 `json:"id"`
+	Params   map[string]interface{}
+}
+
+type NumReportConfig struct {
+	Id         int64  `json:"id"`
+	ReportIcon string `json:"report_icon"`
+	ReportCode string `json:"report_code"`
+	ReportName string `json:"report_name"`
+	ReportDesc string `json:"report_desc"`
+	Sort       int64  `json:"sort"`
+}
+
+type DataReportConfig struct {
+	Id         int64  `json:"id"`
+	ReportCode string `json:"report_code"`
+	ReportName string `json:"report_name"`
+	ReportDesc string `json:"report_desc"`
+	ReportType string `json:"report_type"`
+	LocationX  int64  `json:"location_x"`
+	LocationY  int64  `json:"location_y"`
+	SizeH      int64  `json:"size_h"`
+	SizeW      int64  `json:"size_w"`
+}
+
+type NumReportResponses struct {
+	NumReportResponse []*NumReportResponse `json:"num_report_response"`
+}
+
+type NumReportResponse struct {
+	NumReportConfig
+	Data interface{} `json:"data"`
+}
+
+type DataReportResponse struct {
+	DataReportConfig
+	Data interface{} `json:"data"`
+}

+ 25 - 0
opms_parent/app/model/plat/internal/plat_user_config.go

@@ -0,0 +1,25 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"github.com/gogf/gf/os/gtime"
+)
+
+// PlatUserConfig is the golang structure for table plat_user_config.
+type PlatUserConfig struct {
+	Id          int         `orm:"id,primary"   json:"id"`          // 主键
+	UserId      int         `orm:"user_id"      json:"userId"`      // 用户ID
+	ModuleCode  string      `orm:"module_code"  json:"moduleCode"`  // 模块代码
+	ConfigInfo  string      `orm:"config_info"  json:"configInfo"`  // 配置信息
+	Remark      string      `orm:"remark"       json:"remark"`      // 备注
+	CreatedBy   int         `orm:"created_by"   json:"createdBy"`   // 创建者
+	CreatedName string      `orm:"created_name" json:"createdName"` // 创建人
+	CreatedTime *gtime.Time `orm:"created_time" json:"createdTime"` // 创建时间
+	UpdatedBy   int         `orm:"updated_by"   json:"updatedBy"`   // 更新者
+	UpdatedName string      `orm:"updated_name" json:"updatedName"` // 更新人
+	UpdatedTime *gtime.Time `orm:"updated_time" json:"updatedTime"` // 更新时间
+	DeletedTime *gtime.Time `orm:"deleted_time" json:"deletedTime"` // 删除时间
+}

+ 14 - 0
opms_parent/app/model/plat/plat_user_config.go

@@ -0,0 +1,14 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. Fill this file as you wish.
+// ==========================================================================
+
+package plat
+
+import (
+	"dashoo.cn/micro/app/model/plat/internal"
+)
+
+// PlatUserConfig is the golang structure for table plat_user_config.
+type PlatUserConfig internal.PlatUserConfig
+
+// Fill with you ideas below.

+ 82 - 0
opms_parent/app/service/home/home.go

@@ -0,0 +1,82 @@
+package home
+
+import (
+	"context"
+	"dashoo.cn/micro/app/model/home"
+	"dashoo.cn/micro/app/model/plat"
+	"dashoo.cn/micro/app/service"
+	server "dashoo.cn/micro/app/service/plat"
+	"encoding/json"
+	"github.com/gogf/gf/util/gconv"
+)
+
+type HomeService struct {
+	*service.ContextService
+}
+
+func NewHomeService(ctx context.Context) (svc *HomeService, err error) {
+	svc = new(HomeService)
+	if svc.ContextService, err = svc.Init(ctx); err != nil {
+		return nil, err
+	}
+	return svc, nil
+}
+
+func (s *HomeService) SetUpHomeReportConfig(param *home.SetUpHomeConfig) (err error) {
+	svc, err := server.NewUserConfigService(s.Ctx)
+	config, _ := svc.QueryByUserIdAndModelCode(s.GetCxtUserId(), param.ModuleCode)
+	by, _ := json.Marshal(param)
+	if config != nil {
+		config.ConfigInfo = gconv.String(by)
+		err = svc.Edit(config)
+	} else {
+		config := new(plat.PlatUserConfig)
+		config.UserId = s.GetCxtUserId()
+		config.ModuleCode = param.ModuleCode
+		config.ConfigInfo = gconv.String(by)
+		_, err = svc.Create(config)
+	}
+	return
+}
+
+func (s *HomeService) QueryHomeReportConfig(moduleCode string) (config *plat.PlatUserConfig, err error) {
+	svc, err := server.NewUserConfigService(s.Ctx)
+	config, err = svc.QueryByUserIdAndModelCode(s.GetCxtUserId(), moduleCode)
+	return
+}
+
+func (s *HomeService) QueryHomeNumReportData(param *home.SearchNumReportData) (resp *home.NumReportResponses, err error) {
+	numConfig := make([]*home.NumReportResponse, len(param.ReportId))
+	for _, v := range param.ReportId {
+		numReport := new(home.NumReportResponse)
+		numReport.Id = v
+		value, _ := getReportData(v)
+		numReport.Data = value
+		numConfig = append(numConfig, numReport)
+	}
+
+	resp.NumReportResponse = numConfig
+
+	return
+}
+
+func (s *HomeService) QueryHomeDataReportData(param *home.SearchDataReportData) (resp *home.DataReportResponse, err error) {
+	resp.Id = param.ReportId
+	value, err := getReportData(param.ReportId)
+	if err != nil {
+		return nil, err
+	}
+
+	resp.Data = value
+	return
+}
+
+func getReportData(id int64) (interface{}, error) {
+	switch id {
+	case 0:
+		return nil, nil
+	default:
+		return nil, nil
+
+	}
+}

+ 45 - 0
opms_parent/app/service/plat/plat_user_config.go

@@ -0,0 +1,45 @@
+package plat
+
+import (
+	"context"
+	"dashoo.cn/micro/app/dao/plat"
+	model "dashoo.cn/micro/app/model/plat"
+	"dashoo.cn/micro/app/service"
+)
+
+type UserConfigService struct {
+	*service.ContextService
+
+	Dao *plat.PlatUserConfigDao
+}
+
+func NewUserConfigService(ctx context.Context) (svc *UserConfigService, err error) {
+	svc = new(UserConfigService)
+	if svc.ContextService, err = svc.Init(ctx); err != nil {
+		return nil, err
+	}
+	svc.Dao = plat.NewPlatUserConfigDao(svc.Tenant)
+	return svc, nil
+}
+
+// QueryByUserIdAndModelCode 根据用户ID和模块编码查询
+func (s *UserConfigService) QueryByUserIdAndModelCode(userId int, moduleCode string) (config *model.PlatUserConfig, err error) {
+	return s.Dao.Where("user_id = ? and module_code = ?", s.GetCxtUserId(), moduleCode).One()
+}
+
+// Create 添加用户配置信息
+func (s *UserConfigService) Create(param *model.PlatUserConfig) (lastInsertId int64, err error) {
+	return s.Dao.InsertAndGetId(param)
+}
+
+// Edit 修改配置信息
+func (s *UserConfigService) Edit(param *model.PlatUserConfig) (err error) {
+	_, err = s.Dao.Fields(s.Dao.Columns.ConfigInfo).WherePri(param.Id).Data(param).Update()
+	return err
+}
+
+// Delete 删除配置信息
+func (s *UserConfigService) Delete(param *model.PlatUserConfig) (err error) {
+	_, err = s.Dao.WherePri(param.Id).Delete()
+	return err
+}