更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -15,19 +15,10 @@ import (
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// AppOaController 移动端 OA 协同办公接口(通知公告 / 文档库 / 薪酬工资单 / 员工档案)。
|
||||
//
|
||||
// 与 Web 管理端(/backend/oa/*)的区别:
|
||||
// - 鉴权放宽到 app 令牌(backend/app/platform),供 uniapp 调用;
|
||||
// - 只提供读能力(浏览 / 下载 / 收藏);写入操作仍留在 Web 端;
|
||||
// - 薪酬工资单与员工档案仅返回「本人」数据,通过登录账号匹配员工。
|
||||
//
|
||||
// 数据隔离:一律以 JWT 中的 TenantId 过滤,前端无法指定租户。
|
||||
type AppOaController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// 只放行移动端与租户端令牌:/api/** 仅被 uniapp 调用,平台令牌不该能打移动端接口。
|
||||
func (c *AppOaController) oaClaims() (*jwtutil.Claims, error) {
|
||||
return identity.Claims(c.Ctx.Request.Header.Get("Authorization"), identity.EndApp, identity.EndBackend)
|
||||
}
|
||||
@@ -43,7 +34,6 @@ func (c *AppOaController) oaOk(data interface{}) {
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
// oaMyEmployee 解析当前登录用户对应的员工记录(tid + 账号匹配,口径与 backend_auth 一致)。
|
||||
func (c *AppOaController) oaMyEmployee(claims *jwtutil.Claims) (*models.BackendEmployee, bool) {
|
||||
uid := services.ResolveTenantUID(uint64(claims.TenantId), uint64(claims.UserID))
|
||||
account := strings.TrimSpace(claims.Username)
|
||||
@@ -67,9 +57,6 @@ func (c *AppOaController) oaMyEmployee(claims *jwtutil.Claims) (*models.BackendE
|
||||
return &emp, true
|
||||
}
|
||||
|
||||
// ---------------- 通知公告 ----------------
|
||||
|
||||
// noticeItem 公告列表项(正文只回传摘要,避免列表过大)。
|
||||
func noticeItem(n models.OaNotice) map[string]interface{} {
|
||||
publishTime := ""
|
||||
if n.PublishTime != nil {
|
||||
@@ -88,7 +75,6 @@ func noticeItem(n models.OaNotice) map[string]interface{} {
|
||||
}
|
||||
}
|
||||
|
||||
// oaTextSummary 取正文纯文本摘要,按「字符数」截断(中文安全)。
|
||||
func oaTextSummary(content string, limit int) string {
|
||||
text := strings.Join(strings.Fields(content), " ")
|
||||
runes := []rune(text)
|
||||
@@ -98,7 +84,6 @@ func oaTextSummary(content string, limit int) string {
|
||||
return text
|
||||
}
|
||||
|
||||
// NoticeList GET /app/oa/notice/list 仅返回已发布(status=1)的公告。
|
||||
func (c *AppOaController) NoticeList() {
|
||||
claims, err := c.oaClaims()
|
||||
if err != nil {
|
||||
@@ -141,7 +126,6 @@ func (c *AppOaController) NoticeList() {
|
||||
c.oaOk(map[string]interface{}{"list": list, "total": total, "page": page, "pageSize": pageSize})
|
||||
}
|
||||
|
||||
// NoticeDetail GET /app/oa/notice/:id 公告详情,同时累加阅读数。
|
||||
func (c *AppOaController) NoticeDetail() {
|
||||
claims, err := c.oaClaims()
|
||||
if err != nil {
|
||||
@@ -172,14 +156,10 @@ func (c *AppOaController) NoticeDetail() {
|
||||
c.oaOk(item)
|
||||
}
|
||||
|
||||
// ---------------- 文档库 ----------------
|
||||
|
||||
// oaDocActor 由 JWT 构造文档访问者上下文(租户 + 用户可见性)。
|
||||
func (c *AppOaController) oaDocActor(claims *jwtutil.Claims) services.OaDocActor {
|
||||
return services.NewOaDocActor(claims.TenantId, uint64(claims.UserID))
|
||||
}
|
||||
|
||||
// docItem 文档列表/详情项(不回传体积较大的在线编辑源)。
|
||||
func docItem(d models.OaDoc) map[string]interface{} {
|
||||
updateTime := ""
|
||||
if d.UpdateTime != nil {
|
||||
@@ -210,7 +190,6 @@ func docItem(d models.OaDoc) map[string]interface{} {
|
||||
}
|
||||
}
|
||||
|
||||
// DocCategories GET /app/oa/document/categories?scope=shared|personal|all 分类树(含数量)。
|
||||
func (c *AppOaController) DocCategories() {
|
||||
claims, err := c.oaClaims()
|
||||
if err != nil {
|
||||
@@ -225,7 +204,6 @@ func (c *AppOaController) DocCategories() {
|
||||
c.oaOk(tree)
|
||||
}
|
||||
|
||||
// DocList GET /app/oa/document/list 文档分页(按可见性 + 空间过滤)。
|
||||
func (c *AppOaController) DocList() {
|
||||
claims, err := c.oaClaims()
|
||||
if err != nil {
|
||||
@@ -273,7 +251,6 @@ func (c *AppOaController) DocList() {
|
||||
c.oaOk(map[string]interface{}{"list": items, "total": total, "page": page, "pageSize": pageSize})
|
||||
}
|
||||
|
||||
// DocDetail GET /app/oa/document/:id 文档详情(累加查看数)。
|
||||
func (c *AppOaController) DocDetail() {
|
||||
claims, err := c.oaClaims()
|
||||
if err != nil {
|
||||
@@ -296,7 +273,6 @@ func (c *AppOaController) DocDetail() {
|
||||
c.oaOk(docItem(*doc))
|
||||
}
|
||||
|
||||
// DocDownload GET /app/oa/document/download/:id 记录下载并返回下载地址。
|
||||
func (c *AppOaController) DocDownload() {
|
||||
claims, err := c.oaClaims()
|
||||
if err != nil {
|
||||
@@ -322,7 +298,6 @@ func (c *AppOaController) DocDownload() {
|
||||
})
|
||||
}
|
||||
|
||||
// DocStar POST /app/oa/document/:id/star 收藏 / 取消收藏。
|
||||
func (c *AppOaController) DocStar() {
|
||||
claims, err := c.oaClaims()
|
||||
if err != nil {
|
||||
@@ -342,9 +317,6 @@ func (c *AppOaController) DocStar() {
|
||||
c.oaOk(map[string]interface{}{"is_star": isStar})
|
||||
}
|
||||
|
||||
// ---------------- 薪酬工资单(仅本人) ----------------
|
||||
|
||||
// PayrollList GET /app/oa/compensation/payrolls 仅返回当前登录用户本人的薪资单。
|
||||
func (c *AppOaController) PayrollList() {
|
||||
claims, err := c.oaClaims()
|
||||
if err != nil {
|
||||
@@ -391,7 +363,6 @@ func (c *AppOaController) PayrollList() {
|
||||
c.oaOk(map[string]interface{}{"list": list, "total": total, "page": page, "pageSize": pageSize})
|
||||
}
|
||||
|
||||
// PayrollDetail GET /app/oa/compensation/payrolls/:id 本人薪资单明细(含自定义增减项)。
|
||||
func (c *AppOaController) PayrollDetail() {
|
||||
claims, err := c.oaClaims()
|
||||
if err != nil {
|
||||
@@ -432,9 +403,6 @@ func (c *AppOaController) PayrollDetail() {
|
||||
c.oaOk(data)
|
||||
}
|
||||
|
||||
// ---------------- 员工档案(仅本人) ----------------
|
||||
|
||||
// MyEmployeeFile GET /app/oa/employee-file 返回当前登录用户本人的档案与子记录(只读)。
|
||||
func (c *AppOaController) MyEmployeeFile() {
|
||||
claims, err := c.oaClaims()
|
||||
if err != nil {
|
||||
@@ -470,19 +438,6 @@ func (c *AppOaController) MyEmployeeFile() {
|
||||
c.oaOk(map[string]interface{}{"file": dtos[0], "records": records})
|
||||
}
|
||||
|
||||
// ---------------- 工作台仪表盘(移动端首屏聚合) ----------------
|
||||
|
||||
// Dashboard GET /app/oa/dashboard
|
||||
//
|
||||
// 一次返回移动端 OA 首页顶部仪表盘所需的全部数据,口径对齐 Web 端
|
||||
// /backend/oa/schedule/stats 与 /backend/reimbursements/dashboard:
|
||||
//
|
||||
// {
|
||||
// schedule_stats:{today_total,today_done,week_total,week_done,month_total,month_done,overdue},
|
||||
// reimburse:{week,month,year,trend,status_dist,expense_types},
|
||||
// notices:[...], // 最近已发布公告(置顶优先,最多 5 条)
|
||||
// today_schedules:[...] // 今日日程(含已完成,灰显沉底)
|
||||
// }
|
||||
func (c *AppOaController) Dashboard() {
|
||||
claims, err := c.oaClaims()
|
||||
if err != nil {
|
||||
@@ -499,7 +454,6 @@ func (c *AppOaController) Dashboard() {
|
||||
})
|
||||
}
|
||||
|
||||
// oaDashboardScheduleStats 今日/本周/本月日程统计与逾期数(与 Web 端 Stats 同口径)。
|
||||
func (c *AppOaController) oaDashboardScheduleStats(tid int, uid uint64) map[string]interface{} {
|
||||
now := time.Now()
|
||||
today := now.Format("2006-01-02")
|
||||
@@ -537,7 +491,6 @@ func (c *AppOaController) oaDashboardScheduleStats(tid int, uid uint64) map[stri
|
||||
}
|
||||
}
|
||||
|
||||
// oaDashboardTodaySchedules 今日日程列表(未完成在前,已完成灰显沉底)。
|
||||
func (c *AppOaController) oaDashboardTodaySchedules(tid int, uid uint64) []map[string]interface{} {
|
||||
today := time.Now().Format("2006-01-02")
|
||||
var rows []models.OaSchedule
|
||||
@@ -562,7 +515,6 @@ func (c *AppOaController) oaDashboardTodaySchedules(tid int, uid uint64) []map[s
|
||||
return out
|
||||
}
|
||||
|
||||
// oaDashboardNotices 最近已发布公告(置顶优先,最多 5 条)。
|
||||
func (c *AppOaController) oaDashboardNotices(tid int) []map[string]interface{} {
|
||||
var rows []models.OaNotice
|
||||
_, _ = models.Orm.QueryTable(new(models.OaNotice)).
|
||||
@@ -575,8 +527,6 @@ func (c *AppOaController) oaDashboardNotices(tid int) []map[string]interface{} {
|
||||
return out
|
||||
}
|
||||
|
||||
// oaDashboardReimburse 报销统计(周/月/年 + 近6月趋势 + 状态分布 + 类型分析),
|
||||
// 个人报销单量小,一次全量查询内存聚合(与 Web 端 Dashboard 同口径)。
|
||||
func (c *AppOaController) oaDashboardReimburse(tid, uid uint64) map[string]interface{} {
|
||||
now := time.Now()
|
||||
y, m, _ := now.Date()
|
||||
@@ -661,7 +611,6 @@ func (c *AppOaController) oaDashboardReimburse(tid, uid uint64) map[string]inter
|
||||
})
|
||||
}
|
||||
|
||||
// 报销类型分析:仅统计已打款(status=5)的报销单费用明细
|
||||
paidIDs := map[uint64]bool{}
|
||||
for i := range rows {
|
||||
if rows[i].Status == 5 {
|
||||
@@ -675,7 +624,6 @@ func (c *AppOaController) oaDashboardReimburse(tid, uid uint64) map[string]inter
|
||||
}
|
||||
var items []models.BackendReimbursementItem
|
||||
if len(paidIDList) > 0 {
|
||||
// 按已打款主单 ID 查明细,不依赖明细行的 tid/uid(历史数据可能不一致)
|
||||
if _, err := models.Orm.QueryTable(new(models.BackendReimbursementItem)).
|
||||
Filter("reimbursement_id__in", paidIDList).Filter("is_deleted", 0).
|
||||
All(&items); err == nil {
|
||||
|
||||
Reference in new issue
Block a user