Unverified Commit eb13f652 authored by sarojsingh2021's avatar sarojsingh2021 Committed by GitHub
Browse files

Merge pull request #7 from UPHRH-platform/institute-district

Institute district
No related merge requests found
Showing with 65 additions and 2 deletions
+65 -2
......@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.tarento.retail.config.JwtTokenUtil;
import com.tarento.retail.dto.UserDto;
import com.tarento.retail.model.InstituteCourses;
import com.tarento.retail.model.LoginDto;
import com.tarento.retail.model.LoginUser;
import com.tarento.retail.model.Role;
......@@ -142,7 +143,9 @@ public class AuthenticationController {
null);
LOGGER.info("Fetched Roles Assigned for the User");
userProfile.setRoles(userRoles);
List<InstituteCourses> instituteCourses = userService.findAllInstituteCourses(userProfile.getId());
userProfile.setInstituteCourses(instituteCourses);
return ResponseGenerator.successResponse(userProfile);
}
}
......
package com.tarento.retail.dao;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import com.tarento.retail.model.InstituteCourses;
@Repository
public interface InstituteCoursesDao extends CrudRepository<InstituteCourses, Long>{
List<InstituteCourses> findByProfileId(Long userId);
}
......@@ -2,6 +2,12 @@ package com.tarento.retail.model;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
......@@ -15,20 +21,35 @@ import lombok.ToString;
@NoArgsConstructor
@Setter
@ToString
@Entity
@Table(name = "institute_courses")
public class InstituteCourses {
@Id @GeneratedValue
@Column(name = "id")
private Long id;
@Column(name = "district_name")
private String districtName;
@Column(name = "center_code")
private String centerCode;
@Column(name = "degree")
private String degree;
@Column(name = "course")
private String course;
@Column(name = "applied_year")
private String appliedYear;
@Column(name = "sector")
private String sector;
@Column(name = "profile_id")
private Long profileId; //Fk UserProfile
@Column(name = "created_date")
private Date createdDate;
@Column(name = "created_by")
private Long createdBy;
@Column(name = "updated_date")
private Date updatedDate;
@Column(name = "updated_by")
private Long updatedBy;
}
......@@ -32,6 +32,7 @@ public class UserProfile extends User {
private List<Long> roleId;
private String countryCode;
private Long countryId;
private List<InstituteCourses> instituteCourses;
public Long getCountryId() {
return countryId;
......@@ -204,4 +205,13 @@ public class UserProfile extends User {
this.roleId = roleId;
}
public List<InstituteCourses> getInstituteCourses() {
return instituteCourses;
}
public void setInstituteCourses(List<InstituteCourses> instituteCourses) {
this.instituteCourses = instituteCourses;
}
}
......@@ -252,4 +252,6 @@ public interface UserService {
Boolean softDeleteUser(UserDto userDto);
List<InstituteCourses> findAllInstituteCourses(Long userId);
}
\ No newline at end of file
......@@ -28,6 +28,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.tarento.retail.dao.InstituteCoursesDao;
import com.tarento.retail.dao.RoleDao;
import com.tarento.retail.dao.UserDao;
import com.tarento.retail.dto.CountryDto;
......@@ -71,6 +72,9 @@ public class UserServiceImpl implements UserDetailsService, UserService {
@Autowired
private BCryptPasswordEncoder bcryptEncoder;
@Autowired
private InstituteCoursesDao instituteCoursesDao;
public List<Action> findAllActionsByRoleID(List<Integer> roleID) {
List<Action> actions = new ArrayList<Action>();
......@@ -186,6 +190,11 @@ public class UserServiceImpl implements UserDetailsService, UserService {
}
return roleList;
}
@Override
public List<InstituteCourses> findAllInstituteCourses(Long userId){
return instituteCoursesDao.findByProfileId(userId);
}
@Override
public Set<Action> findAllActionsByUser(Long userId, String orgId) {
......@@ -579,6 +588,7 @@ public class UserServiceImpl implements UserDetailsService, UserService {
LOGGER.error(String.format(Constants.EXCEPTION_METHOD, "validateUserOTP", e.getMessage()));
}
return Boolean.FALSE;
}
@Override
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment