Skip to content

Commit

Permalink
zopsmart#3 schema.sql updated
Browse files Browse the repository at this point in the history
  • Loading branch information
raybittu committed Feb 15, 2021
2 parents bcbac19 + 0ae0747 commit cb99821
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 264 deletions.
194 changes: 169 additions & 25 deletions db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ DROP TABLE IF EXISTS `companies`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `companies` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`description` varchar(45) DEFAULT NULL,
`domain` varchar(45) NOT NULL,
`email` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`description` varchar(45) DEFAULT NULL,
`domain` varchar(45) NOT NULL,
`email` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

Expand All @@ -49,16 +49,16 @@ DROP TABLE IF EXISTS `employees`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `employees` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`email` varchar(45) NOT NULL,
`phone` bigint DEFAULT NULL,
`designation` varchar(45) NOT NULL,
`yoe` int NOT NULL DEFAULT '0',
`company_id` int DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `comapny_id_idx` (`company_id`),
CONSTRAINT `company_id` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`)
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`email` varchar(45) NOT NULL,
`phone` bigint DEFAULT NULL,
`designation` varchar(45) NOT NULL,
`yoe` int NOT NULL DEFAULT '0',
`company_id` int DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `comapny_id_idx` (`company_id`),
CONSTRAINT `company_id` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

Expand All @@ -79,9 +79,9 @@ DROP TABLE IF EXISTS `skills`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `skills` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

Expand All @@ -102,12 +102,12 @@ DROP TABLE IF EXISTS `skillsEmployees`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `skillsEmployees` (
`employee_id` int NOT NULL,
`skill_id` int NOT NULL,
PRIMARY KEY (`employee_id`,`skill_id`),
KEY `skill_id_idx` (`skill_id`),
CONSTRAINT `employee_id` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`),
CONSTRAINT `emp_skill_id` FOREIGN KEY (`skill_id`) REFERENCES `skills` (`id`)
`employee_id` int NOT NULL,
`skill_id` int NOT NULL,
PRIMARY KEY (`employee_id`,`skill_id`),
KEY `skill_id_idx` (`skill_id`),
CONSTRAINT `employee_id` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`),
CONSTRAINT `emp_skill_id` FOREIGN KEY (`skill_id`) REFERENCES `skills` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

Expand All @@ -130,3 +130,147 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2021-02-12 16:03:51

DROP TABLE IF EXISTS `positions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `positions` (
`id` int NOT NULL AUTO_INCREMENT,
`noOfOpenings` int NOT NULL,
`description` varchar(45) NOT NULL,
`location` varchar(45) NOT NULL,
`currentNoOfOpenings` int NOT NULL,
`startDate` datetime NOT NULL,
`endDate` datetime NOT NULL,
`status` tinyint NOT NULL,
`title` varchar(45) NOT NULL,
`postDate` datetime NOT NULL,
`experience` float NOT NULL,
`companyId` int NOT NULL,
`pid` varchar(45) NOT NULL,
`is_deleted` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id_idx` (`companyId`),
CONSTRAINT `id` FOREIGN KEY (`companyId`) REFERENCES `companies` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `positions`
--

LOCK TABLES `positions` WRITE;
/*!40000 ALTER TABLE `positions` DISABLE KEYS */;
/*!40000 ALTER TABLE `positions` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;



/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `candidates`
--

DROP TABLE IF EXISTS `candidates`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `candidates` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`email` varchar(45) NOT NULL,
`phone` bigint NOT NULL,
`college_name` varchar(45) DEFAULT NULL,
`experience` float DEFAULT NULL,
`resume` varchar(60) NOT NULL,
`skills` int DEFAULT NULL,
`gender` varchar(10) NOT NULL,
`bio` varchar(45) DEFAULT NULL,
`dob` datetime NOT NULL,
`github` varchar(60) DEFAULT 'no Link',
`linkedin` varchar(60) DEFAULT 'no Link',
`others` varchar(100) DEFAULT 'no Links',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;



/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `candidates_skills`
--

DROP TABLE IF EXISTS `candidates_skills`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `candidates_skills` (
`candidate_id` int NOT NULL,
`skill_id` int NOT NULL,
PRIMARY KEY (`candidate_id`,`skill_id`),
KEY `skill_id_idx` (`skill_id`),
CONSTRAINT `candidate_id` FOREIGN KEY (`candidate_id`) REFERENCES `candidates` (`id`),
CONSTRAINT `candidate_skill_id` FOREIGN KEY (`skill_id`) REFERENCES `skills` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2021-02-15 11:38:30

Binary file removed panel.zip
Binary file not shown.
Binary file removed panel/.DS_Store
Binary file not shown.
22 changes: 12 additions & 10 deletions panel/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/zopsmart/hiring-portal-api/panel/models"

"github.com/vikash/gofr/pkg/gofr"
customError "github.com/zopsmart/hiring-portal-api/panel/error"
customerror "github.com/zopsmart/hiring-portal-api/panel/error"
"github.com/zopsmart/hiring-portal-api/panel/service"
)

Expand All @@ -21,14 +21,15 @@ func New(service service.PanelEmployee) PanelHTTP {
func (p PanelHTTP) CreateEmployee(c *gofr.Context) (interface{}, error) {
companyID, err := strconv.Atoi(c.Request.PathParam("companyID"))
if err != nil {
return nil, customError.ErrInvalidCompanyID

return nil, customerror.ErrInvalidCompanyID
}
var emp models.Employee

err = c.Request.Bind(&emp)

if err != nil {
return nil, customError.ErrJSONFormat
return nil, customerror.ErrJSONFormat
}

res, err := p.service.CreateEmployee(c, companyID, &emp)
Expand All @@ -43,7 +44,8 @@ func (p PanelHTTP) CreateEmployee(c *gofr.Context) (interface{}, error) {
func (p PanelHTTP) GetAllEmployee(c *gofr.Context) (interface{}, error) {
companyID, err := strconv.Atoi(c.Request.PathParam("companyID"))
if err != nil {
return nil, customError.ErrInvalidCompanyID

return nil, customerror.ErrInvalidCompanyID
}

yoe, _ := strconv.Atoi(c.Param("yoe"))
Expand Down Expand Up @@ -77,11 +79,11 @@ func (p PanelHTTP) GetAllEmployee(c *gofr.Context) (interface{}, error) {
func (p PanelHTTP) GetEmployeeByID(c *gofr.Context) (interface{}, error) {
companyId, err := strconv.Atoi(c.Request.PathParam("companyID"))
if err != nil {
return nil, customError.ErrInvalidCompanyID
return nil, customerror.ErrInvalidCompanyID
}
employeeId, err := strconv.Atoi(c.Request.PathParam("employeeID"))
if err != nil {
return nil, customError.ErrInvalidEmployeeID
return nil, customerror.ErrInvalidEmployeeID
}

res, err := p.service.GetEmployeeByID(c, companyId, employeeId)
Expand All @@ -95,11 +97,11 @@ func (p PanelHTTP) GetEmployeeByID(c *gofr.Context) (interface{}, error) {
func (p PanelHTTP) EditEmployee(c *gofr.Context) (interface{}, error) {
companyID, err := strconv.Atoi(c.Request.PathParam("companyID"))
if err != nil {
return nil, customError.ErrInvalidCompanyID
return nil, customerror.ErrInvalidCompanyID
}
employeeID, err := strconv.Atoi(c.Request.PathParam("employeeID"))
if err != nil {
return nil, customError.ErrInvalidEmployeeID
return nil, customerror.ErrInvalidEmployeeID
}

var data models.Employee
Expand All @@ -116,11 +118,11 @@ func (p PanelHTTP) EditEmployee(c *gofr.Context) (interface{}, error) {
func (p PanelHTTP) DeleteEmployee(c *gofr.Context) (interface{}, error) {
companyID, err := strconv.Atoi(c.Request.PathParam("companyID"))
if err != nil {
return nil, customError.ErrInvalidCompanyID
return nil, customerror.ErrInvalidCompanyID
}
employeeID, err := strconv.Atoi(c.Request.PathParam("employeeID"))
if err != nil {
return nil, customError.ErrInvalidEmployeeID
return nil, customerror.ErrInvalidEmployeeID
}
return nil, p.service.DeleteEmployee(c, companyID, employeeID)

Expand Down
14 changes: 7 additions & 7 deletions panel/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (
"github.com/zopsmart/hiring-portal-api/panel/store"
)

type PanelEmployeeService struct {
type panelEmployeeService struct {
store store.Panel
}

func New(store store.Panel) PanelEmployee {
return PanelEmployeeService{store: store}
return panelEmployeeService{store: store}
}

func (p PanelEmployeeService) GetAllEmployee(c *gofr.Context, companyID int, queryParam map[string]interface{}) ([]models.Employee, error) {
func (p panelEmployeeService) GetAllEmployee(c *gofr.Context, companyID int, queryParam map[string]interface{}) ([]models.Employee, error) {
if companyID <= 0 {
return nil, customError.ErrInvalidCompanyID
}
Expand All @@ -25,7 +25,7 @@ func (p PanelEmployeeService) GetAllEmployee(c *gofr.Context, companyID int, que
return p.store.GetAllEmployeeWithDesignation(c, companyID, queryParam)
}

func (p PanelEmployeeService) GetEmployeeByID(c *gofr.Context, companyID, employeeID int) (models.Employee, error) {
func (p panelEmployeeService) GetEmployeeByID(c *gofr.Context, companyID, employeeID int) (models.Employee, error) {
if companyID <= 0 {
return models.Employee{}, customError.ErrInvalidCompanyID
}
Expand All @@ -35,7 +35,7 @@ func (p PanelEmployeeService) GetEmployeeByID(c *gofr.Context, companyID, employ
return p.store.GetEmployeeByID(c, companyID, employeeID)
}

func (p PanelEmployeeService) CreateEmployee(c *gofr.Context, companyID int, emp *models.Employee) (models.Employee, error) {
func (p panelEmployeeService) CreateEmployee(c *gofr.Context, companyID int, emp *models.Employee) (models.Employee, error) {
if companyID <= 0 {
return models.Employee{}, customError.ErrInvalidCompanyID
}
Expand All @@ -48,7 +48,7 @@ func (p PanelEmployeeService) CreateEmployee(c *gofr.Context, companyID int, emp
return *emp, nil
}

func (p PanelEmployeeService) EditEmployee(c *gofr.Context, companyID, employeeID int, emp *models.Employee) (models.Employee, error) {
func (p panelEmployeeService) EditEmployee(c *gofr.Context, companyID, employeeID int, emp *models.Employee) (models.Employee, error) {
if companyID <= 0 {
return models.Employee{}, customError.ErrInvalidCompanyID
}
Expand All @@ -64,7 +64,7 @@ func (p PanelEmployeeService) EditEmployee(c *gofr.Context, companyID, employeeI
return *emp, nil
}

func (p PanelEmployeeService) DeleteEmployee(c *gofr.Context, companyID, employeeID int) error {
func (p panelEmployeeService) DeleteEmployee(c *gofr.Context, companyID, employeeID int) error {
if companyID <= 0 {
return customError.ErrInvalidCompanyID
}
Expand Down
Loading

0 comments on commit cb99821

Please sign in to comment.