yxh 6 rokov pred
rodič
commit
3acb8ad2ce

+ 13 - 0
app/controller/admin/cms_menu.go

@@ -0,0 +1,13 @@
+package admin
+
+import (
+	"gfast/library/response"
+	"github.com/gogf/gf/net/ghttp"
+)
+
+//cms栏目管理
+type CmsMenu struct{}
+
+func (c *CmsMenu) MenuList(r *ghttp.Request) {
+	response.SusJson(true, r, "栏目列表")
+}

+ 12 - 0
app/controller/admin/cms_news.go

@@ -0,0 +1,12 @@
+package admin
+
+import (
+	"gfast/library/response"
+	"github.com/gogf/gf/net/ghttp"
+)
+
+type CmsNews struct{}
+
+func (c CmsNews) NewsList(r *ghttp.Request) {
+	response.SusJson(true, r, "信息列表")
+}

+ 183 - 0
app/controller/admin/config_dict.go

@@ -0,0 +1,183 @@
+package admin
+
+import (
+	"gfast/app/model/admin/sys_dict_data"
+	"gfast/app/model/admin/sys_dict_type"
+	"gfast/app/service/admin/dict_service"
+	"gfast/app/service/admin/user_service"
+	"gfast/library/response"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/net/ghttp"
+	"github.com/gogf/gf/util/gvalid"
+)
+
+type Dict struct{}
+
+//字典列表
+func (c *Dict) DictList(r *ghttp.Request) {
+	var req *sys_dict_type.SelectPageReq
+	//获取参数
+	if err := r.Parse(&req); err != nil {
+		response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+	}
+
+	total, page, list, err := dict_service.SelectListByPage(req)
+	if err != nil {
+		response.FailJson(true, r, err.Error())
+	}
+	result := g.Map{
+		"currentPage":  page,
+		"total":        total,
+		"list":         list,
+		"searchStatus": map[string]string{"": "所有", "0": "停用", "1": "正常"},
+	}
+	response.SusJson(true, r, "字典列表", result)
+}
+
+//添加字典
+func (c *Dict) DictAdd(r *ghttp.Request) {
+	if r.Method == "POST" {
+		var req *sys_dict_type.AddReq
+		//获取参数
+		if err := r.Parse(&req); err != nil {
+			response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+		}
+		if !dict_service.CheckDictTypeUniqueAll(req.DictType) {
+			response.FailJson(true, r, "字典类型已经存在")
+		}
+		userId := user_service.GetLoginID(r) //获取登陆用户id
+		_, err := dict_service.AddSave(req, userId)
+		if err != nil {
+			g.Log().Error(err.Error())
+			response.FailJson(true, r, "字典类型添加失败")
+		}
+		response.SusJson(true, r, "添加字典成功")
+	}
+}
+
+//修改字典
+func (c *Dict) DictEdit(r *ghttp.Request) {
+	if r.Method == "POST" {
+		var req *sys_dict_type.EditReq
+		//获取参数
+		if err := r.Parse(&req); err != nil {
+			response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+		}
+		if !dict_service.CheckDictTypeUnique(req) {
+			response.FailJson(true, r, "字典类型已经存在")
+		}
+		userId := user_service.GetLoginID(r) //获取登陆用户id
+		_, err := dict_service.EditSave(req, userId)
+		if err != nil {
+			response.FailJson(true, r, err.Error())
+		}
+		response.SusJson(true, r, "修改成功")
+	}
+	id := r.GetInt("id")
+	entity, err := dict_service.GetDictById(id)
+	if err != nil {
+		response.FailJson(true, r, "字典类型添加失败")
+	}
+	response.SusJson(true, r, "ok", g.Map{"dict": entity})
+}
+
+//字典数据列表
+func (c *Dict) DictDataList(r *ghttp.Request) {
+	var req *sys_dict_data.SelectDataPageReq
+	//获取参数
+	if err := r.Parse(&req); err != nil {
+		response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+	}
+
+	total, page, list, err := dict_service.SelectDataListByPage(req)
+	if err != nil {
+		response.FailJson(true, r, err.Error())
+	}
+	result := g.Map{
+		"currentPage":  page,
+		"total":        total,
+		"list":         list,
+		"searchStatus": map[string]string{"": "所有", "0": "停用", "1": "正常"},
+	}
+	response.SusJson(true, r, "ok", result)
+}
+
+//添加数据字典
+func (c *Dict) DictDataAdd(r *ghttp.Request) {
+	if r.Method == "POST" {
+		var req *sys_dict_data.AddDataReq
+		//获取参数
+		if err := r.Parse(&req); err != nil {
+			response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+		}
+		userId := user_service.GetLoginID(r) //获取登陆用户id
+		_, err := dict_service.AddSaveData(req, userId)
+		if err != nil {
+			response.FailJson(true, r, err.Error())
+		}
+		response.SusJson(true, r, "添加字典数据成功")
+	}
+	dictType := r.GetQueryString("dictType")
+	res := g.Map{
+		"listClassSelector": g.Map{"default": "默认", "primary": "主要", "success": "成功", "info": "信息",
+			"warning": "警告", "danger": "危险"},
+		"dictType": dictType,
+	}
+	response.SusJson(true, r, "ok", res)
+}
+
+//修改字典数据
+func (c *Dict) DictDataEdit(r *ghttp.Request) {
+	if r.Method == "POST" {
+		var req *sys_dict_data.EditDataReq
+		//获取参数
+		if err := r.Parse(&req); err != nil {
+			response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+		}
+		userId := user_service.GetLoginID(r)
+		_, err := dict_service.EditSaveData(req, userId)
+		if err != nil {
+			response.FailJson(true, r, err.Error())
+		}
+		response.SusJson(true, r, "修改字典数据成功")
+
+	}
+	dictCode := r.GetInt("dictCode")
+	dictData, err := dict_service.GetDictDataById(dictCode)
+	if err != nil {
+		response.FailJson(true, r, err.Error())
+	}
+	res := g.Map{
+		"listClassSelector": g.Map{"default": "默认", "primary": "主要", "success": "成功", "info": "信息",
+			"warning": "警告", "danger": "危险"},
+		"dictType": dictData.DictType,
+		"dictData": dictData,
+	}
+	response.SusJson(true, r, "ok", res)
+}
+
+//删除字典
+func (c *Dict) DictDelete(r *ghttp.Request) {
+	dictIds := r.GetInts("dictIds")
+	if len(dictIds) == 0 {
+		response.FailJson(true, r, "删除失败")
+	}
+	err := dict_service.DeleteDictByIds(dictIds)
+	if err != nil {
+		response.FailJson(true, r, "删除失败")
+	}
+	response.SusJson(true, r, "删除成功")
+}
+
+//删除字典数据
+func (c *Dict) DictDataDelete(r *ghttp.Request) {
+	dictCodes := r.GetInts("dictCode")
+	if len(dictCodes) == 0 {
+		response.FailJson(true, r, "删除失败")
+	}
+	err := dict_service.DeleteDictDataByIds(dictCodes)
+	if err != nil {
+		response.FailJson(true, r, "删除失败")
+	}
+	response.SusJson(true, r, "删除成功")
+}

+ 30 - 0
app/model/admin/sys_dict_data/sys_dict_data.go

@@ -0,0 +1,30 @@
+package sys_dict_data
+
+// Fill with you ideas below.
+
+//新增字典数据页面请求参数
+type AddDataReq struct {
+	DictLabel string `p:"dictLabel"  v:"required#字典标签不能为空"`
+	DictValue string `p:"dictValue"  v:"required#字典键值不能为空"`
+	DictType  string `p:"dictType"  v:"required#字典类型不能为空"`
+	DictSort  int    `p:"dictSort"  v:"integer#排序只能为整数"`
+	CssClass  string `p:"cssClass"`
+	ListClass string `p:"listClass" v:"required#回显样式不能为空"`
+	IsDefault int    `p:"isDefault" v:"required|in:0,1#系统默认不能为空|默认值只能为0或1"`
+	Status    int    `p:"status"    v:"required|in:0,1#状态不能为空|状态只能为0或1"`
+	Remark    string `p:"remark"`
+}
+
+type EditDataReq struct {
+	DictCode int `p:"dictCode" v:"required|min:1#主键ID不能为空|主键ID不能小于1"`
+	AddDataReq
+}
+
+//分页请求参数
+type SelectDataPageReq struct {
+	DictType  string `p:"dictType"`  //字典名称
+	DictLabel string `p:"dictLabel"` //字典标签
+	Status    string `p:"status"`    //状态
+	PageNum   int    `p:"page"`      //当前页码
+	PageSize  int    `p:"pageSize"`  //每页数
+}

+ 65 - 0
app/model/admin/sys_dict_data/sys_dict_data_entity.go

@@ -0,0 +1,65 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. You may not really want to edit it.
+// ==========================================================================
+
+package sys_dict_data
+
+import (
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+)
+
+// Entity is the golang structure for table qxkj_sys_dict_data.
+type Entity struct {
+	DictCode   int64  `orm:"dict_code,primary" json:"dict_code"`   // 字典编码
+	DictSort   int    `orm:"dict_sort"         json:"dict_sort"`   // 字典排序
+	DictLabel  string `orm:"dict_label"        json:"dict_label"`  // 字典标签
+	DictValue  string `orm:"dict_value"        json:"dict_value"`  // 字典键值
+	DictType   string `orm:"dict_type"         json:"dict_type"`   // 字典类型
+	CssClass   string `orm:"css_class"         json:"css_class"`   // 样式属性(其他样式扩展)
+	ListClass  string `orm:"list_class"        json:"list_class"`  // 表格回显样式
+	IsDefault  int    `orm:"is_default"        json:"is_default"`  // 是否默认(1是 0否)
+	Status     int    `orm:"status"            json:"status"`      // 状态(0正常 1停用)
+	CreateBy   int    `orm:"create_by"         json:"create_by"`   // 创建者
+	CreateTime uint64 `orm:"create_time"       json:"create_time"` // 创建时间
+	UpdateBy   int    `orm:"update_by"         json:"update_by"`   // 更新者
+	UpdateTime uint64 `orm:"update_time"       json:"update_time"` // 更新时间
+	Remark     string `orm:"remark"            json:"remark"`      // 备注
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (r *Entity) OmitEmpty() *arModel {
+	return Model.Data(r).OmitEmpty()
+}
+
+// Inserts does "INSERT...INTO..." statement for inserting current object into table.
+func (r *Entity) Insert() (result sql.Result, err error) {
+	return Model.Data(r).Insert()
+}
+
+// Replace does "REPLACE...INTO..." statement for inserting current object into table.
+// If there's already another same record in the table (it checks using primary key or unique index),
+// it deletes it and insert this one.
+func (r *Entity) Replace() (result sql.Result, err error) {
+	return Model.Data(r).Replace()
+}
+
+// Save does "INSERT...INTO..." statement for inserting/updating current object into table.
+// It updates the record if there's already another same record in the table
+// (it checks using primary key or unique index).
+func (r *Entity) Save() (result sql.Result, err error) {
+	return Model.Data(r).Save()
+}
+
+// Update does "UPDATE...WHERE..." statement for updating current object from table.
+// It updates the record if there's already another same record in the table
+// (it checks using primary key or unique index).
+func (r *Entity) Update() (result sql.Result, err error) {
+	return Model.Data(r).Where(gdb.GetWhereConditionOfStruct(r)).Update()
+}
+
+// Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
+func (r *Entity) Delete() (result sql.Result, err error) {
+	return Model.Where(gdb.GetWhereConditionOfStruct(r)).Delete()
+}

+ 367 - 0
app/model/admin/sys_dict_data/sys_dict_data_model.go

@@ -0,0 +1,367 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. You may not really want to edit it.
+// ==========================================================================
+
+package sys_dict_data
+
+import (
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"time"
+)
+
+// arModel is a active record design model for table qxkj_sys_dict_data operations.
+type arModel struct {
+	M *gdb.Model
+}
+
+var (
+	// Table is the table name of qxkj_sys_dict_data.
+	Table = "qxkj_sys_dict_data"
+	// Model is the model object of qxkj_sys_dict_data.
+	Model = &arModel{g.DB("default").Table(Table).Safe()}
+)
+
+// FindOne is a convenience method for Model.FindOne.
+// See Model.FindOne.
+func FindOne(where ...interface{}) (*Entity, error) {
+	return Model.FindOne(where...)
+}
+
+// FindAll is a convenience method for Model.FindAll.
+// See Model.FindAll.
+func FindAll(where ...interface{}) ([]*Entity, error) {
+	return Model.FindAll(where...)
+}
+
+// FindValue is a convenience method for Model.FindValue.
+// See Model.FindValue.
+func FindValue(fieldsAndWhere ...interface{}) (gdb.Value, error) {
+	return Model.FindValue(fieldsAndWhere...)
+}
+
+// FindCount is a convenience method for Model.FindCount.
+// See Model.FindCount.
+func FindCount(where ...interface{}) (int, error) {
+	return Model.FindCount(where...)
+}
+
+// Insert is a convenience method for Model.Insert.
+func Insert(data ...interface{}) (result sql.Result, err error) {
+	return Model.Insert(data...)
+}
+
+// Replace is a convenience method for Model.Replace.
+func Replace(data ...interface{}) (result sql.Result, err error) {
+	return Model.Replace(data...)
+}
+
+// Save is a convenience method for Model.Save.
+func Save(data ...interface{}) (result sql.Result, err error) {
+	return Model.Save(data...)
+}
+
+// Update is a convenience method for Model.Update.
+func Update(dataAndWhere ...interface{}) (result sql.Result, err error) {
+	return Model.Update(dataAndWhere...)
+}
+
+// Delete is a convenience method for Model.Delete.
+func Delete(where ...interface{}) (result sql.Result, err error) {
+	return Model.Delete(where...)
+}
+
+// As sets an alias name for current table.
+func (m *arModel) As(as string) *arModel {
+	return &arModel{m.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (m *arModel) TX(tx *gdb.TX) *arModel {
+	return &arModel{m.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (m *arModel) Master() *arModel {
+	return &arModel{m.M.Master()}
+}
+
+// Slave marks the following operation on slave node.
+// Note that it makes sense only if there's any slave node configured.
+func (m *arModel) Slave() *arModel {
+	return &arModel{m.M.Slave()}
+}
+
+// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
+func (m *arModel) LeftJoin(joinTable string, on string) *arModel {
+	return &arModel{m.M.LeftJoin(joinTable, on)}
+}
+
+// RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
+func (m *arModel) RightJoin(joinTable string, on string) *arModel {
+	return &arModel{m.M.RightJoin(joinTable, on)}
+}
+
+// InnerJoin does "INNER JOIN ... ON ..." statement on the model.
+func (m *arModel) InnerJoin(joinTable string, on string) *arModel {
+	return &arModel{m.M.InnerJoin(joinTable, on)}
+}
+
+// Fields sets the operation fields of the model, multiple fields joined using char ','.
+func (m *arModel) Fields(fields string) *arModel {
+	return &arModel{m.M.Fields(fields)}
+}
+
+// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
+func (m *arModel) FieldsEx(fields string) *arModel {
+	return &arModel{m.M.FieldsEx(fields)}
+}
+
+// Option sets the extra operation option for the model.
+func (m *arModel) Option(option int) *arModel {
+	return &arModel{m.M.Option(option)}
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (m *arModel) OmitEmpty() *arModel {
+	return &arModel{m.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (m *arModel) Filter() *arModel {
+	return &arModel{m.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 (m *arModel) Where(where interface{}, args ...interface{}) *arModel {
+	return &arModel{m.M.Where(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (m *arModel) And(where interface{}, args ...interface{}) *arModel {
+	return &arModel{m.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (m *arModel) Or(where interface{}, args ...interface{}) *arModel {
+	return &arModel{m.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (m *arModel) Group(groupBy string) *arModel {
+	return &arModel{m.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (m *arModel) Order(orderBy string) *arModel {
+	return &arModel{m.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 (m *arModel) Limit(limit ...int) *arModel {
+	return &arModel{m.M.Limit(limit...)}
+}
+
+// Offset sets the "OFFSET" statement for the model.
+// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
+func (m *arModel) Offset(offset int) *arModel {
+	return &arModel{m.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 (m *arModel) Page(page, limit int) *arModel {
+	return &arModel{m.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (m *arModel) Batch(batch int) *arModel {
+	return &arModel{m.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 (m *arModel) Cache(expire time.Duration, name ...string) *arModel {
+	return &arModel{m.M.Cache(expire, 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 (m *arModel) Data(data ...interface{}) *arModel {
+	return &arModel{m.M.Data(data...)}
+}
+
+// Insert does "INSERT INTO ..." statement for the model.
+// The optional parameter <data> is the same as the parameter of Model.Data function,
+// see Model.Data.
+func (m *arModel) Insert(data ...interface{}) (result sql.Result, err error) {
+	return m.M.Insert(data...)
+}
+
+// Replace does "REPLACE INTO ..." statement for the model.
+// The optional parameter <data> is the same as the parameter of Model.Data function,
+// see Model.Data.
+func (m *arModel) Replace(data ...interface{}) (result sql.Result, err error) {
+	return m.M.Replace(data...)
+}
+
+// Save does "INSERT INTO ... ON DUPLICATE KEY UPDATE..." statement for the model.
+// It updates the record if there's primary or unique index in the saving data,
+// or else it inserts a new record into the table.
+//
+// The optional parameter <data> is the same as the parameter of Model.Data function,
+// see Model.Data.
+func (m *arModel) Save(data ...interface{}) (result sql.Result, err error) {
+	return m.M.Save(data...)
+}
+
+// Update does "UPDATE ... " statement for the model.
+//
+// If the optional parameter <dataAndWhere> is given, the dataAndWhere[0] is the updated
+// data field, and dataAndWhere[1:] is treated as where condition fields.
+// Also see Model.Data and Model.Where functions.
+func (m *arModel) Update(dataAndWhere ...interface{}) (result sql.Result, err error) {
+	return m.M.Update(dataAndWhere...)
+}
+
+// Delete does "DELETE FROM ... " statement for the model.
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+func (m *arModel) Delete(where ...interface{}) (result sql.Result, err error) {
+	return m.M.Delete(where...)
+}
+
+// Count does "SELECT COUNT(x) FROM ..." statement for the model.
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+func (m *arModel) Count(where ...interface{}) (int, error) {
+	return m.M.Count(where...)
+}
+
+// All does "SELECT FROM ..." statement for the model.
+// It retrieves the records from table and returns the result as []*Entity.
+// 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 Model.Where function,
+// see Model.Where.
+func (m *arModel) All(where ...interface{}) ([]*Entity, error) {
+	all, err := m.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*Entity
+	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 *Entity.
+// 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 Model.Where function,
+// see Model.Where.
+func (m *arModel) One(where ...interface{}) (*Entity, error) {
+	one, err := m.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *Entity
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// Value retrieves a specified record value from table and returns the result as interface type.
+// It returns nil if there's no record found with the given conditions from table.
+//
+// If the optional parameter <fieldsAndWhere> is given, the fieldsAndWhere[0] is the selected fields
+// and fieldsAndWhere[1:] is treated as where condition fields.
+// Also see Model.Fields and Model.Where functions.
+func (m *arModel) Value(fieldsAndWhere ...interface{}) (gdb.Value, error) {
+	return m.M.Value(fieldsAndWhere...)
+}
+
+// FindOne retrieves and returns a single Record by Model.WherePri and Model.One.
+// Also see Model.WherePri and Model.One.
+func (m *arModel) FindOne(where ...interface{}) (*Entity, error) {
+	one, err := m.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *Entity
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindAll retrieves and returns Result by by Model.WherePri and Model.All.
+// Also see Model.WherePri and Model.All.
+func (m *arModel) FindAll(where ...interface{}) ([]*Entity, error) {
+	all, err := m.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*Entity
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// FindValue retrieves and returns single field value by Model.WherePri and Model.Value.
+// Also see Model.WherePri and Model.Value.
+func (m *arModel) FindValue(fieldsAndWhere ...interface{}) (gdb.Value, error) {
+	return m.M.FindValue(fieldsAndWhere...)
+}
+
+// FindCount retrieves and returns the record number by Model.WherePri and Model.Count.
+// Also see Model.WherePri and Model.Count.
+func (m *arModel) FindCount(where ...interface{}) (int, error) {
+	return m.M.FindCount(where...)
+}
+
+// Chunk iterates the table with given size and callback function.
+func (m *arModel) Chunk(limit int, callback func(entities []*Entity, err error) bool) {
+	m.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*Entity
+		err = result.Structs(&entities)
+		if err == sql.ErrNoRows {
+			return false
+		}
+		return callback(entities, err)
+	})
+}

+ 28 - 0
app/model/admin/sys_dict_type/sys_dict_type.go

@@ -0,0 +1,28 @@
+package sys_dict_type
+
+// Fill with you ideas below.
+
+//新增操作请求参数
+type AddReq struct {
+	DictName string `p:"dictName"  v:"required#字典名称不能为空"`
+	DictType string `p:"dictType"  v:"required#字典类型不能为空"`
+	Status   uint   `p:"status"  v:"required|in:0,1#状态不能为空|状态只能为0或1"`
+	Remark   string `p:"remark"`
+}
+
+//修改操作请求参数
+type EditReq struct {
+	DictId int64 `p:"dictId" v:"required|min:1#主键ID不能为空|主键ID必须为大于0的值"`
+	AddReq
+}
+
+//分页请求参数
+type SelectPageReq struct {
+	DictName  string `p:"dictName"`  //字典名称
+	DictType  string `p:"dictType"`  //字典类型
+	Status    string `p:"status"`    //字典状态
+	BeginTime string `p:"beginTime"` //开始时间
+	EndTime   string `p:"endTime"`   //结束时间
+	PageNum   int    `p:"page"`      //当前页码
+	PageSize  int    `p:"pageSize"`  //每页数
+}

+ 60 - 0
app/model/admin/sys_dict_type/sys_dict_type_entity.go

@@ -0,0 +1,60 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. You may not really want to edit it.
+// ==========================================================================
+
+package sys_dict_type
+
+import (
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+)
+
+// Entity is the golang structure for table qxkj_sys_dict_type.
+type Entity struct {
+	DictId     uint64 `orm:"dict_id,primary"  json:"dict_id"`     // 字典主键
+	DictName   string `orm:"dict_name"        json:"dict_name"`   // 字典名称
+	DictType   string `orm:"dict_type,unique" json:"dict_type"`   // 字典类型
+	Status     uint   `orm:"status"           json:"status"`      // 状态(0正常 1停用)
+	CreateBy   uint   `orm:"create_by"        json:"create_by"`   // 创建者
+	CreateTime uint64 `orm:"create_time"      json:"create_time"` // 创建时间
+	UpdateBy   uint   `orm:"update_by"        json:"update_by"`   // 更新者
+	UpdateTime uint64 `orm:"update_time"      json:"update_time"` // 更新时间
+	Remark     string `orm:"remark"           json:"remark"`      // 备注
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (r *Entity) OmitEmpty() *arModel {
+	return Model.Data(r).OmitEmpty()
+}
+
+// Inserts does "INSERT...INTO..." statement for inserting current object into table.
+func (r *Entity) Insert() (result sql.Result, err error) {
+	return Model.Data(r).Insert()
+}
+
+// Replace does "REPLACE...INTO..." statement for inserting current object into table.
+// If there's already another same record in the table (it checks using primary key or unique index),
+// it deletes it and insert this one.
+func (r *Entity) Replace() (result sql.Result, err error) {
+	return Model.Data(r).Replace()
+}
+
+// Save does "INSERT...INTO..." statement for inserting/updating current object into table.
+// It updates the record if there's already another same record in the table
+// (it checks using primary key or unique index).
+func (r *Entity) Save() (result sql.Result, err error) {
+	return Model.Data(r).Save()
+}
+
+// Update does "UPDATE...WHERE..." statement for updating current object from table.
+// It updates the record if there's already another same record in the table
+// (it checks using primary key or unique index).
+func (r *Entity) Update() (result sql.Result, err error) {
+	return Model.Data(r).Where(gdb.GetWhereConditionOfStruct(r)).Update()
+}
+
+// Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
+func (r *Entity) Delete() (result sql.Result, err error) {
+	return Model.Where(gdb.GetWhereConditionOfStruct(r)).Delete()
+}

+ 367 - 0
app/model/admin/sys_dict_type/sys_dict_type_model.go

@@ -0,0 +1,367 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. You may not really want to edit it.
+// ==========================================================================
+
+package sys_dict_type
+
+import (
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"time"
+)
+
+// arModel is a active record design model for table qxkj_sys_dict_type operations.
+type arModel struct {
+	M *gdb.Model
+}
+
+var (
+	// Table is the table name of qxkj_sys_dict_type.
+	Table = "qxkj_sys_dict_type"
+	// Model is the model object of qxkj_sys_dict_type.
+	Model = &arModel{g.DB("default").Table(Table).Safe()}
+)
+
+// FindOne is a convenience method for Model.FindOne.
+// See Model.FindOne.
+func FindOne(where ...interface{}) (*Entity, error) {
+	return Model.FindOne(where...)
+}
+
+// FindAll is a convenience method for Model.FindAll.
+// See Model.FindAll.
+func FindAll(where ...interface{}) ([]*Entity, error) {
+	return Model.FindAll(where...)
+}
+
+// FindValue is a convenience method for Model.FindValue.
+// See Model.FindValue.
+func FindValue(fieldsAndWhere ...interface{}) (gdb.Value, error) {
+	return Model.FindValue(fieldsAndWhere...)
+}
+
+// FindCount is a convenience method for Model.FindCount.
+// See Model.FindCount.
+func FindCount(where ...interface{}) (int, error) {
+	return Model.FindCount(where...)
+}
+
+// Insert is a convenience method for Model.Insert.
+func Insert(data ...interface{}) (result sql.Result, err error) {
+	return Model.Insert(data...)
+}
+
+// Replace is a convenience method for Model.Replace.
+func Replace(data ...interface{}) (result sql.Result, err error) {
+	return Model.Replace(data...)
+}
+
+// Save is a convenience method for Model.Save.
+func Save(data ...interface{}) (result sql.Result, err error) {
+	return Model.Save(data...)
+}
+
+// Update is a convenience method for Model.Update.
+func Update(dataAndWhere ...interface{}) (result sql.Result, err error) {
+	return Model.Update(dataAndWhere...)
+}
+
+// Delete is a convenience method for Model.Delete.
+func Delete(where ...interface{}) (result sql.Result, err error) {
+	return Model.Delete(where...)
+}
+
+// As sets an alias name for current table.
+func (m *arModel) As(as string) *arModel {
+	return &arModel{m.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (m *arModel) TX(tx *gdb.TX) *arModel {
+	return &arModel{m.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (m *arModel) Master() *arModel {
+	return &arModel{m.M.Master()}
+}
+
+// Slave marks the following operation on slave node.
+// Note that it makes sense only if there's any slave node configured.
+func (m *arModel) Slave() *arModel {
+	return &arModel{m.M.Slave()}
+}
+
+// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
+func (m *arModel) LeftJoin(joinTable string, on string) *arModel {
+	return &arModel{m.M.LeftJoin(joinTable, on)}
+}
+
+// RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
+func (m *arModel) RightJoin(joinTable string, on string) *arModel {
+	return &arModel{m.M.RightJoin(joinTable, on)}
+}
+
+// InnerJoin does "INNER JOIN ... ON ..." statement on the model.
+func (m *arModel) InnerJoin(joinTable string, on string) *arModel {
+	return &arModel{m.M.InnerJoin(joinTable, on)}
+}
+
+// Fields sets the operation fields of the model, multiple fields joined using char ','.
+func (m *arModel) Fields(fields string) *arModel {
+	return &arModel{m.M.Fields(fields)}
+}
+
+// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
+func (m *arModel) FieldsEx(fields string) *arModel {
+	return &arModel{m.M.FieldsEx(fields)}
+}
+
+// Option sets the extra operation option for the model.
+func (m *arModel) Option(option int) *arModel {
+	return &arModel{m.M.Option(option)}
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (m *arModel) OmitEmpty() *arModel {
+	return &arModel{m.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (m *arModel) Filter() *arModel {
+	return &arModel{m.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 (m *arModel) Where(where interface{}, args ...interface{}) *arModel {
+	return &arModel{m.M.Where(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (m *arModel) And(where interface{}, args ...interface{}) *arModel {
+	return &arModel{m.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (m *arModel) Or(where interface{}, args ...interface{}) *arModel {
+	return &arModel{m.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (m *arModel) Group(groupBy string) *arModel {
+	return &arModel{m.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (m *arModel) Order(orderBy string) *arModel {
+	return &arModel{m.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 (m *arModel) Limit(limit ...int) *arModel {
+	return &arModel{m.M.Limit(limit...)}
+}
+
+// Offset sets the "OFFSET" statement for the model.
+// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
+func (m *arModel) Offset(offset int) *arModel {
+	return &arModel{m.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 (m *arModel) Page(page, limit int) *arModel {
+	return &arModel{m.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (m *arModel) Batch(batch int) *arModel {
+	return &arModel{m.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 (m *arModel) Cache(expire time.Duration, name ...string) *arModel {
+	return &arModel{m.M.Cache(expire, 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 (m *arModel) Data(data ...interface{}) *arModel {
+	return &arModel{m.M.Data(data...)}
+}
+
+// Insert does "INSERT INTO ..." statement for the model.
+// The optional parameter <data> is the same as the parameter of Model.Data function,
+// see Model.Data.
+func (m *arModel) Insert(data ...interface{}) (result sql.Result, err error) {
+	return m.M.Insert(data...)
+}
+
+// Replace does "REPLACE INTO ..." statement for the model.
+// The optional parameter <data> is the same as the parameter of Model.Data function,
+// see Model.Data.
+func (m *arModel) Replace(data ...interface{}) (result sql.Result, err error) {
+	return m.M.Replace(data...)
+}
+
+// Save does "INSERT INTO ... ON DUPLICATE KEY UPDATE..." statement for the model.
+// It updates the record if there's primary or unique index in the saving data,
+// or else it inserts a new record into the table.
+//
+// The optional parameter <data> is the same as the parameter of Model.Data function,
+// see Model.Data.
+func (m *arModel) Save(data ...interface{}) (result sql.Result, err error) {
+	return m.M.Save(data...)
+}
+
+// Update does "UPDATE ... " statement for the model.
+//
+// If the optional parameter <dataAndWhere> is given, the dataAndWhere[0] is the updated
+// data field, and dataAndWhere[1:] is treated as where condition fields.
+// Also see Model.Data and Model.Where functions.
+func (m *arModel) Update(dataAndWhere ...interface{}) (result sql.Result, err error) {
+	return m.M.Update(dataAndWhere...)
+}
+
+// Delete does "DELETE FROM ... " statement for the model.
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+func (m *arModel) Delete(where ...interface{}) (result sql.Result, err error) {
+	return m.M.Delete(where...)
+}
+
+// Count does "SELECT COUNT(x) FROM ..." statement for the model.
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+func (m *arModel) Count(where ...interface{}) (int, error) {
+	return m.M.Count(where...)
+}
+
+// All does "SELECT FROM ..." statement for the model.
+// It retrieves the records from table and returns the result as []*Entity.
+// 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 Model.Where function,
+// see Model.Where.
+func (m *arModel) All(where ...interface{}) ([]*Entity, error) {
+	all, err := m.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*Entity
+	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 *Entity.
+// 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 Model.Where function,
+// see Model.Where.
+func (m *arModel) One(where ...interface{}) (*Entity, error) {
+	one, err := m.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *Entity
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// Value retrieves a specified record value from table and returns the result as interface type.
+// It returns nil if there's no record found with the given conditions from table.
+//
+// If the optional parameter <fieldsAndWhere> is given, the fieldsAndWhere[0] is the selected fields
+// and fieldsAndWhere[1:] is treated as where condition fields.
+// Also see Model.Fields and Model.Where functions.
+func (m *arModel) Value(fieldsAndWhere ...interface{}) (gdb.Value, error) {
+	return m.M.Value(fieldsAndWhere...)
+}
+
+// FindOne retrieves and returns a single Record by Model.WherePri and Model.One.
+// Also see Model.WherePri and Model.One.
+func (m *arModel) FindOne(where ...interface{}) (*Entity, error) {
+	one, err := m.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *Entity
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindAll retrieves and returns Result by by Model.WherePri and Model.All.
+// Also see Model.WherePri and Model.All.
+func (m *arModel) FindAll(where ...interface{}) ([]*Entity, error) {
+	all, err := m.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*Entity
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// FindValue retrieves and returns single field value by Model.WherePri and Model.Value.
+// Also see Model.WherePri and Model.Value.
+func (m *arModel) FindValue(fieldsAndWhere ...interface{}) (gdb.Value, error) {
+	return m.M.FindValue(fieldsAndWhere...)
+}
+
+// FindCount retrieves and returns the record number by Model.WherePri and Model.Count.
+// Also see Model.WherePri and Model.Count.
+func (m *arModel) FindCount(where ...interface{}) (int, error) {
+	return m.M.FindCount(where...)
+}
+
+// Chunk iterates the table with given size and callback function.
+func (m *arModel) Chunk(limit int, callback func(entities []*Entity, err error) bool) {
+	m.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*Entity
+		err = result.Structs(&entities)
+		if err == sql.ErrNoRows {
+			return false
+		}
+		return callback(entities, err)
+	})
+}

+ 137 - 0
app/service/admin/dict_service/dict_data.go

@@ -0,0 +1,137 @@
+package dict_service
+
+import (
+	"gfast/app/model/admin/sys_dict_data"
+	"gfast/app/model/admin/sys_dict_type"
+	"gfast/library/utils"
+	"github.com/gogf/gf/errors/gerror"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/os/gtime"
+	"github.com/gogf/gf/util/gconv"
+)
+
+//添加字典数据操作
+func AddSaveData(req *sys_dict_data.AddDataReq, userId int) (int64, error) {
+	var entity sys_dict_data.Entity
+	entity.DictType = req.DictType
+	entity.Status = req.Status
+	entity.DictLabel = req.DictLabel
+	entity.CssClass = req.CssClass
+	entity.DictSort = req.DictSort
+	entity.DictValue = req.DictValue
+	entity.IsDefault = req.IsDefault
+	entity.ListClass = req.ListClass
+	entity.Remark = req.Remark
+	entity.CreateTime = gconv.Uint64(gtime.Timestamp())
+	entity.CreateBy = userId
+	result, err := entity.Insert()
+	if err != nil {
+		g.Log().Error(err)
+		return 0, gerror.New("添加失败")
+	}
+	id, err := result.LastInsertId()
+	if err != nil {
+		g.Log().Error(err)
+		return 0, gerror.New("添加失败")
+	}
+	return id, nil
+}
+
+//修改字典数据操作
+func EditSaveData(req *sys_dict_data.EditDataReq, userId int) (int64, error) {
+	entity, err := GetDictDataById(req.DictCode)
+	if err != nil {
+		return 0, err
+	}
+	entity.DictType = req.DictType
+	entity.Status = req.Status
+	entity.DictLabel = req.DictLabel
+	entity.CssClass = req.CssClass
+	entity.DictSort = req.DictSort
+	entity.DictValue = req.DictValue
+	entity.IsDefault = req.IsDefault
+	entity.ListClass = req.ListClass
+	entity.Remark = req.Remark
+	entity.UpdateTime = gconv.Uint64(gtime.Timestamp())
+	entity.UpdateBy = userId
+	result, err := entity.Update()
+	if err != nil {
+		g.Log().Error(err)
+		return 0, gerror.New("修改失败")
+	}
+	return result.RowsAffected()
+}
+
+//通过字典数据主键获取数据
+func GetDictDataById(dictCode int) (*sys_dict_data.Entity, error) {
+	entity, err := sys_dict_data.Model.FindOne("dict_code", dictCode)
+	if err != nil {
+		g.Log().Error(err)
+		return nil, gerror.New("获取字典数据失败")
+	}
+	if entity == nil {
+		return nil, gerror.New("获取字典数据失败")
+	}
+	return entity, nil
+}
+
+//字典数据列表查询分页
+func SelectDataListByPage(req *sys_dict_data.SelectDataPageReq) (total, page int, list []*sys_dict_data.Entity, err error) {
+	model := sys_dict_data.Model
+	if req != nil {
+		if req.DictLabel != "" {
+			model = model.Where("dict_label like ?", "%"+req.DictLabel+"%")
+		}
+		if req.Status != "" {
+			model = model.Where("status = ", gconv.Int(req.Status))
+		}
+		if req.DictType != "" {
+			model = model.Where("dict_type = ?", req.DictType)
+		}
+		total, err = model.Count()
+		if err != nil {
+			g.Log().Error(err)
+			err = gerror.New("获取总行数失败")
+			return
+		}
+		if req.PageNum == 0 {
+			req.PageNum = 1
+		}
+	}
+	page = req.PageNum
+	if req.PageSize == 0 {
+		req.PageSize = utils.AdminPageNum
+	}
+	list, err = model.Page(page, req.PageSize).Order("dict_sort asc,dict_code asc").All()
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("获取数据失败")
+		return
+	}
+	return
+}
+
+//删除字典
+func DeleteDictByIds(ids []int) error {
+	discs, err := sys_dict_type.Model.Where("dict_id in(?)", ids).All()
+	if err != nil {
+		g.Log().Error(err)
+		return gerror.New("没有要删除的数据")
+	}
+	//删除字典下的数据
+	for _, v := range discs {
+		sys_dict_data.Model.Delete("dict_type=?", v.DictType)
+		v.Delete()
+	}
+	return nil
+}
+
+//删除字典数据
+func DeleteDictDataByIds(ids []int) error {
+	_, err := sys_dict_data.Model.Delete("dict_code in (?)", ids)
+	if err != nil {
+		g.Log().Error(err)
+		return gerror.New("删除失败")
+	}
+	return nil
+}

+ 134 - 0
app/service/admin/dict_service/dict_type.go

@@ -0,0 +1,134 @@
+package dict_service
+
+import (
+	"gfast/app/model/admin/sys_dict_type"
+	"gfast/library/utils"
+	"github.com/gogf/gf/errors/gerror"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/os/gtime"
+	"github.com/gogf/gf/util/gconv"
+)
+
+//检查字典类型是否唯一
+func CheckDictTypeUniqueAll(dictType string) bool {
+	dict, err := sys_dict_type.Model.FindOne("dict_type=?", dictType)
+	if err != nil {
+		g.Log().Error(err)
+		return false
+	}
+	if dict != nil {
+		return false
+	}
+	return true
+}
+
+//根据主键判断是否唯一
+func CheckDictTypeUnique(dictType *sys_dict_type.EditReq) bool {
+	dict, err := sys_dict_type.Model.FindOne("dict_type=? and dict_id!=?", dictType.DictType, dictType.DictId)
+	if err != nil {
+		g.Log().Error(err)
+		return false
+	}
+	if dict != nil {
+		return false
+	}
+	return true
+}
+
+//添加数据
+func AddSave(req *sys_dict_type.AddReq, userId int) (int64, error) {
+	var entity sys_dict_type.Entity
+	entity.Status = req.Status
+	entity.DictType = req.DictType
+	entity.DictName = req.DictName
+	entity.Remark = req.Remark
+	entity.CreateTime = gconv.Uint64(gtime.Timestamp())
+	entity.CreateBy = gconv.Uint(userId)
+
+	result, err := entity.Insert()
+	if err != nil {
+		return 0, err
+	}
+	id, err := result.LastInsertId()
+	if err != nil || id <= 0 {
+		return 0, err
+	}
+	return id, nil
+}
+
+//修改保存字典类型
+func EditSave(req *sys_dict_type.EditReq, userId int) (int64, error) {
+	entity, err := GetDictById(gconv.Int(req.DictId))
+	if err != nil || entity == nil {
+		return 0, err
+	}
+	entity.DictType = req.DictType
+	entity.DictName = req.DictName
+	entity.Status = req.Status
+	entity.Remark = req.Remark
+	entity.UpdateBy = gconv.Uint(userId)
+	entity.UpdateTime = gconv.Uint64(gtime.Timestamp())
+	res, err := entity.Update()
+	if err != nil {
+		g.Log().Error(err)
+		return 0, gerror.New("更新失败")
+	}
+	return res.RowsAffected()
+}
+
+//字典列表查询分页
+func SelectListByPage(req *sys_dict_type.SelectPageReq) (total, page int, list []*sys_dict_type.Entity, err error) {
+	model := sys_dict_type.Model
+	if req != nil {
+		if req.DictType != "" {
+			model = model.Where("dict_name like ?", "%"+req.DictName+"%")
+		}
+
+		if req.Status != "" {
+			model = model.Where("status = ", gconv.Int(req.Status))
+		}
+
+		if req.BeginTime != "" {
+			model = model.Where("create_time >=?", utils.StrToTimestamp(req.BeginTime))
+		}
+
+		if req.EndTime != "" {
+			model = model.Where("create_time<=?", utils.StrToTimestamp(req.EndTime))
+		}
+	}
+	total, err = model.Count()
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("获取总行数失败")
+		return
+	}
+	if req.PageNum == 0 {
+		req.PageNum = 1
+	}
+	page = req.PageNum
+	if req.PageSize == 0 {
+		req.PageSize = utils.AdminPageNum
+	}
+	list, err = model.Page(page, req.PageSize).Order("dict_id asc").All()
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("获取数据失败")
+		return
+	}
+	return
+}
+
+//通过id获取字典数据
+func GetDictById(id int) (dict *sys_dict_type.Entity, err error) {
+	dict, err = sys_dict_type.Model.FindOne("dict_id=?", id)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("获取字典数据失败")
+		return
+	}
+	if dict == nil {
+		err = gerror.New("获取字典数据失败")
+		return
+	}
+	return
+}

+ 1 - 0
config/config.toml

@@ -1,6 +1,7 @@
 # 数据库连接
 # 数据库连接
 [database]
 [database]
     link = "mysql:root:123456@tcp(127.0.0.1:3306)/gfast"
     link = "mysql:root:123456@tcp(127.0.0.1:3306)/gfast"
+    charset   = "utf8mb4" #数据库编码
     maxIdle      = "10" #连接池最大闲置的连接数
     maxIdle      = "10" #连接池最大闲置的连接数
     maxOpen     = "10" #连接池最大打开的连接数
     maxOpen     = "10" #连接池最大打开的连接数
     maxLifetime  = "30" #(单位秒)连接对象可重复使用的时间长度
     maxLifetime  = "30" #(单位秒)连接对象可重复使用的时间长度

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 2 - 3
data/db.sql


+ 10 - 0
library/utils/function.go

@@ -166,3 +166,13 @@ func signIn(username, password string, r *ghttp.Request) (error, *user.QxkjUser)
 	qxkjUser.Update()
 	qxkjUser.Update()
 	return nil, &returnData
 	return nil, &returnData
 }
 }
+
+//日期字符串转时间戳(秒)
+func StrToTimestamp(dateStr string) int64 {
+	tm, err := gtime.StrToTime(dateStr)
+	if err != nil {
+		g.Log().Error(err)
+		return 0
+	}
+	return tm.Timestamp()
+}

+ 3 - 0
router/router.go

@@ -16,4 +16,7 @@ func init() {
 	systemGroup.Middleware(MiddlewareAuth) //后台权限验证
 	systemGroup.Middleware(MiddlewareAuth) //后台权限验证
 	systemGroup.ALL("/index", new(admin.Index))
 	systemGroup.ALL("/index", new(admin.Index))
 	systemGroup.ALL("/auth", new(admin.Auth))
 	systemGroup.ALL("/auth", new(admin.Auth))
+	systemGroup.ALL("/cms", new(admin.CmsMenu))
+	systemGroup.ALL("/cms", new(admin.CmsNews))
+	systemGroup.ALL("/config", new(admin.Dict))
 }
 }

+ 9 - 1
test/demo2_test.go

@@ -1,6 +1,8 @@
 package test
 package test
 
 
 import (
 import (
+	"fmt"
+	"github.com/gogf/gf/os/gtime"
 	"testing"
 	"testing"
 )
 )
 
 
@@ -9,5 +11,11 @@ func TestDemo2(t *testing.T) {
 }
 }
 
 
 func test21(t *testing.T) {
 func test21(t *testing.T) {
-
+	str := "2018.02.09 20:46:17"
+	tm, err := gtime.StrToTime(str)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println(tm.Timestamp())
 }
 }

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov