mirror of
https://github.com/bufanyun/hotgo.git
synced 2026-05-02 07:54:27 +08:00
tt
This commit is contained in:
358
hotgo-server/app/service/adminService/dept_service.go
Normal file
358
hotgo-server/app/service/adminService/dept_service.go
Normal file
@@ -0,0 +1,358 @@
|
||||
package adminService
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/form/input"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
var Dept = dept{}
|
||||
|
||||
type dept struct{}
|
||||
|
||||
//
|
||||
// @Title 菜单名称是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *dept) NameUnique(ctx context.Context, in input.AdminDeptNameUniqueInp) (*input.AdminDeptNameUniqueModel, error) {
|
||||
|
||||
var res input.AdminDeptNameUniqueModel
|
||||
isUnique, err := dao.AdminDept.IsUniqueName(ctx, in.Id, in.Name)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.IsUnique = isUnique
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 删除
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *dept) Delete(ctx context.Context, in input.AdminDeptDeleteInp) error {
|
||||
|
||||
exist, err := dao.AdminRoleDept.Ctx(ctx).Where("dept_id", in.Id).One()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !exist.IsEmpty() {
|
||||
return gerror.New("请先解除该部门下所有已关联用户关联关系!")
|
||||
}
|
||||
_, err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Delete()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 修改/新增
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *dept) Edit(ctx context.Context, in input.AdminDeptEditInp) (err error) {
|
||||
|
||||
if in.Name == "" {
|
||||
err = gerror.New("名称不能为空")
|
||||
return err
|
||||
}
|
||||
|
||||
uniqueName, err := dao.AdminDept.IsUniqueName(ctx, in.Id, in.Name)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !uniqueName {
|
||||
err = gerror.New("名称已存在")
|
||||
return err
|
||||
}
|
||||
|
||||
// 修改
|
||||
in.UpdatedAt = gtime.Now()
|
||||
if in.Id > 0 {
|
||||
_, err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Data(in).Update()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 新增
|
||||
in.CreatedAt = gtime.Now()
|
||||
_, err = dao.AdminDept.Ctx(ctx).Data(in).Insert()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 最大排序
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictDataMaxSortRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *dept) MaxSort(ctx context.Context, in input.AdminDeptMaxSortInp) (*input.AdminDeptMaxSortModel, error) {
|
||||
var res input.AdminDeptMaxSortModel
|
||||
|
||||
if in.Id > 0 {
|
||||
if err := dao.AdminDept.Ctx(ctx).Where("id", in.Id).Order("sort desc").Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
res.Sort = res.Sort + 10
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取指定字典类型信息
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeViewRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *dept) View(ctx context.Context, in input.AdminDeptViewInp) (res *input.AdminDeptViewModel, err error) {
|
||||
|
||||
if err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *dept) List(ctx context.Context, in input.AdminDeptListInp) (list []*input.AdminDeptListModel, err error) {
|
||||
|
||||
mod := dao.AdminDept.Ctx(ctx)
|
||||
|
||||
var (
|
||||
dataList []*entity.AdminDept
|
||||
models []*DeptTree
|
||||
//searchResult []*entity.AdminDept
|
||||
//id int64
|
||||
//ids []int64
|
||||
)
|
||||
|
||||
// 部门名称
|
||||
if in.Name != "" {
|
||||
//err = dao.AdminDept.Ctx(ctx).WhereLike("name", "%"+in.Name+"%").Scan(&searchResult)
|
||||
//if err != nil {
|
||||
// err = gerror.Wrap(err, consts.ErrorORM)
|
||||
// return nil, err
|
||||
//}
|
||||
//for i := 0; i < len(searchResult); i++ {
|
||||
// id, err = dao.AdminDept.TopPid(ctx, searchResult[i])
|
||||
// ids = append(ids, id)
|
||||
//}
|
||||
//
|
||||
//if len(ids) == 0 {
|
||||
// return nil, nil
|
||||
//}
|
||||
//mod = mod.Where("id", ids)
|
||||
}
|
||||
|
||||
err = mod.Order("id desc").Scan(&dataList)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, err
|
||||
}
|
||||
|
||||
_ = gconv.Structs(dataList, &models)
|
||||
|
||||
childIds := service.getDeptChildIds(ctx, models, 0)
|
||||
|
||||
_ = gconv.Structs(childIds, &list)
|
||||
|
||||
return list, nil
|
||||
}
|
||||
|
||||
type DeptTree struct {
|
||||
entity.AdminDept
|
||||
Children []*DeptTree `json:"children"`
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 将列表转为父子关系列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param lists
|
||||
// @Param pid
|
||||
// @Return []*RelationTree
|
||||
//
|
||||
func (service *dept) getDeptChildIds(ctx context.Context, lists []*DeptTree, pid int64) []*DeptTree {
|
||||
|
||||
var (
|
||||
count = len(lists)
|
||||
newLists []*DeptTree
|
||||
)
|
||||
|
||||
if count == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(lists); i++ {
|
||||
if lists[i].Id > 0 && lists[i].Pid == pid {
|
||||
var row *DeptTree
|
||||
if err := gconv.Structs(lists[i], &row); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
row.Children = service.getDeptChildIds(ctx, lists, row.Id)
|
||||
newLists = append(newLists, row)
|
||||
}
|
||||
}
|
||||
|
||||
return newLists
|
||||
}
|
||||
|
||||
type DeptListTree struct {
|
||||
Id int64 `json:"id" `
|
||||
Key int64 `json:"key" `
|
||||
Pid int64 `json:"pid" `
|
||||
Label string `json:"label"`
|
||||
Title string `json:"title"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Children []*DeptListTree `json:"children"`
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取列表树
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *dept) ListTree(ctx context.Context, in input.AdminDeptListTreeInp) (list []*input.AdminDeptListTreeModel, err error) {
|
||||
|
||||
mod := dao.AdminDept.Ctx(ctx)
|
||||
|
||||
var (
|
||||
dataList []*entity.AdminDept
|
||||
models []*DeptListTree
|
||||
)
|
||||
|
||||
err = mod.Order("id desc").Scan(&dataList)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, err
|
||||
}
|
||||
|
||||
_ = gconv.Structs(dataList, &models)
|
||||
|
||||
// TODO 重写树入参
|
||||
for i := 0; i < len(models); i++ {
|
||||
models[i].Key = models[i].Id
|
||||
models[i].Title = models[i].Name
|
||||
models[i].Label = models[i].Name
|
||||
}
|
||||
|
||||
childIds := service.getDeptTreeChildIds(ctx, models, 0)
|
||||
|
||||
_ = gconv.Structs(childIds, &list)
|
||||
|
||||
return list, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 将列表转为父子关系列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param lists
|
||||
// @Param pid
|
||||
// @Return []*RelationTree
|
||||
//
|
||||
func (service *dept) getDeptTreeChildIds(ctx context.Context, lists []*DeptListTree, pid int64) []*DeptListTree {
|
||||
|
||||
var (
|
||||
count = len(lists)
|
||||
newLists []*DeptListTree
|
||||
)
|
||||
|
||||
if count == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(lists); i++ {
|
||||
if lists[i].Id > 0 && lists[i].Pid == pid {
|
||||
var row *DeptListTree
|
||||
if err := gconv.Structs(lists[i], &row); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
row.Children = service.getDeptTreeChildIds(ctx, lists, row.Id)
|
||||
newLists = append(newLists, row)
|
||||
}
|
||||
}
|
||||
|
||||
return newLists
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取部门名称
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param id
|
||||
// @Return name
|
||||
// @Return err
|
||||
//
|
||||
func (service *dept) GetName(ctx context.Context, id int64) (name string, err error) {
|
||||
|
||||
var data entity.AdminDept
|
||||
|
||||
err = dao.AdminDept.Ctx(ctx).
|
||||
Where("id", id).
|
||||
Fields("name").
|
||||
Scan(&data)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return name, err
|
||||
}
|
||||
|
||||
return data.Name, nil
|
||||
}
|
||||
67
hotgo-server/app/service/adminService/member_post_service.go
Normal file
67
hotgo-server/app/service/adminService/member_post_service.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package adminService
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
var MemberPost = new(memberPost)
|
||||
|
||||
type memberPost struct{}
|
||||
|
||||
func (service *memberPost) UpdatePostIds(ctx context.Context, member_id int64, post_ids []int64) (err error) {
|
||||
_, err = dao.AdminMemberPost.Ctx(ctx).
|
||||
Where("member_id", member_id).
|
||||
Delete()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "删除失败")
|
||||
return err
|
||||
}
|
||||
|
||||
for i := 0; i < len(post_ids); i++ {
|
||||
_, err = dao.AdminMemberPost.Ctx(ctx).
|
||||
Insert(entity.AdminMemberPost{
|
||||
MemberId: member_id,
|
||||
PostId: post_ids[i],
|
||||
})
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "插入会员岗位失败")
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取指定会员的岗位ids
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param member_id
|
||||
// @Return post_ids
|
||||
// @Return err
|
||||
//
|
||||
func (service *memberPost) GetMemberByIds(ctx context.Context, member_id int64) (post_ids []int64, err error) {
|
||||
|
||||
var list []*entity.AdminMemberPost
|
||||
err = dao.AdminMemberPost.Ctx(ctx).
|
||||
Fields("post_id").
|
||||
Where("member_id", member_id).
|
||||
Scan(&list)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return post_ids, err
|
||||
}
|
||||
|
||||
for i := 0; i < len(list); i++ {
|
||||
post_ids = append(post_ids, list[i].PostId)
|
||||
}
|
||||
|
||||
g.Log().Print(ctx, "post_ids:", post_ids)
|
||||
return post_ids, nil
|
||||
}
|
||||
657
hotgo-server/app/service/adminService/member_service.go
Normal file
657
hotgo-server/app/service/adminService/member_service.go
Normal file
@@ -0,0 +1,657 @@
|
||||
//
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2022 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package adminService
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/com"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/form/adminForm"
|
||||
"github.com/bufanyun/hotgo/app/form/input"
|
||||
"github.com/bufanyun/hotgo/app/model"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dto"
|
||||
"github.com/gogf/gf/v2/crypto/gmd5"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
)
|
||||
|
||||
var Member = new(member)
|
||||
|
||||
type member struct{}
|
||||
|
||||
//
|
||||
// @Title 修改登录密码
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *member) UpdateProfile(ctx context.Context, in input.AdminMemberUpdateProfileInp) (err error) {
|
||||
|
||||
memberId := com.Context.Get(ctx).User.Id
|
||||
if memberId <= 0 {
|
||||
err := gerror.New("获取用户信息失败!")
|
||||
return err
|
||||
}
|
||||
|
||||
var memberInfo entity.AdminMember
|
||||
if err = dao.AdminMember.Ctx(ctx).Where("id", memberId).Scan(&memberInfo); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = dao.AdminMember.Ctx(ctx).
|
||||
Where("id", memberId).
|
||||
Data(g.Map{
|
||||
"mobile": in.Mobile,
|
||||
"email": in.Email,
|
||||
"realname": in.Realname,
|
||||
}).
|
||||
Update()
|
||||
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 修改登录密码
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *member) UpdatePwd(ctx context.Context, in input.AdminMemberUpdatePwdInp) (err error) {
|
||||
|
||||
var memberInfo entity.AdminMember
|
||||
if err = dao.AdminMember.Ctx(ctx).Where("id", in.Id).Scan(&memberInfo); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
if gmd5.MustEncryptString(in.OldPassword+memberInfo.Salt) != memberInfo.PasswordHash {
|
||||
err = gerror.New("原密码不正确")
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = dao.AdminMember.Ctx(ctx).
|
||||
Where("id", in.Id).
|
||||
Data(g.Map{
|
||||
"password_hash": gmd5.MustEncryptString(in.NewPassword + memberInfo.Salt),
|
||||
"updated_at": gtime.Now(),
|
||||
}).
|
||||
Update()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 重置密码
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *member) ResetPwd(ctx context.Context, in input.AdminMemberResetPwdInp) (err error) {
|
||||
|
||||
var memberInfo entity.AdminMember
|
||||
if err = dao.AdminMember.Ctx(ctx).Where("id", in.Id).Scan(&memberInfo); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = dao.AdminMember.Ctx(ctx).
|
||||
Where("id", in.Id).
|
||||
Data(g.Map{
|
||||
"password_hash": gmd5.MustEncryptString(in.Password + memberInfo.Salt),
|
||||
"updated_at": gtime.Now(),
|
||||
}).
|
||||
Update()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 菜单名称是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *member) EmailUnique(ctx context.Context, in input.AdminMemberEmailUniqueInp) (*input.AdminMemberEmailUniqueModel, error) {
|
||||
|
||||
var res input.AdminMemberEmailUniqueModel
|
||||
isUnique, err := dao.AdminMember.IsUniqueEmail(ctx, in.Id, in.Email)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.IsUnique = isUnique
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 手机号是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *member) MobileUnique(ctx context.Context, in input.AdminMemberMobileUniqueInp) (*input.AdminMemberMobileUniqueModel, error) {
|
||||
|
||||
var res input.AdminMemberMobileUniqueModel
|
||||
isUnique, err := dao.AdminMember.IsUniqueMobile(ctx, in.Id, in.Mobile)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.IsUnique = isUnique
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 菜单名称是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *member) NameUnique(ctx context.Context, in input.AdminMemberNameUniqueInp) (*input.AdminMemberNameUniqueModel, error) {
|
||||
|
||||
var res input.AdminMemberNameUniqueModel
|
||||
isUnique, err := dao.AdminMember.IsUniqueName(ctx, in.Id, in.Username)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.IsUnique = isUnique
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 删除
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *member) Delete(ctx context.Context, in input.AdminMemberDeleteInp) error {
|
||||
|
||||
exist, err := dao.AdminMember.Ctx(ctx).Where("member_id", in.Id).One()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !exist.IsEmpty() {
|
||||
return gerror.New("请先解除该部门下所有已关联用户关联关系!")
|
||||
}
|
||||
_, err = dao.AdminMember.Ctx(ctx).Where("id", in.Id).Delete()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 修改/新增
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *member) Edit(ctx context.Context, in input.AdminMemberEditInp) (err error) {
|
||||
|
||||
if in.Username == "" {
|
||||
err = gerror.New("帐号不能为空")
|
||||
return err
|
||||
}
|
||||
|
||||
uniqueName, err := dao.AdminMember.IsUniqueName(ctx, in.Id, in.Username)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !uniqueName {
|
||||
err = gerror.New("帐号已存在")
|
||||
return err
|
||||
}
|
||||
|
||||
if in.Mobile != "" {
|
||||
uniqueMobile, err := dao.AdminMember.IsUniqueMobile(ctx, in.Id, in.Mobile)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !uniqueMobile {
|
||||
err = gerror.New("手机号已存在")
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if in.Email != "" {
|
||||
uniqueEmail, err := dao.AdminMember.IsUniqueMobile(ctx, in.Id, in.Email)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !uniqueEmail {
|
||||
err = gerror.New("邮箱已存在")
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// 修改
|
||||
in.UpdatedAt = gtime.Now()
|
||||
if in.Id > 0 {
|
||||
_, err = dao.AdminMember.Ctx(ctx).Where("id", in.Id).Data(in).Update()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
// 更新岗位
|
||||
err = MemberPost.UpdatePostIds(ctx, in.Id, in.PostIds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 新增
|
||||
in.CreatedAt = gtime.Now()
|
||||
|
||||
// 新增用户时的额外属性
|
||||
var data input.AdminMemberAddInp
|
||||
data.AdminMemberEditInp = in
|
||||
data.Salt = grand.S(6)
|
||||
data.PasswordHash = gmd5.MustEncryptString(data.Password + data.Salt)
|
||||
|
||||
g.Log().Print(ctx, "data.Salt:", data)
|
||||
insert, err := dao.AdminMember.Ctx(ctx).Data(data).Insert()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
// 更新岗位
|
||||
id, err := insert.LastInsertId()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = MemberPost.UpdatePostIds(ctx, id, in.PostIds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 最大排序
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictDataMaxSortRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *member) MaxSort(ctx context.Context, in input.AdminMemberMaxSortInp) (*input.AdminMemberMaxSortModel, error) {
|
||||
var res input.AdminMemberMaxSortModel
|
||||
|
||||
if in.Id > 0 {
|
||||
if err := dao.AdminMember.Ctx(ctx).Where("id", in.Id).Order("sort desc").Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
res.Sort = res.Sort + 10
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取指定字典类型信息
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeViewRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *member) View(ctx context.Context, in input.AdminMemberViewInp) (res *input.AdminMemberViewModel, err error) {
|
||||
|
||||
if err = dao.AdminMember.Ctx(ctx).Where("id", in.Id).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *member) List(ctx context.Context, in input.AdminMemberListInp) (list []*input.AdminMemberListModel, totalCount int, err error) {
|
||||
|
||||
var authorization = com.Jwt.GetAuthorization(com.Context.Get(ctx).Request)
|
||||
// TODO 获取jwtToken
|
||||
jwtToken := consts.RedisJwtToken + gmd5.MustEncryptString(authorization)
|
||||
g.Log().Print(ctx, "jwtToken:", jwtToken)
|
||||
|
||||
mod := dao.AdminMember.Ctx(ctx)
|
||||
|
||||
if in.Realname != "" {
|
||||
mod = mod.WhereLike("realname", "%"+in.Realname+"%")
|
||||
}
|
||||
if in.Username != "" {
|
||||
mod = mod.WhereLike("username", "%"+in.Username+"%")
|
||||
}
|
||||
if in.Mobile > 0 {
|
||||
mod = mod.Where("mobile", in.Mobile)
|
||||
}
|
||||
if in.Status > 0 {
|
||||
mod = mod.Where("status", in.Status)
|
||||
}
|
||||
if in.DeptId > 0 {
|
||||
mod = mod.Where("dept_id", in.DeptId)
|
||||
}
|
||||
|
||||
// 日期范围
|
||||
if in.StartTime != "" {
|
||||
mod = mod.WhereGTE("created_at", in.StartTime)
|
||||
}
|
||||
if in.EndTime != "" {
|
||||
mod = mod.WhereLTE("created_at", in.EndTime)
|
||||
}
|
||||
|
||||
totalCount, err = mod.Count()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
err = mod.Page(in.Page, in.Limit).Order("id desc").Scan(&list)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
// TODO 重写树入参
|
||||
for i := 0; i < len(list); i++ {
|
||||
// TODO 部门
|
||||
deptName, err := dao.AdminDept.Ctx(ctx).
|
||||
Fields("name").
|
||||
Where("id", list[i].DeptId).
|
||||
Value()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
list[i].DeptName = deptName.String()
|
||||
|
||||
// TODO 角色
|
||||
roleName, err := dao.AdminRole.Ctx(ctx).
|
||||
Fields("name").
|
||||
Where("id", list[i].Role).
|
||||
Value()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
list[i].RoleName = roleName.String()
|
||||
}
|
||||
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
// //
|
||||
// @Title 获取登录用户信息
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *member) LoginMemberInfo(ctx context.Context, req *adminForm.MemberInfoReq) (res *adminForm.MemberInfoRes, err error) {
|
||||
|
||||
var (
|
||||
defaultPortalConfig adminForm.PortalConfig
|
||||
defaultPortalConfigs []*adminForm.PortalConfig
|
||||
configContent adminForm.PortalConfigContent
|
||||
configContents []*adminForm.PortalConfigContent
|
||||
configContentOptions []*adminForm.PortalConfigContentOptions
|
||||
Options adminForm.PortalConfigContentOptions
|
||||
)
|
||||
|
||||
g.Log().Print(ctx, "测试")
|
||||
|
||||
// TODO 配置内容选项
|
||||
Options.TitleRequired = true
|
||||
Options.Refresh = 1
|
||||
configContentOptions = append(configContentOptions, &Options)
|
||||
|
||||
// TODO 配置内容
|
||||
configContent.Options = configContentOptions
|
||||
configContent.Id = 1
|
||||
configContent.X = 0
|
||||
configContent.Y = 0
|
||||
configContent.W = 3
|
||||
configContent.H = 262
|
||||
configContent.I = 1
|
||||
configContent.Key = "kuaijierukou"
|
||||
configContent.IsShowTitle = "N"
|
||||
configContent.IsAllowDrag = false
|
||||
configContent.Name = "快捷入口"
|
||||
configContent.Type = "smallPage"
|
||||
configContent.Url = "dashboard/portal/CommonUse"
|
||||
configContent.Moved = true
|
||||
|
||||
configContents = append(configContents, &configContent)
|
||||
|
||||
// TODO 默认配置
|
||||
defaultPortalConfig.Id = "4ae60dd1debe462096698e1da993317a"
|
||||
defaultPortalConfig.Name = "首页"
|
||||
defaultPortalConfig.Code = "6c297eb4651940edbb45c87c75be00d7"
|
||||
defaultPortalConfig.ApplicationRange = "U"
|
||||
defaultPortalConfig.IsDefault = "Y"
|
||||
defaultPortalConfig.ResourceId = "1"
|
||||
defaultPortalConfig.SystemDefinedId = "app1"
|
||||
defaultPortalConfig.PortalConfigContent = gconv.String(configContents)
|
||||
|
||||
defaultPortalConfigs = append(defaultPortalConfigs, &defaultPortalConfig)
|
||||
|
||||
member := com.Context.Get(ctx).User
|
||||
|
||||
noticeList, err := Notice.WhereAll(ctx, dto.AdminNotice{
|
||||
Status: consts.StatusEnabled,
|
||||
})
|
||||
if err != nil {
|
||||
noticeList = nil
|
||||
}
|
||||
|
||||
res = &adminForm.MemberInfoRes{
|
||||
LincenseInfo: consts.VersionApp,
|
||||
Permissions: []string{"*:*:*"},
|
||||
Roles: []string{"admin"},
|
||||
User: *member,
|
||||
DefaultPortalConfig: defaultPortalConfigs,
|
||||
UserPortalConfig: defaultPortalConfigs,
|
||||
SysNoticeList: noticeList,
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 提交登录
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *member) Login(ctx context.Context, in input.AdminMemberLoginSignInp) (res *input.AdminMemberLoginSignModel, err error) {
|
||||
|
||||
var member *entity.AdminMember
|
||||
err = dao.AdminMember.Ctx(ctx).Where("username", in.Username).Scan(&member)
|
||||
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return
|
||||
}
|
||||
if member == nil {
|
||||
err = gerror.New(consts.ErrorNotData)
|
||||
return
|
||||
}
|
||||
|
||||
if member.Salt == "" {
|
||||
err = gerror.New("用户信息错误")
|
||||
return
|
||||
}
|
||||
|
||||
if member.PasswordHash != gmd5.MustEncryptString(in.Password+member.Salt) {
|
||||
err = gerror.New("用户密码不正确")
|
||||
return
|
||||
}
|
||||
|
||||
// 默认设备
|
||||
if in.Device != consts.AppAdmin && in.Device != consts.AppApi {
|
||||
in.Device = consts.AppAdmin
|
||||
}
|
||||
|
||||
// TODO 生成token
|
||||
jwtExpires, err := g.Cfg().Get(ctx, "jwt.expires", 1)
|
||||
if err != nil {
|
||||
err := gerror.New(err.Error())
|
||||
return nil, err
|
||||
}
|
||||
// TODO 有效期
|
||||
expires := jwtExpires.Int64()
|
||||
|
||||
// TODO 过期时间戳
|
||||
exp := gconv.Int64(gtime.Timestamp()) + expires
|
||||
|
||||
var identity *model.Identity
|
||||
identity = &model.Identity{
|
||||
Id: member.Id,
|
||||
Username: member.Username,
|
||||
Realname: member.Realname,
|
||||
Avatar: member.Avatar,
|
||||
Email: member.Email,
|
||||
Mobile: member.Mobile,
|
||||
VisitCount: member.VisitCount,
|
||||
LastTime: member.LastTime,
|
||||
LastIp: member.LastIp,
|
||||
Role: member.Role,
|
||||
Exp: exp,
|
||||
Expires: expires,
|
||||
App: consts.AppAdmin,
|
||||
}
|
||||
token, err := com.Jwt.GenerateLoginToken(ctx, identity, false)
|
||||
if err != nil {
|
||||
err = gerror.New(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// TODO 更新登录信息
|
||||
authKey := gmd5.MustEncryptString(gconv.String(token))
|
||||
|
||||
_, err = dao.AdminMember.Ctx(ctx).Data(dto.AdminMember{
|
||||
AuthKey: gmd5.MustEncryptString(authKey),
|
||||
VisitCount: member.VisitCount + 1,
|
||||
LastTime: gtime.Timestamp(),
|
||||
LastIp: com.Context.Get(ctx).Request.GetClientIp(),
|
||||
}).Where(dto.AdminMember{
|
||||
Id: member.Id,
|
||||
}).Update()
|
||||
|
||||
if err != nil {
|
||||
err = gerror.New(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
res = &input.AdminMemberLoginSignModel{
|
||||
Identity: *identity,
|
||||
Token: gconv.String(token),
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取角色下的会员列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *member) RoleMemberList(ctx context.Context, in input.AdminRoleMemberListInp) (list []*input.AdminMemberListModel, totalCount int, err error) {
|
||||
|
||||
mod := dao.AdminMember.Ctx(ctx)
|
||||
if in.Role > 0 {
|
||||
mod = mod.Where("role", in.Role)
|
||||
}
|
||||
|
||||
totalCount, err = mod.Count()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
err = mod.Page(in.Page, in.Limit).Order("id desc").Scan(&list)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
return list, totalCount, err
|
||||
}
|
||||
533
hotgo-server/app/service/adminService/menu_service.go
Normal file
533
hotgo-server/app/service/adminService/menu_service.go
Normal file
@@ -0,0 +1,533 @@
|
||||
//
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2022 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package adminService
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/form/adminForm"
|
||||
"github.com/bufanyun/hotgo/app/form/input"
|
||||
"github.com/bufanyun/hotgo/app/model"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dto"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
var Menu = new(menu)
|
||||
|
||||
type menu struct{}
|
||||
|
||||
//
|
||||
// @Title 查询角色菜单列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.MenuSearchListRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *menu) RoleList(ctx context.Context, in input.MenuRoleListInp) (*input.MenuRoleListModel, error) {
|
||||
|
||||
var (
|
||||
mod = dao.AdminRoleMenu.Ctx(ctx)
|
||||
roleMenu []*entity.AdminRoleMenu
|
||||
lst []*model.LabelTreeMenu
|
||||
res input.MenuRoleListModel
|
||||
err error
|
||||
checkedKeys []int64
|
||||
)
|
||||
|
||||
// TODO 获取选中菜单ID
|
||||
if in.RoleId > 0 {
|
||||
mod = mod.Where("role_id", in.RoleId)
|
||||
}
|
||||
err = mod.Fields().Scan(&roleMenu)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
for i := 0; i < len(roleMenu); i++ {
|
||||
checkedKeys = append(checkedKeys, roleMenu[i].MenuId)
|
||||
}
|
||||
res.CheckedKeys = checkedKeys
|
||||
|
||||
// TODO 获取菜单树
|
||||
lst, err = dao.AdminMenu.GenLabelTreeList(ctx, 0)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_ = gconv.Structs(lst, &res.Menus)
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 查询菜单列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.MenuSearchListRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *menu) SearchList(ctx context.Context, req *adminForm.MenuSearchListReq) (*adminForm.MenuSearchListRes, error) {
|
||||
|
||||
var (
|
||||
mod = dao.AdminMenu.Ctx(ctx)
|
||||
lst []*model.TreeMenu
|
||||
res adminForm.MenuSearchListRes
|
||||
searchResult []*entity.AdminMenu
|
||||
id int64
|
||||
ids []int64
|
||||
err error
|
||||
)
|
||||
|
||||
if req.Name != "" {
|
||||
mod = mod.WhereLike("name", "%"+req.Name+"%")
|
||||
}
|
||||
|
||||
if req.Status > 0 {
|
||||
mod = mod.Where("status", req.Status)
|
||||
}
|
||||
|
||||
if req.Name != "" || req.Status > 0 {
|
||||
err = mod.Scan(&searchResult)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
for i := 0; i < len(searchResult); i++ {
|
||||
id, err = dao.AdminMenu.TopPid(ctx, searchResult[i])
|
||||
ids = append(ids, id)
|
||||
}
|
||||
}
|
||||
|
||||
lst, err = dao.AdminMenu.GenTreeList(ctx, 0, ids)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_ = gconv.Structs(lst, &res)
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 最大排序
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictDataMaxSortRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *menu) MaxSort(ctx context.Context, req *adminForm.MenuMaxSortReq) (*adminForm.MenuMaxSortRes, error) {
|
||||
var (
|
||||
res adminForm.MenuMaxSortRes
|
||||
err error
|
||||
)
|
||||
|
||||
if req.Id > 0 {
|
||||
if err = dao.AdminMenu.Ctx(ctx).Where("id", req.Id).Order("sort desc").Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
res.Sort = res.Sort + 10
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 菜单名称是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *menu) NameUnique(ctx context.Context, req *adminForm.MenuNameUniqueReq) (*adminForm.MenuNameUniqueRes, error) {
|
||||
var (
|
||||
res adminForm.MenuNameUniqueRes
|
||||
err error
|
||||
)
|
||||
|
||||
res.IsUnique, err = dao.AdminMenu.IsUniqueName(ctx, req.Id, req.Name)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 菜单编码是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *menu) CodeUnique(ctx context.Context, req *adminForm.MenuCodeUniqueReq) (*adminForm.MenuCodeUniqueRes, error) {
|
||||
var (
|
||||
res adminForm.MenuCodeUniqueRes
|
||||
err error
|
||||
)
|
||||
|
||||
res.IsUnique, err = dao.AdminMenu.IsUniqueCode(ctx, req.Id, req.Code)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 删除
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *menu) Delete(ctx context.Context, req *adminForm.MenuDeleteReq) error {
|
||||
|
||||
exist, err := dao.AdminMenu.Ctx(ctx).Where("pid", req.Id).One()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !exist.IsEmpty() {
|
||||
return gerror.New("请先删除该菜单下的所有菜单!")
|
||||
}
|
||||
_, err = dao.AdminMenu.Ctx(ctx).Where("id", req.Id).Delete()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 修改/新增
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *menu) Edit(ctx context.Context, req *adminForm.MenuEditReq) (err error) {
|
||||
var (
|
||||
pidData *dto.AdminMenu
|
||||
uniqueName bool
|
||||
uniqueCode bool
|
||||
)
|
||||
|
||||
if req.Name == "" {
|
||||
err = gerror.New("菜单名称不能为空")
|
||||
return err
|
||||
}
|
||||
if req.Path == "" {
|
||||
err = gerror.New("菜单路径不能为空")
|
||||
return err
|
||||
}
|
||||
if req.Code == "" {
|
||||
err = gerror.New("菜单编码不能为空")
|
||||
return err
|
||||
}
|
||||
|
||||
uniqueName, err = dao.AdminMenu.IsUniqueName(ctx, req.Id, req.Name)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !uniqueName {
|
||||
err = gerror.New("菜单名称已存在")
|
||||
return err
|
||||
}
|
||||
|
||||
uniqueCode, err = dao.AdminMenu.IsUniqueCode(ctx, req.Id, req.Code)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !uniqueCode {
|
||||
err = gerror.New("菜单编码已存在")
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO 维护菜单等级
|
||||
if req.Pid == 0 {
|
||||
req.Level = 1
|
||||
} else {
|
||||
if err = dao.AdminMenu.Ctx(ctx).Where("id", req.Pid).Scan(&pidData); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if pidData == nil {
|
||||
return gerror.New("上级菜单信息错误")
|
||||
}
|
||||
req.Level = gconv.Int(pidData.Level) + 1
|
||||
}
|
||||
|
||||
// 修改
|
||||
req.UpdatedAt = gtime.Now()
|
||||
if req.Id > 0 {
|
||||
if req.Pid == req.Id {
|
||||
return gerror.New("上级菜单不能是当前菜单")
|
||||
}
|
||||
_, err = dao.AdminMenu.Ctx(ctx).Where("id", req.Id).Data(req).Update()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 新增
|
||||
req.CreatedAt = gtime.Now()
|
||||
_, err = dao.AdminMenu.Ctx(ctx).Data(req).Insert()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取信息
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeViewRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *menu) View(ctx context.Context, req *adminForm.MenuViewReq) (res *adminForm.MenuViewRes, err error) {
|
||||
//var (
|
||||
// res adminForm.MenuViewRes
|
||||
//)
|
||||
|
||||
if err = dao.AdminMenu.Ctx(ctx).Where("id", req.Id).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取菜单列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *menu) List(ctx context.Context, req *adminForm.MenuListReq) (*adminForm.MenuListRes, error) {
|
||||
var (
|
||||
m = dao.AdminMenu.Ctx(ctx)
|
||||
list []*entity.AdminMenu
|
||||
res adminForm.MenuListRes
|
||||
totalCount int
|
||||
err error
|
||||
)
|
||||
|
||||
if req.Pid == 0 {
|
||||
m = m.Where("level", 1)
|
||||
} else {
|
||||
m = m.Where("pid", req.Pid)
|
||||
}
|
||||
|
||||
totalCount, err = m.Count()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = m.Page(req.Page, req.Limit).Scan(&list)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.List = list
|
||||
res.Page = req.Page
|
||||
res.Limit = req.Limit
|
||||
res.TotalCount = totalCount
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
type RelationTree struct {
|
||||
adminForm.RoleDynamicBase
|
||||
Children []*RelationTree `json:"children"`
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取菜单列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param member_id
|
||||
//
|
||||
func (service *menu) GetMenuList(ctx context.Context, member_id int64) (lists *adminForm.RoleDynamicRes, err error) {
|
||||
|
||||
var (
|
||||
results []*entity.AdminMenu
|
||||
models []*RelationTree
|
||||
recursion []*adminForm.RoleDynamicBase
|
||||
finalResponse adminForm.RoleDynamicRes
|
||||
)
|
||||
|
||||
err = dao.AdminMenu.Ctx(ctx).Order("sort asc,id desc").Scan(&results)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i := 0; i < len(results); i++ {
|
||||
|
||||
// 元数据
|
||||
var (
|
||||
meta adminForm.RoleDynamicMeta
|
||||
rec adminForm.RoleDynamicBase
|
||||
)
|
||||
|
||||
meta.Title = results[i].Name
|
||||
meta.Icon = results[i].Icon
|
||||
meta.NoCache = gconv.Bool(results[i].IsCache)
|
||||
meta.Remark = results[i].Remark
|
||||
|
||||
rec.Id = results[i].Id
|
||||
rec.Pid = results[i].Pid
|
||||
rec.IsFrame = results[i].IsFrame
|
||||
rec.Name = results[i].Name
|
||||
rec.Code = results[i].Code
|
||||
rec.Path = results[i].Path
|
||||
rec.Hidden = results[i].IsVisible == "1"
|
||||
rec.Redirect = service.getRedirect(results[i])
|
||||
rec.Component = service.getComponent(results[i])
|
||||
rec.AlwaysShow = true
|
||||
rec.Meta = &meta
|
||||
|
||||
recursion = append(recursion, &rec)
|
||||
}
|
||||
|
||||
_ = gconv.Structs(recursion, &models)
|
||||
|
||||
childIds := service.getChildIds(ctx, models, 0)
|
||||
|
||||
_ = gconv.Structs(childIds, &finalResponse)
|
||||
|
||||
return &finalResponse, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取菜单的组件配置
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param model
|
||||
// @Return string
|
||||
//
|
||||
func (service *menu) getComponent(mod *entity.AdminMenu) string {
|
||||
|
||||
if mod.Type == "M" {
|
||||
return "Layout"
|
||||
}
|
||||
|
||||
if mod.Type == "C" {
|
||||
return mod.Component
|
||||
}
|
||||
|
||||
return mod.Component
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取菜单是否重定向
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param model
|
||||
// @Return string
|
||||
//
|
||||
func (service *menu) getRedirect(model *entity.AdminMenu) string {
|
||||
if model.Type == "M" {
|
||||
return "noRedirect"
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 将菜单转为父子关系菜单
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param lists
|
||||
// @Param pid
|
||||
// @Return []*RelationTree
|
||||
//
|
||||
func (service *menu) getChildIds(ctx context.Context, lists []*RelationTree, pid int64) []*RelationTree {
|
||||
|
||||
var (
|
||||
count = len(lists)
|
||||
newLists []*RelationTree
|
||||
)
|
||||
|
||||
if count == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(lists); i++ {
|
||||
if lists[i].Id > 0 && lists[i].Pid == pid {
|
||||
var row *RelationTree
|
||||
if err := gconv.Structs(lists[i], &row); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
row.Children = service.getChildIds(ctx, lists, row.Id)
|
||||
newLists = append(newLists, row)
|
||||
}
|
||||
}
|
||||
|
||||
return newLists
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 根据条件查询一行的数据
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param where
|
||||
// @Return *entity.AdminMenu
|
||||
//
|
||||
func (service *menu) WhereScan(ctx context.Context, where dto.AdminMenu) *entity.AdminMenu {
|
||||
var (
|
||||
mod *entity.AdminMenu
|
||||
err error
|
||||
)
|
||||
|
||||
if err = dao.AdminMenu.Ctx(ctx).Where(where).Scan(&mod); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil
|
||||
}
|
||||
|
||||
return mod
|
||||
}
|
||||
263
hotgo-server/app/service/adminService/notice_service.go
Normal file
263
hotgo-server/app/service/adminService/notice_service.go
Normal file
@@ -0,0 +1,263 @@
|
||||
//
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2022 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package adminService
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/form/input"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dto"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
var Notice = new(notice)
|
||||
|
||||
type notice struct{}
|
||||
|
||||
//
|
||||
// @Title 菜单名称是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *notice) NameUnique(ctx context.Context, in input.AdminNoticeNameUniqueInp) (*input.AdminNoticeNameUniqueModel, error) {
|
||||
|
||||
var res input.AdminNoticeNameUniqueModel
|
||||
isUnique, err := dao.AdminNotice.IsUniqueTitle(ctx, in.Id, in.Title)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.IsUnique = isUnique
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 删除
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *notice) Delete(ctx context.Context, in input.AdminNoticeDeleteInp) error {
|
||||
|
||||
_, err := dao.AdminNotice.Ctx(ctx).Where("id", in.Id).Delete()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 修改/新增
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *notice) Edit(ctx context.Context, in input.AdminNoticeEditInp) (err error) {
|
||||
|
||||
if in.Title == "" {
|
||||
err = gerror.New("名称不能为空")
|
||||
return err
|
||||
}
|
||||
|
||||
uniqueName, err := dao.AdminNotice.IsUniqueTitle(ctx, in.Id, in.Title)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !uniqueName {
|
||||
err = gerror.New("名称已存在")
|
||||
return err
|
||||
}
|
||||
|
||||
// 修改
|
||||
in.UpdatedAt = gtime.Now()
|
||||
if in.Id > 0 {
|
||||
_, err = dao.AdminNotice.Ctx(ctx).Where("id", in.Id).Data(in).Update()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 新增
|
||||
in.CreatedAt = gtime.Now()
|
||||
_, err = dao.AdminNotice.Ctx(ctx).Data(in).Insert()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 最大排序
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictDataMaxSortRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *notice) MaxSort(ctx context.Context, in input.AdminNoticeMaxSortInp) (*input.AdminNoticeMaxSortModel, error) {
|
||||
var res input.AdminNoticeMaxSortModel
|
||||
|
||||
if in.Id > 0 {
|
||||
if err := dao.AdminNotice.Ctx(ctx).Where("id", in.Id).Order("sort desc").Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
res.Sort = res.Sort + 10
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取指定字典类型信息
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeViewRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *notice) View(ctx context.Context, in input.AdminNoticeViewInp) (res *input.AdminNoticeViewModel, err error) {
|
||||
|
||||
if err = dao.AdminNotice.Ctx(ctx).Where("id", in.Id).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *notice) List(ctx context.Context, in input.AdminNoticeListInp) (list []*input.AdminNoticeListModel, totalCount int, err error) {
|
||||
|
||||
mod := dao.AdminNotice.Ctx(ctx)
|
||||
|
||||
if in.Realname != "" {
|
||||
mod = mod.WhereLike("realname", "%"+in.Realname+"%")
|
||||
}
|
||||
if in.Username != "" {
|
||||
mod = mod.WhereLike("username", "%"+in.Username+"%")
|
||||
}
|
||||
if in.Mobile > 0 {
|
||||
mod = mod.Where("mobile", in.Mobile)
|
||||
}
|
||||
if in.Status > 0 {
|
||||
mod = mod.Where("status", in.Status)
|
||||
}
|
||||
if in.DeptId > 0 {
|
||||
mod = mod.Where("dept_id", in.DeptId)
|
||||
}
|
||||
|
||||
// 日期范围
|
||||
if in.StartTime != "" {
|
||||
mod = mod.WhereGTE("created_at", in.StartTime)
|
||||
}
|
||||
if in.EndTime != "" {
|
||||
mod = mod.WhereLTE("created_at", in.EndTime)
|
||||
}
|
||||
|
||||
totalCount, err = mod.Count()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
err = mod.Page(in.Page, in.Limit).Order("id desc").Scan(&list)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
//// TODO 重写树入参
|
||||
//for i := 0; i < len(list); i++ {
|
||||
//}
|
||||
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 根据条件查询所有数据
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param where
|
||||
// @Return []*entity.AdminNotice
|
||||
// @Return error
|
||||
//
|
||||
func (service *notice) WhereAll(ctx context.Context, where dto.AdminNotice) ([]*entity.AdminNotice, error) {
|
||||
var (
|
||||
model []*entity.AdminNotice
|
||||
err error
|
||||
result gdb.Result
|
||||
)
|
||||
result, err = dao.AdminNotice.Ctx(ctx).Where(where).All()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = gconv.Scan(result, &model)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorRotaPointer)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return model, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 根据条件查询一行的数据
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param where
|
||||
// @Return *entity.AdminMenu
|
||||
//
|
||||
func (service *notice) WhereScan(ctx context.Context, where dto.AdminNotice) *entity.AdminNotice {
|
||||
var (
|
||||
model *entity.AdminNotice
|
||||
err error
|
||||
)
|
||||
|
||||
if err = dao.AdminMenu.Ctx(ctx).Where(where).Scan(&model); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil
|
||||
}
|
||||
|
||||
return model
|
||||
}
|
||||
274
hotgo-server/app/service/adminService/post_service.go
Normal file
274
hotgo-server/app/service/adminService/post_service.go
Normal file
@@ -0,0 +1,274 @@
|
||||
//
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2022 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package adminService
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/form/input"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
var Post = new(post)
|
||||
|
||||
type post struct{}
|
||||
|
||||
//
|
||||
// @Title 删除
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *post) Delete(ctx context.Context, in input.AdminPostDeleteInp) error {
|
||||
|
||||
exist, err := dao.AdminMemberPost.Ctx(ctx).Where("post_id", in.Id).One()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !exist.IsEmpty() {
|
||||
return gerror.New("请先解除该岗位下所有已关联用户关联关系!")
|
||||
}
|
||||
_, err = dao.AdminPost.Ctx(ctx).Where("id", in.Id).Delete()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 修改/新增
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *post) Edit(ctx context.Context, in input.AdminPostEditInp) (err error) {
|
||||
|
||||
if in.Name == "" {
|
||||
err = gerror.New("名称不能为空")
|
||||
return err
|
||||
}
|
||||
if in.Code == "" {
|
||||
err = gerror.New("编码不能为空")
|
||||
return err
|
||||
}
|
||||
|
||||
uniqueName, err := dao.AdminPost.IsUniqueName(ctx, in.Id, in.Name)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !uniqueName {
|
||||
err = gerror.New("名称已存在")
|
||||
return err
|
||||
}
|
||||
|
||||
uniqueCode, err := dao.AdminPost.IsUniqueCode(ctx, in.Id, in.Code)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !uniqueCode {
|
||||
err = gerror.New("编码已存在")
|
||||
return err
|
||||
}
|
||||
|
||||
// 修改
|
||||
in.UpdatedAt = gtime.Now()
|
||||
if in.Id > 0 {
|
||||
_, err = dao.AdminPost.Ctx(ctx).Where("id", in.Id).Data(in).Update()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 新增
|
||||
in.CreatedAt = gtime.Now()
|
||||
_, err = dao.AdminPost.Ctx(ctx).Data(in).Insert()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 最大排序
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictDataMaxSortRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *post) MaxSort(ctx context.Context, in input.AdminPostMaxSortInp) (*input.AdminPostMaxSortModel, error) {
|
||||
var res input.AdminPostMaxSortModel
|
||||
|
||||
if in.Id > 0 {
|
||||
if err := dao.AdminMenu.Ctx(ctx).Where("id", in.Id).Order("sort desc").Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
res.Sort = res.Sort + 10
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 菜单名称是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *post) NameUnique(ctx context.Context, in input.AdminPostNameUniqueInp) (*input.AdminPostNameUniqueModel, error) {
|
||||
|
||||
var res input.AdminPostNameUniqueModel
|
||||
isUnique, err := dao.AdminPost.IsUniqueName(ctx, in.Id, in.Name)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.IsUnique = isUnique
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 编码是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *post) CodeUnique(ctx context.Context, in input.AdminPostCodeUniqueInp) (*input.AdminPostCodeUniqueModel, error) {
|
||||
|
||||
var res input.AdminPostCodeUniqueModel
|
||||
isUnique, err := dao.AdminPost.IsUniqueCode(ctx, in.Id, in.Code)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.IsUnique = isUnique
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取指定字典类型信息
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeViewRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *post) View(ctx context.Context, in input.AdminPostViewInp) (res *input.AdminPostViewModel, err error) {
|
||||
|
||||
if err = dao.AdminPost.Ctx(ctx).Where("id", in.Id).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *post) List(ctx context.Context, in input.AdminPostListInp) (list []*input.AdminPostListModel, totalCount int, err error) {
|
||||
|
||||
mod := dao.AdminPost.Ctx(ctx)
|
||||
|
||||
// 访问路径
|
||||
if in.Name != "" {
|
||||
mod = mod.WhereLike("name", "%"+in.Name+"%")
|
||||
}
|
||||
|
||||
// 模块
|
||||
if in.Code != "" {
|
||||
mod = mod.Where("code", in.Code)
|
||||
}
|
||||
|
||||
// 请求方式
|
||||
if in.Status > 0 {
|
||||
mod = mod.Where("status", in.Status)
|
||||
}
|
||||
|
||||
totalCount, err = mod.Count()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
err = mod.Page(in.Page, in.Limit).Order("id desc").Scan(&list)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取指定用户的第一岗位
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param RoleId
|
||||
// @Return name
|
||||
// @Return err
|
||||
//
|
||||
func (service *post) GetMemberByStartName(ctx context.Context, memberId int64) (name string, err error) {
|
||||
|
||||
// TODO 默认取第一岗位
|
||||
postId, err := dao.AdminMemberPost.Ctx(ctx).
|
||||
Fields("post_id").
|
||||
Where("member_id", memberId).
|
||||
Limit(1).
|
||||
Value()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return name, err
|
||||
}
|
||||
|
||||
val, err := dao.AdminPost.Ctx(ctx).
|
||||
Fields("name").
|
||||
Where("id", postId.Int()).
|
||||
Order("id desc").
|
||||
Value()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return name, err
|
||||
}
|
||||
|
||||
return val.String(), nil
|
||||
}
|
||||
130
hotgo-server/app/service/adminService/role_service.go
Normal file
130
hotgo-server/app/service/adminService/role_service.go
Normal file
@@ -0,0 +1,130 @@
|
||||
//
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2022 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package adminService
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/form/input"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dto"
|
||||
"github.com/bufanyun/hotgo/app/utils"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
var Role = new(role)
|
||||
|
||||
type role struct{}
|
||||
|
||||
//
|
||||
// @Title 验证权限
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param member_id
|
||||
// @Param path
|
||||
// @Return bool
|
||||
//
|
||||
func (service *role) Verify(ctx context.Context, member_id int, path string) bool {
|
||||
var (
|
||||
err error
|
||||
)
|
||||
|
||||
if utils.Auth.IsExceptAuth(ctx, path) {
|
||||
return true
|
||||
}
|
||||
|
||||
menu := Menu.WhereScan(ctx, dto.AdminMenu{
|
||||
Path: path,
|
||||
Status: consts.StatusEnabled,
|
||||
})
|
||||
|
||||
if menu == nil {
|
||||
err = gerror.New(consts.ErrorNotData)
|
||||
return false
|
||||
}
|
||||
|
||||
g.Log().Print(ctx, "menu:", menu)
|
||||
g.Log().Print(ctx, "err:", err)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *role) List(ctx context.Context, in input.AdminRoleListInp) (list []*input.AdminRoleListModel, totalCount int, err error) {
|
||||
|
||||
mod := dao.AdminRole.Ctx(ctx)
|
||||
|
||||
totalCount, err = mod.Count()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
err = mod.Page(in.Page, in.Limit).Order("id asc").Scan(&list)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取指定角色的名称
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param RoleId
|
||||
// @Return name
|
||||
// @Return err
|
||||
//
|
||||
func (service *role) GetName(ctx context.Context, RoleId int64) (name string, err error) {
|
||||
roleName, err := dao.AdminRole.Ctx(ctx).
|
||||
Fields("name").
|
||||
Where("id", RoleId).
|
||||
Order("id desc").
|
||||
Value()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return name, err
|
||||
}
|
||||
|
||||
return roleName.String(), nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取指定会员的岗位列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *role) GetMemberList(ctx context.Context, RoleId int64) (list []*input.AdminRoleListModel, err error) {
|
||||
|
||||
err = dao.AdminRole.Ctx(ctx).
|
||||
Where("id", RoleId).
|
||||
Order("id desc").
|
||||
Scan(&list)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, err
|
||||
}
|
||||
|
||||
return list, err
|
||||
}
|
||||
23
hotgo-server/app/service/apiService/member_service.go
Normal file
23
hotgo-server/app/service/apiService/member_service.go
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2022 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package apiService
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
var Member = new(member)
|
||||
|
||||
type member struct {}
|
||||
|
||||
func (service *member) Test() (ctx context.Context) {
|
||||
g.Log().Print(ctx, "apiService--WithMember--test...")
|
||||
|
||||
//g.Log().Print(ctx, "api调用:" , service.App.Admin.Member.Test())
|
||||
return
|
||||
}
|
||||
81
hotgo-server/app/service/internal/dao/admin_dept.go
Normal file
81
hotgo-server/app/service/internal/dao/admin_dept.go
Normal file
@@ -0,0 +1,81 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
// adminDeptDao is the data access object for table hg_admin_dept.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type adminDeptDao struct {
|
||||
*internal.AdminDeptDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminDept is globally public accessible object for table hg_admin_dept operations.
|
||||
AdminDept = adminDeptDao{
|
||||
internal.NewAdminDeptDao(),
|
||||
}
|
||||
)
|
||||
|
||||
//
|
||||
// @Title 判断名称是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param id
|
||||
// @Param name
|
||||
// @Return bool
|
||||
// @Return error
|
||||
//
|
||||
func (dao *adminDeptDao) IsUniqueName(ctx context.Context, id int64, name string) (bool, error) {
|
||||
var data *entity.AdminDept
|
||||
m := dao.Ctx(ctx).Where("name", name)
|
||||
|
||||
if id > 0 {
|
||||
m = m.WhereNot("id", id)
|
||||
}
|
||||
|
||||
if err := m.Scan(&data); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取最上级pid
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param data
|
||||
// @Return int64
|
||||
// @Return error
|
||||
//
|
||||
func (dao *adminDeptDao) TopPid(ctx context.Context, data *entity.AdminDept) (int64, error) {
|
||||
var pidData *entity.AdminDept
|
||||
if data.Pid == 0 {
|
||||
return data.Id, nil
|
||||
}
|
||||
err := dao.Ctx(ctx).Where("id", data.Pid).Scan(&pidData)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return dao.TopPid(ctx, pidData)
|
||||
}
|
||||
|
||||
// Fill with you ideas below.
|
||||
118
hotgo-server/app/service/internal/dao/admin_member.go
Normal file
118
hotgo-server/app/service/internal/dao/admin_member.go
Normal file
@@ -0,0 +1,118 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
// adminMemberDao is the data access object for table hg_admin_member.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type adminMemberDao struct {
|
||||
*internal.AdminMemberDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminMember is globally public accessible object for table hg_admin_member operations.
|
||||
AdminMember = adminMemberDao{
|
||||
internal.NewAdminMemberDao(),
|
||||
}
|
||||
)
|
||||
|
||||
//
|
||||
// @Title 判断用户名是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param id
|
||||
// @Param name
|
||||
// @Return bool
|
||||
// @Return error
|
||||
//
|
||||
func (dao *adminMemberDao) IsUniqueName(ctx context.Context, id int64, name string) (bool, error) {
|
||||
var data *entity.AdminDept
|
||||
m := dao.Ctx(ctx).Where("username", name)
|
||||
|
||||
if id > 0 {
|
||||
m = m.WhereNot("id", id)
|
||||
}
|
||||
|
||||
if err := m.Scan(&data); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 判断邮箱是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param id
|
||||
// @Param name
|
||||
// @Return bool
|
||||
// @Return error
|
||||
//
|
||||
func (dao *adminMemberDao) IsUniqueEmail(ctx context.Context, id int64, email string) (bool, error) {
|
||||
var data *entity.AdminMember
|
||||
m := dao.Ctx(ctx).Where("email", email)
|
||||
|
||||
if id > 0 {
|
||||
m = m.WhereNot("id", id)
|
||||
}
|
||||
|
||||
if err := m.Scan(&data); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 判断手机号是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param id
|
||||
// @Param name
|
||||
// @Return bool
|
||||
// @Return error
|
||||
//
|
||||
func (dao *adminMemberDao) IsUniqueMobile(ctx context.Context, id int64, mobile string) (bool, error) {
|
||||
var data *entity.AdminMember
|
||||
m := dao.Ctx(ctx).Where("mobile", mobile)
|
||||
|
||||
if id > 0 {
|
||||
m = m.WhereNot("id", id)
|
||||
}
|
||||
|
||||
if err := m.Scan(&data); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// Fill with you ideas below.
|
||||
24
hotgo-server/app/service/internal/dao/admin_member_post.go
Normal file
24
hotgo-server/app/service/internal/dao/admin_member_post.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminMemberPostDao is the data access object for table hg_admin_member_post.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type adminMemberPostDao struct {
|
||||
*internal.AdminMemberPostDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminMemberPost is globally public accessible object for table hg_admin_member_post operations.
|
||||
AdminMemberPost = adminMemberPostDao{
|
||||
internal.NewAdminMemberPostDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Fill with you ideas below.
|
||||
24
hotgo-server/app/service/internal/dao/admin_member_role.go
Normal file
24
hotgo-server/app/service/internal/dao/admin_member_role.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminMemberRoleDao is the data access object for table hg_admin_member_role.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type adminMemberRoleDao struct {
|
||||
*internal.AdminMemberRoleDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminMemberRole is globally public accessible object for table hg_admin_member_role operations.
|
||||
AdminMemberRole = adminMemberRoleDao{
|
||||
internal.NewAdminMemberRoleDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Fill with you ideas below.
|
||||
180
hotgo-server/app/service/internal/dao/admin_menu.go
Normal file
180
hotgo-server/app/service/internal/dao/admin_menu.go
Normal file
@@ -0,0 +1,180 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/model"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
// @Description
|
||||
type adminMenuDao struct {
|
||||
*internal.AdminMenuDao // }
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminMenu is globally public accessible object for table hg_admin_menu operations.
|
||||
AdminMenu = adminMenuDao{
|
||||
internal.NewAdminMenuDao(),
|
||||
}
|
||||
)
|
||||
|
||||
//
|
||||
// @Title 判断名称是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param id
|
||||
// @Param name
|
||||
// @Return bool
|
||||
// @Return error
|
||||
//
|
||||
func (dao *adminMenuDao) IsUniqueName(ctx context.Context, id int64, name string) (bool, error) {
|
||||
var data *entity.AdminMenu
|
||||
m := dao.Ctx(ctx).Where("name", name)
|
||||
|
||||
if id > 0 {
|
||||
m = m.WhereNot("id", id)
|
||||
}
|
||||
|
||||
if err := m.Scan(&data); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 判断编码是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param id
|
||||
// @Param code
|
||||
// @Return bool
|
||||
// @Return error
|
||||
//
|
||||
func (dao *adminMenuDao) IsUniqueCode(ctx context.Context, id int64, code string) (bool, error) {
|
||||
var data *entity.AdminMenu
|
||||
m := dao.Ctx(ctx).Where("code", code)
|
||||
|
||||
if id > 0 {
|
||||
m = m.WhereNot("id", id)
|
||||
}
|
||||
|
||||
if err := m.Scan(&data); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 生成kl树列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param pid
|
||||
// @Param lists
|
||||
// @Return []*model.TreeMenu
|
||||
// @Return error
|
||||
//
|
||||
func (dao *adminMenuDao) GenLabelTreeList(ctx context.Context, pid int64) ([]*model.LabelTreeMenu, error) {
|
||||
|
||||
var (
|
||||
newLst []*model.LabelTreeMenu
|
||||
)
|
||||
if err := dao.Ctx(ctx).Where("pid", pid).Order("sort asc,id desc").Scan(&newLst); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i := 0; i < len(newLst); i++ {
|
||||
newLst[i].Key = newLst[i].Id
|
||||
newLst[i].Label = newLst[i].Name
|
||||
err := dao.Ctx(ctx).Where("pid", newLst[i].Id).Order("sort asc,id desc").Scan(&newLst[i].Children)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i2 := 0; i2 < len(newLst[i].Children); i2++ {
|
||||
newLst[i].Children[i2].Key = newLst[i].Children[i2].Id
|
||||
newLst[i].Children[i2].Label = newLst[i].Children[i2].Name
|
||||
}
|
||||
}
|
||||
|
||||
return newLst, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 生成树列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param pid
|
||||
// @Param lists
|
||||
// @Return []*model.TreeMenu
|
||||
// @Return error
|
||||
//
|
||||
func (dao *adminMenuDao) GenTreeList(ctx context.Context, pid int64, ids []int64) ([]*model.TreeMenu, error) {
|
||||
|
||||
var (
|
||||
newLst []*model.TreeMenu
|
||||
)
|
||||
if err := dao.Ctx(ctx).Where("id", ids).Where("pid", pid).Order("sort asc,id desc").Scan(&newLst); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i := 0; i < len(newLst); i++ {
|
||||
err := dao.Ctx(ctx).Where("pid", newLst[i].Id).Order("sort asc,id desc").Scan(&newLst[i].Children)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return newLst, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取最上级pid
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param data
|
||||
// @Return int64
|
||||
// @Return error
|
||||
//
|
||||
func (dao *adminMenuDao) TopPid(ctx context.Context, data *entity.AdminMenu) (int64, error) {
|
||||
var pidData *entity.AdminMenu
|
||||
if data.Pid == 0 {
|
||||
return data.Id, nil
|
||||
}
|
||||
err := dao.Ctx(ctx).Where("id", data.Pid).Scan(&pidData)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return dao.TopPid(ctx, pidData)
|
||||
}
|
||||
|
||||
// Fill with you ideas below.
|
||||
24
hotgo-server/app/service/internal/dao/admin_menu_old.go
Normal file
24
hotgo-server/app/service/internal/dao/admin_menu_old.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminMenuOldDao is the data access object for table hg_admin_menu_old.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type adminMenuOldDao struct {
|
||||
*internal.AdminMenuOldDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminMenuOld is globally public accessible object for table hg_admin_menu_old operations.
|
||||
AdminMenuOld = adminMenuOldDao{
|
||||
internal.NewAdminMenuOldDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Fill with you ideas below.
|
||||
58
hotgo-server/app/service/internal/dao/admin_notice.go
Normal file
58
hotgo-server/app/service/internal/dao/admin_notice.go
Normal file
@@ -0,0 +1,58 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
// adminNoticeDao is the data access object for table hg_admin_notice.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type adminNoticeDao struct {
|
||||
*internal.AdminNoticeDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminNotice is globally public accessible object for table hg_admin_notice operations.
|
||||
AdminNotice = adminNoticeDao{
|
||||
internal.NewAdminNoticeDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Fill with you ideas below.
|
||||
|
||||
//
|
||||
// @Title 判断名称是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param id
|
||||
// @Param name
|
||||
// @Return bool
|
||||
// @Return error
|
||||
//
|
||||
func (dao *adminNoticeDao) IsUniqueTitle(ctx context.Context, id int64, title string) (bool, error) {
|
||||
var data *entity.AdminNotice
|
||||
m := dao.Ctx(ctx).Where("title", title)
|
||||
|
||||
if id > 0 {
|
||||
m = m.WhereNot("id", id)
|
||||
}
|
||||
|
||||
if err := m.Scan(&data); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
88
hotgo-server/app/service/internal/dao/admin_post.go
Normal file
88
hotgo-server/app/service/internal/dao/admin_post.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
// adminPostDao is the data access object for table hg_admin_post.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type adminPostDao struct {
|
||||
*internal.AdminPostDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminPost is globally public accessible object for table hg_admin_post operations.
|
||||
AdminPost = adminPostDao{
|
||||
internal.NewAdminPostDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Fill with you ideas below.
|
||||
|
||||
//
|
||||
// @Title 判断名称是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param id
|
||||
// @Param name
|
||||
// @Return bool
|
||||
// @Return error
|
||||
//
|
||||
func (dao *adminPostDao) IsUniqueName(ctx context.Context, id int64, name string) (bool, error) {
|
||||
var data *entity.AdminPost
|
||||
m := dao.Ctx(ctx).Where("name", name)
|
||||
|
||||
if id > 0 {
|
||||
m = m.WhereNot("id", id)
|
||||
}
|
||||
|
||||
if err := m.Scan(&data); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 判断编码是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param id
|
||||
// @Param code
|
||||
// @Return bool
|
||||
// @Return error
|
||||
//
|
||||
func (dao *adminPostDao) IsUniqueCode(ctx context.Context, id int64, code string) (bool, error) {
|
||||
var data *entity.AdminPost
|
||||
m := dao.Ctx(ctx).Where("code", code)
|
||||
|
||||
if id > 0 {
|
||||
m = m.WhereNot("id", id)
|
||||
}
|
||||
|
||||
if err := m.Scan(&data); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
24
hotgo-server/app/service/internal/dao/admin_role.go
Normal file
24
hotgo-server/app/service/internal/dao/admin_role.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminRoleDao is the data access object for table hg_admin_role.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type adminRoleDao struct {
|
||||
*internal.AdminRoleDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminRole is globally public accessible object for table hg_admin_role operations.
|
||||
AdminRole = adminRoleDao{
|
||||
internal.NewAdminRoleDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Fill with you ideas below.
|
||||
29
hotgo-server/app/service/internal/dao/admin_role_dept.go
Normal file
29
hotgo-server/app/service/internal/dao/admin_role_dept.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
//
|
||||
// @Package dao
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
//
|
||||
package dao
|
||||
|
||||
import (
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminRoleDeptDao is the data access object for table hg_admin_role_dept.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type adminRoleDeptDao struct {
|
||||
*internal.AdminRoleDeptDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminRoleDept is globally public accessible object for table hg_admin_role_dept operations.
|
||||
AdminRoleDept = adminRoleDeptDao{
|
||||
internal.NewAdminRoleDeptDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Fill with you ideas below.
|
||||
24
hotgo-server/app/service/internal/dao/admin_role_menu.go
Normal file
24
hotgo-server/app/service/internal/dao/admin_role_menu.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminRoleMenuDao is the data access object for table hg_admin_role_menu.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type adminRoleMenuDao struct {
|
||||
*internal.AdminRoleMenuDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminRoleMenu is globally public accessible object for table hg_admin_role_menu operations.
|
||||
AdminRoleMenu = adminRoleMenuDao{
|
||||
internal.NewAdminRoleMenuDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Fill with you ideas below.
|
||||
96
hotgo-server/app/service/internal/dao/internal/admin_dept.go
Normal file
96
hotgo-server/app/service/internal/dao/internal/admin_dept.go
Normal file
@@ -0,0 +1,96 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminDeptDao is the data access object for table hg_admin_dept.
|
||||
type AdminDeptDao 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 AdminDeptColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// AdminDeptColumns defines and stores column names for table hg_admin_dept.
|
||||
type AdminDeptColumns struct {
|
||||
Id string // 部门id
|
||||
Pid string // 父部门id
|
||||
Ancestors string // 祖级列表
|
||||
Name string // 部门名称
|
||||
Code string // 部门编码
|
||||
Type string // 部门类型
|
||||
Leader string // 负责人
|
||||
Phone string // 联系电话
|
||||
Email string // 邮箱
|
||||
Sort string // 排序
|
||||
Status string // 部门状态
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
}
|
||||
|
||||
// adminDeptColumns holds the columns for table hg_admin_dept.
|
||||
var adminDeptColumns = AdminDeptColumns{
|
||||
Id: "id",
|
||||
Pid: "pid",
|
||||
Ancestors: "ancestors",
|
||||
Name: "name",
|
||||
Code: "code",
|
||||
Type: "type",
|
||||
Leader: "leader",
|
||||
Phone: "phone",
|
||||
Email: "email",
|
||||
Sort: "sort",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
}
|
||||
|
||||
// NewAdminDeptDao creates and returns a new DAO object for table data access.
|
||||
func NewAdminDeptDao() *AdminDeptDao {
|
||||
return &AdminDeptDao{
|
||||
group: "default",
|
||||
table: "hg_admin_dept",
|
||||
columns: adminDeptColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *AdminDeptDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *AdminDeptDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *AdminDeptDao) Columns() AdminDeptColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *AdminDeptDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *AdminDeptDao) 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 *AdminDeptDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
128
hotgo-server/app/service/internal/dao/internal/admin_member.go
Normal file
128
hotgo-server/app/service/internal/dao/internal/admin_member.go
Normal file
@@ -0,0 +1,128 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminMemberDao is the data access object for table hg_admin_member.
|
||||
type AdminMemberDao 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 AdminMemberColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// AdminMemberColumns defines and stores column names for table hg_admin_member.
|
||||
type AdminMemberColumns struct {
|
||||
Id string //
|
||||
DeptId string // 部门ID
|
||||
Username string // 帐号
|
||||
PasswordHash string // 密码
|
||||
Salt string // 密码盐
|
||||
AuthKey string // 授权令牌
|
||||
PasswordResetToken string // 密码重置令牌
|
||||
Type string // 1:普通管理员;10超级管理员
|
||||
Realname string // 真实姓名
|
||||
Avatar string // 头像
|
||||
Sex string // 性别[0:未知;1:男;2:女]
|
||||
Qq string // qq
|
||||
Email string // 邮箱
|
||||
Birthday string // 生日
|
||||
ProvinceId string // 省
|
||||
CityId string // 城市
|
||||
AreaId string // 地区
|
||||
Address string // 默认地址
|
||||
Mobile string // 手机号码
|
||||
HomePhone string // 家庭号码
|
||||
DingtalkRobotToken string // 钉钉机器人token
|
||||
VisitCount string // 访问次数
|
||||
LastTime string // 最后一次登录时间
|
||||
LastIp string // 最后一次登录ip
|
||||
Role string // 权限
|
||||
Remark string // 备注
|
||||
Status string // 状态
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 修改时间
|
||||
}
|
||||
|
||||
// adminMemberColumns holds the columns for table hg_admin_member.
|
||||
var adminMemberColumns = AdminMemberColumns{
|
||||
Id: "id",
|
||||
DeptId: "dept_id",
|
||||
Username: "username",
|
||||
PasswordHash: "password_hash",
|
||||
Salt: "salt",
|
||||
AuthKey: "auth_key",
|
||||
PasswordResetToken: "password_reset_token",
|
||||
Type: "type",
|
||||
Realname: "realname",
|
||||
Avatar: "avatar",
|
||||
Sex: "sex",
|
||||
Qq: "qq",
|
||||
Email: "email",
|
||||
Birthday: "birthday",
|
||||
ProvinceId: "province_id",
|
||||
CityId: "city_id",
|
||||
AreaId: "area_id",
|
||||
Address: "address",
|
||||
Mobile: "mobile",
|
||||
HomePhone: "home_phone",
|
||||
DingtalkRobotToken: "dingtalk_robot_token",
|
||||
VisitCount: "visit_count",
|
||||
LastTime: "last_time",
|
||||
LastIp: "last_ip",
|
||||
Role: "role",
|
||||
Remark: "remark",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
}
|
||||
|
||||
// NewAdminMemberDao creates and returns a new DAO object for table data access.
|
||||
func NewAdminMemberDao() *AdminMemberDao {
|
||||
return &AdminMemberDao{
|
||||
group: "default",
|
||||
table: "hg_admin_member",
|
||||
columns: adminMemberColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *AdminMemberDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *AdminMemberDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *AdminMemberDao) Columns() AdminMemberColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *AdminMemberDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *AdminMemberDao) 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 *AdminMemberDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminMemberPostDao is the data access object for table hg_admin_member_post.
|
||||
type AdminMemberPostDao 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 AdminMemberPostColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// AdminMemberPostColumns defines and stores column names for table hg_admin_member_post.
|
||||
type AdminMemberPostColumns struct {
|
||||
MemberId string // 用户ID
|
||||
PostId string // 岗位ID
|
||||
}
|
||||
|
||||
// adminMemberPostColumns holds the columns for table hg_admin_member_post.
|
||||
var adminMemberPostColumns = AdminMemberPostColumns{
|
||||
MemberId: "member_id",
|
||||
PostId: "post_id",
|
||||
}
|
||||
|
||||
// NewAdminMemberPostDao creates and returns a new DAO object for table data access.
|
||||
func NewAdminMemberPostDao() *AdminMemberPostDao {
|
||||
return &AdminMemberPostDao{
|
||||
group: "default",
|
||||
table: "hg_admin_member_post",
|
||||
columns: adminMemberPostColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *AdminMemberPostDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *AdminMemberPostDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *AdminMemberPostDao) Columns() AdminMemberPostColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *AdminMemberPostDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *AdminMemberPostDao) 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 *AdminMemberPostDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminMemberRoleDao is the data access object for table hg_admin_member_role.
|
||||
type AdminMemberRoleDao 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 AdminMemberRoleColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// AdminMemberRoleColumns defines and stores column names for table hg_admin_member_role.
|
||||
type AdminMemberRoleColumns struct {
|
||||
MemberId string // 用户ID
|
||||
RoleId string // 角色ID
|
||||
}
|
||||
|
||||
// adminMemberRoleColumns holds the columns for table hg_admin_member_role.
|
||||
var adminMemberRoleColumns = AdminMemberRoleColumns{
|
||||
MemberId: "member_id",
|
||||
RoleId: "role_id",
|
||||
}
|
||||
|
||||
// NewAdminMemberRoleDao creates and returns a new DAO object for table data access.
|
||||
func NewAdminMemberRoleDao() *AdminMemberRoleDao {
|
||||
return &AdminMemberRoleDao{
|
||||
group: "default",
|
||||
table: "hg_admin_member_role",
|
||||
columns: adminMemberRoleColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *AdminMemberRoleDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *AdminMemberRoleDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *AdminMemberRoleDao) Columns() AdminMemberRoleColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *AdminMemberRoleDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *AdminMemberRoleDao) 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 *AdminMemberRoleDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
110
hotgo-server/app/service/internal/dao/internal/admin_menu.go
Normal file
110
hotgo-server/app/service/internal/dao/internal/admin_menu.go
Normal file
@@ -0,0 +1,110 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminMenuDao is the data access object for table hg_admin_menu.
|
||||
type AdminMenuDao 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 AdminMenuColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// AdminMenuColumns defines and stores column names for table hg_admin_menu.
|
||||
type AdminMenuColumns struct {
|
||||
Id string // 菜单ID
|
||||
Pid string // 父菜单ID
|
||||
Name string // 菜单名称
|
||||
Code string // 菜单编码
|
||||
Icon string // 菜单图标
|
||||
Type string // 菜单类型(M目录 C菜单 F按钮)
|
||||
Perms string // 权限标识
|
||||
Path string // 路由地址
|
||||
Component string // 组件路径
|
||||
Query string // 路由参数
|
||||
IsFrame string // 是否内嵌
|
||||
IsCache string // 是否不缓存
|
||||
IsVisible string // 是否隐藏
|
||||
Remark string // 备注
|
||||
Level string // 级别
|
||||
Tree string // 树
|
||||
Sort string // 排序
|
||||
Status string // 菜单状态
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
}
|
||||
|
||||
// adminMenuColumns holds the columns for table hg_admin_menu.
|
||||
var adminMenuColumns = AdminMenuColumns{
|
||||
Id: "id",
|
||||
Pid: "pid",
|
||||
Name: "name",
|
||||
Code: "code",
|
||||
Icon: "icon",
|
||||
Type: "type",
|
||||
Perms: "perms",
|
||||
Path: "path",
|
||||
Component: "component",
|
||||
Query: "query",
|
||||
IsFrame: "is_frame",
|
||||
IsCache: "is_cache",
|
||||
IsVisible: "is_visible",
|
||||
Remark: "remark",
|
||||
Level: "level",
|
||||
Tree: "tree",
|
||||
Sort: "sort",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
}
|
||||
|
||||
// NewAdminMenuDao creates and returns a new DAO object for table data access.
|
||||
func NewAdminMenuDao() *AdminMenuDao {
|
||||
return &AdminMenuDao{
|
||||
group: "default",
|
||||
table: "hg_admin_menu",
|
||||
columns: adminMenuColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *AdminMenuDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *AdminMenuDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *AdminMenuDao) Columns() AdminMenuColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *AdminMenuDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *AdminMenuDao) 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 *AdminMenuDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
108
hotgo-server/app/service/internal/dao/internal/admin_menu_old.go
Normal file
108
hotgo-server/app/service/internal/dao/internal/admin_menu_old.go
Normal file
@@ -0,0 +1,108 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminMenuOldDao is the data access object for table hg_admin_menu_old.
|
||||
type AdminMenuOldDao 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 AdminMenuOldColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// AdminMenuOldColumns defines and stores column names for table hg_admin_menu_old.
|
||||
type AdminMenuOldColumns struct {
|
||||
Id string // 菜单ID
|
||||
Pid string // 父菜单ID
|
||||
Name string // 菜单名称
|
||||
Icon string // 菜单图标
|
||||
Type string // 菜单类型(M目录 C菜单 F按钮)
|
||||
Perms string // 权限标识
|
||||
Path string // 路由地址
|
||||
Component string // 组件路径
|
||||
Query string // 路由参数
|
||||
IsFrame string // 是否为外链(0是 1否)
|
||||
IsCache string // 是否缓存(0缓存 1不缓存)
|
||||
IsVisible string // 菜单状态(0显示 1隐藏)
|
||||
Remark string // 备注
|
||||
Level string // 级别
|
||||
Tree string // 树
|
||||
Sort string // 排序
|
||||
Status string // 菜单状态
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
}
|
||||
|
||||
// adminMenuOldColumns holds the columns for table hg_admin_menu_old.
|
||||
var adminMenuOldColumns = AdminMenuOldColumns{
|
||||
Id: "id",
|
||||
Pid: "pid",
|
||||
Name: "name",
|
||||
Icon: "icon",
|
||||
Type: "type",
|
||||
Perms: "perms",
|
||||
Path: "path",
|
||||
Component: "component",
|
||||
Query: "query",
|
||||
IsFrame: "is_frame",
|
||||
IsCache: "is_cache",
|
||||
IsVisible: "is_visible",
|
||||
Remark: "remark",
|
||||
Level: "level",
|
||||
Tree: "tree",
|
||||
Sort: "sort",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
}
|
||||
|
||||
// NewAdminMenuOldDao creates and returns a new DAO object for table data access.
|
||||
func NewAdminMenuOldDao() *AdminMenuOldDao {
|
||||
return &AdminMenuOldDao{
|
||||
group: "default",
|
||||
table: "hg_admin_menu_old",
|
||||
columns: adminMenuOldColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *AdminMenuOldDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *AdminMenuOldDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *AdminMenuOldDao) Columns() AdminMenuOldColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *AdminMenuOldDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *AdminMenuOldDao) 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 *AdminMenuOldDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminNoticeDao is the data access object for table hg_admin_notice.
|
||||
type AdminNoticeDao 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 AdminNoticeColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// AdminNoticeColumns defines and stores column names for table hg_admin_notice.
|
||||
type AdminNoticeColumns struct {
|
||||
Id string // 公告ID
|
||||
Title string // 公告标题
|
||||
Type string // 公告类型(1通知 2公告)
|
||||
Content string // 公告内容
|
||||
Remark string // 备注
|
||||
Status string // 公告状态
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
}
|
||||
|
||||
// adminNoticeColumns holds the columns for table hg_admin_notice.
|
||||
var adminNoticeColumns = AdminNoticeColumns{
|
||||
Id: "id",
|
||||
Title: "title",
|
||||
Type: "type",
|
||||
Content: "content",
|
||||
Remark: "remark",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
}
|
||||
|
||||
// NewAdminNoticeDao creates and returns a new DAO object for table data access.
|
||||
func NewAdminNoticeDao() *AdminNoticeDao {
|
||||
return &AdminNoticeDao{
|
||||
group: "default",
|
||||
table: "hg_admin_notice",
|
||||
columns: adminNoticeColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *AdminNoticeDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *AdminNoticeDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *AdminNoticeDao) Columns() AdminNoticeColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *AdminNoticeDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *AdminNoticeDao) 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 *AdminNoticeDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
86
hotgo-server/app/service/internal/dao/internal/admin_post.go
Normal file
86
hotgo-server/app/service/internal/dao/internal/admin_post.go
Normal file
@@ -0,0 +1,86 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminPostDao is the data access object for table hg_admin_post.
|
||||
type AdminPostDao 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 AdminPostColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// AdminPostColumns defines and stores column names for table hg_admin_post.
|
||||
type AdminPostColumns struct {
|
||||
Id string // 岗位ID
|
||||
Code string // 岗位编码
|
||||
Name string // 岗位名称
|
||||
Remark string // 备注
|
||||
Sort string // 显示顺序
|
||||
Status string // 状态
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
}
|
||||
|
||||
// adminPostColumns holds the columns for table hg_admin_post.
|
||||
var adminPostColumns = AdminPostColumns{
|
||||
Id: "id",
|
||||
Code: "code",
|
||||
Name: "name",
|
||||
Remark: "remark",
|
||||
Sort: "sort",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
}
|
||||
|
||||
// NewAdminPostDao creates and returns a new DAO object for table data access.
|
||||
func NewAdminPostDao() *AdminPostDao {
|
||||
return &AdminPostDao{
|
||||
group: "default",
|
||||
table: "hg_admin_post",
|
||||
columns: adminPostColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *AdminPostDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *AdminPostDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *AdminPostDao) Columns() AdminPostColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *AdminPostDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *AdminPostDao) 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 *AdminPostDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
92
hotgo-server/app/service/internal/dao/internal/admin_role.go
Normal file
92
hotgo-server/app/service/internal/dao/internal/admin_role.go
Normal file
@@ -0,0 +1,92 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminRoleDao is the data access object for table hg_admin_role.
|
||||
type AdminRoleDao 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 AdminRoleColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// AdminRoleColumns defines and stores column names for table hg_admin_role.
|
||||
type AdminRoleColumns struct {
|
||||
Id string // 角色ID
|
||||
Name string // 角色名称
|
||||
Key string // 角色权限字符串
|
||||
DataScope string // 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)
|
||||
MenuCheckStrictly string // 菜单树选择项是否关联显示
|
||||
DeptCheckStrictly string // 部门树选择项是否关联显示
|
||||
Remark string // 备注
|
||||
Sort string // 排序
|
||||
Status string // 角色状态
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
}
|
||||
|
||||
// adminRoleColumns holds the columns for table hg_admin_role.
|
||||
var adminRoleColumns = AdminRoleColumns{
|
||||
Id: "id",
|
||||
Name: "name",
|
||||
Key: "key",
|
||||
DataScope: "data_scope",
|
||||
MenuCheckStrictly: "menu_check_strictly",
|
||||
DeptCheckStrictly: "dept_check_strictly",
|
||||
Remark: "remark",
|
||||
Sort: "sort",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
}
|
||||
|
||||
// NewAdminRoleDao creates and returns a new DAO object for table data access.
|
||||
func NewAdminRoleDao() *AdminRoleDao {
|
||||
return &AdminRoleDao{
|
||||
group: "default",
|
||||
table: "hg_admin_role",
|
||||
columns: adminRoleColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *AdminRoleDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *AdminRoleDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *AdminRoleDao) Columns() AdminRoleColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *AdminRoleDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *AdminRoleDao) 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 *AdminRoleDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminRoleDeptDao is the data access object for table hg_admin_role_dept.
|
||||
type AdminRoleDeptDao 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 AdminRoleDeptColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// AdminRoleDeptColumns defines and stores column names for table hg_admin_role_dept.
|
||||
type AdminRoleDeptColumns struct {
|
||||
RoleId string // 角色ID
|
||||
DeptId string // 部门ID
|
||||
}
|
||||
|
||||
// adminRoleDeptColumns holds the columns for table hg_admin_role_dept.
|
||||
var adminRoleDeptColumns = AdminRoleDeptColumns{
|
||||
RoleId: "role_id",
|
||||
DeptId: "dept_id",
|
||||
}
|
||||
|
||||
// NewAdminRoleDeptDao creates and returns a new DAO object for table data access.
|
||||
func NewAdminRoleDeptDao() *AdminRoleDeptDao {
|
||||
return &AdminRoleDeptDao{
|
||||
group: "default",
|
||||
table: "hg_admin_role_dept",
|
||||
columns: adminRoleDeptColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *AdminRoleDeptDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *AdminRoleDeptDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *AdminRoleDeptDao) Columns() AdminRoleDeptColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *AdminRoleDeptDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *AdminRoleDeptDao) 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 *AdminRoleDeptDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminRoleMenuDao is the data access object for table hg_admin_role_menu.
|
||||
type AdminRoleMenuDao 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 AdminRoleMenuColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// AdminRoleMenuColumns defines and stores column names for table hg_admin_role_menu.
|
||||
type AdminRoleMenuColumns struct {
|
||||
RoleId string // 角色ID
|
||||
MenuId string // 菜单ID
|
||||
}
|
||||
|
||||
// adminRoleMenuColumns holds the columns for table hg_admin_role_menu.
|
||||
var adminRoleMenuColumns = AdminRoleMenuColumns{
|
||||
RoleId: "role_id",
|
||||
MenuId: "menu_id",
|
||||
}
|
||||
|
||||
// NewAdminRoleMenuDao creates and returns a new DAO object for table data access.
|
||||
func NewAdminRoleMenuDao() *AdminRoleMenuDao {
|
||||
return &AdminRoleMenuDao{
|
||||
group: "default",
|
||||
table: "hg_admin_role_menu",
|
||||
columns: adminRoleMenuColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *AdminRoleMenuDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *AdminRoleMenuDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *AdminRoleMenuDao) Columns() AdminRoleMenuColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *AdminRoleMenuDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *AdminRoleMenuDao) 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 *AdminRoleMenuDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
88
hotgo-server/app/service/internal/dao/internal/sys_config.go
Normal file
88
hotgo-server/app/service/internal/dao/internal/sys_config.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// SysConfigDao is the data access object for table hg_sys_config.
|
||||
type SysConfigDao 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 SysConfigColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// SysConfigColumns defines and stores column names for table hg_sys_config.
|
||||
type SysConfigColumns struct {
|
||||
Id string // 配置ID
|
||||
Name string // 参数名称
|
||||
Key string // 参数键名
|
||||
Value string // 参数键值
|
||||
IsDefault string // 是否默认
|
||||
Status string // 状态
|
||||
Remark string // 备注
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
}
|
||||
|
||||
// sysConfigColumns holds the columns for table hg_sys_config.
|
||||
var sysConfigColumns = SysConfigColumns{
|
||||
Id: "id",
|
||||
Name: "name",
|
||||
Key: "key",
|
||||
Value: "value",
|
||||
IsDefault: "is_default",
|
||||
Status: "status",
|
||||
Remark: "remark",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
}
|
||||
|
||||
// NewSysConfigDao creates and returns a new DAO object for table data access.
|
||||
func NewSysConfigDao() *SysConfigDao {
|
||||
return &SysConfigDao{
|
||||
group: "default",
|
||||
table: "hg_sys_config",
|
||||
columns: sysConfigColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *SysConfigDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *SysConfigDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *SysConfigDao) Columns() SysConfigColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *SysConfigDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *SysConfigDao) 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 *SysConfigDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// SysDictDataDao is the data access object for table hg_sys_dict_data.
|
||||
type SysDictDataDao 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 SysDictDataColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// SysDictDataColumns defines and stores column names for table hg_sys_dict_data.
|
||||
type SysDictDataColumns struct {
|
||||
Id string // 字典编码
|
||||
Label string // 字典标签
|
||||
Value string // 字典键值
|
||||
Type string // 字典类型
|
||||
ListClass string // 表格回显样式
|
||||
IsDefault string // 是否默认
|
||||
Sort string // 字典排序
|
||||
Remark string // 备注
|
||||
Status string // 状态
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
}
|
||||
|
||||
// sysDictDataColumns holds the columns for table hg_sys_dict_data.
|
||||
var sysDictDataColumns = SysDictDataColumns{
|
||||
Id: "id",
|
||||
Label: "label",
|
||||
Value: "value",
|
||||
Type: "type",
|
||||
ListClass: "list_class",
|
||||
IsDefault: "is_default",
|
||||
Sort: "sort",
|
||||
Remark: "remark",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
}
|
||||
|
||||
// NewSysDictDataDao creates and returns a new DAO object for table data access.
|
||||
func NewSysDictDataDao() *SysDictDataDao {
|
||||
return &SysDictDataDao{
|
||||
group: "default",
|
||||
table: "hg_sys_dict_data",
|
||||
columns: sysDictDataColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *SysDictDataDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *SysDictDataDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *SysDictDataDao) Columns() SysDictDataColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *SysDictDataDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *SysDictDataDao) 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 *SysDictDataDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// SysDictTypeDao is the data access object for table hg_sys_dict_type.
|
||||
type SysDictTypeDao 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 SysDictTypeColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// SysDictTypeColumns defines and stores column names for table hg_sys_dict_type.
|
||||
type SysDictTypeColumns struct {
|
||||
Id string // 字典主键
|
||||
Name string // 字典名称
|
||||
Type string // 字典类型
|
||||
Sort string // 排序
|
||||
Remark string // 备注
|
||||
Status string // 状态
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
}
|
||||
|
||||
// sysDictTypeColumns holds the columns for table hg_sys_dict_type.
|
||||
var sysDictTypeColumns = SysDictTypeColumns{
|
||||
Id: "id",
|
||||
Name: "name",
|
||||
Type: "type",
|
||||
Sort: "sort",
|
||||
Remark: "remark",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
}
|
||||
|
||||
// NewSysDictTypeDao creates and returns a new DAO object for table data access.
|
||||
func NewSysDictTypeDao() *SysDictTypeDao {
|
||||
return &SysDictTypeDao{
|
||||
group: "default",
|
||||
table: "hg_sys_dict_type",
|
||||
columns: sysDictTypeColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *SysDictTypeDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *SysDictTypeDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *SysDictTypeDao) Columns() SysDictTypeColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *SysDictTypeDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *SysDictTypeDao) 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 *SysDictTypeDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
116
hotgo-server/app/service/internal/dao/internal/sys_log.go
Normal file
116
hotgo-server/app/service/internal/dao/internal/sys_log.go
Normal file
@@ -0,0 +1,116 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// SysLogDao is the data access object for table hg_sys_log.
|
||||
type SysLogDao 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 SysLogColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// SysLogColumns defines and stores column names for table hg_sys_log.
|
||||
type SysLogColumns struct {
|
||||
Id string //
|
||||
AppId string // 应用id
|
||||
MerchantId string // 商户id
|
||||
MemberId string // 用户id
|
||||
Method string // 提交类型
|
||||
Module string // 模块
|
||||
Url string // 提交url
|
||||
GetData string // get数据
|
||||
PostData string // post数据
|
||||
HeaderData string // header数据
|
||||
Ip string // ip地址
|
||||
ProvinceId string // 省编码
|
||||
CityId string // 市编码
|
||||
ErrorCode string // 报错code
|
||||
ErrorMsg string // 报错信息
|
||||
ErrorData string // 报错日志
|
||||
ReqId string // 对外id
|
||||
Timestamp string // 响应时间
|
||||
UserAgent string // UA信息
|
||||
TakeUpTime string // 请求耗时
|
||||
Status string // 状态
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 修改时间
|
||||
}
|
||||
|
||||
// sysLogColumns holds the columns for table hg_sys_log.
|
||||
var sysLogColumns = SysLogColumns{
|
||||
Id: "id",
|
||||
AppId: "app_id",
|
||||
MerchantId: "merchant_id",
|
||||
MemberId: "member_id",
|
||||
Method: "method",
|
||||
Module: "module",
|
||||
Url: "url",
|
||||
GetData: "get_data",
|
||||
PostData: "post_data",
|
||||
HeaderData: "header_data",
|
||||
Ip: "ip",
|
||||
ProvinceId: "province_id",
|
||||
CityId: "city_id",
|
||||
ErrorCode: "error_code",
|
||||
ErrorMsg: "error_msg",
|
||||
ErrorData: "error_data",
|
||||
ReqId: "req_id",
|
||||
Timestamp: "timestamp",
|
||||
UserAgent: "user_agent",
|
||||
TakeUpTime: "take_up_time",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
}
|
||||
|
||||
// NewSysLogDao creates and returns a new DAO object for table data access.
|
||||
func NewSysLogDao() *SysLogDao {
|
||||
return &SysLogDao{
|
||||
group: "default",
|
||||
table: "hg_sys_log",
|
||||
columns: sysLogColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *SysLogDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *SysLogDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *SysLogDao) Columns() SysLogColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *SysLogDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *SysLogDao) 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 *SysLogDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// SysProvincesDao is the data access object for table hg_sys_provinces.
|
||||
type SysProvincesDao 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 SysProvincesColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// SysProvincesColumns defines and stores column names for table hg_sys_provinces.
|
||||
type SysProvincesColumns struct {
|
||||
Id string // ID
|
||||
Title string // 栏目名
|
||||
Pid string // 父栏目
|
||||
ShortTitle string // 缩写
|
||||
Areacode string // 区域编码
|
||||
Zipcode string // 邮政编码
|
||||
Pinyin string // 拼音
|
||||
Lng string // 经度
|
||||
Lat string // 纬度
|
||||
Level string // 级别
|
||||
Tree string //
|
||||
Sort string // 排序
|
||||
}
|
||||
|
||||
// sysProvincesColumns holds the columns for table hg_sys_provinces.
|
||||
var sysProvincesColumns = SysProvincesColumns{
|
||||
Id: "id",
|
||||
Title: "title",
|
||||
Pid: "pid",
|
||||
ShortTitle: "short_title",
|
||||
Areacode: "areacode",
|
||||
Zipcode: "zipcode",
|
||||
Pinyin: "pinyin",
|
||||
Lng: "lng",
|
||||
Lat: "lat",
|
||||
Level: "level",
|
||||
Tree: "tree",
|
||||
Sort: "sort",
|
||||
}
|
||||
|
||||
// NewSysProvincesDao creates and returns a new DAO object for table data access.
|
||||
func NewSysProvincesDao() *SysProvincesDao {
|
||||
return &SysProvincesDao{
|
||||
group: "default",
|
||||
table: "hg_sys_provinces",
|
||||
columns: sysProvincesColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *SysProvincesDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *SysProvincesDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *SysProvincesDao) Columns() SysProvincesColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *SysProvincesDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *SysProvincesDao) 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 *SysProvincesDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
58
hotgo-server/app/service/internal/dao/sys_config.go
Normal file
58
hotgo-server/app/service/internal/dao/sys_config.go
Normal file
@@ -0,0 +1,58 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
// sysConfigDao is the data access object for table hg_sys_config.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type sysConfigDao struct {
|
||||
*internal.SysConfigDao
|
||||
}
|
||||
|
||||
var (
|
||||
// SysConfig is globally public accessible object for table hg_sys_config operations.
|
||||
SysConfig = sysConfigDao{
|
||||
internal.NewSysConfigDao(),
|
||||
}
|
||||
)
|
||||
|
||||
//
|
||||
// @Title 判断名称是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param id
|
||||
// @Param name
|
||||
// @Return bool
|
||||
// @Return error
|
||||
//
|
||||
func (dao *sysConfigDao) IsUniqueName(ctx context.Context, id int64, name string) (bool, error) {
|
||||
var data *entity.SysConfig
|
||||
m := dao.Ctx(ctx).Where("name", name)
|
||||
|
||||
if id > 0 {
|
||||
m = m.WhereNot("id", id)
|
||||
}
|
||||
|
||||
if err := m.Scan(&data); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// Fill with you ideas below.
|
||||
62
hotgo-server/app/service/internal/dao/sys_dict_data.go
Normal file
62
hotgo-server/app/service/internal/dao/sys_dict_data.go
Normal file
@@ -0,0 +1,62 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
// sysDictDataDao is the data access object for table hg_sys_dict_data.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type sysDictDataDao struct {
|
||||
*internal.SysDictDataDao
|
||||
}
|
||||
|
||||
var (
|
||||
// SysDictData is globally public accessible object for table hg_sys_dict_data operations.
|
||||
SysDictData = sysDictDataDao{
|
||||
internal.NewSysDictDataDao(),
|
||||
}
|
||||
)
|
||||
|
||||
//
|
||||
// @Title 判断字典类型是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param id
|
||||
// @Param dictType
|
||||
// @Return bool
|
||||
// @Return error
|
||||
//
|
||||
func (dao *sysDictDataDao) IsUnique(ctx context.Context, id int64, dictType string, dictValue string) (bool, error) {
|
||||
var (
|
||||
data *entity.SysDictData
|
||||
err error
|
||||
)
|
||||
m := dao.Ctx(ctx).Where("type", dictType).Where("value", dictValue)
|
||||
|
||||
if id > 0 {
|
||||
m = m.WhereNot("id", id)
|
||||
}
|
||||
|
||||
if err = m.Scan(&data); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
|
||||
}
|
||||
|
||||
// Fill with you ideas below.
|
||||
62
hotgo-server/app/service/internal/dao/sys_dict_type.go
Normal file
62
hotgo-server/app/service/internal/dao/sys_dict_type.go
Normal file
@@ -0,0 +1,62 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
// sysDictTypeDao is the data access object for table hg_sys_dict_type.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type sysDictTypeDao struct {
|
||||
*internal.SysDictTypeDao
|
||||
}
|
||||
|
||||
var (
|
||||
// SysDictType is globally public accessible object for table hg_sys_dict_type operations.
|
||||
SysDictType = sysDictTypeDao{
|
||||
internal.NewSysDictTypeDao(),
|
||||
}
|
||||
)
|
||||
|
||||
//
|
||||
// @Title 判断字典类型是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param id
|
||||
// @Param dictType
|
||||
// @Return bool
|
||||
// @Return error
|
||||
//
|
||||
func (dao *sysDictTypeDao) IsUnique(ctx context.Context, id int64, dictType string) (bool, error) {
|
||||
var (
|
||||
data *entity.SysDictType
|
||||
err error
|
||||
)
|
||||
m := dao.Ctx(ctx).Where("type", dictType)
|
||||
|
||||
if id > 0 {
|
||||
m = m.WhereNot("id", id)
|
||||
}
|
||||
|
||||
if err = m.Scan(&data); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
|
||||
}
|
||||
|
||||
// Fill with you ideas below.
|
||||
24
hotgo-server/app/service/internal/dao/sys_log.go
Normal file
24
hotgo-server/app/service/internal/dao/sys_log.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
)
|
||||
|
||||
// sysLogDao is the data access object for table hg_sys_log.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type sysLogDao struct {
|
||||
*internal.SysLogDao
|
||||
}
|
||||
|
||||
var (
|
||||
// SysLog is globally public accessible object for table hg_sys_log operations.
|
||||
SysLog = sysLogDao{
|
||||
internal.NewSysLogDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Fill with you ideas below.
|
||||
73
hotgo-server/app/service/internal/dao/sys_provinces.go
Normal file
73
hotgo-server/app/service/internal/dao/sys_provinces.go
Normal file
@@ -0,0 +1,73 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
|
||||
"github.com/gogf/gf/v2/container/gvar"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
// sysProvincesDao is the data access object for table hg_sys_provinces.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type sysProvincesDao struct {
|
||||
*internal.SysProvincesDao
|
||||
}
|
||||
|
||||
var (
|
||||
// SysProvinces is globally public accessible object for table hg_sys_provinces operations.
|
||||
SysProvinces = sysProvincesDao{
|
||||
internal.NewSysProvincesDao(),
|
||||
}
|
||||
)
|
||||
|
||||
//
|
||||
// @Title 获取省市编码对应的地区名称
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param province
|
||||
// @Param city
|
||||
// @Param spilt
|
||||
// @Return string
|
||||
// @Return error
|
||||
//
|
||||
func (dao *sysProvincesDao) GetRegion(ctx context.Context, province int, city int, spilt ...string) (string, error) {
|
||||
|
||||
var (
|
||||
provinceName *gvar.Var
|
||||
cityName *gvar.Var
|
||||
err error
|
||||
)
|
||||
// TODO 默认分隔符
|
||||
spiltSymbol := "-"
|
||||
if len(spilt) > 0 {
|
||||
spiltSymbol = spilt[0]
|
||||
}
|
||||
|
||||
if province > 0 {
|
||||
provinceName, err = dao.Ctx(ctx).Where("id", province).Fields("title").Value()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return "", err
|
||||
}
|
||||
|
||||
if city > 0 {
|
||||
cityName, err = dao.Ctx(ctx).Where("id", city).Fields("title").Value()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return "内网IP", nil
|
||||
}
|
||||
|
||||
return provinceName.String() + spiltSymbol + cityName.String(), nil
|
||||
}
|
||||
|
||||
// Fill with you ideas below.
|
||||
28
hotgo-server/app/service/internal/dto/admin_dept.go
Normal file
28
hotgo-server/app/service/internal/dto/admin_dept.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// AdminDept is the golang structure of table hg_admin_dept for DAO operations like Where/Data.
|
||||
type AdminDept struct {
|
||||
g.Meta `orm:"table:hg_admin_dept, dto:true"`
|
||||
Id interface{} // 部门id
|
||||
Pid interface{} // 父部门id
|
||||
Ancestors interface{} // 祖级列表
|
||||
Name interface{} // 部门名称
|
||||
Code interface{} // 部门编码
|
||||
Type interface{} // 部门类型
|
||||
Leader interface{} // 负责人
|
||||
Phone interface{} // 联系电话
|
||||
Email interface{} // 邮箱
|
||||
Sort interface{} // 排序
|
||||
Status interface{} // 部门状态
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
}
|
||||
44
hotgo-server/app/service/internal/dto/admin_member.go
Normal file
44
hotgo-server/app/service/internal/dto/admin_member.go
Normal file
@@ -0,0 +1,44 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// AdminMember is the golang structure of table hg_admin_member for DAO operations like Where/Data.
|
||||
type AdminMember struct {
|
||||
g.Meta `orm:"table:hg_admin_member, dto:true"`
|
||||
Id interface{} //
|
||||
DeptId interface{} // 部门ID
|
||||
Username interface{} // 帐号
|
||||
PasswordHash interface{} // 密码
|
||||
Salt interface{} // 密码盐
|
||||
AuthKey interface{} // 授权令牌
|
||||
PasswordResetToken interface{} // 密码重置令牌
|
||||
Type interface{} // 1:普通管理员;10超级管理员
|
||||
Realname interface{} // 真实姓名
|
||||
Avatar interface{} // 头像
|
||||
Sex interface{} // 性别[0:未知;1:男;2:女]
|
||||
Qq interface{} // qq
|
||||
Email interface{} // 邮箱
|
||||
Birthday *gtime.Time // 生日
|
||||
ProvinceId interface{} // 省
|
||||
CityId interface{} // 城市
|
||||
AreaId interface{} // 地区
|
||||
Address interface{} // 默认地址
|
||||
Mobile interface{} // 手机号码
|
||||
HomePhone interface{} // 家庭号码
|
||||
DingtalkRobotToken interface{} // 钉钉机器人token
|
||||
VisitCount interface{} // 访问次数
|
||||
LastTime interface{} // 最后一次登录时间
|
||||
LastIp interface{} // 最后一次登录ip
|
||||
Role interface{} // 权限
|
||||
Remark interface{} // 备注
|
||||
Status interface{} // 状态
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 修改时间
|
||||
}
|
||||
16
hotgo-server/app/service/internal/dto/admin_member_post.go
Normal file
16
hotgo-server/app/service/internal/dto/admin_member_post.go
Normal file
@@ -0,0 +1,16 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminMemberPost is the golang structure of table hg_admin_member_post for DAO operations like Where/Data.
|
||||
type AdminMemberPost struct {
|
||||
g.Meta `orm:"table:hg_admin_member_post, dto:true"`
|
||||
MemberId interface{} // 用户ID
|
||||
PostId interface{} // 岗位ID
|
||||
}
|
||||
16
hotgo-server/app/service/internal/dto/admin_member_role.go
Normal file
16
hotgo-server/app/service/internal/dto/admin_member_role.go
Normal file
@@ -0,0 +1,16 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminMemberRole is the golang structure of table hg_admin_member_role for DAO operations like Where/Data.
|
||||
type AdminMemberRole struct {
|
||||
g.Meta `orm:"table:hg_admin_member_role, dto:true"`
|
||||
MemberId interface{} // 用户ID
|
||||
RoleId interface{} // 角色ID
|
||||
}
|
||||
35
hotgo-server/app/service/internal/dto/admin_menu.go
Normal file
35
hotgo-server/app/service/internal/dto/admin_menu.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// AdminMenu is the golang structure of table hg_admin_menu for DAO operations like Where/Data.
|
||||
type AdminMenu struct {
|
||||
g.Meta `orm:"table:hg_admin_menu, dto:true"`
|
||||
Id interface{} // 菜单ID
|
||||
Pid interface{} // 父菜单ID
|
||||
Name interface{} // 菜单名称
|
||||
Code interface{} // 菜单编码
|
||||
Icon interface{} // 菜单图标
|
||||
Type interface{} // 菜单类型(M目录 C菜单 F按钮)
|
||||
Perms interface{} // 权限标识
|
||||
Path interface{} // 路由地址
|
||||
Component interface{} // 组件路径
|
||||
Query interface{} // 路由参数
|
||||
IsFrame interface{} // 是否内嵌
|
||||
IsCache interface{} // 是否不缓存
|
||||
IsVisible interface{} // 是否隐藏
|
||||
Remark interface{} // 备注
|
||||
Level interface{} // 级别
|
||||
Tree interface{} // 树
|
||||
Sort interface{} // 排序
|
||||
Status interface{} // 菜单状态
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
}
|
||||
34
hotgo-server/app/service/internal/dto/admin_menu_old.go
Normal file
34
hotgo-server/app/service/internal/dto/admin_menu_old.go
Normal file
@@ -0,0 +1,34 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// AdminMenuOld is the golang structure of table hg_admin_menu_old for DAO operations like Where/Data.
|
||||
type AdminMenuOld struct {
|
||||
g.Meta `orm:"table:hg_admin_menu_old, dto:true"`
|
||||
Id interface{} // 菜单ID
|
||||
Pid interface{} // 父菜单ID
|
||||
Name interface{} // 菜单名称
|
||||
Icon interface{} // 菜单图标
|
||||
Type interface{} // 菜单类型(M目录 C菜单 F按钮)
|
||||
Perms interface{} // 权限标识
|
||||
Path interface{} // 路由地址
|
||||
Component interface{} // 组件路径
|
||||
Query interface{} // 路由参数
|
||||
IsFrame interface{} // 是否为外链(0是 1否)
|
||||
IsCache interface{} // 是否缓存(0缓存 1不缓存)
|
||||
IsVisible interface{} // 菜单状态(0显示 1隐藏)
|
||||
Remark interface{} // 备注
|
||||
Level interface{} // 级别
|
||||
Tree interface{} // 树
|
||||
Sort interface{} // 排序
|
||||
Status interface{} // 菜单状态
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
}
|
||||
23
hotgo-server/app/service/internal/dto/admin_notice.go
Normal file
23
hotgo-server/app/service/internal/dto/admin_notice.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// AdminNotice is the golang structure of table hg_admin_notice for DAO operations like Where/Data.
|
||||
type AdminNotice struct {
|
||||
g.Meta `orm:"table:hg_admin_notice, dto:true"`
|
||||
Id interface{} // 公告ID
|
||||
Title interface{} // 公告标题
|
||||
Type interface{} // 公告类型(1通知 2公告)
|
||||
Content interface{} // 公告内容
|
||||
Remark interface{} // 备注
|
||||
Status interface{} // 公告状态
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
}
|
||||
23
hotgo-server/app/service/internal/dto/admin_post.go
Normal file
23
hotgo-server/app/service/internal/dto/admin_post.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// AdminPost is the golang structure of table hg_admin_post for DAO operations like Where/Data.
|
||||
type AdminPost struct {
|
||||
g.Meta `orm:"table:hg_admin_post, dto:true"`
|
||||
Id interface{} // 岗位ID
|
||||
Code interface{} // 岗位编码
|
||||
Name interface{} // 岗位名称
|
||||
Remark interface{} // 备注
|
||||
Sort interface{} // 显示顺序
|
||||
Status interface{} // 状态
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
}
|
||||
26
hotgo-server/app/service/internal/dto/admin_role.go
Normal file
26
hotgo-server/app/service/internal/dto/admin_role.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// AdminRole is the golang structure of table hg_admin_role for DAO operations like Where/Data.
|
||||
type AdminRole struct {
|
||||
g.Meta `orm:"table:hg_admin_role, dto:true"`
|
||||
Id interface{} // 角色ID
|
||||
Name interface{} // 角色名称
|
||||
Key interface{} // 角色权限字符串
|
||||
DataScope interface{} // 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)
|
||||
MenuCheckStrictly interface{} // 菜单树选择项是否关联显示
|
||||
DeptCheckStrictly interface{} // 部门树选择项是否关联显示
|
||||
Remark interface{} // 备注
|
||||
Sort interface{} // 排序
|
||||
Status interface{} // 角色状态
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
}
|
||||
16
hotgo-server/app/service/internal/dto/admin_role_dept.go
Normal file
16
hotgo-server/app/service/internal/dto/admin_role_dept.go
Normal file
@@ -0,0 +1,16 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminRoleDept is the golang structure of table hg_admin_role_dept for DAO operations like Where/Data.
|
||||
type AdminRoleDept struct {
|
||||
g.Meta `orm:"table:hg_admin_role_dept, dto:true"`
|
||||
RoleId interface{} // 角色ID
|
||||
DeptId interface{} // 部门ID
|
||||
}
|
||||
16
hotgo-server/app/service/internal/dto/admin_role_menu.go
Normal file
16
hotgo-server/app/service/internal/dto/admin_role_menu.go
Normal file
@@ -0,0 +1,16 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// AdminRoleMenu is the golang structure of table hg_admin_role_menu for DAO operations like Where/Data.
|
||||
type AdminRoleMenu struct {
|
||||
g.Meta `orm:"table:hg_admin_role_menu, dto:true"`
|
||||
RoleId interface{} // 角色ID
|
||||
MenuId interface{} // 菜单ID
|
||||
}
|
||||
24
hotgo-server/app/service/internal/dto/sys_config.go
Normal file
24
hotgo-server/app/service/internal/dto/sys_config.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// SysConfig is the golang structure of table hg_sys_config for DAO operations like Where/Data.
|
||||
type SysConfig struct {
|
||||
g.Meta `orm:"table:hg_sys_config, dto:true"`
|
||||
Id interface{} // 配置ID
|
||||
Name interface{} // 参数名称
|
||||
Key interface{} // 参数键名
|
||||
Value interface{} // 参数键值
|
||||
IsDefault interface{} // 是否默认
|
||||
Status interface{} // 状态
|
||||
Remark interface{} // 备注
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
}
|
||||
26
hotgo-server/app/service/internal/dto/sys_dict_data.go
Normal file
26
hotgo-server/app/service/internal/dto/sys_dict_data.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// SysDictData is the golang structure of table hg_sys_dict_data for DAO operations like Where/Data.
|
||||
type SysDictData struct {
|
||||
g.Meta `orm:"table:hg_sys_dict_data, dto:true"`
|
||||
Id interface{} // 字典编码
|
||||
Label interface{} // 字典标签
|
||||
Value interface{} // 字典键值
|
||||
Type interface{} // 字典类型
|
||||
ListClass interface{} // 表格回显样式
|
||||
IsDefault interface{} // 是否默认
|
||||
Sort interface{} // 字典排序
|
||||
Remark interface{} // 备注
|
||||
Status interface{} // 状态
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
}
|
||||
23
hotgo-server/app/service/internal/dto/sys_dict_type.go
Normal file
23
hotgo-server/app/service/internal/dto/sys_dict_type.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// SysDictType is the golang structure of table hg_sys_dict_type for DAO operations like Where/Data.
|
||||
type SysDictType struct {
|
||||
g.Meta `orm:"table:hg_sys_dict_type, dto:true"`
|
||||
Id interface{} // 字典主键
|
||||
Name interface{} // 字典名称
|
||||
Type interface{} // 字典类型
|
||||
Sort interface{} // 排序
|
||||
Remark interface{} // 备注
|
||||
Status interface{} // 状态
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
}
|
||||
38
hotgo-server/app/service/internal/dto/sys_log.go
Normal file
38
hotgo-server/app/service/internal/dto/sys_log.go
Normal file
@@ -0,0 +1,38 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// SysLog is the golang structure of table hg_sys_log for DAO operations like Where/Data.
|
||||
type SysLog struct {
|
||||
g.Meta `orm:"table:hg_sys_log, dto:true"`
|
||||
Id interface{} //
|
||||
AppId interface{} // 应用id
|
||||
MerchantId interface{} // 商户id
|
||||
MemberId interface{} // 用户id
|
||||
Method interface{} // 提交类型
|
||||
Module interface{} // 模块
|
||||
Url interface{} // 提交url
|
||||
GetData interface{} // get数据
|
||||
PostData interface{} // post数据
|
||||
HeaderData interface{} // header数据
|
||||
Ip interface{} // ip地址
|
||||
ProvinceId interface{} // 省编码
|
||||
CityId interface{} // 市编码
|
||||
ErrorCode interface{} // 报错code
|
||||
ErrorMsg interface{} // 报错信息
|
||||
ErrorData interface{} // 报错日志
|
||||
ReqId interface{} // 对外id
|
||||
Timestamp interface{} // 响应时间
|
||||
UserAgent interface{} // UA信息
|
||||
TakeUpTime interface{} // 请求耗时
|
||||
Status interface{} // 状态
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 修改时间
|
||||
}
|
||||
26
hotgo-server/app/service/internal/dto/sys_provinces.go
Normal file
26
hotgo-server/app/service/internal/dto/sys_provinces.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// SysProvinces is the golang structure of table hg_sys_provinces for DAO operations like Where/Data.
|
||||
type SysProvinces struct {
|
||||
g.Meta `orm:"table:hg_sys_provinces, dto:true"`
|
||||
Id interface{} // ID
|
||||
Title interface{} // 栏目名
|
||||
Pid interface{} // 父栏目
|
||||
ShortTitle interface{} // 缩写
|
||||
Areacode interface{} // 区域编码
|
||||
Zipcode interface{} // 邮政编码
|
||||
Pinyin interface{} // 拼音
|
||||
Lng interface{} // 经度
|
||||
Lat interface{} // 纬度
|
||||
Level interface{} // 级别
|
||||
Tree interface{} //
|
||||
Sort interface{} // 排序
|
||||
}
|
||||
233
hotgo-server/app/service/sysService/config_service.go
Normal file
233
hotgo-server/app/service/sysService/config_service.go
Normal file
@@ -0,0 +1,233 @@
|
||||
package sysService
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/form/input"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
var Config = new(config)
|
||||
|
||||
type config struct{}
|
||||
|
||||
//
|
||||
// @Title 最大排序
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictDataMaxSortRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *config) GetValue(ctx context.Context, in input.SysConfigGetValueInp) (*input.SysConfigGetValueModel, error) {
|
||||
var res input.SysConfigGetValueModel
|
||||
|
||||
if err := dao.SysConfig.Ctx(ctx).
|
||||
Fields("value").
|
||||
Where("key", in.Key).
|
||||
Order("id desc").
|
||||
Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 菜单名称是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *config) NameUnique(ctx context.Context, in input.SysConfigNameUniqueInp) (*input.SysConfigNameUniqueModel, error) {
|
||||
|
||||
var res input.SysConfigNameUniqueModel
|
||||
isUnique, err := dao.SysConfig.IsUniqueName(ctx, in.Id, in.Name)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.IsUnique = isUnique
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 删除
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *config) Delete(ctx context.Context, in input.SysConfigDeleteInp) error {
|
||||
|
||||
exist, err := dao.SysConfig.Ctx(ctx).Where("Member_id", in.Id).One()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !exist.IsEmpty() {
|
||||
return gerror.New("请先解除该部门下所有已关联用户关联关系!")
|
||||
}
|
||||
_, err = dao.SysConfig.Ctx(ctx).Where("id", in.Id).Delete()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 修改/新增
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *config) Edit(ctx context.Context, in input.SysConfigEditInp) (err error) {
|
||||
|
||||
if in.Name == "" {
|
||||
err = gerror.New("名称不能为空")
|
||||
return err
|
||||
}
|
||||
|
||||
uniqueName, err := dao.SysConfig.IsUniqueName(ctx, in.Id, in.Name)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
if !uniqueName {
|
||||
err = gerror.New("名称已存在")
|
||||
return err
|
||||
}
|
||||
|
||||
// 修改
|
||||
in.UpdatedAt = gtime.Now()
|
||||
if in.Id > 0 {
|
||||
_, err = dao.SysConfig.Ctx(ctx).Where("id", in.Id).Data(in).Update()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 新增
|
||||
in.CreatedAt = gtime.Now()
|
||||
_, err = dao.SysConfig.Ctx(ctx).Data(in).Insert()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 最大排序
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictDataMaxSortRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *config) MaxSort(ctx context.Context, in input.SysConfigMaxSortInp) (*input.SysConfigMaxSortModel, error) {
|
||||
var res input.SysConfigMaxSortModel
|
||||
|
||||
if in.Id > 0 {
|
||||
if err := dao.SysConfig.Ctx(ctx).Where("id", in.Id).Order("sort desc").Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
res.Sort = res.Sort + 10
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取指定字典类型信息
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeViewRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *config) View(ctx context.Context, in input.SysConfigViewInp) (res *input.SysConfigViewModel, err error) {
|
||||
|
||||
if err = dao.SysConfig.Ctx(ctx).Where("id", in.Id).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *config) List(ctx context.Context, in input.SysConfigListInp) (list []*input.SysConfigListModel, totalCount int, err error) {
|
||||
|
||||
mod := dao.SysConfig.Ctx(ctx)
|
||||
|
||||
if in.Realname != "" {
|
||||
mod = mod.WhereLike("realname", "%"+in.Realname+"%")
|
||||
}
|
||||
if in.Username != "" {
|
||||
mod = mod.WhereLike("username", "%"+in.Username+"%")
|
||||
}
|
||||
if in.Mobile > 0 {
|
||||
mod = mod.Where("mobile", in.Mobile)
|
||||
}
|
||||
if in.Status > 0 {
|
||||
mod = mod.Where("status", in.Status)
|
||||
}
|
||||
if in.DeptId > 0 {
|
||||
mod = mod.Where("dept_id", in.DeptId)
|
||||
}
|
||||
|
||||
// 日期范围
|
||||
if in.StartTime != "" {
|
||||
mod = mod.WhereGTE("created_at", in.StartTime)
|
||||
}
|
||||
if in.EndTime != "" {
|
||||
mod = mod.WhereLTE("created_at", in.EndTime)
|
||||
}
|
||||
|
||||
totalCount, err = mod.Count()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
err = mod.Page(in.Page, in.Limit).Order("id desc").Scan(&list)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
//// TODO 重写树入参
|
||||
//for i := 0; i < len(list); i++ {
|
||||
//}
|
||||
|
||||
return list, totalCount, err
|
||||
}
|
||||
505
hotgo-server/app/service/sysService/dict_service.go
Normal file
505
hotgo-server/app/service/sysService/dict_service.go
Normal file
@@ -0,0 +1,505 @@
|
||||
//
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2022 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package sysService
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/com"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/form/adminForm"
|
||||
"github.com/bufanyun/hotgo/app/model"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao"
|
||||
"github.com/bufanyun/hotgo/app/utils"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
var Dict = new(dict)
|
||||
|
||||
type dict struct{}
|
||||
|
||||
//
|
||||
// @Title 数据键值是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *dict) DataUnique(ctx context.Context, req *adminForm.DictDataUniqueReq) (*adminForm.DictDataUniqueRes, error) {
|
||||
var (
|
||||
res adminForm.DictDataUniqueRes
|
||||
err error
|
||||
)
|
||||
|
||||
res.IsUnique, err = dao.SysDictData.IsUnique(ctx, req.Id, req.Type, req.Value)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 查询字典数据最大排序
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictDataMaxSortRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *dict) DataMaxSort(ctx context.Context, req *adminForm.DictDataMaxSortReq) (*adminForm.DictDataMaxSortRes, error) {
|
||||
var (
|
||||
m = dao.SysDictData.Ctx(ctx).Where("type", req.Type).Order("sort desc")
|
||||
res adminForm.DictDataMaxSortRes
|
||||
err error
|
||||
)
|
||||
|
||||
if err = m.Scan(&res); err != nil && err.Error() != "sql: no rows in result set" {
|
||||
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.Sort = res.Sort + 10
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 删除字典类型
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *dict) DataDelete(ctx context.Context, req *adminForm.DictDataDeleteReq) error {
|
||||
var (
|
||||
m = dao.SysDictData.Ctx(ctx).Where("id", req.Id)
|
||||
err error
|
||||
)
|
||||
|
||||
_, err = m.Delete()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 修改/新增字典类型
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *dict) DataEdit(ctx context.Context, req *adminForm.DictDataEditReq) error {
|
||||
var (
|
||||
m = dao.SysDictData.Ctx(ctx)
|
||||
isUnique bool
|
||||
err error
|
||||
)
|
||||
|
||||
if req.Label == "" {
|
||||
err = gerror.New("字典标签不能为空")
|
||||
return err
|
||||
}
|
||||
if req.Type == "" {
|
||||
err = gerror.New("字典类型不能为空")
|
||||
return err
|
||||
}
|
||||
if req.Value == "" {
|
||||
err = gerror.New("字典键值不能为空")
|
||||
return err
|
||||
}
|
||||
|
||||
isUnique, err = dao.SysDictData.IsUnique(ctx, req.Id, req.Type, req.Value)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
if !isUnique {
|
||||
err = gerror.New("字典键值已存在")
|
||||
return err
|
||||
}
|
||||
|
||||
req.UpdatedAt = gtime.Now()
|
||||
|
||||
// 修改
|
||||
if req.Id > 0 {
|
||||
_, err = m.Where("id", req.Id).Data(req).Update()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
req.CreatedAt = gtime.Now()
|
||||
|
||||
// 新增
|
||||
_, err = m.Data(req).Insert()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取指定字典数据信息
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeViewRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *dict) DataView(ctx context.Context, req *adminForm.DictDataViewReq) (*adminForm.DictDataViewRes, error) {
|
||||
var (
|
||||
m = dao.SysDictData.Ctx(ctx).Where("id", req.Id)
|
||||
res adminForm.DictDataViewRes
|
||||
err error
|
||||
)
|
||||
|
||||
if err = m.Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取指定字典类型的属性数据
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictAttributeRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *dict) Attribute(ctx context.Context, req *adminForm.DictAttributeReq) (*adminForm.DictAttributeRes, error) {
|
||||
var (
|
||||
m = dao.SysDictData.Ctx(ctx).Where("type", req.Type).Order("sort asc,id desc")
|
||||
res adminForm.DictAttributeRes
|
||||
err error
|
||||
)
|
||||
|
||||
if err = m.Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取字典数据列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *dict) DataList(ctx context.Context, req *adminForm.DictDataListReq) (*adminForm.DictDataListRes, error) {
|
||||
var (
|
||||
m = dao.SysDictData.Ctx(ctx).Where("type", req.Type)
|
||||
list []*entity.SysDictData
|
||||
res adminForm.DictDataListRes
|
||||
totalCount int
|
||||
err error
|
||||
)
|
||||
|
||||
totalCount, err = m.Count()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = m.Page(req.Page, req.Limit).Order("sort asc,id desc").Scan(&list); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.List = list
|
||||
res.Page = req.Page
|
||||
res.Limit = req.Limit
|
||||
res.TotalCount = totalCount
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 导出字典类型
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictDataListRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *dict) TypeExport(ctx context.Context, req *adminForm.DictTypeExportReq) error {
|
||||
|
||||
// 导出格式
|
||||
type exportImage struct {
|
||||
Id int64 `json:"id" `
|
||||
Name string `json:"name" `
|
||||
Type string `json:"type" `
|
||||
Remark string `json:"remark" `
|
||||
Status string `json:"status" `
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
var (
|
||||
list []exportImage
|
||||
titleList = []string{"ID", "字典名称", "字典类型", "备注", "状态", "创建时间", "更新时间"}
|
||||
fileName = "字典类型导出-" + com.Context.Get(ctx).ReqId + ".xlsx"
|
||||
sheetName = "HotGo"
|
||||
err error
|
||||
)
|
||||
|
||||
if err = dao.SysDictType.Ctx(ctx).Page(req.Page, req.Limit).Order("sort asc,id desc").Scan(&list); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO 格式化格式
|
||||
for i := 0; i < len(list); i++ {
|
||||
if list[i].Status == consts.StatusEnabled {
|
||||
list[i].Status = "启用"
|
||||
} else if list[i].Status == consts.StatusDisable {
|
||||
list[i].Status = "禁用"
|
||||
} else if list[i].Status == consts.StatusDelete {
|
||||
list[i].Status = "已删除"
|
||||
}
|
||||
}
|
||||
|
||||
// TODO 强转类型
|
||||
writer := com.Context.Get(ctx).Request.Response.Writer
|
||||
w, _ := interface{}(writer).(*ghttp.ResponseWriter)
|
||||
|
||||
g.Log().Print(ctx, "gconv.Interfaces(list):", gconv.Interfaces(list))
|
||||
if err = utils.Excel.ExportByStruct(w, titleList, gconv.Interfaces(list), fileName, sheetName); err != nil {
|
||||
err = gerror.Wrap(err, "ExportByStruct:")
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO 加入到上下文
|
||||
com.Context.SetResponse(ctx, &model.Response{
|
||||
Code: consts.CodeOK,
|
||||
Message: "导出成功",
|
||||
Timestamp: time.Now().Unix(),
|
||||
ReqId: com.Context.Get(ctx).ReqId,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 删除字典类型
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *dict) TypeDelete(ctx context.Context, req *adminForm.DictTypeDeleteReq) error {
|
||||
var (
|
||||
m = dao.SysDictType.Ctx(ctx).Where("id", req.Id)
|
||||
err error
|
||||
)
|
||||
|
||||
_, err = m.Delete()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 修改/新增字典类型
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return error
|
||||
//
|
||||
func (service *dict) TypeEdit(ctx context.Context, req *adminForm.DictTypeEditReq) error {
|
||||
var (
|
||||
m = dao.SysDictType.Ctx(ctx)
|
||||
isUnique bool
|
||||
err error
|
||||
)
|
||||
|
||||
if req.Name == "" {
|
||||
err = gerror.New("字典名称不能为空")
|
||||
return err
|
||||
}
|
||||
if req.Type == "" {
|
||||
err = gerror.New("字典类型不能为空")
|
||||
return err
|
||||
}
|
||||
|
||||
isUnique, err = dao.SysDictType.IsUnique(ctx, req.Id, req.Type)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
if !isUnique {
|
||||
err = gerror.New("字典类型已存在")
|
||||
return err
|
||||
}
|
||||
|
||||
req.UpdatedAt = gtime.Now()
|
||||
|
||||
// 修改
|
||||
if req.Id > 0 {
|
||||
_, err = m.Where("id", req.Id).Data(req).Update()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
req.CreatedAt = gtime.Now()
|
||||
|
||||
// 新增
|
||||
_, err = m.Where("id", req.Id).Data(req).Insert()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 类型是否唯一
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeUniqueRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *dict) TypeUnique(ctx context.Context, req *adminForm.DictTypeUniqueReq) (*adminForm.DictTypeUniqueRes, error) {
|
||||
var (
|
||||
res adminForm.DictTypeUniqueRes
|
||||
err error
|
||||
)
|
||||
|
||||
res.IsUnique, err = dao.SysDictType.IsUnique(ctx, req.Id, req.Type)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取指定字典类型信息
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return *adminForm.DictTypeViewRes
|
||||
// @Return error
|
||||
//
|
||||
func (service *dict) TypeView(ctx context.Context, req *adminForm.DictTypeViewReq) (*adminForm.DictTypeViewRes, error) {
|
||||
var (
|
||||
m = dao.SysDictType.Ctx(ctx).Where("id", req.Id)
|
||||
res adminForm.DictTypeViewRes
|
||||
err error
|
||||
)
|
||||
|
||||
if err = m.Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取字典类型列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *dict) TypeList(ctx context.Context, req *adminForm.DictTypeListReq) (*adminForm.DictTypeListRes, error) {
|
||||
var (
|
||||
m = dao.SysDictType.Ctx(ctx)
|
||||
list []*entity.SysDictType
|
||||
res adminForm.DictTypeListRes
|
||||
totalCount int
|
||||
err error
|
||||
)
|
||||
|
||||
if req.Name != "" {
|
||||
m = m.WhereLike("name", "%"+req.Name+"%")
|
||||
}
|
||||
|
||||
if req.Type != "" {
|
||||
m = m.Where("type", req.Type)
|
||||
}
|
||||
|
||||
// 日期范围
|
||||
if req.StartTime != "" {
|
||||
m = m.WhereGTE("created_at", req.StartTime)
|
||||
}
|
||||
if req.EndTime != "" {
|
||||
m = m.WhereLTE("created_at", req.EndTime)
|
||||
}
|
||||
|
||||
// 状态
|
||||
if req.Status > 0 {
|
||||
m = m.Where("status", req.Status)
|
||||
}
|
||||
|
||||
totalCount, err = m.Count()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = m.Page(req.Page, req.Limit).Order("sort asc,id desc").Scan(&list); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.List = list
|
||||
res.Page = req.Page
|
||||
res.Limit = req.Limit
|
||||
res.TotalCount = totalCount
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
400
hotgo-server/app/service/sysService/log_service.go
Normal file
400
hotgo-server/app/service/sysService/log_service.go
Normal file
@@ -0,0 +1,400 @@
|
||||
//
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2022 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package sysService
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/bufanyun/hotgo/app/com"
|
||||
"github.com/bufanyun/hotgo/app/consts"
|
||||
"github.com/bufanyun/hotgo/app/factory/queue"
|
||||
"github.com/bufanyun/hotgo/app/form/input"
|
||||
"github.com/bufanyun/hotgo/app/model"
|
||||
"github.com/bufanyun/hotgo/app/model/entity"
|
||||
"github.com/bufanyun/hotgo/app/service/internal/dao"
|
||||
"github.com/bufanyun/hotgo/app/utils"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
var Log = new(log)
|
||||
|
||||
type log struct{}
|
||||
|
||||
//
|
||||
// @Title 导出
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param in
|
||||
// @Return err
|
||||
//
|
||||
func (service *log) Export(ctx context.Context, in input.LogListInp) (err error) {
|
||||
|
||||
// 导出格式
|
||||
type exportImage struct {
|
||||
Id int64 `json:"id" description:""`
|
||||
AppId string `json:"app_id" description:"应用id"`
|
||||
Method string `json:"method" description:"提交类型"`
|
||||
Module string `json:"module" description:"模块"`
|
||||
Url string `json:"url" description:"提交url"`
|
||||
Ip string `json:"ip" description:"ip地址"`
|
||||
ErrorCode int `json:"error_code" description:"报错code"`
|
||||
ErrorMsg string `json:"error_msg" description:"报错信息"`
|
||||
ReqId string `json:"req_id" description:"对外id"`
|
||||
TakeUpTime int64 `json:"take_up_time" description:"请求耗时"`
|
||||
CreatedAt *gtime.Time `json:"created_at" description:"创建时间"`
|
||||
MemberName string `json:"member_name"`
|
||||
Region string `json:"region"`
|
||||
}
|
||||
|
||||
var (
|
||||
titleList = []string{"ID", "应用", "提交类型", "模块", "提交url", "ip地址", "报错code", "报错信息", "对外id", "请求耗时", "创建时间", "用户", "访问地"}
|
||||
fileName = "全局日志导出-" + com.Context.Get(ctx).ReqId + ".xlsx"
|
||||
sheetName = "HotGo"
|
||||
exportList []exportImage
|
||||
row exportImage
|
||||
)
|
||||
|
||||
list, _, err := service.List(ctx, in)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO 格式化格式
|
||||
for i := 0; i < len(list); i++ {
|
||||
row.Id = list[i].Id
|
||||
row.AppId = list[i].AppId
|
||||
row.Module = list[i].Module
|
||||
row.Method = list[i].Method
|
||||
row.Url = list[i].Url
|
||||
row.Ip = list[i].Ip
|
||||
row.ReqId = list[i].ReqId
|
||||
row.ErrorCode = list[i].ErrorCode
|
||||
row.ErrorMsg = list[i].ErrorMsg
|
||||
row.TakeUpTime = list[i].TakeUpTime
|
||||
row.CreatedAt = list[i].CreatedAt
|
||||
row.MemberName = list[i].MemberName
|
||||
row.Region = list[i].Region
|
||||
exportList = append(exportList, row)
|
||||
}
|
||||
|
||||
// TODO 强转类型
|
||||
writer := com.Context.Get(ctx).Request.Response.Writer
|
||||
w, _ := interface{}(writer).(*ghttp.ResponseWriter)
|
||||
|
||||
if err = utils.Excel.ExportByStruct(w, titleList, gconv.Interfaces(exportList), fileName, sheetName); err != nil {
|
||||
err = gerror.Wrap(err, "ExportByStruct:")
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO 加入到上下文
|
||||
com.Context.SetResponse(ctx, &model.Response{
|
||||
Code: consts.CodeOK,
|
||||
Message: "导出成功",
|
||||
Timestamp: time.Now().Unix(),
|
||||
ReqId: com.Context.Get(ctx).ReqId,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 获取菜单列表
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param req
|
||||
// @Return res
|
||||
// @Return err
|
||||
//
|
||||
func (service *log) List(ctx context.Context, in input.LogListInp) (list []*input.LogListModel, totalCount int, err error) {
|
||||
|
||||
mod := dao.SysLog.Ctx(ctx)
|
||||
|
||||
// 访问路径
|
||||
if in.Url != "" {
|
||||
mod = mod.WhereLike("url", "%"+in.Url+"%")
|
||||
}
|
||||
|
||||
// 模块
|
||||
if in.Module != "" {
|
||||
mod = mod.Where("module", in.Module)
|
||||
}
|
||||
|
||||
// 请求方式
|
||||
if in.Method != "" {
|
||||
mod = mod.Where("method", in.Method)
|
||||
}
|
||||
|
||||
// 用户
|
||||
if in.MemberId > 0 {
|
||||
mod = mod.Where("member_id", in.MemberId)
|
||||
}
|
||||
|
||||
// 访问IP
|
||||
if in.Ip != "" {
|
||||
mod = mod.Where("ip", in.Ip)
|
||||
}
|
||||
|
||||
// 日期范围
|
||||
if in.StartTime != "" {
|
||||
mod = mod.WhereGTE("created_at", in.StartTime)
|
||||
}
|
||||
if in.EndTime != "" {
|
||||
mod = mod.WhereLTE("created_at", in.EndTime)
|
||||
}
|
||||
|
||||
// 状态码
|
||||
if in.ErrorCode != "" {
|
||||
mod = mod.Where("error_code", in.ErrorCode)
|
||||
}
|
||||
|
||||
// 请求耗时
|
||||
if in.TakeUpTime > 0 {
|
||||
mod = mod.WhereGTE("take_up_time", in.TakeUpTime)
|
||||
}
|
||||
|
||||
totalCount, err = mod.Count()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
err = mod.Page(in.Page, in.Limit).Order("id desc").Scan(&list)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
for i := 0; i < len(list); i++ {
|
||||
// TODO 管理员
|
||||
if list[i].AppId == consts.AppAdmin {
|
||||
memberName, err := dao.AdminMember.Ctx(ctx).Fields("realname").Where("id", list[i].MemberId).Value()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
list[i].MemberName = memberName.String()
|
||||
}
|
||||
// TODO 接口
|
||||
if list[i].AppId == consts.AppApi {
|
||||
//memberName, err = dao.Member.Ctx(ctx).Fields("realname").Where("id", res.List[i].MemberId).Value()
|
||||
//if err != nil {
|
||||
// err = gerror.Wrap(err, consts.ErrorORM)
|
||||
// return nil, err
|
||||
//}
|
||||
}
|
||||
|
||||
if list[i].MemberName == "" {
|
||||
list[i].MemberName = "游客"
|
||||
}
|
||||
|
||||
// TODO 获取省市编码对应的地区名称
|
||||
region, err := dao.SysProvinces.GetRegion(ctx, list[i].ProvinceId, list[i].CityId)
|
||||
if err != nil {
|
||||
return list, totalCount, err
|
||||
}
|
||||
list[i].Region = region
|
||||
|
||||
// TODO 截取请求url路径
|
||||
if gstr.Contains(list[i].Url, "?") {
|
||||
list[i].Url = gstr.StrTillEx(list[i].Url, "?")
|
||||
}
|
||||
}
|
||||
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 真实写入
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param commonLog
|
||||
// @Return err
|
||||
//
|
||||
func (service *log) RealWrite(ctx context.Context, commonLog entity.SysLog) error {
|
||||
|
||||
result, err := dao.SysLog.Ctx(ctx).Data(commonLog).Insert()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := result.LastInsertId(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 根据配置自动记录请求日志
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Return err
|
||||
//
|
||||
func (service *log) AutoLog(ctx context.Context) (err error) {
|
||||
// TODO 日志开关
|
||||
logSwitch, _ := g.Cfg().Get(ctx, "hotgo.log.switch", true)
|
||||
if !logSwitch.Bool() {
|
||||
return nil
|
||||
}
|
||||
|
||||
data := service.AnalysisLog(ctx)
|
||||
|
||||
// TODO 判断模块是否需要记录
|
||||
module, _ := g.Cfg().Get(ctx, "hotgo.log.module", nil)
|
||||
if module == nil {
|
||||
return nil
|
||||
}
|
||||
if exist := utils.Charset.IsExists(module.Strings(), data.Module); !exist {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO 判断状态码是否需要记录
|
||||
code, _ := g.Cfg().Get(ctx, "hotgo.log.skipCode", nil)
|
||||
if code != nil {
|
||||
if exist := utils.Charset.IsExists(code.Strings(), gconv.String(data.ErrorCode)); exist {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// TODO 是否开启队列
|
||||
queueSwitch, _ := g.Cfg().Get(ctx, "hotgo.log.queue", true)
|
||||
if queueSwitch.Bool() {
|
||||
// TODO 获取生产者实例
|
||||
queueInstance, err := queue.InstanceProducer()
|
||||
if err != nil {
|
||||
queue.FatalLog(ctx, "InstanceProducer异常", err)
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO 生产消息
|
||||
mqMsg, err := queueInstance.SendMsg(consts.QueueLogTopic, gconv.String(data))
|
||||
|
||||
// TODO 记录生产日志
|
||||
queue.ProducerLog(ctx, consts.QueueLogTopic, mqMsg.MsgId, err)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return service.RealWrite(ctx, data)
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 队列消费
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param mqMsg
|
||||
// @Return err
|
||||
//
|
||||
func (service *log) QueueJob(ctx context.Context, mqMsg queue.MqMsg) (err error) {
|
||||
|
||||
var data entity.SysLog
|
||||
if err = json.Unmarshal(mqMsg.Body, &data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return service.RealWrite(ctx, data)
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 解析日志数据
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Return entity.SysLog
|
||||
//
|
||||
func (service *log) AnalysisLog(ctx context.Context) entity.SysLog {
|
||||
|
||||
var (
|
||||
modelContext = com.Context.Get(ctx)
|
||||
response = modelContext.ComResponse
|
||||
user = modelContext.User
|
||||
request = modelContext.Request
|
||||
module = modelContext.Module
|
||||
ip = request.GetClientIp()
|
||||
locationData = com.Ip.GetLocation(ctx, ip)
|
||||
postData = "null"
|
||||
getData = "null"
|
||||
headerData = "null"
|
||||
data = entity.SysLog{}
|
||||
memberId = 0
|
||||
errorCode = 0
|
||||
errorMsg = ""
|
||||
errorData = "null"
|
||||
reqId = ""
|
||||
timestamp = 0
|
||||
appId = ""
|
||||
)
|
||||
|
||||
// TODO 响应数据
|
||||
if response != nil {
|
||||
errorCode = response.Code
|
||||
errorMsg = response.Message
|
||||
reqId = response.ReqId
|
||||
timestamp = gconv.Int(response.Timestamp)
|
||||
|
||||
if len(gconv.String(response.Error)) > 0 {
|
||||
errorData = gconv.String(response.Error)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO 请求头
|
||||
if reqHeadersBytes, _ := json.Marshal(request.Header); len(gconv.String(reqHeadersBytes)) > 0 {
|
||||
headerData = gconv.String(reqHeadersBytes)
|
||||
}
|
||||
|
||||
// TODO post参数
|
||||
if gconv.String(request.PostForm) != "" {
|
||||
postData = gconv.String(request.PostForm)
|
||||
}
|
||||
|
||||
// TODO get参数
|
||||
if len(request.URL.Query()) > 0 {
|
||||
getData = gconv.String(request.URL.Query())
|
||||
}
|
||||
|
||||
// TODO 当前登录用户
|
||||
if user != nil {
|
||||
memberId = int(user.Id)
|
||||
appId = user.App
|
||||
}
|
||||
|
||||
data = entity.SysLog{
|
||||
AppId: appId,
|
||||
MerchantId: 0,
|
||||
MemberId: memberId,
|
||||
Method: request.Method,
|
||||
Module: module,
|
||||
Url: request.RequestURI,
|
||||
GetData: getData,
|
||||
PostData: postData,
|
||||
HeaderData: headerData,
|
||||
Ip: ip,
|
||||
ProvinceId: locationData.ProvinceCode,
|
||||
CityId: locationData.CityCode,
|
||||
ErrorCode: errorCode,
|
||||
ErrorMsg: errorMsg,
|
||||
ErrorData: errorData,
|
||||
ReqId: reqId,
|
||||
Timestamp: timestamp,
|
||||
UserAgent: request.Header.Get("User-Agent"),
|
||||
Status: consts.StatusEnabled,
|
||||
TakeUpTime: modelContext.TakeUpTime,
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
29
hotgo-server/app/service/sysService/provinces_service.go
Normal file
29
hotgo-server/app/service/sysService/provinces_service.go
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2022 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package sysService
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/bufanyun/hotgo/app/com"
|
||||
)
|
||||
|
||||
var Provinces = new(provinces)
|
||||
|
||||
type provinces struct{}
|
||||
|
||||
//
|
||||
// @Title 获取地区中的省市编码
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Param location
|
||||
//
|
||||
func (service *provinces) GetLocationCode(ctx context.Context, location com.IpLocationData) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user