Muhammad al-xorazmiy nomidagi toshkent axborot texnologiylari universiteti



Download 1,13 Mb.
bet25/25
Sana31.12.2021
Hajmi1,13 Mb.
#275298
1   ...   17   18   19   20   21   22   23   24   25
Bog'liq
Abrorbek BMI New 23ИЮН 21июн 22июн 23июн

ILOVALAR

package com.nana.varaq.backend.model;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
import java.util.Set;

@Entity
@Table(name = "guruh")


@Getter
@Setter
public class Guruh extends CompanyEntity {

@Column(name = "name")


String name;

@Column(name = "max_students")


Integer maxStudents;

@Column(name = "start_date")


@Temporal(value = TemporalType.DATE)
Date startDate;

@Column(name = "end_date")


@Temporal(value = TemporalType.DATE)
Date endDate;

@Column(name = "payment_for_guruh")


BigDecimal paymentForGuruh;

@ManyToOne


@JoinColumn(name = "photo_id")
FileEntity photo;

@ManyToOne


@JoinColumn(name = "subject_id")
Subject subject;

@ManyToOne


@JoinColumn(name = "level_id")
Reference level;

@ManyToOne


@JoinColumn(name = "teacher1_id")
Teacher teacher;

@ManyToOne


@JoinColumn(name = "teacher2_id")
Teacher teacher2;

@ManyToOne


@JoinColumn(name = "room_id")
Room room;

@ManyToMany(cascade = {CascadeType.MERGE},


targetEntity = Student.class, fetch = FetchType.LAZY)
@JoinTable(name = "groups_students", joinColumns = {@JoinColumn(name = "class_id")}, inverseJoinColumns = {@JoinColumn(name = "student_id")})
Set students;
}

package com.nana.varaq.backend.model;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name = "rooms")


@Getter
@Setter
public class Room extends CompanyEntity {

@Column(name = "name")


String name;

@Column(name = "comment")


String comment;

@Column(name = "student_capacity")


int studentCapacity;

@Override


public String toString() {
return name;
}
}

package com.nana.varaq.backend.model;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.time.LocalDate;

@Entity
@Table(name = "payments")


@Getter
@Setter
public class Payment extends CompanyEntity {
public enum Type {
FULL, PARTIAL
}

Type type = Type.FULL;

BigDecimal amount;

LocalDate paymentDate;

String month;

@ManyToOne


@JoinColumn(name = "student_id")
Student student;

@ManyToOne


@JoinColumn(name = "guruh_id")
Guruh guruh;

/*
* studentning guruhga to'lanadigan oylik to'lovlari kiritiladi.
*
* */
}

package com.nana.varaq.backend.model;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDate;

@Entity
@Table(name = "teachers")


@Getter
@Setter
public class Teacher extends CompanyEntity {

@Column(name = "full_name")


String fullName;

@Column(name = "date_of_Birth")


LocalDate dateOfBirth;

@Column(name = "phone")


String phone;

@Column(name = "email")


String email;

@Column(name = "bio")


String bio;

@ManyToOne


@JoinColumn(name = "degree_id")
@Fetch(FetchMode.JOIN)
Reference degree;

@ManyToOne


@JoinColumn(name = "subject_id")
Subject subject;

@Column(name = "work_experience")


String workExperience;

@ManyToOne


@JoinColumn(name = "salary_type_id")
@Fetch(FetchMode.JOIN)
Reference salaryType;

@Column(name = "salary")


BigDecimal salary;

@ManyToOne


@JoinColumn(name = "photo_id")
FileEntity photo;
}

package com.nana.varaq.backend.model;

import com.nana.varaq.SpringContext;
import com.nana.varaq.backend.repository.UniqueNumberRepository;
import com.nana.varaq.backend.service.UniqueNumberService;
import com.nana.varaq.ui.authentication.CurrentUser;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import javax.persistence.*;
import java.time.LocalDate;

@Entity
@Table(name = "students")


@Getter
@Setter
@Slf4j
public class Student extends CompanyEntity {

@Column(name = "status")


Status status;

@Column(name = "fullName")


String fullName;

@Column(name = "date_of_birth")


LocalDate dateOfBirth;

@Column(name = "date_registration")


LocalDate dateRegistration;

@Column(name = "phone1")


String phone1;

@Column(name = "phone_parents")


String phoneParents;

@Column(name = "additional_phone")


String additionalPhone;

@Column(name = "parents_name")


String parentsName;

@Column(name = "email")


String email;

@Column(name = "bio")


String bio;

@Column(name = "target")


String target;

@Column(name = "referal")


Reference referal;

@ManyToOne


@JoinColumn(name = "photo_id")
FileEntity photo;

@Column(name = "bajic_code")


String bajikCode;

@PrePersist


@PreUpdate
public void beforePersist() {
if (bajikCode != null) return;
try {
Long code = SpringContext.getBean(UniqueNumberService.class).getNextNumber(companyCode);
bajikCode = "S" + companyCode + String.format("%05d", code);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}

}
public class BCryptPasswordEncoder {


private Pattern BCRYPT_PATTERN = Pattern
.compile("\\A\\$2a?\\$\\d\\d\\$[./0-9A-Za-z]{53}");
private final Log logger = LogFactory.getLog(getClass());

private final int strength;

private final SecureRandom random;

public BCryptPasswordEncoder() {
this(-1);
}
public BCryptPasswordEncoder(int strength) {
this(strength, null);
}

package com.nana.varaq.bot.command;

import static com.nana.varaq.bot.command.Command.RU;
import static com.nana.varaq.bot.command.Command.UZ;

public class CommandFactory {
public static final String COMMAND_START = "/start";
public static final String COMMAND_RUSSIAN = "\uD83C\uDDF7\uD83C\uDDFA Русский";
public static final String COMMAND_UZBEK = "\uD83C\uDDFA\uD83C\uDDFF Ўзбекча";

public static final String COMMAND_RU_LINK_STUDENT = "Подключить ученик(ца)";
public static final String COMMAND_UZ_LINK_STUDENT = "Ўқувчини улаш";

public static final String SEND_BAYJIC_CODE_UZ = "Ўқувчини бейжик кодини юборинг";
public static final String SEND_BAYJIC_CODE_RU = "Пришлите код ученического бейджика";
public static final String STUDENT_NOT_FOUND_RU = "Ученик не найден";
public static final String STUDENT_NOT_FOUND_UZ = "Ўқувчи топилмади";
public static final String STUDENT_CONNECTED_RU = "Ученик подключен к вашей телеграм";
public static final String STUDENT_CONNECTED_UZ = "Ўқувчи сизнинг телеграмингизга уланди";

public static Command create(String text) {
if (COMMAND_START.equals(text)) {
return new CommandStart();
} else if (COMMAND_RUSSIAN.equals(text)) {
return new CommandSelectedLanguage(RU);
} else if (COMMAND_UZBEK.equals(text)) {
return new CommandSelectedLanguage(UZ);
} else if (COMMAND_RU_LINK_STUDENT.equals(text)) {
return new CommandLinkStudent(RU);
} else if (COMMAND_UZ_LINK_STUDENT.equals(text)) {
return new CommandLinkStudent(UZ);
}
return null;
}
}
package com.nana.varaq.bot.command;

import com.pengrad.telegrambot.model.Update;
import com.pengrad.telegrambot.model.request.Keyboard;
import com.pengrad.telegrambot.model.request.KeyboardButton;
import com.pengrad.telegrambot.model.request.ReplyKeyboardMarkup;
import com.pengrad.telegrambot.request.SendMessage;

import static com.nana.varaq.bot.command.CommandFactory.COMMAND_RU_LINK_STUDENT;

public class CommandRussian implements Command {

@Override


public SendMessage run(Update update) {
Long chatId = update.message().chat().id();

SendMessage message = new SendMessage(chatId, "Вы выбрали русский язык");


Keyboard keyboard = new ReplyKeyboardMarkup(
new KeyboardButton[]{
new KeyboardButton(COMMAND_RU_LINK_STUDENT)
}
).resizeKeyboard(true);
message.replyMarkup(keyboard);
return message;
}
}

package com.nana.varaq.bot.command;

import com.pengrad.telegrambot.model.Update;
import com.pengrad.telegrambot.model.request.Keyboard;
import com.pengrad.telegrambot.model.request.KeyboardButton;
import com.pengrad.telegrambot.model.request.ReplyKeyboardMarkup;
import com.pengrad.telegrambot.request.SendMessage;

import static com.nana.varaq.bot.command.CommandFactory.COMMAND_UZ_LINK_STUDENT;

public class CommandUzbek implements Command {
@Override
public SendMessage run(Update update) {
Long chatId = update.message().chat().id();

SendMessage message = new SendMessage(chatId, "Сиз ўзбек тилини танладингиз");


Keyboard keyboard = new ReplyKeyboardMarkup(
new KeyboardButton[]{
new KeyboardButton(COMMAND_UZ_LINK_STUDENT)
}
).resizeKeyboard(true);
message.replyMarkup(keyboard);
return message;
}
}

package com.nana.varaq.backend.service.impl;

import com.nana.varaq.backend.model.Guruh;
import com.nana.varaq.backend.model.Student;
import com.nana.varaq.backend.model.Teacher;
import com.nana.varaq.backend.repository.GuruhRepository;
import com.nana.varaq.backend.service.GuruhService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;
import java.util.HashSet;

@Service
public class GuruhServiceBean implements GuruhService {


@Autowired
GuruhRepository guruhRepository;

@Transactional


@Override
public void addStudents(Guruh guruh, Collection students) {
guruh = guruhRepository.save(guruh);
if (guruh.getStudents() == null)
guruh.setStudents(new HashSet<>());
guruh.getStudents().addAll(students);
guruhRepository.save(guruh);
}

@Transactional


@Override
public void addTeacher(Guruh guruh, Teacher teacher) {
guruh = guruhRepository.save(guruh);
if (guruh.getTeacher() == null) {
guruh.setTeacher(teacher);
} else if (guruh.getTeacher2() == null) {
guruh.setTeacher2(teacher);
}
guruhRepository.save(guruh);
}

@Transactional


@Override
public void deleteStudent(Guruh guruh, Student student) {
guruh = guruhRepository.save(guruh);
guruh.getStudents().remove(student);
guruhRepository.save(guruh);
}
}

package com.nana.varaq.backend.service.impl;


import com.nana.varaq.Application;
import com.nana.varaq.backend.bcrypt.BCryptPasswordEncoder;
import com.nana.varaq.backend.model.Status;
import com.nana.varaq.backend.model.User;
import com.nana.varaq.backend.repository.UserRepository;
import com.nana.varaq.backend.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.time.LocalDateTime;

@Service
public class UserServiceBean implements UserService {

@Autowired
UserRepository userRepository;

@Bean
public BCryptPasswordEncoder passwordEncoder() {


return new BCryptPasswordEncoder();
}

@Override


public User createAdminUserAtStartup(String username, String password) {

User user = userRepository.findByEmail(username);


if (user != null) {
return user;
}

user = new User();


user.setFullName(username);
user.setEmail(username);
String encodedPass = passwordEncoder().encode(password);
user.setPassword(encodedPass);
user.setStatus(Status.ACTIVE);
user.setIsAdmin(Boolean.TRUE);
user.setCompanyCode("00000");
user.setLanguage(Application.RUSSIAN);

userRepository.save(user);
return user;
}

@Override


public User signInByLoginPassword(String email, String password) {
User user = userRepository.findByEmail(email);
if (user == null) return null;
if (passwordEncoder().matches(password, user.getPassword())) {
user.setLastLogin(LocalDateTime.now());
userRepository.save(user);
return user;
}
return null;
}

@Override


public User changePassword(User user, String newPassword) {

String encodedPass = passwordEncoder().encode(newPassword);


user = userRepository.findById(user.getId()).orElse(null);
user.setPassword(encodedPass);
userRepository.save(user);
return user;
}
}


1O`zbekiston Respublikasi prezidentining 2017 yil 7 fevraldagi PF-4947-son “O`zbekiston Respublikasini yanada rivojlantirish bo`yicha Harakatlar strategiyasi to`g`risida”gi Farmoni





Download 1,13 Mb.

Do'stlaringiz bilan baham:
1   ...   17   18   19   20   21   22   23   24   25




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish