Skip to content

Commit ffb30e9

Browse files
committed
API Gateway/Solutions: исправлена модель для отправки решения
1 parent c9f617a commit ffb30e9

File tree

5 files changed

+55
-27
lines changed

5 files changed

+55
-27
lines changed

HwProj.APIGateway/HwProj.APIGateway.API/Controllers/SolutionsController.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using HwProj.SolutionsService.Client;
1717
using Microsoft.AspNetCore.Authorization;
1818
using Microsoft.AspNetCore.Mvc;
19+
using PostSolutionModel = HwProj.APIGateway.API.Models.Solutions.PostSolutionModel;
1920

2021
namespace HwProj.APIGateway.API.Controllers;
2122

@@ -279,10 +280,12 @@ public async Task<IActionResult> GetTaskSolutionsPageData(long taskId, string? s
279280
[HttpPost("{taskId}")]
280281
[Authorize(Roles = Roles.StudentRole)]
281282
[ProducesResponseType(typeof(long), (int)HttpStatusCode.OK)]
282-
public async Task<IActionResult> PostSolution(SolutionViewModel model, long taskId)
283+
public async Task<IActionResult> PostSolution(PostSolutionModel model, long taskId)
283284
{
284-
var solutionModel = new PostSolutionModel(model)
285+
var solutionModel = new HwProj.Models.SolutionsService.PostSolutionModel
285286
{
287+
GithubUrl = model.GithubUrl,
288+
Comment = model.Comment,
286289
StudentId = UserId
287290
};
288291

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace HwProj.APIGateway.API.Models.Solutions;
2+
3+
public class PostSolutionModel
4+
{
5+
public string? GithubUrl { get; set; }
6+
public string? Comment { get; set; }
7+
public string[]? GroupMateIds { get; set; }
8+
}

HwProj.Common/HwProj.Models/SolutionsService/PostSolutionModel.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,6 @@ namespace HwProj.Models.SolutionsService
44
{
55
public class PostSolutionModel
66
{
7-
public PostSolutionModel(SolutionViewModel model)
8-
{
9-
GithubUrl = model.GithubUrl;
10-
Comment = model.Comment;
11-
StudentId = model.StudentId;
12-
PublicationDate = model.PublicationDate;
13-
LecturerComment = model.LecturerComment;
14-
Rating = model.Rating;
15-
}
16-
17-
public PostSolutionModel()
18-
{
19-
}
20-
217
public string GithubUrl { get; set; }
228

239
public string Comment { get; set; }

hwproj.front/src/api/api.ts

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,31 @@ export interface NotificationsSettingDto {
15761576
*/
15771577
isEnabled?: boolean;
15781578
}
1579+
/**
1580+
*
1581+
* @export
1582+
* @interface PostSolutionModel
1583+
*/
1584+
export interface PostSolutionModel {
1585+
/**
1586+
*
1587+
* @type {string}
1588+
* @memberof PostSolutionModel
1589+
*/
1590+
githubUrl?: string;
1591+
/**
1592+
*
1593+
* @type {string}
1594+
* @memberof PostSolutionModel
1595+
*/
1596+
comment?: string;
1597+
/**
1598+
*
1599+
* @type {Array<string>}
1600+
* @memberof PostSolutionModel
1601+
*/
1602+
groupMateIds?: Array<string>;
1603+
}
15791604
/**
15801605
*
15811606
* @export
@@ -8054,11 +8079,11 @@ export const SolutionsApiFetchParamCreator = function (configuration?: Configura
80548079
/**
80558080
*
80568081
* @param {number} taskId
8057-
* @param {SolutionViewModel} [body]
8082+
* @param {PostSolutionModel} [body]
80588083
* @param {*} [options] Override http request option.
80598084
* @throws {RequiredError}
80608085
*/
8061-
solutionsPostSolution(taskId: number, body?: SolutionViewModel, options: any = {}): FetchArgs {
8086+
solutionsPostSolution(taskId: number, body?: PostSolutionModel, options: any = {}): FetchArgs {
80628087
// verify required parameter 'taskId' is not null or undefined
80638088
if (taskId === null || taskId === undefined) {
80648089
throw new RequiredError('taskId','Required parameter taskId was null or undefined when calling solutionsPostSolution.');
@@ -8084,7 +8109,7 @@ export const SolutionsApiFetchParamCreator = function (configuration?: Configura
80848109
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
80858110
localVarUrlObj.search = null;
80868111
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
8087-
const needsSerialization = (<any>"SolutionViewModel" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
8112+
const needsSerialization = (<any>"PostSolutionModel" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
80888113
localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || "");
80898114

80908115
return {
@@ -8329,11 +8354,11 @@ export const SolutionsApiFp = function(configuration?: Configuration) {
83298354
/**
83308355
*
83318356
* @param {number} taskId
8332-
* @param {SolutionViewModel} [body]
8357+
* @param {PostSolutionModel} [body]
83338358
* @param {*} [options] Override http request option.
83348359
* @throws {RequiredError}
83358360
*/
8336-
solutionsPostSolution(taskId: number, body?: SolutionViewModel, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<number> {
8361+
solutionsPostSolution(taskId: number, body?: PostSolutionModel, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<number> {
83378362
const localVarFetchArgs = SolutionsApiFetchParamCreator(configuration).solutionsPostSolution(taskId, body, options);
83388363
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
83398364
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
@@ -8470,11 +8495,11 @@ export const SolutionsApiFactory = function (configuration?: Configuration, fetc
84708495
/**
84718496
*
84728497
* @param {number} taskId
8473-
* @param {SolutionViewModel} [body]
8498+
* @param {PostSolutionModel} [body]
84748499
* @param {*} [options] Override http request option.
84758500
* @throws {RequiredError}
84768501
*/
8477-
solutionsPostSolution(taskId: number, body?: SolutionViewModel, options?: any) {
8502+
solutionsPostSolution(taskId: number, body?: PostSolutionModel, options?: any) {
84788503
return SolutionsApiFp(configuration).solutionsPostSolution(taskId, body, options)(fetch, basePath);
84798504
},
84808505
/**
@@ -8614,12 +8639,12 @@ export class SolutionsApi extends BaseAPI {
86148639
/**
86158640
*
86168641
* @param {number} taskId
8617-
* @param {SolutionViewModel} [body]
8642+
* @param {PostSolutionModel} [body]
86188643
* @param {*} [options] Override http request option.
86198644
* @throws {RequiredError}
86208645
* @memberof SolutionsApi
86218646
*/
8622-
public solutionsPostSolution(taskId: number, body?: SolutionViewModel, options?: any) {
8647+
public solutionsPostSolution(taskId: number, body?: PostSolutionModel, options?: any) {
86238648
return SolutionsApiFp(this.configuration).solutionsPostSolution(taskId, body, options)(this.fetch, this.basePath);
86248649
}
86258650

hwproj.front/src/components/Solutions/AddOrEditSolution.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import * as React from 'react';
22
import ApiSingleton from "../../api/ApiSingleton";
3-
import {AccountDataDto, GetSolutionModel, HomeworkTaskViewModel, SolutionState, SolutionViewModel} from "@/api";
3+
import {
4+
AccountDataDto,
5+
GetSolutionModel,
6+
HomeworkTaskViewModel,
7+
PostSolutionModel,
8+
SolutionState
9+
} from "@/api";
410
import {FC, useState} from "react";
511
import {Alert, Autocomplete, Grid, DialogContent, Dialog, DialogTitle, DialogActions, Button} from "@mui/material";
612
import {MarkdownEditor} from "../Common/MarkdownEditor";
@@ -23,7 +29,7 @@ const AddOrEditSolution: FC<IAddSolutionProps> = (props) => {
2329
const isEdit = lastSolution?.state === SolutionState.NUMBER_0
2430
const lastGroup = lastSolution?.groupMates?.map(x => x.userId!) || []
2531

26-
const [solution, setSolution] = useState<SolutionViewModel>({
32+
const [solution, setSolution] = useState<PostSolutionModel>({
2733
githubUrl: lastSolution?.githubUrl || "",
2834
comment: isEdit ? lastSolution!.comment : "",
2935
groupMateIds: lastGroup

0 commit comments

Comments
 (0)