forked from liuyingliuxia/bluebook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 36feb64
Showing
25 changed files
with
1,932 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
package-lock.json |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
const http = require("http"); | ||
const host = "localhost"; | ||
const port = "8888"; | ||
const server = http.createServer(app); | ||
const template = require("art-template"); | ||
const cookie_parser = require("cookie-parser"); | ||
|
||
const app = require("./control/app_router"); // 软件的路由基础 | ||
const app_init = require("./control/app_init"); // 建立初始数据表及数据库相关操作 | ||
const app_login = require("./control/app_ogin"); // 登录/注册的逻辑 | ||
const app_conf = require("./control/app_conf"); // 软件配置项的操作逻辑 | ||
const main_material = require("./control/main_material"); // 任务卡片的操作逻辑 | ||
const main_material_area = require("./control/main_material_area"); // 任务卡片区域的操作逻辑 | ||
const main_material_detail = require("./control/main_material_detail"); // 任务详情的操作逻辑 | ||
const main_material_operation_button = require("./control/main_material_operation_button"); // 任务详情按钮的操作逻辑 | ||
const main_material_operation_form = require("./control/main_material_operation_form"); // 任务详情表单的操作逻辑 | ||
const main_material_table = require("./control/main_material_table"); // 任务详情表格的操作逻辑 | ||
const mine_uaer_info = require("./control/mine_uaer_info"); // 用户资料信息卡的操作逻辑 | ||
const mine_group_info = require("./control/mine_group_info"); // 团队资料信息卡的操作逻辑 | ||
const theme_path = __dirname + "/theme/default/"; | ||
|
||
app.get("/", (req, res) => { | ||
let app_login_obj = new app_login; | ||
|
||
/* 判断是否未登录,已登录继续,未登录跳转到 login */ | ||
if (app_login_obj.is_not_login()){ | ||
// todo | ||
} | ||
|
||
// fixme | ||
let app_init_obj = new app_init(); | ||
connection = app_init_obj.get_database_connection(); | ||
//materials = get_all_material(); | ||
|
||
// 通过 art-template 拼合模板内容 | ||
html = template( | ||
theme_path + "index.html",{ | ||
app_title: "Bluebook", | ||
app_link: "https://github.com/gearkey/bluebook", | ||
app_licence_link: "https://github.com/gearkey/bluebook/blob/master/LICENSE", | ||
app_header_home: "首页", | ||
app_header_outside: "外部", | ||
app_header_mine: "我的", | ||
material_area_title_opened: "已开启的任务", | ||
material_area_title_voting: "表决中的任务", | ||
material_area_title_doing: "进行中的任务", | ||
material_area_title_feedback_in_progress: "反馈中的任务", | ||
material_area_title_finished: "已完成的任务", | ||
material_title: "任务标题", | ||
material_content: "任务内容", | ||
material_desc: "任务预览内容", | ||
material_desc_time: "任务预览时间", | ||
material_detail_sub_title: "任务详情子标题", | ||
material_detail_connection_tree: "物料/任务关系表", | ||
material_detail_material_info: "物料/任务属性表", | ||
material_detail_vote_info: "物料/任务投票信息表", | ||
material_detail_trigger_process : "任务触发流程表", | ||
material_detail_operation_history: "任务操作历史记录表", | ||
group_detail_flow_info: "团队资金流水表", | ||
material_operation_support: "▲", | ||
material_operation_oppose: "▼", | ||
material_operation_split: "拆解", | ||
material_operation_automate: "自动化", | ||
material_operation_modify: "修改", | ||
material_operation_finish: "完成", | ||
material_operation_cancel: "x", | ||
material_operation_form_title: "操作表单标题", | ||
material_operation_form_content: "操作表单内容" | ||
} | ||
) | ||
|
||
res.write(html); | ||
res.end() | ||
}); | ||
|
||
app.get("/login", (req, res) => { | ||
html = template( | ||
theme_path + "login.html",{ | ||
login_title: "登录到 Bluebook", | ||
login_desc: "欢迎来到 Bluebook 的世界,从此开始愉悦生活", | ||
login_input_username: "用户名/邮箱/电话", | ||
login_input_password: "输入密码", | ||
login_input_password_again: "再次输入密码", | ||
login_input_referee: "推荐人用户名/邮箱/电话", | ||
login_button_text: "登录", | ||
login_i_want_register: "我要注册" | ||
}, | ||
) | ||
res.write(html); | ||
res.end() | ||
}); | ||
|
||
app.get("/style.css", (req, res) => { | ||
css = template(theme_path + "style.css", {}) | ||
res.write(css); | ||
res.end() | ||
}); | ||
|
||
app.get("/main.js", (req, res) => { | ||
css = template(theme_path + "main.js", {}) | ||
res.write(css); | ||
res.end() | ||
}); | ||
|
||
server.listen(port, host, () => { | ||
console.log(`Server running at http://${host}:${port}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function app_conf(){ | ||
// todo | ||
} | ||
|
||
module.exports = app_conf(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
function app_init(){ | ||
this.get_database_connection = function (){ | ||
let mysql = require("mysql"); | ||
let connection = mysql.createConnection({ | ||
host: "localhost:3306", | ||
user: "root", | ||
password: "root", | ||
database: "bluebook" | ||
}); | ||
connection.connect(); | ||
console.log("ok") | ||
|
||
return connection; | ||
}; | ||
|
||
this.creat_database_init = function (){ | ||
connection = this.get_database_connection() | ||
|
||
let sqls = [ | ||
"create database bluebook;", | ||
|
||
/* 团队对象信息表 */ | ||
"create table group_info (" + | ||
"group_id uuid, " + // 团队/用户id | ||
"group_tel varchar, " + // 团队/用户电话 | ||
"group_email varchar, " + // 团队/用户邮箱 | ||
"group_password varchar, " + // 团队/用户密码(加盐非对称加密储存) | ||
"group_name varchar, " + // 团队/用户名称 | ||
"group_desc varchar, " + // 团队/用户简介 | ||
"group_avatar varchar, " + // 团队/用户头像(储存uri) | ||
"group_realname varchar, " + // 团队全名/用户实名(加盐对称加密储存) | ||
"group_identity_no varchar, " + // 团队社会认证号码/用户身份证号(加盐对称加密储存) | ||
"group_default_vote_pass_percent tinyint, " + // 团队默认投票自动通过的百分比阈值 | ||
"group_default_vote_power_percent tinyint, " + // 团队默认投票自动通过的百分比阈值(group_default_vote_pass_percent,int) | ||
"group_surplus decimal(14,4), " + // 团队节余/用户余额(精确到厘位) | ||
"group_state tinyint, " + // 团队/用户状态(0-正常,1-关闭,2-封禁,3-死亡,4-注销) | ||
"group_for_parent_status varchar" + // 用户/团队相对父团队的身份 | ||
");", | ||
|
||
/* 用户/子团队与父团队,多对多关系表 */ | ||
"create table group_connection (" + | ||
"group_connection_id uuid, " + // 关系id | ||
"group_id uuid, " + // 用户/子团队id | ||
"group_parent uuid, " + // 父团队id | ||
");", | ||
|
||
/* 团队物料/任务表 */ | ||
"create table group_material (" + | ||
"material_id uuid, " + // 物料/任务 id | ||
"material_name varchar, " + // 物料名称/任务标题 | ||
"material_desc varchar, " + // 物料/任务简介 | ||
"material_unit varchar, " + // 物料/任务单位 | ||
"material_unit_production_time decimal(13,3), " + // 物料/任务单位生产时间(秒数,精确到毫秒,以100年计算,整数部分需要10位,可以支持到最多300年) | ||
"material_unit_cluster int, " + // 物料/任务单位簇,以此大单位加减数量 | ||
"material_estimated_count int, " + // 物料/任务预估数量 | ||
"material_need_count int, " + //物料/任务需求数量 | ||
"material_plan_count int, " + //物料/任务计划数量 | ||
"material_real_count int, " + // 物料/任务实际数量 | ||
"material_surplus_count int, " + // 物料/任务剩余数量 | ||
"material_group_need varchar, " + // 物料/任务的需求团队 | ||
"material_group_made varchar, " + // 物料/任务的生产团队 | ||
"material_group_manage varchar, " + // 物料管理员/任务队长 | ||
"material_is_rejected_by_one_vote boolean, " + // 物料/任务是否已被一票否决 | ||
"material_state tinyint, " + // 物料/任务状态(0-草稿,1-触发,2-开启,3-需选,4-产选,5-生产,6-分配,7-反馈,8-完成,9-倾销,10-已销,11-取消,12-暂停) | ||
"material_priority tinyint, " + // 物料/任务优先级(0-中,1-高,2-低) | ||
"material_vote_pass_percent tinyint, " + // 物料/任务自动投票通过的百分比阈值 | ||
"material_vote_power_percent tinyint, " + // 物料/任务可否决一票否决的百分比阈值(反否阈值) | ||
"material_harvest_percent tinyint, " + // 物料/任务过剩成果保留给生产团队集体的百分比值 | ||
"material_is_outside boolean" + // 是否团队外部物料/任务(可能可以化简) | ||
"material_for_parent_status varchar, " + // 物料/任务相对父物料/任务的身份 | ||
");", | ||
|
||
/* 物料任务多对多关系表 */ | ||
"create table group_material_connection (" + | ||
"material_connection_id uuid, " + // 物料任务对应id | ||
"material_id varchar uuid, " + // 物料/任务id | ||
"material_parent uuid, " + // 父物料/任务id | ||
");", | ||
|
||
/* 团队投票决策表 */ | ||
"create table group_vote (" + | ||
"vote_id uuid, " + // 选票id | ||
"vote_material uuid, " + // 选票对应物料/任务 | ||
"vote_group uuid, " + // 投票对象id | ||
"vote_is_support boolean, " + // 投票对象是否支持此任务(false 反对,true 支持) | ||
"vote_desc varchar, " + // 投票原因表述 | ||
"vote_need_count int, " + // 投票对象需要的物料/任务数量 | ||
"vote_is_vote_power boolean, " + // 是否行使一票否决权(false 不行使,true 行使) | ||
"vote_is_feedback boolean, " + // 投票对象是否需要在获得结果后反馈(false 不需要,true 需要) | ||
"vote_feedback_is_satisfied boolean, " + // 投票对象对此物料/任务的结果是否满意(false 不满意,true 满意) | ||
"vote_feedback_desc varchar, " + // 投票对象对此选票的反馈内容 | ||
");", | ||
|
||
/* 触发/操作信息表 */ | ||
"create table group_operation_info (" + | ||
"operation_id uuid, " + // 操作id | ||
"operation_target varchar, " + // 操作对象(group_id / material_id / vote_id) | ||
"operation_state_change tinyint, " + // 将物料/任务的状态变更为(对应到对象的状态代码) | ||
"operation_touch_off_reach_time timestamp, " + // 触发条件:到达某个时间 | ||
"operation_touch_off_reach_material_state tinyint, " + // 触发条件:物料/任务到达某个状态(reach_material_state,int,对应到 material_state) | ||
"operation_time timestamp, " + // 操作时间 | ||
"operation_group uuid, " + // 操作人 | ||
"operation_ip varchar, " + // 操作ip | ||
"operation_ua varchar, " + // 操作ua | ||
"operation_remark varchar, " + // 操作备注 | ||
");", | ||
|
||
/* 软件配置表 */ | ||
"create table app_conf (" + | ||
"conf_key varchar, " + // 配置项id | ||
"conf_value varchar, " + // 配置项值 | ||
");", | ||
|
||
/* 团队资金流水表 */ | ||
"create table group_flow (" + | ||
"flow_id uuid, " + // 流水id | ||
"flow_material uuid, " + // 流水对应的物料/任务id | ||
"flow_inside_group uuid, " + // 内部交易对象 | ||
"flow_outside_group uuid, " + // 外部交易对象 | ||
"flow_pay_type tinyint, " + // 流水支付方式(0-现金,1-信用卡,2-储蓄卡,3-云闪付,4-支付宝,5-微信) | ||
"flow_pay_card_number varchar, " + // 外部交易对象银行卡号/支付软件id | ||
"flow_pay_amount decimal(14,4), " + // 流水支付金额(精确到厘) | ||
"flow_serial_no varchar, " + // 外部交易支付方式提供的流水号 | ||
"flow_invoice_no varchar, " + // 外部交易的发票号 | ||
");", | ||
|
||
/* 外部交易对象表 */ | ||
"create table outside_group (" + | ||
"outside_group_id uuid, " + // 外部交易对象id | ||
"outside_group_tel varchar, " + // 外部交易对象电话 | ||
"outside_group_email varchar, " + // 外部交易对象邮箱 | ||
"outside_group_name varchar, " + // 外部交易对象名称 | ||
"outside_group_desc varchar, " + // 外部交易对象简介 | ||
"outside_group_realname varchar, " + // 外部交易对象全名 | ||
"outside_group_identity_no varchar, " + // 外部交易对象社会认证号码/身份证号 | ||
"outside_group_surplus decimal(14,4), " + // 预估其货币价值 | ||
"outside_group_state tinyint, " + // 外部交易对象状态(0-正常,1-关闭,2-黑名单) | ||
"outside_group_for_parent_state varchar, " + // 子交易对象相对父交易对象的身份(,varchar) | ||
");", | ||
|
||
/* 外部交易对象关系表 */ | ||
"create table outside_group_connection (" + | ||
"outside_group_connection_id uuid, " + // 关系id | ||
"outside_group_id uuid, " + // 子交易对象id | ||
"outside_group_parent uuid, " + // 父交易对象id | ||
");", | ||
|
||
/* 外部对象操作信息表 */ | ||
"create table outside_group_operation_info (" + | ||
"operation_id uuid, " + // 操作id | ||
"operation_target varchar, " + // 操作对象(group_id / material_id / vote_id) | ||
"operation_state_change tinyint, " + // 将物料/任务的状态变更为(对应到对象的状态代码) | ||
"operation_touch_off_reach_time timestamp, " + // 触发条件:到达某个时间 | ||
"operation_touch_off_reach_material_state tinyint, " + // 触发条件:物料/任务到达某个状态(reach_material_state,int,对应到 material_state) | ||
"operation_time timestamp, " + // 操作时间 | ||
"operation_group uuid, " + // 操作人 | ||
"operation_ip varchar, " + // 操作ip | ||
"operation_ua varchar, " + // 操作ua | ||
"operation_remark varchar, " + // 操作备注 | ||
");", | ||
] | ||
|
||
// fixme:因为模块的连接问题,不知道它能不能正常执行,之后应该测试并修复它 | ||
for (i=0; ;i++){ | ||
connection.query(sqls[i], function (result){ | ||
console.log("sql_execute_success: " + result) | ||
|
||
connection.end(); | ||
}); | ||
} | ||
}; | ||
|
||
this.creat_ex_database_init = function (){ | ||
// todo:建立软件的基础扩展表 | ||
}; | ||
} | ||
|
||
module.exports = app_init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
function app_login(){ | ||
/* 判断当前是否未登录 */ | ||
this.is_not_login = function (){ | ||
// todo:填写逻辑,通过是否存在 cookie 判定 | ||
return true; | ||
}; | ||
} | ||
|
||
module.exports = app_login(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const url = require("url"); | ||
|
||
function create_application(){ | ||
this.get = {}; | ||
this.post = {}; | ||
|
||
const app = (req, res) => { | ||
let pathname = url.parse(req.url).pathname; | ||
let method = req.method.toLowerCase(); | ||
|
||
if (this[method][pathname]){ | ||
if (method === "get"){ | ||
this[method][pathname](req, res); | ||
} | ||
else { | ||
let params = ""; | ||
req.on("data", chunk => { | ||
params += chunk; | ||
}); | ||
req.on("end", () => { | ||
req.body = params; | ||
this[method][pathname](req, res); | ||
}) | ||
} | ||
} | ||
else { | ||
res.end("404"); | ||
} | ||
}; | ||
|
||
app.get = (url, cb) => { | ||
this.get[url] = cb; | ||
}; | ||
app.post = (url, cb) => { | ||
this.post[url] = cb; | ||
}; | ||
|
||
return app; | ||
} | ||
|
||
module.exports = create_application(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
function main_material(){ | ||
/* 获取所有任务卡片的 json 信息 */ | ||
/* materials = [ | ||
{material_name: "", material_desc:"", material_state:""}, | ||
... | ||
]*/ | ||
let get_all_material = function (){ | ||
// 连接数据库 | ||
connection = get_database_connection(); | ||
|
||
// 获取用户所有任务的名称、简介和状态 | ||
connection.query( | ||
"select material_name, material_desc, material_state from group_material" + | ||
"where need_material_group = <group_id> or made_material_group = <group_id>", | ||
|
||
function (error, results, fields){ | ||
if (error) throw error; | ||
|
||
console.log('The solution is: ', results[0].solution); | ||
|
||
connection.end(); | ||
} | ||
); | ||
|
||
return materials; | ||
}; | ||
} | ||
|
||
module.exports = main_material(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function main_material_area(){ | ||
// todo | ||
} | ||
|
||
module.exports = main_material_area(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function main_material_detail(){ | ||
// todo | ||
} | ||
|
||
module.exports = main_material_detail(); |
Oops, something went wrong.