巴林闲侠
2 years ago
11 changed files with 292 additions and 5 deletions
@ -0,0 +1,77 @@ |
|||
'use strict'; |
|||
|
|||
'use strict'; |
|||
|
|||
async function projectGet (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { type } = ctx.query; |
|||
|
|||
const projectRes = await models.Project.findAll({ |
|||
where: { |
|||
type |
|||
}, |
|||
order: [['id', 'DESC']] |
|||
}) |
|||
|
|||
ctx.status = 200; |
|||
ctx.body = projectRes |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function projectEdit (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const data = ctx.request.body; |
|||
|
|||
if (!data.projectId) { |
|||
await models.Project.create(data) |
|||
} else { |
|||
await models.Project.update( |
|||
data, { |
|||
where: { |
|||
id: data.projectId |
|||
} |
|||
}) |
|||
} |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function projectDel (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { projectId } = ctx.params; |
|||
|
|||
await models.Project.destroy({ |
|||
where: { |
|||
id: projectId |
|||
} |
|||
}) |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
module.exports = { |
|||
projectGet, projectEdit, projectDel, |
|||
}; |
@ -0,0 +1,124 @@ |
|||
/* eslint-disable*/ |
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const Project = sequelize.define("project", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true, |
|||
unique: "project_id_uindex" |
|||
}, |
|||
entryName: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "项目名称", |
|||
primaryKey: false, |
|||
field: "entry_name", |
|||
autoIncrement: false |
|||
}, |
|||
projectMileage: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "工程里程", |
|||
primaryKey: false, |
|||
field: "project_mileage", |
|||
autoIncrement: false |
|||
}, |
|||
investment: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "投资", |
|||
primaryKey: false, |
|||
field: "investment", |
|||
autoIncrement: false |
|||
}, |
|||
buildUnit: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "建设单位", |
|||
primaryKey: false, |
|||
field: "build_unit", |
|||
autoIncrement: false |
|||
}, |
|||
constructionControlUnit: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "监理单位", |
|||
primaryKey: false, |
|||
field: "construction_control_unit", |
|||
autoIncrement: false |
|||
}, |
|||
designUnit: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "设计单位", |
|||
primaryKey: false, |
|||
field: "design_unit", |
|||
autoIncrement: false |
|||
}, |
|||
constructionUnit: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "施工单位", |
|||
primaryKey: false, |
|||
field: "construction_unit", |
|||
autoIncrement: false |
|||
}, |
|||
supervisorAndSupervisor: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "监督负责人及监督人员", |
|||
primaryKey: false, |
|||
field: "supervisor_and_supervisor", |
|||
autoIncrement: false |
|||
}, |
|||
projectProgress: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "项目进展情况", |
|||
primaryKey: false, |
|||
field: "project_progress", |
|||
autoIncrement: false |
|||
}, |
|||
done: { |
|||
type: DataTypes.BOOLEAN, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "done", |
|||
autoIncrement: false |
|||
}, |
|||
type: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "类型 道路:road / 桥梁:bridge", |
|||
primaryKey: false, |
|||
field: "type", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "project", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.Project = Project; |
|||
return Project; |
|||
}; |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,11 @@ |
|||
{ |
|||
"项目名称": "entryName", |
|||
"工程里程": "projectMileage", |
|||
"投资": "investment", |
|||
"建设单位": "buildUnit", |
|||
"监理单位": "constructionControlUnit", |
|||
"设计单位": "designUnit", |
|||
"施工单位": "constructionUnit", |
|||
"监督负责人及监督人员": "supervisorAndSupervisor", |
|||
"项目进展情况": "projectProgress" |
|||
} |
@ -0,0 +1,11 @@ |
|||
{ |
|||
"entryName": "项目名称", |
|||
"projectMileage": "工程里程", |
|||
"investment": "投资", |
|||
"buildUnit": "建设单位", |
|||
"constructionControlUnit": "监理单位", |
|||
"designUnit": "设计单位", |
|||
"constructionUnit": "施工单位", |
|||
"supervisorAndSupervisor": "监督负责人及监督人员", |
|||
"projectProgress": "项目进展情况" |
|||
} |
@ -0,0 +1,11 @@ |
|||
{ |
|||
"项目名称": "entry_name", |
|||
"工程里程": "project_mileage", |
|||
"投资": "investment", |
|||
"建设单位": "build_unit", |
|||
"监理单位": "construction_control_unit", |
|||
"设计单位": "design_unit", |
|||
"施工单位": "construction_unit", |
|||
"监督负责人及监督人员": "supervisor_and_supervisor", |
|||
"项目进展情况": "project_progress" |
|||
} |
@ -0,0 +1,15 @@ |
|||
-- 工程一览 |
|||
|
|||
CREATE TABLE if not exists "project" ( id serial not null ); |
|||
|
|||
CREATE unique index if not exists project_id_uindex |
|||
ON project (id); alter TABLE project add constraint project_pk primary key (id); alter TABLE project add Entry_Name varchar(1024); comment |
|||
ON column project.Entry_Name is '项目名称'; alter TABLE project add Project_Mileage varchar(1024); comment |
|||
ON column project.Project_Mileage is '工程里程'; alter TABLE project add Investment varchar(1024); comment |
|||
ON column project.Investment is '投资'; alter TABLE project add Build_Unit varchar(1024); comment |
|||
ON column project.Build_Unit is '建设单位'; alter TABLE project add Construction_Control_Unit varchar(1024); comment |
|||
ON column project.Construction_Control_Unit is '监理单位'; alter TABLE project add Design_Unit varchar(1024); comment |
|||
ON column project.Design_Unit is '设计单位'; alter TABLE project add Construction_Unit varchar(1024); comment |
|||
ON column project.Construction_Unit is '施工单位'; alter TABLE project add Supervisor_And_Supervisor varchar(1024); comment |
|||
ON column project.Supervisor_And_Supervisor is '监督负责人及监督人员'; alter TABLE project add Project_Progress varchar(1024); comment |
|||
ON column project.Project_Progress is '项目进展情况'; |
Loading…
Reference in new issue