Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.
/ whms Public archive

A pacakge for improving post/get method of my compony.

License

Notifications You must be signed in to change notification settings

benny123tw/whms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WHMS

npm version license

A package that simplifies the work hour management system (get/post) process.

new

  1. add id to UploadConfig.
  2. fix upload function error handling

Installing

Using npm:

$ npm install whms

Example

note: CommonJS usage

In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with require() use the following approach:

const whms = require("whms").default;

// whms.<method> will now provide autocomplete and parameter typings

Upload Work Reocrd List to database

import whms from "whms";

whms.upload({
  id: 69,
  employeeAccount: "John Doe",
  projectCode: "C000",
  content: "This is a content",
  dateStart: "2021-09-06",
  dateEnd: "2021-09-08",
  passHoliday: true,
  exclude: ["2021-09-07"],
}).then((response) => {
  console.log(response);
});

Get data from work hour management system

import whms from 'whms';

whms.get({
  method: "getProjects",
  data: {}
});

whms.get({
  method: "getAvalibleProjects",
  data: {}
});

whms.get({
  method: "getProjectsByCondition",
  data: {
    projectCodeSearch: "",
    projectNameSearch: "",
    projectShowAll: false
  }
});

whms.get({
  method: "getWorkRecord",
  data: {
    workRecordEmployeeId: 69,
    workRecordCreateDate: new Date().getTime() // Unix time
  }
});

whms.get({
  method: "getEmployees",
  data: {
    employeeShowDisabled: true
  }
});

whms.get({
  method: "getEmployeesByCondition"
  data: {
    employeeIdSearch: "",
    employeeNameSearch: ""
  }
});

Post data to work hour management system

import whms from "whms";

whms.post({
  method: "addWorkRecord",
  data: {
    workRecordList: [], // Array<WorkRecord> length should be 8
  },
});

Generate Work Record List

import whms, { Employee, WorkRecord } from "whms";

const employee: Employee = {
  id: 69,
  code: "",
  name: "John Doe",
  account: "johndoe",
  password: "password",
  tel: "123-45678",
  ext: "234",
  email: "johndoe@example.com",
  enabled: true,
};

const wrList: WorkRecord[] = whms.generateWorkReocrd({
  employee: employee, // employee object
  projectId: 10, // project index
  content: "This is a content.",
  createDate: 0, // unix time
});
console.log(wrList.length); // print 8

Upload Config

{
  id: 69,
  employeeAccount: "johndoe", // [optional] `employeeaccount` is your account not usernmae
  projectCode: "C000",
  content: "This is a content",

  // date format: "yyyy-MM-dd" or "yyyy/MM/dd"
  dateStart: "2021-09-06",
  dateEnd: "2021-09-08",
  passHoliday: true,
  exclude: ["2021-09-07"]
}

About

A pacakge for improving post/get method of my compony.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published