更新密码找回uniapp

This commit is contained in:
hero920103 committed 2026-11-16 17:22:50 +08:00
1 parent 7f9a66da0f
commit 3fdda89833
1304 files changed
+3503 -26132

No files matched your search

-48
View File
@@ -14,20 +14,10 @@ import (
beego "github.com/beego/beego/v2/server/web"
)
// BackendOaSchedulingController OA 工作排班(班次 / 排班方案 / 排班看板 / 临时调配)。
//
// 排班的作用范围直接复用租户的组织架构(yz_backend_organization):
// 公司、部门、小组是同一棵树上的不同层级,选中某个节点并勾选“含下级”
// 即可把排班下发给该节点下的全部员工;也可以跳过组织,直接挑选
// 一个或多个员工做临时安排。所有数据按 JWT 中的 tid 做租户隔离。
type BackendOaSchedulingController struct {
beego.Controller
}
// ---------------------------------------------------------------------------
// 认证与响应
// ---------------------------------------------------------------------------
func (c *BackendOaSchedulingController) scClaims() (*jwtutil.Claims, bool) {
claims, err := identity.Claims(c.Ctx.Request.Header.Get("Authorization"), identity.EndBackend)
if err != nil || claims.TenantId <= 0 {
@@ -36,7 +26,6 @@ func (c *BackendOaSchedulingController) scClaims() (*jwtutil.Claims, bool) {
return claims, true
}
// scOperator 返回当前操作人信息:tid、uid、用户名。
func (c *BackendOaSchedulingController) scOperator() (uint64, uint64, string, bool) {
claims, ok := c.scClaims()
if !ok {
@@ -73,10 +62,6 @@ func (c *BackendOaSchedulingController) scPathID(param string) (uint64, bool) {
return id, err == nil && id > 0
}
// ---------------------------------------------------------------------------
// 参数解析辅助
// ---------------------------------------------------------------------------
func scStringValue(body map[string]interface{}, keys ...string) string {
for _, key := range keys {
raw, ok := body[key]
@@ -116,7 +101,6 @@ func scUintValue(body map[string]interface{}, keys ...string) uint64 {
return value
}
// scUintSlice 解析 [] 形式的 ID 列表,兼容数字与字符串两种元素。
func scUintSlice(body map[string]interface{}, key string) []uint64 {
raw, ok := body[key]
if !ok || raw == nil {
@@ -162,8 +146,6 @@ func scBoolValue(body map[string]interface{}, keys ...string) bool {
return false
}
// scWeekdaySet 解析星期筛选,1=周一 ... 7=周日。
// 支持 [1,3,5] 数组与 "1,3,5" 字符串;空值表示每天。
func scWeekdaySet(body map[string]interface{}) map[int]bool {
result := map[int]bool{}
raw, ok := body["weekdays"]
@@ -195,7 +177,6 @@ func scWeekdaySet(body map[string]interface{}) map[int]bool {
return result
}
// scParseDate 解析 "YYYY-MM-DD" 并返回时间对象。
func scParseDate(value string) (time.Time, bool) {
if !isValidOaDate(value) {
return time.Time{}, false
@@ -207,8 +188,6 @@ func scParseDate(value string) (time.Time, bool) {
return parsed, true
}
// scDateSpan 展开 [start, end] 之间的全部日期字符串;区间上限 92 天,
// 避免一次请求把看板拖垮。
func scDateSpan(start, end string) ([]string, string) {
startDate, ok := scParseDate(start)
if !ok {
@@ -231,12 +210,8 @@ func scDateSpan(start, end string) ([]string, string) {
return dates, ""
}
// scPlanNoEndDate 无期限方案的结束日期哨兵:数据库日期列不支持空串,
// 统一存 2099-12-31,前端按 no_end 标记展示为「无期限」。
const scPlanNoEndDate = "2099-12-31"
// scDateSpanUnbounded 展开任意长度的日期区间,供无期限方案的
// 「当年窗口」使用,不受 scDateSpan 的 92 天上限约束。
func scDateSpanUnbounded(start, end string) ([]string, string) {
startDate, ok := scParseDate(start)
if !ok {
@@ -257,14 +232,10 @@ func scDateSpanUnbounded(start, end string) ([]string, string) {
return dates, ""
}
// scIsNoEnd 判断结束日期是否表示无期限(空串或哨兵值)。
func scIsNoEnd(end string) bool {
return end == "" || end >= scPlanNoEndDate
}
// scPlanGenWindow 计算一次预览 / 发布实际展开的日期窗口。
// 普通方案:[start, end] 原样展开;无期限方案:从 max(start, 今天) 生成到
// 当年 12 月 31 日,跨年不自动延续,新的一年需要重新排班。
func scPlanGenWindow(startText, endText string) ([]string, string) {
if !scIsNoEnd(endText) {
return scDateSpan(startText, endText)
@@ -285,7 +256,6 @@ func scPlanGenWindow(startText, endText string) ([]string, string) {
return scDateSpanUnbounded(windowStart.Format("2006-01-02"), windowEnd.Format("2006-01-02"))
}
// scMinutes 把 "HH:mm" 转为当日分钟数。
func scMinutes(value string) (int, bool) {
if value == "" {
return 0, false
@@ -297,8 +267,6 @@ func scMinutes(value string) (int, bool) {
return parsed.Hour()*60 + parsed.Minute(), true
}
// scCalcWorkHours 计算班次工时(小时):上下班跨度扣除休息时段。
// 下班时间早于上班时间视为跨天班次,自动加 24 小时。
func scCalcWorkHours(workStart, workEnd, restStart, restEnd string) float64 {
start, okStart := scMinutes(workStart)
end, okEnd := scMinutes(workEnd)
@@ -336,10 +304,6 @@ func scCalcWorkHours(workStart, workEnd, restStart, restEnd string) float64 {
return float64(span) / 60
}
// ---------------------------------------------------------------------------
// 班次管理
// ---------------------------------------------------------------------------
func (c *BackendOaSchedulingController) shiftQuery(tid uint64) orm.QuerySeter {
return models.Orm.QueryTable(new(models.OaShift)).
Filter("tid", tid).
@@ -354,8 +318,6 @@ func (c *BackendOaSchedulingController) shiftByID(tid, id uint64) (*models.OaShi
return &row, true
}
// ShiftList 班次列表。
// GET /backend/oa/scheduling/shifts
func (c *BackendOaSchedulingController) ShiftList() {
tid, _, _, ok := c.scOperator()
if !ok {
@@ -386,8 +348,6 @@ func (c *BackendOaSchedulingController) ShiftList() {
})
}
// CreateShift 新增班次。
// POST /backend/oa/scheduling/shifts
func (c *BackendOaSchedulingController) CreateShift() {
tid, _, _, ok := c.scOperator()
if !ok {
@@ -413,8 +373,6 @@ func (c *BackendOaSchedulingController) CreateShift() {
c.scOK(row)
}
// UpdateShift 更新班次。
// POST /backend/oa/scheduling/shifts/:id
func (c *BackendOaSchedulingController) UpdateShift() {
tid, _, _, ok := c.scOperator()
if !ok {
@@ -459,14 +417,11 @@ func (c *BackendOaSchedulingController) UpdateShift() {
return
}
// 班次名称/时间变化时同步已排班的快照,避免看板显示旧时间。
c.syncShiftSnapshot(tid, existing)
c.scOK(existing)
}
// DeleteShift 删除班次(软删除)。已被排班使用时拒绝删除,建议改为停用。
// DELETE /backend/oa/scheduling/shifts/:id
func (c *BackendOaSchedulingController) DeleteShift() {
tid, _, _, ok := c.scOperator()
if !ok {
@@ -503,7 +458,6 @@ func (c *BackendOaSchedulingController) DeleteShift() {
c.scOK(map[string]interface{}{"id": id})
}
// buildShiftFromBody 校验并构造班次对象;返回非空 msg 表示参数错误。
func (c *BackendOaSchedulingController) buildShiftFromBody(body map[string]interface{}) (*models.OaShift, string) {
name := scStringValue(body, "name")
if name == "" {
@@ -568,7 +522,6 @@ func (c *BackendOaSchedulingController) buildShiftFromBody(body map[string]inter
return row, ""
}
// clearDefaultShift 把同租户下其它班次的默认标记清掉,保证只有一个默认班次。
func (c *BackendOaSchedulingController) clearDefaultShift(tid, excludeID uint64) {
qs := c.shiftQuery(tid).Filter("is_default", 1)
if excludeID > 0 {
@@ -584,7 +537,6 @@ func (c *BackendOaSchedulingController) clearDefaultShift(tid, excludeID uint64)
}
}
// syncShiftSnapshot 班次变更后,把新快照写回已生成的排班明细。
func (c *BackendOaSchedulingController) syncShiftSnapshot(tid uint64, shift *models.OaShift) {
_, _ = models.Orm.Raw(
"UPDATE yz_backend_oa_schedule_entry SET shift_name=?, short_name=?, color=?, work_start=?, work_end=? "+