added time
This commit is contained in:
parent
054dc5afce
commit
f89589d0db
@ -20,8 +20,7 @@
|
||||
"prefix": "icod",
|
||||
"styles": [
|
||||
"styles.scss",
|
||||
"../node_modules/font-awesome/css/font-awesome.min.css",
|
||||
"../node_modules/primeng/resources/themes/omega/theme.css",
|
||||
"../node_modules/primeng/resources/themes/darkness/theme.css",
|
||||
"../node_modules/primeng/resources/primeng.min.css"
|
||||
],
|
||||
"scripts": [],
|
||||
|
1
angular/src/_variables.scss
Normal file
1
angular/src/_variables.scss
Normal file
@ -0,0 +1 @@
|
||||
$fa-font-path : '../node_modules/font-awesome/fonts';
|
@ -6,5 +6,5 @@ import { Component } from '@angular/core';
|
||||
styleUrls: ['./app.component.scss']
|
||||
})
|
||||
export class AppComponent {
|
||||
title = 'icod';
|
||||
|
||||
}
|
||||
|
@ -1,23 +1,37 @@
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { NgModule } from '@angular/core';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {NgModule} from '@angular/core';
|
||||
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
import {AppRoutingModule} from './app-routing.module';
|
||||
|
||||
import { ServiceWorkerModule } from '@angular/service-worker';
|
||||
import { AppComponent } from './app.component';
|
||||
import {ServiceWorkerModule} from '@angular/service-worker';
|
||||
import {AppComponent} from './app.component';
|
||||
|
||||
import { environment } from '../environments/environment';
|
||||
import {environment} from '../environments/environment';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||
import {HttpClientModule} from '@angular/common/http';
|
||||
import {SplitButtonModule, ToolbarModule} from 'primeng/primeng';
|
||||
import {MenuModule} from 'primeng/menu';
|
||||
import { DataComponent } from './components/data/data.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent
|
||||
AppComponent,
|
||||
DataComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
AppRoutingModule,
|
||||
ServiceWorkerModule.register('/ngsw-worker.js', { enabled: environment.production })
|
||||
ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production}),
|
||||
FormsModule,
|
||||
BrowserAnimationsModule,
|
||||
HttpClientModule,
|
||||
ToolbarModule,
|
||||
SplitButtonModule,
|
||||
MenuModule,
|
||||
],
|
||||
providers: [],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
export class AppModule { }
|
||||
export class AppModule {
|
||||
}
|
||||
|
@ -1 +1,3 @@
|
||||
@import "~bootstrap/scss/bootstrap";
|
||||
/*@import "~bootstrap/scss/bootstrap";*/
|
||||
@import "variables";
|
||||
@import "~font-awesome/scss/font-awesome";
|
||||
|
@ -3,6 +3,8 @@ package handler
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"time"
|
||||
|
||||
"git.icod.de/dalu/refdata/api/repo"
|
||||
"git.icod.de/dalu/refdata/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
@ -57,6 +59,7 @@ func (h *Handler) ListData(cx *gin.Context) {
|
||||
age := cx.Query("age")
|
||||
price := cx.Query("price")
|
||||
enabled := cx.Query("enabled")
|
||||
when := cx.Query("when")
|
||||
|
||||
// string
|
||||
if name == "1" {
|
||||
@ -109,6 +112,7 @@ func (h *Handler) ListData(cx *gin.Context) {
|
||||
if price == "1" {
|
||||
p.Price = true
|
||||
p.PriceQuery = repo.DataPriceQuery{}
|
||||
p.PriceQuery.Operation = cx.Query("price.operation")
|
||||
from, e := strconv.ParseFloat(cx.Query("age.from"), 64)
|
||||
if e != nil {
|
||||
cx.AbortWithStatus(400)
|
||||
@ -136,6 +140,25 @@ func (h *Handler) ListData(cx *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// time
|
||||
if when == "1" {
|
||||
p.When = true
|
||||
p.WhenQuery = repo.DataWhenQuery{}
|
||||
p.WhenQuery.Operation = cx.Query("when.operation")
|
||||
from, e := time.Parse(time.RFC3339, cx.Query("when.from"))
|
||||
if e != nil {
|
||||
cx.AbortWithStatus(400)
|
||||
return
|
||||
}
|
||||
to, e := time.Parse(time.RFC3339, cx.Query("when.to"))
|
||||
if e != nil {
|
||||
cx.AbortWithStatus(400)
|
||||
return
|
||||
}
|
||||
p.WhenQuery.From = from
|
||||
p.WhenQuery.To = to
|
||||
}
|
||||
|
||||
m, e := h.dataRepo.List(p)
|
||||
if e != nil {
|
||||
cx.AbortWithError(500, e)
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"time"
|
||||
|
||||
"git.icod.de/dalu/refdata/model"
|
||||
"github.com/globalsign/mgo"
|
||||
"github.com/globalsign/mgo/bson"
|
||||
@ -54,6 +56,18 @@ type DataEnabledQuery struct {
|
||||
Query bool
|
||||
}
|
||||
|
||||
// refid
|
||||
type DataRefIdQuery struct {
|
||||
Query string
|
||||
}
|
||||
|
||||
// time
|
||||
type DataWhenQuery struct {
|
||||
Operation string
|
||||
From time.Time
|
||||
To time.Time
|
||||
}
|
||||
|
||||
type DataParams struct {
|
||||
Start int // list only
|
||||
Limit int // list only
|
||||
@ -66,6 +80,7 @@ type DataParams struct {
|
||||
Age bool
|
||||
Price bool
|
||||
Enabled bool
|
||||
When bool
|
||||
|
||||
IdQuery DataIdQuery // get only
|
||||
NameQuery DataNameQuery
|
||||
@ -74,6 +89,7 @@ type DataParams struct {
|
||||
AgeQuery DataAgeQuery
|
||||
PriceQuery DataPriceQuery
|
||||
EnabledQuery DataEnabledQuery
|
||||
WhenQuery DataWhenQuery
|
||||
}
|
||||
|
||||
type DataRepository struct {
|
||||
|
@ -1,6 +1,10 @@
|
||||
package model
|
||||
|
||||
import "github.com/globalsign/mgo/bson"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/globalsign/mgo/bson"
|
||||
)
|
||||
|
||||
type Data struct {
|
||||
Id bson.ObjectId `bson:"_id,omitempty" json:"id"`
|
||||
@ -9,4 +13,5 @@ type Data struct {
|
||||
Location string `bson:"location" json:"location"`
|
||||
Age float64 `bson:"age,omitempty" json:"age,omitempty"`
|
||||
Price float64 `bson:"price,omitempty" json:"price,omitempty"`
|
||||
When time.Time `bson:"when" json:"when"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user