Lang change
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/target
|
29
.gitlab-ci.yml
Normal file
29
.gitlab-ci.yml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
stages:
|
||||||
|
- build
|
||||||
|
- test
|
||||||
|
|
||||||
|
build:
|
||||||
|
stage: build
|
||||||
|
image: rust:1.85
|
||||||
|
script:
|
||||||
|
- cargo build --release
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- target/release/icarus-models
|
||||||
|
expire_in: 1 week
|
||||||
|
cache:
|
||||||
|
key: "cargo-cache"
|
||||||
|
paths:
|
||||||
|
- target/
|
||||||
|
- ~/.cargo/
|
||||||
|
|
||||||
|
test:
|
||||||
|
stage: test
|
||||||
|
image: rust:1.85
|
||||||
|
script:
|
||||||
|
- cargo test
|
||||||
|
cache:
|
||||||
|
key: "cargo-cache"
|
||||||
|
paths:
|
||||||
|
- target/
|
||||||
|
- ~/.cargo/
|
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "icarus-models"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = { version = "1.0.218", features = ["derive"] }
|
||||||
|
serde_json = "1.0.139"
|
@@ -1,9 +0,0 @@
|
|||||||
package models
|
|
||||||
|
|
||||||
type LoginResult struct {
|
|
||||||
Id int `json:"id"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Token string `json:"token"`
|
|
||||||
TokenType string `json:"token_type"`
|
|
||||||
Expiration int `json:"expiration"`
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
package models
|
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
type User struct {
|
|
||||||
Id int `json:"id"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Password string `json:"password"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Phone string `json:"phone"`
|
|
||||||
Firstname string `json:"firstname"`
|
|
||||||
Lastname string `json:"lastname"`
|
|
||||||
EmailVerified bool `json:"email_verified"`
|
|
||||||
DateCreated time.Time `json:"date_created"`
|
|
||||||
Status string `json:"status"`
|
|
||||||
LastLogin time.Time `json:"last_login"`
|
|
||||||
}
|
|
26
src/access_level.rs
Normal file
26
src/access_level.rs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
use std::default::Default;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
pub struct AccessLevel {
|
||||||
|
pub id: i32,
|
||||||
|
pub level: String,
|
||||||
|
pub song_id: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for AccessLevel {
|
||||||
|
fn default() -> Self {
|
||||||
|
AccessLevel {
|
||||||
|
id: -1,
|
||||||
|
level: String::new(),
|
||||||
|
song_id: -1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AccessLevel {
|
||||||
|
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||||
|
return serde_json::to_string_pretty(&self);
|
||||||
|
}
|
||||||
|
}
|
18
src/lib.rs
Normal file
18
src/lib.rs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
pub mod access_level;
|
||||||
|
pub mod login_result;
|
||||||
|
pub mod user;
|
||||||
|
|
||||||
|
pub fn add(left: u64, right: u64) -> u64 {
|
||||||
|
left + right
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
let result = add(2, 2);
|
||||||
|
assert_eq!(result, 4);
|
||||||
|
}
|
||||||
|
}
|
31
src/login_result.rs
Normal file
31
src/login_result.rs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
use std::default::Default;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
pub struct LoginResult {
|
||||||
|
pub id: i32,
|
||||||
|
pub username: String,
|
||||||
|
pub token: String,
|
||||||
|
#[serde(alias = "token_type")]
|
||||||
|
pub token_type: String,
|
||||||
|
pub expiration: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for LoginResult {
|
||||||
|
fn default() -> Self {
|
||||||
|
LoginResult {
|
||||||
|
id: -1,
|
||||||
|
username: String::new(),
|
||||||
|
token: String::new(),
|
||||||
|
token_type: String::new(),
|
||||||
|
expiration: -1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LoginResult {
|
||||||
|
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||||
|
return serde_json::to_string_pretty(&self);
|
||||||
|
}
|
||||||
|
}
|
42
src/user.rs
Normal file
42
src/user.rs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
use std::default::Default;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
pub struct User {
|
||||||
|
pub id: i32,
|
||||||
|
pub username: String,
|
||||||
|
pub password: String,
|
||||||
|
pub email: String,
|
||||||
|
pub phone: String,
|
||||||
|
pub firstname: String,
|
||||||
|
pub lastname: String,
|
||||||
|
pub email_verified: bool,
|
||||||
|
pub date_created: String,
|
||||||
|
pub status: String,
|
||||||
|
pub last_login: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for User {
|
||||||
|
fn default() -> Self {
|
||||||
|
User {
|
||||||
|
id: -1,
|
||||||
|
username: String::new(),
|
||||||
|
password: String::new(),
|
||||||
|
email: String::new(),
|
||||||
|
phone: String::new(),
|
||||||
|
firstname: String::new(),
|
||||||
|
lastname: String::new(),
|
||||||
|
email_verified: false,
|
||||||
|
date_created: String::new(),
|
||||||
|
status: String::new(),
|
||||||
|
last_login: String::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl User {
|
||||||
|
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||||
|
return serde_json::to_string_pretty(&self);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user