mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-30 01:21:24 +08:00
iot init
This commit is contained in:
@@ -16,7 +16,7 @@ type SystemApiApi struct {
|
||||
|
||||
func (s *SystemApiApi) CreateApi(rc *restfulx.ReqCtx) {
|
||||
var api entity.SysApi
|
||||
restfulx.BindQuery(rc, &api)
|
||||
restfulx.BindJsonAndValid(rc, &api)
|
||||
s.ApiApp.Insert(api)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func (s *SystemApiApi) GetApiById(rc *restfulx.ReqCtx) {
|
||||
|
||||
func (s *SystemApiApi) UpdateApi(rc *restfulx.ReqCtx) {
|
||||
var api entity.SysApi
|
||||
restfulx.BindQuery(rc, &api)
|
||||
restfulx.BindJsonAndValid(rc, &api)
|
||||
s.ApiApp.Update(api)
|
||||
}
|
||||
|
||||
|
||||
@@ -43,14 +43,14 @@ func (p *ConfigApi) GetConfig(rc *restfulx.ReqCtx) {
|
||||
|
||||
func (p *ConfigApi) InsertConfig(rc *restfulx.ReqCtx) {
|
||||
var config entity.SysConfig
|
||||
restfulx.BindQuery(rc, &config)
|
||||
restfulx.BindJsonAndValid(rc, &config)
|
||||
|
||||
p.ConfigApp.Insert(config)
|
||||
}
|
||||
|
||||
func (p *ConfigApi) UpdateConfig(rc *restfulx.ReqCtx) {
|
||||
var post entity.SysConfig
|
||||
restfulx.BindQuery(rc, &post)
|
||||
restfulx.BindJsonAndValid(rc, &post)
|
||||
p.ConfigApp.Update(post)
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,6 @@ type DeptApi struct {
|
||||
func (m *DeptApi) GetDeptTreeRoleSelect(rc *restfulx.ReqCtx) {
|
||||
roleId := restfulx.PathParamInt(rc, "roleId")
|
||||
var dept entity.SysDept
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
dept.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
result := m.DeptApp.SelectDeptLable(dept)
|
||||
|
||||
deptIds := make([]int64, 0)
|
||||
@@ -43,9 +40,7 @@ func (a *DeptApi) GetDeptList(rc *restfulx.ReqCtx) {
|
||||
status := restfulx.QueryParam(rc, "status")
|
||||
deptId := restfulx.QueryInt(rc, "deptId", 0)
|
||||
dept := entity.SysDept{DeptName: deptName, Status: status, DeptId: int64(deptId)}
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
dept.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
|
||||
if dept.DeptName == "" {
|
||||
rc.ResData = a.DeptApp.SelectDept(dept)
|
||||
} else {
|
||||
@@ -55,9 +50,6 @@ func (a *DeptApi) GetDeptList(rc *restfulx.ReqCtx) {
|
||||
|
||||
func (a *DeptApi) GetOrdinaryDeptList(rc *restfulx.ReqCtx) {
|
||||
var dept entity.SysDept
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
dept.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
|
||||
rc.ResData = a.DeptApp.FindList(dept)
|
||||
}
|
||||
@@ -67,9 +59,7 @@ func (a *DeptApi) GetDeptTree(rc *restfulx.ReqCtx) {
|
||||
status := restfulx.QueryParam(rc, "status")
|
||||
deptId := restfulx.QueryInt(rc, "deptId", 0)
|
||||
dept := entity.SysDept{DeptName: deptName, Status: status, DeptId: int64(deptId)}
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
dept.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
|
||||
rc.ResData = a.DeptApp.SelectDept(dept)
|
||||
}
|
||||
|
||||
@@ -80,15 +70,14 @@ func (a *DeptApi) GetDept(rc *restfulx.ReqCtx) {
|
||||
|
||||
func (a *DeptApi) InsertDept(rc *restfulx.ReqCtx) {
|
||||
var dept entity.SysDept
|
||||
restfulx.BindQuery(rc, &dept)
|
||||
dept.TenantId = rc.LoginAccount.TenantId
|
||||
restfulx.BindJsonAndValid(rc, &dept)
|
||||
dept.CreateBy = rc.LoginAccount.UserName
|
||||
a.DeptApp.Insert(dept)
|
||||
}
|
||||
|
||||
func (a *DeptApi) UpdateDept(rc *restfulx.ReqCtx) {
|
||||
var dept entity.SysDept
|
||||
restfulx.BindQuery(rc, &dept)
|
||||
restfulx.BindJsonAndValid(rc, &dept)
|
||||
|
||||
dept.UpdateBy = rc.LoginAccount.UserName
|
||||
a.DeptApp.Update(dept)
|
||||
|
||||
@@ -39,7 +39,7 @@ func (p *DictApi) GetDictType(rc *restfulx.ReqCtx) {
|
||||
|
||||
func (p *DictApi) InsertDictType(rc *restfulx.ReqCtx) {
|
||||
var dict entity.SysDictType
|
||||
restfulx.BindQuery(rc, &dict)
|
||||
restfulx.BindJsonAndValid(rc, &dict)
|
||||
|
||||
dict.CreateBy = rc.LoginAccount.UserName
|
||||
p.DictType.Insert(dict)
|
||||
@@ -47,7 +47,7 @@ func (p *DictApi) InsertDictType(rc *restfulx.ReqCtx) {
|
||||
|
||||
func (p *DictApi) UpdateDictType(rc *restfulx.ReqCtx) {
|
||||
var dict entity.SysDictType
|
||||
restfulx.BindQuery(rc, &dict)
|
||||
restfulx.BindJsonAndValid(rc, &dict)
|
||||
|
||||
dict.CreateBy = rc.LoginAccount.UserName
|
||||
p.DictType.Update(dict)
|
||||
@@ -102,14 +102,14 @@ func (p *DictApi) GetDictData(rc *restfulx.ReqCtx) {
|
||||
|
||||
func (p *DictApi) InsertDictData(rc *restfulx.ReqCtx) {
|
||||
var data entity.SysDictData
|
||||
restfulx.BindQuery(rc, &data)
|
||||
restfulx.BindJsonAndValid(rc, &data)
|
||||
data.CreateBy = rc.LoginAccount.UserName
|
||||
p.DictData.Insert(data)
|
||||
}
|
||||
|
||||
func (p *DictApi) UpdateDictData(rc *restfulx.ReqCtx) {
|
||||
var data entity.SysDictData
|
||||
restfulx.BindQuery(rc, &data)
|
||||
restfulx.BindJsonAndValid(rc, &data)
|
||||
|
||||
data.CreateBy = rc.LoginAccount.UserName
|
||||
p.DictData.Update(data)
|
||||
|
||||
@@ -11,7 +11,7 @@ type Register struct {
|
||||
|
||||
// User login structure
|
||||
type Login struct {
|
||||
Username string `json:"username"` // 用户名
|
||||
Username string `json:"username" ` // 用户名
|
||||
Password string `json:"password"` // 密码
|
||||
Captcha string `json:"captcha"` // 验证码
|
||||
CaptchaId string `json:"captchaId"` // 验证码ID
|
||||
|
||||
@@ -68,7 +68,7 @@ func (m *MenuApi) GetMenu(rc *restfulx.ReqCtx) {
|
||||
|
||||
func (m *MenuApi) InsertMenu(rc *restfulx.ReqCtx) {
|
||||
var menu entity.SysMenu
|
||||
restfulx.BindQuery(rc, &menu)
|
||||
restfulx.BindJsonAndValid(rc, &menu)
|
||||
menu.CreateBy = rc.LoginAccount.UserName
|
||||
m.MenuApp.Insert(menu)
|
||||
permis := m.RoleMenuApp.GetPermis(rc.LoginAccount.RoleId)
|
||||
@@ -81,7 +81,7 @@ func (m *MenuApi) InsertMenu(rc *restfulx.ReqCtx) {
|
||||
|
||||
func (m *MenuApi) UpdateMenu(rc *restfulx.ReqCtx) {
|
||||
var menu entity.SysMenu
|
||||
restfulx.BindQuery(rc, &menu)
|
||||
restfulx.BindJsonAndValid(rc, &menu)
|
||||
menu.UpdateBy = rc.LoginAccount.UserName
|
||||
m.MenuApp.Update(menu)
|
||||
permis := m.RoleMenuApp.GetPermis(rc.LoginAccount.RoleId)
|
||||
|
||||
@@ -40,7 +40,7 @@ func (p *NoticeApi) GetNoticeList(rc *restfulx.ReqCtx) {
|
||||
// InsertNotice 添加通知
|
||||
func (p *NoticeApi) InsertNotice(rc *restfulx.ReqCtx) {
|
||||
var notice entity.SysNotice
|
||||
restfulx.BindQuery(rc, ¬ice)
|
||||
restfulx.BindJsonAndValid(rc, ¬ice)
|
||||
notice.UserName = rc.LoginAccount.UserName
|
||||
p.NoticeApp.Insert(notice)
|
||||
}
|
||||
@@ -48,7 +48,7 @@ func (p *NoticeApi) InsertNotice(rc *restfulx.ReqCtx) {
|
||||
// UpdateNotice 修改通知
|
||||
func (p *NoticeApi) UpdateNotice(rc *restfulx.ReqCtx) {
|
||||
var notice entity.SysNotice
|
||||
restfulx.BindQuery(rc, ¬ice)
|
||||
restfulx.BindJsonAndValid(rc, ¬ice)
|
||||
|
||||
p.NoticeApp.Update(notice)
|
||||
}
|
||||
|
||||
@@ -28,10 +28,6 @@ func (p *PostApi) GetPostList(rc *restfulx.ReqCtx) {
|
||||
postCode := restfulx.QueryParam(rc, "postCode")
|
||||
post := entity.SysPost{Status: status, PostName: postName, PostCode: postCode}
|
||||
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
post.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
|
||||
list, total := p.PostApp.FindListPage(pageNum, pageSize, post)
|
||||
|
||||
rc.ResData = model.ResultPage{
|
||||
@@ -51,8 +47,7 @@ func (p *PostApi) GetPost(rc *restfulx.ReqCtx) {
|
||||
// InsertPost 添加职位
|
||||
func (p *PostApi) InsertPost(rc *restfulx.ReqCtx) {
|
||||
var post entity.SysPost
|
||||
restfulx.BindQuery(rc, &post)
|
||||
post.TenantId = rc.LoginAccount.TenantId
|
||||
restfulx.BindJsonAndValid(rc, &post)
|
||||
post.CreateBy = rc.LoginAccount.UserName
|
||||
p.PostApp.Insert(post)
|
||||
}
|
||||
@@ -60,7 +55,7 @@ func (p *PostApi) InsertPost(rc *restfulx.ReqCtx) {
|
||||
// UpdatePost 修改职位
|
||||
func (p *PostApi) UpdatePost(rc *restfulx.ReqCtx) {
|
||||
var post entity.SysPost
|
||||
restfulx.BindQuery(rc, &post)
|
||||
restfulx.BindJsonAndValid(rc, &post)
|
||||
|
||||
post.CreateBy = rc.LoginAccount.UserName
|
||||
p.PostApp.Update(post)
|
||||
|
||||
@@ -28,11 +28,6 @@ func (r *RoleApi) GetRoleList(rc *restfulx.ReqCtx) {
|
||||
roleName := restfulx.QueryParam(rc, "roleName")
|
||||
roleKey := restfulx.QueryParam(rc, "roleKey")
|
||||
role := entity.SysRole{Status: status, RoleName: roleName, RoleKey: roleKey}
|
||||
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
role.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
|
||||
list, total := r.RoleApp.FindListPage(pageNum, pageSize, role)
|
||||
|
||||
rc.ResData = model.ResultPage{
|
||||
@@ -55,9 +50,8 @@ func (r *RoleApi) GetRole(rc *restfulx.ReqCtx) {
|
||||
// InsertRole 创建角色
|
||||
func (r *RoleApi) InsertRole(rc *restfulx.ReqCtx) {
|
||||
var role entity.SysRole
|
||||
restfulx.BindQuery(rc, &role)
|
||||
restfulx.BindJsonAndValid(rc, &role)
|
||||
role.CreateBy = rc.LoginAccount.UserName
|
||||
role.TenantId = rc.LoginAccount.TenantId
|
||||
insert := r.RoleApp.Insert(role)
|
||||
role.RoleId = insert.RoleId
|
||||
r.RoleMenuApp.Insert(insert.RoleId, role.MenuIds)
|
||||
@@ -69,7 +63,7 @@ func (r *RoleApi) InsertRole(rc *restfulx.ReqCtx) {
|
||||
// UpdateRole 修改用户角色
|
||||
func (r *RoleApi) UpdateRole(rc *restfulx.ReqCtx) {
|
||||
var role entity.SysRole
|
||||
restfulx.BindQuery(rc, &role)
|
||||
restfulx.BindJsonAndValid(rc, &role)
|
||||
role.UpdateBy = rc.LoginAccount.UserName
|
||||
// 修改角色
|
||||
r.RoleApp.Update(role)
|
||||
@@ -85,7 +79,7 @@ func (r *RoleApi) UpdateRole(rc *restfulx.ReqCtx) {
|
||||
// UpdateRoleStatus 修改用户角色状态
|
||||
func (r *RoleApi) UpdateRoleStatus(rc *restfulx.ReqCtx) {
|
||||
var role entity.SysRole
|
||||
restfulx.BindQuery(rc, &role)
|
||||
restfulx.BindJsonAndValid(rc, &role)
|
||||
role.UpdateBy = rc.LoginAccount.UserName
|
||||
// 修改角色
|
||||
r.RoleApp.Update(role)
|
||||
@@ -94,7 +88,7 @@ func (r *RoleApi) UpdateRoleStatus(rc *restfulx.ReqCtx) {
|
||||
// UpdateRoleDataScope 修改用户角色部门
|
||||
func (r *RoleApi) UpdateRoleDataScope(rc *restfulx.ReqCtx) {
|
||||
var role entity.SysRole
|
||||
restfulx.BindQuery(rc, &role)
|
||||
restfulx.BindJsonAndValid(rc, &role)
|
||||
role.UpdateBy = rc.LoginAccount.UserName
|
||||
// 修改角色
|
||||
update := r.RoleApp.Update(role)
|
||||
@@ -141,9 +135,7 @@ func (p *RoleApi) ExportRole(rc *restfulx.ReqCtx) {
|
||||
roleName := restfulx.QueryParam(rc, "roleName")
|
||||
roleKey := restfulx.QueryParam(rc, "roleKey")
|
||||
role := entity.SysRole{Status: status, RoleName: roleName, RoleKey: roleKey}
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
role.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
|
||||
list := p.RoleApp.FindList(role)
|
||||
|
||||
fileName := utils.GetFileName(global.Conf.Server.ExcelDir, filename)
|
||||
|
||||
@@ -3,18 +3,21 @@ package api
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/XM-GO/PandaKit/biz"
|
||||
"github.com/XM-GO/PandaKit/oss"
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
"net/http"
|
||||
"os"
|
||||
"pandax/pkg/config"
|
||||
"pandax/pkg/global"
|
||||
"pandax/pkg/tool"
|
||||
"path"
|
||||
"time"
|
||||
)
|
||||
|
||||
type UploadApi struct{}
|
||||
|
||||
const filePath = "uploads/file"
|
||||
|
||||
// UploadImage 图片上传
|
||||
// UploadImage 图片上传
|
||||
func (up *UploadApi) UploadImage(rc *restfulx.ReqCtx) {
|
||||
_, fileHeader, err := rc.Request.Request.FormFile("file")
|
||||
@@ -25,6 +28,19 @@ func (up *UploadApi) UploadImage(rc *restfulx.ReqCtx) {
|
||||
rc.ResData = map[string]string{"fileName": fileName, "filePath": link}
|
||||
}
|
||||
|
||||
// UplaodResOsses 上传文件ResOsses
|
||||
func (p *UploadApi) UplaodToOss(rc *restfulx.ReqCtx) {
|
||||
_, handler, _ := rc.Request.Request.FormFile("file")
|
||||
yunFileTmpPath := "uploads/" + time.Now().Format("2006-01-02") + "/" + handler.Filename
|
||||
// 读取本地文件。
|
||||
f, openError := handler.Open()
|
||||
biz.ErrIsNil(openError, "function file.Open() Failed")
|
||||
config := global.Conf.Oss
|
||||
biz.ErrIsNil(NewOss(*config).PutObj(yunFileTmpPath, f), "上传OSS失败")
|
||||
|
||||
rc.ResData = fmt.Sprintf("http://%s/%s/%s", config.Endpoint, config.BucketName, yunFileTmpPath)
|
||||
}
|
||||
|
||||
func (up *UploadApi) GetImage(rc *restfulx.ReqCtx) {
|
||||
actual := path.Join(filePath, restfulx.PathParam(rc, "subpath"))
|
||||
http.ServeFile(
|
||||
@@ -39,3 +55,14 @@ func (up *UploadApi) DeleteImage(rc *restfulx.ReqCtx) {
|
||||
err := os.Remove(fmt.Sprintf("%s/%s", filePath, fileName))
|
||||
biz.ErrIsNil(err, "文件删除失败")
|
||||
}
|
||||
|
||||
func NewOss(ens config.Oss) oss.Driver {
|
||||
return oss.NewMiniOss(oss.MiniOConfig{
|
||||
BucketName: ens.BucketName,
|
||||
Endpoint: ens.Endpoint,
|
||||
AccessKeyID: ens.AccessKey,
|
||||
SecretAccessKey: ens.SecretKey,
|
||||
UseSSL: ens.UseSSL,
|
||||
Location: "cn-north-1",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ func (u *UserApi) RefreshToken(rc *restfulx.ReqCtx) {
|
||||
// Login 用户登录
|
||||
func (u *UserApi) Login(rc *restfulx.ReqCtx) {
|
||||
var l form.Login
|
||||
restfulx.BindQuery(rc, &l)
|
||||
restfulx.BindJsonAndValid(rc, &l)
|
||||
log.Println(l)
|
||||
biz.IsTrue(captcha.Verify(l.CaptchaId, l.Captcha), "验证码认证失败")
|
||||
|
||||
@@ -67,7 +67,6 @@ func (u *UserApi) Login(rc *restfulx.ReqCtx) {
|
||||
j := token.NewJWT("", []byte(global.Conf.Jwt.Key), jwt.SigningMethodHS256)
|
||||
token, err := j.CreateToken(token.Claims{
|
||||
UserId: login.UserId,
|
||||
TenantId: login.TenantId,
|
||||
UserName: login.Username,
|
||||
RoleId: login.RoleId,
|
||||
RoleKey: role.RoleKey,
|
||||
@@ -156,9 +155,6 @@ func (u *UserApi) GetSysUserList(rc *restfulx.ReqCtx) {
|
||||
user.Phone = phone
|
||||
user.DeptId = int64(deptId)
|
||||
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
user.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
list, total := u.UserApp.FindListPage(pageNum, pageSize, user)
|
||||
|
||||
rc.ResData = model.ResultPage{
|
||||
@@ -222,7 +218,7 @@ func (u *UserApi) InsetSysUserAvatar(rc *restfulx.ReqCtx) {
|
||||
// SysUserUpdatePwd 修改密码
|
||||
func (u *UserApi) SysUserUpdatePwd(rc *restfulx.ReqCtx) {
|
||||
var pws entity.SysUserPwd
|
||||
restfulx.BindQuery(rc, &pws)
|
||||
restfulx.BindJsonAndValid(rc, &pws)
|
||||
|
||||
user := entity.SysUser{}
|
||||
user.UserId = rc.LoginAccount.UserId
|
||||
@@ -238,23 +234,16 @@ func (u *UserApi) GetSysUser(rc *restfulx.ReqCtx) {
|
||||
result := u.UserApp.FindOne(user)
|
||||
|
||||
var role entity.SysRole
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
role.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
roles := u.RoleApp.FindList(role)
|
||||
|
||||
var post entity.SysPost
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
post.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
posts := u.PostApp.FindList(post)
|
||||
var dept entity.SysDept
|
||||
|
||||
rc.ResData = vo.UserVo{
|
||||
Data: result,
|
||||
PostIds: result.PostIds,
|
||||
RoleIds: result.RoleIds,
|
||||
Roles: *roles,
|
||||
Posts: *posts,
|
||||
Roles: *u.RoleApp.FindList(role),
|
||||
Posts: *u.PostApp.FindList(post),
|
||||
Depts: u.DeptApp.SelectDept(dept),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,14 +251,8 @@ func (u *UserApi) GetSysUser(rc *restfulx.ReqCtx) {
|
||||
func (u *UserApi) GetSysUserInit(rc *restfulx.ReqCtx) {
|
||||
|
||||
var role entity.SysRole
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
role.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
roles := u.RoleApp.FindList(role)
|
||||
var post entity.SysPost
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
post.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
posts := u.PostApp.FindList(post)
|
||||
rc.ResData = vo.UserRolePost{
|
||||
Roles: *roles,
|
||||
@@ -303,7 +286,7 @@ func (u *UserApi) GetUserRolePost(rc *restfulx.ReqCtx) {
|
||||
// InsertSysUser 创建用户
|
||||
func (u *UserApi) InsertSysUser(rc *restfulx.ReqCtx) {
|
||||
var sysUser entity.SysUser
|
||||
restfulx.BindQuery(rc, &sysUser)
|
||||
restfulx.BindJsonAndValid(rc, &sysUser)
|
||||
sysUser.CreateBy = rc.LoginAccount.UserName
|
||||
u.UserApp.Insert(sysUser)
|
||||
}
|
||||
@@ -311,7 +294,7 @@ func (u *UserApi) InsertSysUser(rc *restfulx.ReqCtx) {
|
||||
// UpdateSysUser 修改用户数据
|
||||
func (u *UserApi) UpdateSysUser(rc *restfulx.ReqCtx) {
|
||||
var sysUser entity.SysUser
|
||||
restfulx.BindQuery(rc, &sysUser)
|
||||
restfulx.BindJsonAndValid(rc, &sysUser)
|
||||
sysUser.CreateBy = rc.LoginAccount.UserName
|
||||
u.UserApp.Update(sysUser)
|
||||
}
|
||||
@@ -319,7 +302,7 @@ func (u *UserApi) UpdateSysUser(rc *restfulx.ReqCtx) {
|
||||
// UpdateSysUserStu 修改用户状态
|
||||
func (u *UserApi) UpdateSysUserStu(rc *restfulx.ReqCtx) {
|
||||
var sysUser entity.SysUser
|
||||
restfulx.BindQuery(rc, &sysUser)
|
||||
restfulx.BindJsonAndValid(rc, &sysUser)
|
||||
sysUser.CreateBy = rc.LoginAccount.UserName
|
||||
u.UserApp.Update(sysUser)
|
||||
}
|
||||
@@ -342,10 +325,6 @@ func (u *UserApi) ExportUser(rc *restfulx.ReqCtx) {
|
||||
user.Username = username
|
||||
user.Phone = phone
|
||||
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
user.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
|
||||
list := u.UserApp.FindList(user)
|
||||
fileName := utils.GetFileName(global.Conf.Server.ExcelDir, filename)
|
||||
utils.InterfaceToExcel(*list, fileName)
|
||||
|
||||
@@ -55,6 +55,7 @@ type UserVo struct {
|
||||
RoleIds string `json:"roleIds"`
|
||||
Roles []entity.SysRole `json:"roles"`
|
||||
Posts []entity.SysPost `json:"posts"`
|
||||
Depts []entity.SysDept `json:"depts"`
|
||||
}
|
||||
|
||||
type UserRolePost struct {
|
||||
|
||||
@@ -2,9 +2,9 @@ package entity
|
||||
|
||||
import "github.com/XM-GO/PandaKit/model"
|
||||
|
||||
// 部门组织
|
||||
type SysDept struct {
|
||||
DeptId int64 `json:"deptId" gorm:"primary_key;AUTO_INCREMENT"` //部门编码
|
||||
TenantId int64 `json:"tenantId" gorm:"type:int;comment:租户Id"`
|
||||
ParentId int64 `json:"parentId" gorm:"type:int;comment:上级部门"`
|
||||
DeptPath string `json:"deptPath" gorm:"type:varchar(255);comment:部门路径"`
|
||||
DeptName string `json:"deptName" gorm:"type:varchar(128);comment:部门名称"`
|
||||
|
||||
@@ -4,7 +4,6 @@ import "github.com/XM-GO/PandaKit/model"
|
||||
|
||||
type SysPost struct {
|
||||
PostId int64 `gorm:"primary_key;AUTO_INCREMENT" json:"postId"`
|
||||
TenantId int64 `json:"tenantId" gorm:"type:int;comment:租户Id"`
|
||||
PostName string `gorm:"type:varchar(128);comment:岗位名称" json:"postName"`
|
||||
PostCode string `gorm:"type:varchar(128);comment:岗位代码" json:"postCode"`
|
||||
Sort int64 `gorm:"type:int;comment:岗位排序" json:"sort"`
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
type SysRole struct {
|
||||
model.BaseModel
|
||||
RoleId int64 `json:"roleId" gorm:"primary_key;AUTO_INCREMENT"`
|
||||
TenantId int64 `json:"tenantId" gorm:"type:int"`
|
||||
RoleName string `json:"roleName" gorm:"type:varchar(128);comment:角色名称"`
|
||||
Status string `json:"status" gorm:"type:varchar(1);comment:状态"`
|
||||
RoleKey string `json:"roleKey" gorm:"type:varchar(128);comment:角色代码"`
|
||||
|
||||
@@ -12,23 +12,21 @@ type SysUserId struct {
|
||||
}
|
||||
|
||||
type SysUserB struct {
|
||||
TenantId int64 `gorm:"type:int" json:"tenantId"` //租户id
|
||||
NickName string `gorm:"type:varchar(128)" json:"nickName"` // 昵称
|
||||
Phone string `gorm:"type:varchar(11)" json:"phone"` // 手机号
|
||||
RoleId int64 `gorm:"type:int" json:"roleId"` // 角色编码
|
||||
Salt string `gorm:"type:varchar(255)" json:"salt"` //盐
|
||||
Avatar string `gorm:"type:varchar(255)" json:"avatar"` //头像
|
||||
Sex string `gorm:"type:varchar(255)" json:"sex"` //性别
|
||||
Email string `gorm:"type:varchar(128)" json:"email"` //邮箱
|
||||
DeptId int64 `gorm:"type:int" json:"deptId"` //部门编码
|
||||
PostId int64 `gorm:"type:int" json:"postId"` //职位编码
|
||||
RoleIds string `gorm:"type:varchar(255)" json:"roleIds"` //多角色
|
||||
PostIds string `gorm:"type:varchar(255)" json:"postIds"` // 多岗位
|
||||
CreateBy string `gorm:"type:varchar(128)" json:"createBy"` //
|
||||
UpdateBy string `gorm:"type:varchar(128)" json:"updateBy"` //
|
||||
Remark string `gorm:"type:varchar(255)" json:"remark"` //备注
|
||||
Status string `gorm:"type:varchar(1);" json:"status"`
|
||||
SysTenants SysTenants `gorm:"foreignKey:TenantId;references:Id" json:"tenants"`
|
||||
NickName string `gorm:"type:varchar(128)" json:"nickName"` // 昵称
|
||||
Phone string `gorm:"type:varchar(11)" json:"phone"` // 手机号
|
||||
RoleId int64 `gorm:"type:int" json:"roleId"` // 角色编码
|
||||
Salt string `gorm:"type:varchar(255)" json:"salt"` //盐
|
||||
Avatar string `gorm:"type:varchar(255)" json:"avatar"` //头像
|
||||
Sex string `gorm:"type:varchar(255)" json:"sex"` //性别
|
||||
Email string `gorm:"type:varchar(128)" json:"email"` //邮箱
|
||||
DeptId int64 `gorm:"type:int" json:"deptId"` //部门编码
|
||||
PostId int64 `gorm:"type:int" json:"postId"` //职位编码
|
||||
RoleIds string `gorm:"type:varchar(255)" json:"roleIds"` //多角色
|
||||
PostIds string `gorm:"type:varchar(255)" json:"postIds"` // 多岗位
|
||||
CreateBy string `gorm:"type:varchar(128)" json:"createBy"` //
|
||||
UpdateBy string `gorm:"type:varchar(128)" json:"updateBy"` //
|
||||
Remark string `gorm:"type:varchar(255)" json:"remark"` //备注
|
||||
Status string `gorm:"type:varchar(1);" json:"status"`
|
||||
model.BaseModel
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,14 @@ func InitUploadRouter(container *restful.Container) {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", map[string]string{}))
|
||||
|
||||
ws.Route(ws.POST("/up/oss").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("上传图片").Handle(s.UplaodToOss)
|
||||
}).
|
||||
Doc("上传图片到oss").
|
||||
Param(ws.FormParameter("imagefile", "文件")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", map[string]string{}))
|
||||
|
||||
ws.Route(ws.GET("/get/{subpath}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithNeedToken(false).WithNeedCasbin(false).WithLog("获取图片").Handle(s.GetImage)
|
||||
}).
|
||||
|
||||
@@ -63,9 +63,6 @@ func (m *sysDeptModelImpl) FindListPage(page, pageSize int, data entity.SysDept)
|
||||
if data.DeptName != "" {
|
||||
db = db.Where("dept_name like ?", "%"+data.DeptName+"%")
|
||||
}
|
||||
if data.TenantId != 0 {
|
||||
db = db.Where("tenant_id = ?", data.TenantId)
|
||||
}
|
||||
if data.Status != "" {
|
||||
db = db.Where("status = ?", data.Status)
|
||||
}
|
||||
@@ -87,9 +84,6 @@ func (m *sysDeptModelImpl) FindList(data entity.SysDept) *[]entity.SysDept {
|
||||
if data.DeptId != 0 {
|
||||
db = db.Where("dept_id = ?", data.DeptId)
|
||||
}
|
||||
if data.TenantId != 0 {
|
||||
db = db.Where("tenant_id = ?", data.TenantId)
|
||||
}
|
||||
if data.DeptName != "" {
|
||||
db = db.Where("dept_name like ?", "%"+data.DeptName+"%")
|
||||
}
|
||||
|
||||
@@ -50,9 +50,6 @@ func (m *sysPostModelImpl) FindListPage(page, pageSize int, data entity.SysPost)
|
||||
if data.PostName != "" {
|
||||
db = db.Where("post_name like ?", "%"+data.PostName+"%")
|
||||
}
|
||||
if data.TenantId != 0 {
|
||||
db = db.Where("tenant_id = ?", data.TenantId)
|
||||
}
|
||||
if data.PostCode != "" {
|
||||
db = db.Where("post_code like ?", "%"+data.PostCode+"%")
|
||||
}
|
||||
@@ -76,9 +73,6 @@ func (m *sysPostModelImpl) FindList(data entity.SysPost) *[]entity.SysPost {
|
||||
if data.PostName != "" {
|
||||
db = db.Where("post_name = ?", data.PostName)
|
||||
}
|
||||
if data.TenantId != 0 {
|
||||
db = db.Where("tenant_id = ?", data.TenantId)
|
||||
}
|
||||
if data.PostCode != "" {
|
||||
db = db.Where("post_code = ?", data.PostCode)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"pandax/apps/system/entity"
|
||||
"pandax/pkg/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -40,11 +39,6 @@ func (m *sysUserModelImpl) Login(u entity.Login) *entity.SysUser {
|
||||
b := kgo.KEncr.PasswordVerify([]byte(u.Password), []byte(user.Password))
|
||||
biz.IsTrue(b, "密码错误")
|
||||
|
||||
//验证租户
|
||||
if SysTenantModelDao.FindOne(user.TenantId).ExpireTime.Unix() < time.Now().Unix() {
|
||||
biz.IsTrue(b, "租户已经过期")
|
||||
}
|
||||
|
||||
return user
|
||||
}
|
||||
|
||||
@@ -69,9 +63,6 @@ func (m *sysUserModelImpl) FindOne(data entity.SysUser) *entity.SysUserView {
|
||||
if data.UserId != 0 {
|
||||
db = db.Where("user_id = ?", data.UserId)
|
||||
}
|
||||
if data.TenantId != 0 {
|
||||
db = db.Where("tenant_id = ?", data.TenantId)
|
||||
}
|
||||
if data.Username != "" {
|
||||
db = db.Where("username = ?", data.Username)
|
||||
}
|
||||
@@ -87,7 +78,7 @@ func (m *sysUserModelImpl) FindOne(data entity.SysUser) *entity.SysUserView {
|
||||
if data.PostId != 0 {
|
||||
db = db.Where("post_id = ?", data.PostId)
|
||||
}
|
||||
biz.ErrIsNil(db.Preload("SysTenants").First(resData).Error, "查询用户失败")
|
||||
biz.ErrIsNil(db.First(resData).Error, "查询用户失败")
|
||||
|
||||
return resData
|
||||
}
|
||||
@@ -102,9 +93,6 @@ func (m *sysUserModelImpl) FindListPage(page, pageSize int, data entity.SysUser)
|
||||
if data.Username != "" {
|
||||
db = db.Where("sys_users.username = ?", data.Username)
|
||||
}
|
||||
if data.TenantId != 0 {
|
||||
db = db.Where("sys_users.tenant_id = ?", data.TenantId)
|
||||
}
|
||||
if data.NickName != "" {
|
||||
db = db.Where("sys_users.nick_name like ?", "%"+data.NickName+"%")
|
||||
}
|
||||
@@ -121,7 +109,7 @@ func (m *sysUserModelImpl) FindListPage(page, pageSize int, data entity.SysUser)
|
||||
}
|
||||
db.Where("sys_users.delete_time IS NULL")
|
||||
err := db.Count(&total).Error
|
||||
err = db.Limit(pageSize).Offset(offset).Preload("SysTenants").Find(&list).Error
|
||||
err = db.Limit(pageSize).Offset(offset).Find(&list).Error
|
||||
biz.ErrIsNil(err, "查询用户分页列表失败")
|
||||
return &list, total
|
||||
}
|
||||
@@ -134,9 +122,6 @@ func (m *sysUserModelImpl) FindList(data entity.SysUser) *[]entity.SysUserView {
|
||||
if data.UserId != 0 {
|
||||
db = db.Where("user_id = ?", data.UserId)
|
||||
}
|
||||
if data.TenantId != 0 {
|
||||
db = db.Where("tenant_id = ?", data.TenantId)
|
||||
}
|
||||
if data.Username != "" {
|
||||
db = db.Where("username = ?", data.Username)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user