Loggest thy stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

340 lines
8.8 KiB

3 years ago
3 years ago
3 years ago
  1. // Code generated by sqlc. DO NOT EDIT.
  2. // versions:
  3. // sqlc v1.13.0
  4. // source: project.sql
  5. package mysqlcore
  6. import (
  7. "context"
  8. "database/sql"
  9. "time"
  10. )
  11. const deleteAllProjectRequirementStats = `-- name: DeleteAllProjectRequirementStats :exec
  12. DELETE FROM project_requirement_stat WHERE project_requirement_id = ?
  13. `
  14. func (q *Queries) DeleteAllProjectRequirementStats(ctx context.Context, projectRequirementID int) error {
  15. _, err := q.exec(ctx, q.deleteAllProjectRequirementStatsStmt, deleteAllProjectRequirementStats, projectRequirementID)
  16. return err
  17. }
  18. const deleteAllProjectRequirementStatsByStat = `-- name: DeleteAllProjectRequirementStatsByStat :exec
  19. DELETE FROM project_requirement_stat WHERE stat_id = ?
  20. `
  21. func (q *Queries) DeleteAllProjectRequirementStatsByStat(ctx context.Context, statID int) error {
  22. _, err := q.exec(ctx, q.deleteAllProjectRequirementStatsByStatStmt, deleteAllProjectRequirementStatsByStat, statID)
  23. return err
  24. }
  25. const deleteAllProjectRequirements = `-- name: DeleteAllProjectRequirements :exec
  26. DELETE FROM project_requirement WHERE project_id = ?
  27. `
  28. func (q *Queries) DeleteAllProjectRequirements(ctx context.Context, projectID int) error {
  29. _, err := q.exec(ctx, q.deleteAllProjectRequirementsStmt, deleteAllProjectRequirements, projectID)
  30. return err
  31. }
  32. const deleteProject = `-- name: DeleteProject :exec
  33. DELETE FROM project WHERE id = ?
  34. `
  35. func (q *Queries) DeleteProject(ctx context.Context, id int) error {
  36. _, err := q.exec(ctx, q.deleteProjectStmt, deleteProject, id)
  37. return err
  38. }
  39. const deleteProjectRequirement = `-- name: DeleteProjectRequirement :exec
  40. DELETE FROM project_requirement WHERE id = ?
  41. `
  42. func (q *Queries) DeleteProjectRequirement(ctx context.Context, id int) error {
  43. _, err := q.exec(ctx, q.deleteProjectRequirementStmt, deleteProjectRequirement, id)
  44. return err
  45. }
  46. const deleteProjectRequirementStat = `-- name: DeleteProjectRequirementStat :exec
  47. DELETE FROM project_requirement_stat WHERE project_requirement_id = ? AND stat_id = ?
  48. `
  49. type DeleteProjectRequirementStatParams struct {
  50. ProjectRequirementID int
  51. StatID int
  52. }
  53. func (q *Queries) DeleteProjectRequirementStat(ctx context.Context, arg DeleteProjectRequirementStatParams) error {
  54. _, err := q.exec(ctx, q.deleteProjectRequirementStatStmt, deleteProjectRequirementStat, arg.ProjectRequirementID, arg.StatID)
  55. return err
  56. }
  57. const getProject = `-- name: GetProject :one
  58. SELECT id, scope_id, author_id, name, status, description, created_time FROM project WHERE id = ?
  59. `
  60. func (q *Queries) GetProject(ctx context.Context, id int) (Project, error) {
  61. row := q.queryRow(ctx, q.getProjectStmt, getProject, id)
  62. var i Project
  63. err := row.Scan(
  64. &i.ID,
  65. &i.ScopeID,
  66. &i.AuthorID,
  67. &i.Name,
  68. &i.Status,
  69. &i.Description,
  70. &i.CreatedTime,
  71. )
  72. return i, err
  73. }
  74. const getProjectRequirement = `-- name: GetProjectRequirement :one
  75. SELECT id, scope_id, project_id, name, status, description FROM project_requirement WHERE id = ?
  76. `
  77. func (q *Queries) GetProjectRequirement(ctx context.Context, id int) (ProjectRequirement, error) {
  78. row := q.queryRow(ctx, q.getProjectRequirementStmt, getProjectRequirement, id)
  79. var i ProjectRequirement
  80. err := row.Scan(
  81. &i.ID,
  82. &i.ScopeID,
  83. &i.ProjectID,
  84. &i.Name,
  85. &i.Status,
  86. &i.Description,
  87. )
  88. return i, err
  89. }
  90. const insertProject = `-- name: InsertProject :execresult
  91. INSERT INTO project (scope_id, author_id, name, status, description, created_time)
  92. VALUES (?, ?, ?, ?, ?, ?)
  93. `
  94. type InsertProjectParams struct {
  95. ScopeID int
  96. AuthorID string
  97. Name string
  98. Status int
  99. Description string
  100. CreatedTime time.Time
  101. }
  102. func (q *Queries) InsertProject(ctx context.Context, arg InsertProjectParams) (sql.Result, error) {
  103. return q.exec(ctx, q.insertProjectStmt, insertProject,
  104. arg.ScopeID,
  105. arg.AuthorID,
  106. arg.Name,
  107. arg.Status,
  108. arg.Description,
  109. arg.CreatedTime,
  110. )
  111. }
  112. const insertProjectRequirement = `-- name: InsertProjectRequirement :execresult
  113. INSERT INTO project_requirement (scope_id, project_id, name, status, description)
  114. VALUES (?, ?, ?, ?, ?)
  115. `
  116. type InsertProjectRequirementParams struct {
  117. ScopeID int
  118. ProjectID int
  119. Name string
  120. Status int
  121. Description string
  122. }
  123. func (q *Queries) InsertProjectRequirement(ctx context.Context, arg InsertProjectRequirementParams) (sql.Result, error) {
  124. return q.exec(ctx, q.insertProjectRequirementStmt, insertProjectRequirement,
  125. arg.ScopeID,
  126. arg.ProjectID,
  127. arg.Name,
  128. arg.Status,
  129. arg.Description,
  130. )
  131. }
  132. const listProjectEntries = `-- name: ListProjectEntries :many
  133. SELECT id, name, status, created_time, author_id FROM project
  134. WHERE scope_id = ?
  135. ORDER BY status, created_time
  136. `
  137. type ListProjectEntriesRow struct {
  138. ID int
  139. Name string
  140. Status int
  141. CreatedTime time.Time
  142. AuthorID string
  143. }
  144. func (q *Queries) ListProjectEntries(ctx context.Context, scopeID int) ([]ListProjectEntriesRow, error) {
  145. rows, err := q.query(ctx, q.listProjectEntriesStmt, listProjectEntries, scopeID)
  146. if err != nil {
  147. return nil, err
  148. }
  149. defer rows.Close()
  150. items := []ListProjectEntriesRow{}
  151. for rows.Next() {
  152. var i ListProjectEntriesRow
  153. if err := rows.Scan(
  154. &i.ID,
  155. &i.Name,
  156. &i.Status,
  157. &i.CreatedTime,
  158. &i.AuthorID,
  159. ); err != nil {
  160. return nil, err
  161. }
  162. items = append(items, i)
  163. }
  164. if err := rows.Close(); err != nil {
  165. return nil, err
  166. }
  167. if err := rows.Err(); err != nil {
  168. return nil, err
  169. }
  170. return items, nil
  171. }
  172. const listProjectRequirementStats = `-- name: ListProjectRequirementStats :many
  173. SELECT prs.required, s.id, s.name, s.weight FROM project_requirement_stat prs
  174. RIGHT JOIN stat s ON s.id = prs.stat_id
  175. WHERE project_requirement_id = ?
  176. `
  177. type ListProjectRequirementStatsRow struct {
  178. Required sql.NullInt32
  179. ID int
  180. Name string
  181. Weight float64
  182. }
  183. func (q *Queries) ListProjectRequirementStats(ctx context.Context, projectRequirementID int) ([]ListProjectRequirementStatsRow, error) {
  184. rows, err := q.query(ctx, q.listProjectRequirementStatsStmt, listProjectRequirementStats, projectRequirementID)
  185. if err != nil {
  186. return nil, err
  187. }
  188. defer rows.Close()
  189. items := []ListProjectRequirementStatsRow{}
  190. for rows.Next() {
  191. var i ListProjectRequirementStatsRow
  192. if err := rows.Scan(
  193. &i.Required,
  194. &i.ID,
  195. &i.Name,
  196. &i.Weight,
  197. ); err != nil {
  198. return nil, err
  199. }
  200. items = append(items, i)
  201. }
  202. if err := rows.Close(); err != nil {
  203. return nil, err
  204. }
  205. if err := rows.Err(); err != nil {
  206. return nil, err
  207. }
  208. return items, nil
  209. }
  210. const listProjectRequirementsByProjectID = `-- name: ListProjectRequirementsByProjectID :many
  211. SELECT id, scope_id, project_id, name, status, description FROM project_requirement WHERE project_id = ?
  212. `
  213. func (q *Queries) ListProjectRequirementsByProjectID(ctx context.Context, projectID int) ([]ProjectRequirement, error) {
  214. rows, err := q.query(ctx, q.listProjectRequirementsByProjectIDStmt, listProjectRequirementsByProjectID, projectID)
  215. if err != nil {
  216. return nil, err
  217. }
  218. defer rows.Close()
  219. items := []ProjectRequirement{}
  220. for rows.Next() {
  221. var i ProjectRequirement
  222. if err := rows.Scan(
  223. &i.ID,
  224. &i.ScopeID,
  225. &i.ProjectID,
  226. &i.Name,
  227. &i.Status,
  228. &i.Description,
  229. ); err != nil {
  230. return nil, err
  231. }
  232. items = append(items, i)
  233. }
  234. if err := rows.Close(); err != nil {
  235. return nil, err
  236. }
  237. if err := rows.Err(); err != nil {
  238. return nil, err
  239. }
  240. return items, nil
  241. }
  242. const replaceProjectRequirementStat = `-- name: ReplaceProjectRequirementStat :exec
  243. REPLACE INTO project_requirement_stat (project_requirement_id, stat_id, required)
  244. VALUES (?, ?, ?)
  245. `
  246. type ReplaceProjectRequirementStatParams struct {
  247. ProjectRequirementID int
  248. StatID int
  249. Required int
  250. }
  251. func (q *Queries) ReplaceProjectRequirementStat(ctx context.Context, arg ReplaceProjectRequirementStatParams) error {
  252. _, err := q.exec(ctx, q.replaceProjectRequirementStatStmt, replaceProjectRequirementStat, arg.ProjectRequirementID, arg.StatID, arg.Required)
  253. return err
  254. }
  255. const updateProject = `-- name: UpdateProject :exec
  256. UPDATE project
  257. SET name = ?,
  258. status = ?,
  259. description = ?
  260. WHERE id = ?
  261. `
  262. type UpdateProjectParams struct {
  263. Name string
  264. Status int
  265. Description string
  266. ID int
  267. }
  268. func (q *Queries) UpdateProject(ctx context.Context, arg UpdateProjectParams) error {
  269. _, err := q.exec(ctx, q.updateProjectStmt, updateProject,
  270. arg.Name,
  271. arg.Status,
  272. arg.Description,
  273. arg.ID,
  274. )
  275. return err
  276. }
  277. const updateProjectRequirement = `-- name: UpdateProjectRequirement :exec
  278. UPDATE project_requirement
  279. SET name = ?,
  280. status = ?,
  281. description = ?
  282. WHERE id = ?
  283. `
  284. type UpdateProjectRequirementParams struct {
  285. Name string
  286. Status int
  287. Description string
  288. ID int
  289. }
  290. func (q *Queries) UpdateProjectRequirement(ctx context.Context, arg UpdateProjectRequirementParams) error {
  291. _, err := q.exec(ctx, q.updateProjectRequirementStmt, updateProjectRequirement,
  292. arg.Name,
  293. arg.Status,
  294. arg.Description,
  295. arg.ID,
  296. )
  297. return err
  298. }