Code Monkey home page Code Monkey logo

ems's Introduction

ems

Employee management system

Api's

  • Create Department
    If parent_name is empty, assumes root

    curl -d '{"name": "subadmin", "parent_name": "admin"}' "http://localhost:8080/departments"
    
  • Create Employee
    If department_name is empty, assumes root

    curl -d '{"name": "kiran", "department_name": "admin"}' "http://localhost:8080/employees"  
    
  • Get Employees
    For getting employees under root, use department_name as root

    curl -d "http://localhost:8080/employees/{empname}/{department_name}"      
    

How to run app directly

There is an executable in the repository.Clone the repo and run the executable.

./ems

How to run app from source

  1. Clone this app and cd into it.
  2. Ensure dependencies dep init and dep ensure
  3. Build :
    • go build .
    • After this step, executable ems is generated in same directory
  4. Run :
    • ./ems

Test

curl -d '{"name": "admin", "parent_name": ""}' "http://localhost:8080/departments"
curl -d '{"name": "subadmin", "parent_name": "admin"}' "http://localhost:8080/departments"
curl -d '{"name": "subadmin1", "parent_name": "admin"}' "http://localhost:8080/departments"

Create Employee

curl -d '{"name": "kiran", "department_name": "admin"}' "http://localhost:8080/employees"
curl -d '{"name": "kiran", "department_name": "subadmin"}' "http://localhost:8080/employees"  

Get Employees

curl -d "http://localhost:8080/employees/kiran/admin"
{"employee":[{"name":"kiran","department_name":"admin"},{"name":"kiran","department_name":"subadmin"}]}

Assumptions

  1. More domain specific handling or use cases are not covered
  2. Employee creation can be done only with a pre-exsiting department

Further Improvements

  1. Improve locking code by using channels and verify race conditions
  2. Write tests for all packages and comprehensively.
  3. Return more meaningful errors
  4. The tree code is not clean.Can be segregated more
  5. Model propagation between packages can be cleaned up.
  6. The performance of department lookup can be optimized by using a hashmap index into the tree nodes.

ems's People

Contributors

nexthack avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.