diff --git a/docs/course_api.md b/docs/course_api.md deleted file mode 100644 index 895a06a..0000000 --- a/docs/course_api.md +++ /dev/null @@ -1,403 +0,0 @@ -# 刷课接口文档 - -## 接口列表 - -### 1. 获取刷课列表 - -**接口地址**: `GET /course` - -**请求参数**: - -| 参数名 | 类型 | 必填 | 说明 | -|--------|------|------|------| -| type | string | 否 | 类型,可选值:`xxt`(学习通) | -| username | string | 否 | 账号(模糊搜索) | -| status | string | 否 | 状态,可选值:`not_start`(未开始)、`waiting`(等待中)、`doing`(进行中)、`done`(已完成)、`fail`(失败)、`pause`(暂停) | -| page | int | 否 | 页码,默认 1 | -| size | int | 否 | 每页数量,默认 10 | - -**返回示例**: - -```json -{ - "code": 200, - "message": "success", - "data": [ - { - "id": 1, - "user_id": 1, - "username": "学习通账号", - "password": "", - "type": "xxt", - "course_name": "大学英语", - "course_id": "123456", - "need": "task", - "status": "waiting", - "task_count": 10, - "success_count": 5, - "exam_state": "not_start", - "violence": "no", - "desc": "备注信息", - "create_time": "2024-01-01T00:00:00Z", - "update_time": "2024-01-01T00:00:00Z" - } - ], - "total": 100 -} -``` - -**字段说明**: - -- `type`: 类型 - `xxt`(学习通) -- `need`: 需要刷的内容 - `task`(任务点)、`exam`(考试)、`all`(全部) -- `status`: 状态 - `not_start`(未开始)、`waiting`(等待中)、`doing`(进行中)、`done`(已完成)、`fail`(失败)、`pause`(暂停) -- `exam_state`: 考试状态 - `not_start`(未开始)、`waiting`(等待中)、`doing`(进行中)、`done`(已完成)、`fail`(失败) -- `violence`: 是否暴力刷课 - `no`(否)、`yes`(是) - ---- - -### 2. 查询课程列表 - -**接口地址**: `POST /course/query` - -**说明**: 通过学习通账号密码查询当前可选的课程列表,用于在添加刷课前选择课程。 - -**请求参数**: - -| 参数名 | 类型 | 必填 | 说明 | -|--------|------|------|------| -| username | string | 是 | 学习通账号 | -| password | string | 是 | 学习通密码 | - -**请求示例**: - -```json -{ - "username": "学习通账号", - "password": "学习通密码" -} -``` - -**返回示例**: - -```json -{ - "code": 200, - "message": "success", - "data": [ - { - "cpi": 123456, - "key": "234567", - "courseId": "345678", - "chatId": "456789", - "courseTeacher": "张老师", - "courseName": "大学英语", - "courseImage": "https://example.com/image.jpg", - "courseImageBase64": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAA...", - "courseDataId": 567890, - "ContentID": 678901, - "isstart": true, - "state": 0 - } - ] -} -``` - -**字段说明**: - -- `cpi`: 用户唯一标识 -- `key`: 课程班级ID(classId) -- `courseId`: 课程ID(**添加刷课时需要使用**) -- `chatId`: 聊天ID -- `courseTeacher`: 授课教师 -- `courseName`: 课程名称(**添加刷课时需要使用**) -- `courseImage`: 课程封面图片URL -- `courseImageBase64`: 课程封面图片Base64编码(包含Data URL前缀,可直接用于img标签的src属性) -- `courseDataId`: 课程数据ID -- `ContentID`: 内容ID -- `isstart`: 是否已开课(true:已开课,false:未开课) -- `state`: 课程状态(0:正常,1:已结束) - -**注意事项**: - -- `courseImageBase64` 字段已经包含了 Data URL 前缀(如 `data:image/jpeg;base64,`),可以直接设置到 `` 标签的 `src` 属性 -- 如果图片下载失败,`courseImageBase64` 字段将为空字符串,此时可以使用 `courseImage` URL 作为备用 - -**错误示例**: - -```json -{ - "code": 400, - "message": "登录失败,请检查账号密码", - "data": null -} -``` - ---- - -### 3. 添加刷课 - -**接口地址**: `POST /course` - -**请求参数**: - -| 参数名 | 类型 | 必填 | 说明 | -|--------|------|------|------| -| username | string | 是 | 学习通账号 | -| password | string | 是 | 学习通密码 | -| type | string | 是 | 类型,目前只支持 `xxt`(学习通) | -| course_name | string | 是 | 课程名称 | -| course_id | string | 是 | 课程ID | -| need | string | 是 | 需要刷的内容,可选值:`task`(任务点)、`exam`(考试)、`all`(全部) | -| violence | string | 否 | 是否暴力刷课,可选值:`no`(否,默认)、`yes`(是) | -| desc | string | 否 | 备注信息 | - -**请求示例**: - -```json -{ - "username": "学习通账号", - "password": "学习通密码", - "type": "xxt", - "course_name": "大学英语", - "course_id": "123456", - "need": "task", - "violence": "no", - "desc": "备注信息" -} -``` - -**返回示例**: - -```json -{ - "code": 200, - "message": "添加成功", - "data": null -} -``` - -**错误示例**: - -```json -{ - "code": 400, - "message": "该课程已存在刷课任务", - "data": null -} -``` - ---- - -### 4. 修改刷课密码 - -**接口地址**: `PUT /course/password/{id}` - -**路径参数**: - -| 参数名 | 类型 | 必填 | 说明 | -|--------|------|------|------| -| id | int64 | 是 | 刷课任务ID | - -**请求参数**: - -| 参数名 | 类型 | 必填 | 说明 | -|--------|------|------|------| -| password | string | 是 | 新密码 | - -**请求示例**: - -```json -{ - "password": "新密码" -} -``` - -**返回示例**: - -```json -{ - "code": 200, - "message": "密码修改成功", - "data": null -} -``` - -**错误示例**: - -```json -{ - "code": 400, - "message": "课程不存在或无权限操作", - "data": null -} -``` - ---- - -### 5. 重刷课程 - -**接口地址**: `POST /course/restart/{id}` - -**路径参数**: - -| 参数名 | 类型 | 必填 | 说明 | -|--------|------|------|------| -| id | int64 | 是 | 刷课任务ID | - -**说明**: 只有状态为 `done`(已完成)的课程才能重刷,重刷后会重置课程状态、任务数量、成功数量和考试状态。 - -**返回示例**: - -```json -{ - "code": 200, - "message": "重刷成功", - "data": null -} -``` - -**错误示例**: - -```json -{ - "code": 400, - "message": "只有已完成的课程才能重刷", - "data": null -} -``` - ---- - -### 6. 暂停/恢复刷课 - -**接口地址**: `POST /course/pause/{id}` - -**路径参数**: - -| 参数名 | 类型 | 必填 | 说明 | -|--------|------|------|------| -| id | int64 | 是 | 刷课任务ID | - -**说明**: 该接口会在暂停和恢复之间切换: -- 如果当前状态是 `pause`(暂停),则恢复为 `waiting`(等待中) -- 如果当前状态不是暂停,则设置为 `pause`(暂停) - -**返回示例(暂停)**: - -```json -{ - "code": 200, - "message": "已暂停刷课", - "data": null -} -``` - -**返回示例(恢复)**: - -```json -{ - "code": 200, - "message": "已恢复刷课", - "data": null -} -``` - ---- - -### 7. 删除刷课 - -**接口地址**: `DELETE /course/{id}` - -**路径参数**: - -| 参数名 | 类型 | 必填 | 说明 | -|--------|------|------|------| -| id | int64 | 是 | 刷课任务ID | - -**返回示例**: - -```json -{ - "code": 200, - "message": "删除成功", - "data": null -} -``` - -**错误示例**: - -```json -{ - "code": 400, - "message": "课程不存在或无权限操作", - "data": null -} -``` - ---- - -## 枚举值说明 - -### 类型 (type) - -| 值 | 说明 | -|-----|------| -| xxt | 学习通 | - -### 需要刷的内容 (need) - -| 值 | 说明 | -|-----|------| -| task | 任务点 | -| exam | 考试 | -| all | 全部 | - -### 状态 (status) - -| 值 | 说明 | -|-----|------| -| not_start | 未开始 | -| waiting | 等待中 | -| doing | 进行中 | -| done | 已完成 | -| fail | 失败 | -| pause | 暂停 | - -### 考试状态 (exam_state) - -| 值 | 说明 | -|-----|------| -| not_start | 未开始 | -| waiting | 等待中 | -| doing | 进行中 | -| done | 已完成 | -| fail | 失败 | - -### 是否暴力刷课 (violence) - -| 值 | 说明 | -|-----|------| -| no | 否 | -| yes | 是 | - ---- - -## 通用说明 - -### 认证 - -所有接口都需要用户认证,需要在请求头中携带认证信息(具体认证方式根据项目配置)。 - -### 权限 - -用户只能操作自己创建的刷课任务,无法访问或修改其他用户的数据。 - -### 错误码 - -| 错误码 | 说明 | -|--------|------| -| 200 | 成功 | -| 400 | 业务错误(如参数错误、权限不足等) | -| 401 | 未认证 | -| 500 | 服务器错误 | diff --git a/internal/api/v1/cpleave_req.go b/internal/api/v1/cpleave_req.go index 47e12fd..362f4b8 100644 --- a/internal/api/v1/cpleave_req.go +++ b/internal/api/v1/cpleave_req.go @@ -19,8 +19,11 @@ type GetLeaveListFromSystemReq struct { } type CpLeaveReportReq struct { - g.Meta `path:"/leave/report" method:"post" tags:"CpLeave" summary:"执行销假"` - CpUserId int64 `json:"cpUserId" v:"required#今日校园账号ID不能为空"` - LeaveId string `json:"leaveId" v:"required#请假记录ID不能为空"` - Title string `json:"title" v:"required#请假记录标题不能为空"` + g.Meta `path:"/leave/report" method:"post" tags:"CpLeave" summary:"执行销假"` + CpUserId int64 `json:"cpUserId" v:"required#今日校园账号ID不能为空"` + LeaveId string `json:"leaveId" v:"required#请假记录ID不能为空"` + Title string `json:"title" v:"required#请假记录标题不能为空"` + Longitude string `json:"longitude"` // 经度(可选,不传则使用系统默认) + Latitude string `json:"latitude"` // 纬度(可选,不传则使用系统默认) + Address string `json:"address"` // 地址(可选,不传则使用系统默认) } diff --git a/internal/application/cpdaily/leave/report.go b/internal/application/cpdaily/leave/report.go index 7ac200a..d7adb99 100644 --- a/internal/application/cpdaily/leave/report.go +++ b/internal/application/cpdaily/leave/report.go @@ -75,6 +75,14 @@ func (c *CpdailyReportApp) GetLeaveList() []leavetype.LeaveListOne { AceEndTime: row.Get("actEndTime").String(), Status: row.Get("status").String(), } + + // 获取详情以填充位置信息 + detail := c.LeaveDetail(leaveOne.Id) + lon, lat := c.GetLocation(detail) + leaveOne.Longitude = lon + leaveOne.Latitude = lat + leaveOne.Address = detail.Get("detail.applyLocation.address").String() + listList = append(listList, leaveOne) } return listList diff --git a/internal/application/cpdaily/task/leavetype/leave_list.go b/internal/application/cpdaily/task/leavetype/leave_list.go index 7033127..0a381e0 100644 --- a/internal/application/cpdaily/task/leavetype/leave_list.go +++ b/internal/application/cpdaily/task/leavetype/leave_list.go @@ -7,4 +7,8 @@ type LeaveListOne struct { AceEndTime string `json:"aceEndTime"` Reason string `json:"reason"` Status string `json:"status"` + // 销假时填充的位置信息 + Longitude string `json:"longitude"` // 经度 + Latitude string `json:"latitude"` // 纬度 + Address string `json:"address"` // 地址 } diff --git a/internal/ent/sysannouncement/sysannouncement.go b/internal/ent/sysannouncement/sysannouncement.go deleted file mode 100644 index 68c3c2d..0000000 --- a/internal/ent/sysannouncement/sysannouncement.go +++ /dev/null @@ -1,175 +0,0 @@ -// ENT数据库文件,请勿编辑。 - -package sysannouncement - -import ( - "fmt" - "likedream-goframe/internal/framework/ent2" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the sysannouncement type in the database. - Label = "sys_announcement" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldCreateTime holds the string denoting the create_time field in the database. - FieldCreateTime = "create_time" - // FieldUpdateTime holds the string denoting the update_time field in the database. - FieldUpdateTime = "update_time" - // FieldTitle holds the string denoting the title field in the database. - FieldTitle = "title" - // FieldContent holds the string denoting the content field in the database. - FieldContent = "content" - // FieldStatus holds the string denoting the status field in the database. - FieldStatus = "status" - // FieldPinned holds the string denoting the pinned field in the database. - FieldPinned = "pinned" - // FieldOrder holds the string denoting the order field in the database. - FieldOrder = "order" - // FieldCreatorID holds the string denoting the creator_id field in the database. - FieldCreatorID = "creator_id" - // EdgeCreator holds the string denoting the creator edge name in mutations. - EdgeCreator = "creator" - // Table holds the table name of the sysannouncement in the database. - Table = "sys_announcement" - // CreatorTable is the table that holds the creator relation/edge. - CreatorTable = "sys_announcement" - // CreatorInverseTable is the table name for the SysUser entity. - // It exists in this package in order to avoid circular dependency with the "sysuser" package. - CreatorInverseTable = "sys_user" - // CreatorColumn is the table column denoting the creator relation/edge. - CreatorColumn = "creator_id" -) - -// Columns holds all SQL columns for sysannouncement fields. -var Columns = []string{ - FieldID, - FieldCreateTime, - FieldUpdateTime, - FieldTitle, - FieldContent, - FieldStatus, - FieldPinned, - FieldOrder, - FieldCreatorID, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -// Note that the variables below are initialized by the runtime -// package on the initialization of the application. Therefore, -// it should be imported in the main as follows: -// -// import _ "likedream-goframe/internal/ent/runtime" -var ( - Hooks [1]ent.Hook - // DefaultCreateTime holds the default value on creation for the "create_time" field. - DefaultCreateTime func() *ent2.CustomTime - // DefaultUpdateTime holds the default value on creation for the "update_time" field. - DefaultUpdateTime func() *ent2.CustomTime - // DefaultPinned holds the default value on creation for the "pinned" field. - DefaultPinned bool - // DefaultOrder holds the default value on creation for the "order" field. - DefaultOrder uint -) - -// Status defines the type for the "status" enum field. -type Status string - -// StatusDraft is the default value of the Status enum. -const DefaultStatus = StatusDraft - -// Status values. -const ( - StatusDraft Status = "draft" - StatusPublished Status = "published" - StatusArchived Status = "archived" -) - -func (s Status) String() string { - return string(s) -} - -// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save. -func StatusValidator(s Status) error { - switch s { - case StatusDraft, StatusPublished, StatusArchived: - return nil - default: - return fmt.Errorf("sysannouncement: invalid enum value for status field: %q", s) - } -} - -// OrderOption defines the ordering options for the SysAnnouncement queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByCreateTime orders the results by the create_time field. -func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreateTime, opts...).ToFunc() -} - -// ByUpdateTime orders the results by the update_time field. -func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() -} - -// ByTitle orders the results by the title field. -func ByTitle(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldTitle, opts...).ToFunc() -} - -// ByContent orders the results by the content field. -func ByContent(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldContent, opts...).ToFunc() -} - -// ByStatus orders the results by the status field. -func ByStatus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldStatus, opts...).ToFunc() -} - -// ByPinned orders the results by the pinned field. -func ByPinned(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPinned, opts...).ToFunc() -} - -// ByOrder orders the results by the order field. -func ByOrder(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldOrder, opts...).ToFunc() -} - -// ByCreatorID orders the results by the creator_id field. -func ByCreatorID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreatorID, opts...).ToFunc() -} - -// ByCreatorField orders the results by creator field. -func ByCreatorField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newCreatorStep(), sql.OrderByField(field, opts...)) - } -} -func newCreatorStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(CreatorInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, CreatorTable, CreatorColumn), - ) -} diff --git a/internal/ent/sysannouncement/where.go b/internal/ent/sysannouncement/where.go deleted file mode 100644 index f691ae9..0000000 --- a/internal/ent/sysannouncement/where.go +++ /dev/null @@ -1,496 +0,0 @@ -// ENT数据库文件,请勿编辑。 - -package sysannouncement - -import ( - "likedream-goframe/internal/ent/internal" - "likedream-goframe/internal/ent/predicate" - "likedream-goframe/internal/framework/ent2" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int64) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int64) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int64) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int64) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int64) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int64) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int64) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int64) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int64) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldLTE(FieldID, id)) -} - -// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. -func CreateTime(v *ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldCreateTime, v)) -} - -// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. -func UpdateTime(v *ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldUpdateTime, v)) -} - -// Title applies equality check predicate on the "title" field. It's identical to TitleEQ. -func Title(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldTitle, v)) -} - -// Content applies equality check predicate on the "content" field. It's identical to ContentEQ. -func Content(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldContent, v)) -} - -// Pinned applies equality check predicate on the "pinned" field. It's identical to PinnedEQ. -func Pinned(v bool) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldPinned, v)) -} - -// Order applies equality check predicate on the "order" field. It's identical to OrderEQ. -func Order(v uint) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldOrder, v)) -} - -// CreatorID applies equality check predicate on the "creator_id" field. It's identical to CreatorIDEQ. -func CreatorID(v int64) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldCreatorID, v)) -} - -// CreateTimeEQ applies the EQ predicate on the "create_time" field. -func CreateTimeEQ(v *ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldCreateTime, v)) -} - -// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. -func CreateTimeNEQ(v *ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNEQ(FieldCreateTime, v)) -} - -// CreateTimeIn applies the In predicate on the "create_time" field. -func CreateTimeIn(vs ...*ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldIn(FieldCreateTime, vs...)) -} - -// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. -func CreateTimeNotIn(vs ...*ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNotIn(FieldCreateTime, vs...)) -} - -// CreateTimeGT applies the GT predicate on the "create_time" field. -func CreateTimeGT(v *ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldGT(FieldCreateTime, v)) -} - -// CreateTimeGTE applies the GTE predicate on the "create_time" field. -func CreateTimeGTE(v *ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldGTE(FieldCreateTime, v)) -} - -// CreateTimeLT applies the LT predicate on the "create_time" field. -func CreateTimeLT(v *ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldLT(FieldCreateTime, v)) -} - -// CreateTimeLTE applies the LTE predicate on the "create_time" field. -func CreateTimeLTE(v *ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldLTE(FieldCreateTime, v)) -} - -// CreateTimeContains applies the Contains predicate on the "create_time" field. -func CreateTimeContains(v *ent2.CustomTime) predicate.SysAnnouncement { - vc := v.String() - return predicate.SysAnnouncement(sql.FieldContains(FieldCreateTime, vc)) -} - -// CreateTimeHasPrefix applies the HasPrefix predicate on the "create_time" field. -func CreateTimeHasPrefix(v *ent2.CustomTime) predicate.SysAnnouncement { - vc := v.String() - return predicate.SysAnnouncement(sql.FieldHasPrefix(FieldCreateTime, vc)) -} - -// CreateTimeHasSuffix applies the HasSuffix predicate on the "create_time" field. -func CreateTimeHasSuffix(v *ent2.CustomTime) predicate.SysAnnouncement { - vc := v.String() - return predicate.SysAnnouncement(sql.FieldHasSuffix(FieldCreateTime, vc)) -} - -// CreateTimeEqualFold applies the EqualFold predicate on the "create_time" field. -func CreateTimeEqualFold(v *ent2.CustomTime) predicate.SysAnnouncement { - vc := v.String() - return predicate.SysAnnouncement(sql.FieldEqualFold(FieldCreateTime, vc)) -} - -// CreateTimeContainsFold applies the ContainsFold predicate on the "create_time" field. -func CreateTimeContainsFold(v *ent2.CustomTime) predicate.SysAnnouncement { - vc := v.String() - return predicate.SysAnnouncement(sql.FieldContainsFold(FieldCreateTime, vc)) -} - -// UpdateTimeEQ applies the EQ predicate on the "update_time" field. -func UpdateTimeEQ(v *ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldUpdateTime, v)) -} - -// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. -func UpdateTimeNEQ(v *ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNEQ(FieldUpdateTime, v)) -} - -// UpdateTimeIn applies the In predicate on the "update_time" field. -func UpdateTimeIn(vs ...*ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. -func UpdateTimeNotIn(vs ...*ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNotIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeGT applies the GT predicate on the "update_time" field. -func UpdateTimeGT(v *ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldGT(FieldUpdateTime, v)) -} - -// UpdateTimeGTE applies the GTE predicate on the "update_time" field. -func UpdateTimeGTE(v *ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldGTE(FieldUpdateTime, v)) -} - -// UpdateTimeLT applies the LT predicate on the "update_time" field. -func UpdateTimeLT(v *ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldLT(FieldUpdateTime, v)) -} - -// UpdateTimeLTE applies the LTE predicate on the "update_time" field. -func UpdateTimeLTE(v *ent2.CustomTime) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldLTE(FieldUpdateTime, v)) -} - -// UpdateTimeContains applies the Contains predicate on the "update_time" field. -func UpdateTimeContains(v *ent2.CustomTime) predicate.SysAnnouncement { - vc := v.String() - return predicate.SysAnnouncement(sql.FieldContains(FieldUpdateTime, vc)) -} - -// UpdateTimeHasPrefix applies the HasPrefix predicate on the "update_time" field. -func UpdateTimeHasPrefix(v *ent2.CustomTime) predicate.SysAnnouncement { - vc := v.String() - return predicate.SysAnnouncement(sql.FieldHasPrefix(FieldUpdateTime, vc)) -} - -// UpdateTimeHasSuffix applies the HasSuffix predicate on the "update_time" field. -func UpdateTimeHasSuffix(v *ent2.CustomTime) predicate.SysAnnouncement { - vc := v.String() - return predicate.SysAnnouncement(sql.FieldHasSuffix(FieldUpdateTime, vc)) -} - -// UpdateTimeEqualFold applies the EqualFold predicate on the "update_time" field. -func UpdateTimeEqualFold(v *ent2.CustomTime) predicate.SysAnnouncement { - vc := v.String() - return predicate.SysAnnouncement(sql.FieldEqualFold(FieldUpdateTime, vc)) -} - -// UpdateTimeContainsFold applies the ContainsFold predicate on the "update_time" field. -func UpdateTimeContainsFold(v *ent2.CustomTime) predicate.SysAnnouncement { - vc := v.String() - return predicate.SysAnnouncement(sql.FieldContainsFold(FieldUpdateTime, vc)) -} - -// TitleEQ applies the EQ predicate on the "title" field. -func TitleEQ(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldTitle, v)) -} - -// TitleNEQ applies the NEQ predicate on the "title" field. -func TitleNEQ(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNEQ(FieldTitle, v)) -} - -// TitleIn applies the In predicate on the "title" field. -func TitleIn(vs ...string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldIn(FieldTitle, vs...)) -} - -// TitleNotIn applies the NotIn predicate on the "title" field. -func TitleNotIn(vs ...string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNotIn(FieldTitle, vs...)) -} - -// TitleGT applies the GT predicate on the "title" field. -func TitleGT(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldGT(FieldTitle, v)) -} - -// TitleGTE applies the GTE predicate on the "title" field. -func TitleGTE(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldGTE(FieldTitle, v)) -} - -// TitleLT applies the LT predicate on the "title" field. -func TitleLT(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldLT(FieldTitle, v)) -} - -// TitleLTE applies the LTE predicate on the "title" field. -func TitleLTE(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldLTE(FieldTitle, v)) -} - -// TitleContains applies the Contains predicate on the "title" field. -func TitleContains(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldContains(FieldTitle, v)) -} - -// TitleHasPrefix applies the HasPrefix predicate on the "title" field. -func TitleHasPrefix(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldHasPrefix(FieldTitle, v)) -} - -// TitleHasSuffix applies the HasSuffix predicate on the "title" field. -func TitleHasSuffix(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldHasSuffix(FieldTitle, v)) -} - -// TitleEqualFold applies the EqualFold predicate on the "title" field. -func TitleEqualFold(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEqualFold(FieldTitle, v)) -} - -// TitleContainsFold applies the ContainsFold predicate on the "title" field. -func TitleContainsFold(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldContainsFold(FieldTitle, v)) -} - -// ContentEQ applies the EQ predicate on the "content" field. -func ContentEQ(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldContent, v)) -} - -// ContentNEQ applies the NEQ predicate on the "content" field. -func ContentNEQ(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNEQ(FieldContent, v)) -} - -// ContentIn applies the In predicate on the "content" field. -func ContentIn(vs ...string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldIn(FieldContent, vs...)) -} - -// ContentNotIn applies the NotIn predicate on the "content" field. -func ContentNotIn(vs ...string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNotIn(FieldContent, vs...)) -} - -// ContentGT applies the GT predicate on the "content" field. -func ContentGT(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldGT(FieldContent, v)) -} - -// ContentGTE applies the GTE predicate on the "content" field. -func ContentGTE(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldGTE(FieldContent, v)) -} - -// ContentLT applies the LT predicate on the "content" field. -func ContentLT(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldLT(FieldContent, v)) -} - -// ContentLTE applies the LTE predicate on the "content" field. -func ContentLTE(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldLTE(FieldContent, v)) -} - -// ContentContains applies the Contains predicate on the "content" field. -func ContentContains(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldContains(FieldContent, v)) -} - -// ContentHasPrefix applies the HasPrefix predicate on the "content" field. -func ContentHasPrefix(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldHasPrefix(FieldContent, v)) -} - -// ContentHasSuffix applies the HasSuffix predicate on the "content" field. -func ContentHasSuffix(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldHasSuffix(FieldContent, v)) -} - -// ContentEqualFold applies the EqualFold predicate on the "content" field. -func ContentEqualFold(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEqualFold(FieldContent, v)) -} - -// ContentContainsFold applies the ContainsFold predicate on the "content" field. -func ContentContainsFold(v string) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldContainsFold(FieldContent, v)) -} - -// StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v Status) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldStatus, v)) -} - -// StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v Status) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNEQ(FieldStatus, v)) -} - -// StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...Status) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldIn(FieldStatus, vs...)) -} - -// StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...Status) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNotIn(FieldStatus, vs...)) -} - -// PinnedEQ applies the EQ predicate on the "pinned" field. -func PinnedEQ(v bool) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldPinned, v)) -} - -// PinnedNEQ applies the NEQ predicate on the "pinned" field. -func PinnedNEQ(v bool) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNEQ(FieldPinned, v)) -} - -// OrderEQ applies the EQ predicate on the "order" field. -func OrderEQ(v uint) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldOrder, v)) -} - -// OrderNEQ applies the NEQ predicate on the "order" field. -func OrderNEQ(v uint) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNEQ(FieldOrder, v)) -} - -// OrderIn applies the In predicate on the "order" field. -func OrderIn(vs ...uint) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldIn(FieldOrder, vs...)) -} - -// OrderNotIn applies the NotIn predicate on the "order" field. -func OrderNotIn(vs ...uint) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNotIn(FieldOrder, vs...)) -} - -// OrderGT applies the GT predicate on the "order" field. -func OrderGT(v uint) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldGT(FieldOrder, v)) -} - -// OrderGTE applies the GTE predicate on the "order" field. -func OrderGTE(v uint) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldGTE(FieldOrder, v)) -} - -// OrderLT applies the LT predicate on the "order" field. -func OrderLT(v uint) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldLT(FieldOrder, v)) -} - -// OrderLTE applies the LTE predicate on the "order" field. -func OrderLTE(v uint) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldLTE(FieldOrder, v)) -} - -// CreatorIDEQ applies the EQ predicate on the "creator_id" field. -func CreatorIDEQ(v int64) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldEQ(FieldCreatorID, v)) -} - -// CreatorIDNEQ applies the NEQ predicate on the "creator_id" field. -func CreatorIDNEQ(v int64) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNEQ(FieldCreatorID, v)) -} - -// CreatorIDIn applies the In predicate on the "creator_id" field. -func CreatorIDIn(vs ...int64) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldIn(FieldCreatorID, vs...)) -} - -// CreatorIDNotIn applies the NotIn predicate on the "creator_id" field. -func CreatorIDNotIn(vs ...int64) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.FieldNotIn(FieldCreatorID, vs...)) -} - -// HasCreator applies the HasEdge predicate on the "creator" edge. -func HasCreator() predicate.SysAnnouncement { - return predicate.SysAnnouncement(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, CreatorTable, CreatorColumn), - ) - schemaConfig := internal.SchemaConfigFromContext(s.Context()) - step.To.Schema = schemaConfig.SysUser - step.Edge.Schema = schemaConfig.SysAnnouncement - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasCreatorWith applies the HasEdge predicate on the "creator" edge with a given conditions (other predicates). -func HasCreatorWith(preds ...predicate.SysUser) predicate.SysAnnouncement { - return predicate.SysAnnouncement(func(s *sql.Selector) { - step := newCreatorStep() - schemaConfig := internal.SchemaConfigFromContext(s.Context()) - step.To.Schema = schemaConfig.SysUser - step.Edge.Schema = schemaConfig.SysAnnouncement - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.SysAnnouncement) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.SysAnnouncement) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.SysAnnouncement) predicate.SysAnnouncement { - return predicate.SysAnnouncement(sql.NotPredicates(p)) -} diff --git a/internal/service/cpdaily/cpleave.go b/internal/service/cpdaily/cpleave.go index 98eb448..52d05e8 100644 --- a/internal/service/cpdaily/cpleave.go +++ b/internal/service/cpdaily/cpleave.go @@ -17,6 +17,7 @@ import ( "likedream-goframe/internal/service/balance" "likedream-goframe/internal/utils" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/frame/g" "github.com/shopspring/decimal" ) @@ -169,8 +170,19 @@ func (v CpLeaveServiceV1) Report(ctx context.Context, req *v1.CpLeaveReportReq) // 填充表单 form := reportApp.FillReportForm(detail) - // 获取位置信息 - lon, lat := reportApp.GetLocation(detail) + // 获取位置信息,优先使用前端传入的 + var lon, lat string + if req.Longitude != "" && req.Latitude != "" { + lon = req.Longitude + lat = req.Latitude + } else { + lon, lat = reportApp.GetLocation(detail) + } + + // 如果前端传入了地址,使用前端的地址 + if req.Address != "" { + form["reportLocation"] = gvar.New(req.Address) + } // 提交销假 reportApp.SubmitReport(ctx, form, lon, lat, cpUser.Username, cpUser.MobileCode)