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; ...@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.tarento.retail.config.JwtTokenUtil; import com.tarento.retail.config.JwtTokenUtil;
import com.tarento.retail.dto.UserDto; import com.tarento.retail.dto.UserDto;
import com.tarento.retail.model.InstituteCourses;
import com.tarento.retail.model.LoginDto; import com.tarento.retail.model.LoginDto;
import com.tarento.retail.model.LoginUser; import com.tarento.retail.model.LoginUser;
import com.tarento.retail.model.Role; import com.tarento.retail.model.Role;
...@@ -142,7 +143,9 @@ public class AuthenticationController { ...@@ -142,7 +143,9 @@ public class AuthenticationController {
null); null);
LOGGER.info("Fetched Roles Assigned for the User"); LOGGER.info("Fetched Roles Assigned for the User");
userProfile.setRoles(userRoles); userProfile.setRoles(userRoles);
List<InstituteCourses> instituteCourses = userService.findAllInstituteCourses(userProfile.getId());
userProfile.setInstituteCourses(instituteCourses);
return ResponseGenerator.successResponse(userProfile); 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; ...@@ -2,6 +2,12 @@ package com.tarento.retail.model;
import java.util.Date; 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.AllArgsConstructor;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
...@@ -15,20 +21,35 @@ import lombok.ToString; ...@@ -15,20 +21,35 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@Setter @Setter
@ToString @ToString
@Entity
@Table(name = "institute_courses")
public class InstituteCourses { public class InstituteCourses {
@Id @GeneratedValue
@Column(name = "id")
private Long id; private Long id;
@Column(name = "district_name")
private String districtName; private String districtName;
@Column(name = "center_code")
private String centerCode; private String centerCode;
@Column(name = "degree")
private String degree; private String degree;
@Column(name = "course")
private String course; private String course;
@Column(name = "applied_year")
private String appliedYear; private String appliedYear;
@Column(name = "sector")
private String sector; private String sector;
@Column(name = "profile_id")
private Long profileId; //Fk UserProfile private Long profileId; //Fk UserProfile
@Column(name = "created_date")
private Date createdDate; private Date createdDate;
@Column(name = "created_by")
private Long createdBy; private Long createdBy;
@Column(name = "updated_date")
private Date updatedDate; private Date updatedDate;
@Column(name = "updated_by")
private Long updatedBy; private Long updatedBy;
} }
...@@ -32,6 +32,7 @@ public class UserProfile extends User { ...@@ -32,6 +32,7 @@ public class UserProfile extends User {
private List<Long> roleId; private List<Long> roleId;
private String countryCode; private String countryCode;
private Long countryId; private Long countryId;
private List<InstituteCourses> instituteCourses;
public Long getCountryId() { public Long getCountryId() {
return countryId; return countryId;
...@@ -204,4 +205,13 @@ public class UserProfile extends User { ...@@ -204,4 +205,13 @@ public class UserProfile extends User {
this.roleId = roleId; 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 { ...@@ -252,4 +252,6 @@ public interface UserService {
Boolean softDeleteUser(UserDto userDto); 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; ...@@ -28,6 +28,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.tarento.retail.dao.InstituteCoursesDao;
import com.tarento.retail.dao.RoleDao; import com.tarento.retail.dao.RoleDao;
import com.tarento.retail.dao.UserDao; import com.tarento.retail.dao.UserDao;
import com.tarento.retail.dto.CountryDto; import com.tarento.retail.dto.CountryDto;
...@@ -71,6 +72,9 @@ public class UserServiceImpl implements UserDetailsService, UserService { ...@@ -71,6 +72,9 @@ public class UserServiceImpl implements UserDetailsService, UserService {
@Autowired @Autowired
private BCryptPasswordEncoder bcryptEncoder; private BCryptPasswordEncoder bcryptEncoder;
@Autowired
private InstituteCoursesDao instituteCoursesDao;
public List<Action> findAllActionsByRoleID(List<Integer> roleID) { public List<Action> findAllActionsByRoleID(List<Integer> roleID) {
List<Action> actions = new ArrayList<Action>(); List<Action> actions = new ArrayList<Action>();
...@@ -186,6 +190,11 @@ public class UserServiceImpl implements UserDetailsService, UserService { ...@@ -186,6 +190,11 @@ public class UserServiceImpl implements UserDetailsService, UserService {
} }
return roleList; return roleList;
} }
@Override
public List<InstituteCourses> findAllInstituteCourses(Long userId){
return instituteCoursesDao.findByProfileId(userId);
}
@Override @Override
public Set<Action> findAllActionsByUser(Long userId, String orgId) { public Set<Action> findAllActionsByUser(Long userId, String orgId) {
...@@ -579,6 +588,7 @@ public class UserServiceImpl implements UserDetailsService, UserService { ...@@ -579,6 +588,7 @@ public class UserServiceImpl implements UserDetailsService, UserService {
LOGGER.error(String.format(Constants.EXCEPTION_METHOD, "validateUserOTP", e.getMessage())); LOGGER.error(String.format(Constants.EXCEPTION_METHOD, "validateUserOTP", e.getMessage()));
} }
return Boolean.FALSE; return Boolean.FALSE;
} }
@Override @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