Skip to content

Commit 8fdf662

Browse files
bruce-willisspolezhaev
authored andcommitted
First step of creation database scheme. Add Properties&Types for template (#3)
* Db config * move headers to ApiService * Create normal migration * Azure Integration * Adding models for types and properties
1 parent 2366df0 commit 8fdf662

28 files changed

Lines changed: 1709 additions & 210 deletions

ClientApp/components/callback/callback.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { Component, Prop } from "vue-property-decorator";
33
import AuthService from "../../auth/AuthService";
44

55

6-
@Component({
7-
name: 'callback'
8-
})
6+
@Component
97
export default class Callback extends Vue {
108
@Prop()
119
auth: AuthService

ClientApp/components/fetchdata/fetchdata.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ export default class FetchDataComponent extends Vue {
1515
forecasts: WeatherForecast[] = [];
1616

1717
mounted() {
18-
ApiService.get("SampleData/WeatherForecasts",
19-
{
20-
headers: {
21-
Authorization: 'Bearer ' + localStorage.getItem('access_token')
22-
}
23-
})
18+
ApiService.get("SampleData/WeatherForecasts")
2419
.then(response => {
2520
this.forecasts = response.data
2621
})

ClientApp/components/home/home.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default class Home extends Vue {
3434
}
3535

3636
getLastOpenedDocs() {
37-
ApiService.get('lastopeneddocuments/lastopeneddocuments')
37+
ApiService.get('lastopeneddocuments/getlastopeneddocuments')
3838
.then(response => {
3939
this.lastOpenedDocs = response.data;
4040
//TODO: lastOpenedDoc.lastOpenedTime -> to date (now string)
@@ -46,7 +46,9 @@ export default class Home extends Vue {
4646

4747

4848
mounted() {
49-
this.getLastOpenedDocs();
50-
this.getTemplates();
49+
if (this.auth.authenticated) {
50+
this.getLastOpenedDocs();
51+
this.getTemplates();
52+
}
5153
}
5254
}

ClientApp/components/home/home.vue.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h1 align="center">Здравствуй, врач! Система скоро б
1111
<h1>
1212
<span style="font-size: 30px;">{{lastOpenedDoc.patient}}</span>
1313
</h1>
14-
<h3>{{lastOpenedDoc.template.name}}</h3>
14+
<h3>{{templates[lastOpenedDoc.templateId - 1].name}}</h3>
1515
<hr>
1616
<p>{{lastOpenedDoc.lastOpenedTime}}</p>
1717
<a href="#" class="btn btn-dark">Продолжить работу

ClientApp/models/ApiService.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import axios from 'axios';
22

33
export const ApiService = axios.create({
4-
baseURL: 'api/'
4+
baseURL: 'api/',
5+
headers: {
6+
Authorization: 'Bearer ' + localStorage.getItem('access_token')
7+
}
58
});

ClientApp/models/LastOpenedDocument.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import {Template} from "./Template"
1+
import { Template } from "./Template"
22

33
export class LastOpenedDocument {
4+
lastOpenedDocumentId: number;
45
patient: string;
56
lastOpenedTime: Date;
6-
template: Template;
7+
templateId: number;
78

89
//not working and I don't now why
910
// public constructor() {

ClientApp/models/Template.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export class Template {
2+
templateId: number;
23
name: string;
34
description: string;
45
imagePath: string;
Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,28 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using MedHelp.Data;
45
using MedHelp.Models;
6+
using Microsoft.AspNetCore.Authorization;
57
using Microsoft.AspNetCore.Mvc;
68

79
namespace MedHelp.Controllers
810
{
11+
[Authorize]
912
[Route("api/[controller]")]
1013
public class LastOpenedDocumentsController : Controller
1114
{
12-
private static readonly Template[] Templates =
13-
{
14-
new Template
15-
{
16-
Name = "Справка о приеме",
17-
Description = "Самая обычная справка о приеме какая только может быть",
18-
ImagePath = "https://pp.userapi.com/c638519/v638519335/547d6/N8qDUbqrCG4.jpg"
19-
},
20-
new Template
21-
{
22-
Name = "Направление на анализы",
23-
Description = "Куда сказано, туда и иди",
24-
ImagePath = "https://pp.userapi.com/c630317/v630317313/1303d/i-eVXtwVRSo.jpg"
25-
},
26-
new Template
27-
{
28-
Name = "Направление к другому врачу",
29-
Description = "Ну, в этой ситуации я как бы уже это... Мои полномочия уже как бы всё... Окончены!",
30-
ImagePath = "https://pp.userapi.com/c623226/v623226313/4ab8b/RJ8H-rRuc3U.jpg"
31-
}
32-
};
15+
private readonly MedHelpContext _context;
3316

34-
private static readonly string[] Patients =
17+
public LastOpenedDocumentsController(MedHelpContext context)
3518
{
36-
"Наглая бабка, у которой болит мизинец на ноге",
37-
"Дедуля",
38-
"Ребенок, у которого 36.9"
39-
};
19+
_context = context;
20+
}
4021

41-
[HttpGet]
4222
[HttpGet("[action]")]
43-
public IEnumerable<LastOpenedDocument> LastOpenedDocuments()
23+
public IEnumerable<LastOpenedDocument> GetLastOpenedDocuments()
4424
{
45-
var random = new Random();
46-
return Enumerable.Range(1, 3).Select(index => new LastOpenedDocument
47-
{
48-
Template = Templates[random.Next(Templates.Length)],
49-
Patient = Patients[random.Next(Patients.Length)],
50-
LastOpenedTime = DateTime.Now.AddHours(-random.Next(10))
51-
});
25+
return _context.LastOpenedDocuments;
5226
}
5327
}
5428
}

Controllers/TemplatesController.cs

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,28 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using MedHelp.Data;
45
using MedHelp.Models;
6+
using Microsoft.AspNetCore.Authorization;
57
using Microsoft.AspNetCore.Mvc;
68

79
namespace MedHelp.Controllers
810
{
11+
[Authorize]
912
[Route("api/[controller]")]
1013
public class TemplatesController : Controller
1114
{
12-
private static readonly Template[] Templates =
15+
private readonly MedHelpContext _context;
16+
17+
public TemplatesController(MedHelpContext context)
1318
{
14-
new Template
15-
{
16-
Name = "Справка о приеме",
17-
Description = "Самая обычная справка о приеме какая только может быть",
18-
ImagePath = "https://pp.userapi.com/c638519/v638519335/547d6/N8qDUbqrCG4.jpg"
19-
},
20-
new Template
21-
{
22-
Name = "Направление на анализы",
23-
Description = "Куда сказано, туда и иди",
24-
ImagePath = "https://pp.userapi.com/c630317/v630317313/1303d/i-eVXtwVRSo.jpg"
25-
},
26-
new Template
27-
{
28-
Name = "Направление к другому врачу",
29-
Description = "Ну, в этой ситуации я как бы уже это... Мои полномочия уже как бы всё... Окончены!",
30-
ImagePath = "https://pp.userapi.com/c623226/v623226313/4ab8b/RJ8H-rRuc3U.jpg"
31-
}
32-
};
33-
[HttpGet]
19+
_context = context;
20+
}
21+
3422
[HttpGet("[action]")]
3523
public IEnumerable<Template> GetTemplates()
3624
{
37-
return Templates;
25+
return _context.Templates;
3826
}
3927
}
4028
}

Data/MedHelpContext.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using MedHelp.Models;
6+
using Microsoft.EntityFrameworkCore;
7+
using Type = MedHelp.Models.Type;
8+
9+
10+
namespace MedHelp.Data
11+
{
12+
public class MedHelpContext : DbContext
13+
{
14+
public MedHelpContext(DbContextOptions<MedHelpContext> options) : base(options)
15+
{ }
16+
17+
public DbSet<LastOpenedDocument> LastOpenedDocuments { get; set; }
18+
public DbSet<Template> Templates { get; set; }
19+
public DbSet<Type> Types { get; set; }
20+
public DbSet<Property> Properties { get; set; }
21+
}
22+
}

0 commit comments

Comments
 (0)