Commit 6dbbb80c by lixinming

Merge branch 'master' of http://123.207.147.179:8888/node_server/zjxcxServer

# Conflicts:
#	src/config/errorEnum.ts
parents 70941204 e6084817
/**
* 月度表单逻辑层
* 作者: 陈金晶
* 月度表单相关逻辑 包括孵化器月度填报的增删改查
*/
import { ERRORENUM } from "../../config/errorEnum";
import { BizError } from "../../util/bizError";
......@@ -27,3 +28,35 @@ export async function createReport(uscc:string, occupancyRate:number) {
return {isSuccess:true};
}
/**
* 修改孵化器月度报表
* @param uscc 孵化器的统一信用代码
* @param occupancyRate 本月出租率
* @returns {isSuccess:true/false}
*/
export async function updateReport(uscc:string, occupancyRate:number) {
const TaskId = getTaskId(uscc);
let dataBaseInfo = await monthData.findmonthTableListByTaskId(TaskId);
if (dataBaseInfo || dataBaseInfo.taskId) throw new BizError(ERRORENUM.未找到数据);
dataBaseInfo.occupancyRate = occupancyRate;
await dataBaseInfo.save();
return {isSuccess:true};
}
/**
* 删除孵化器月度报表
* @param uscc 孵化器的统一信用代码
* @returns {isSuccess:true/false}
*/
export async function deleteReport(uscc:string) {
const TaskId = getTaskId(uscc);
let dataBaseInfo = await monthData.findmonthTableListByTaskId(TaskId);
if (dataBaseInfo || dataBaseInfo.taskId) throw new BizError(ERRORENUM.未找到数据);
await monthData.deleteReport(uscc);
return {isSuccess:true};
}
\ No newline at end of file
......@@ -7,8 +7,7 @@
import { ERRORENUM } from "../../config/errorEnum";
import * as fuhuaqiData from "../../data/fuHuaQi/fuhuaqi"
import { BizError } from "../../util/bizError";
const md5 = require("md5");
import { getPwdMd5 } from "../../util/tools";
/**
* 登录
......@@ -18,17 +17,17 @@ const md5 = require("md5");
*/
export async function login(uscc:string, pwd:string):Promise<object> {
if (typeof uscc != "string" || typeof pwd != "string") throw new BizError(ERRORENUM.参数错误, uscc, pwd);
let fuhuaqiInfo = await fuhuaqiData.findFuHuaQiByUSCC(uscc);
let fuhuaqiInfo = await fuhuaqiData.findFuHuaQiByUscc(uscc);
if(!fuhuaqiInfo) throw new BizError(ERRORENUM.未找到数据);
let checkPwd = getPwdMd5(fuhuaqiInfo.uscc, pwd);
if (fuhuaqiInfo.pwd != checkPwd) throw new BizError("密码不正确");
if (fuhuaqiInfo.pwd != checkPwd) throw new BizError(ERRORENUM.密码错误);
let fuhuaqiUserInfo = {
uscc: fuhuaqiInfo.uscc,
name: fuhuaqiInfo.name
};
return fuhuaqiUserInfo;
return {fuhuaqiUserInfo};
}
/**
......@@ -36,37 +35,32 @@ export async function login(uscc:string, pwd:string):Promise<object> {
* @param uscc 信用代码
* @param pwd 原密码
* @param newPwd 修改后的密码
* @returns
* @returns {isSuccess:true/false}
*/
export async function changePassword(uscc:string, pwd:string, newPwd:string) {
if (typeof uscc != "string" || typeof pwd != "string" || typeof newPwd != "string") throw new BizError(ERRORENUM.参数错误, uscc, pwd, newPwd);
let reg = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]");
if (reg.test(newPwd)) {
throw new BizError("密码不允许有特殊字符");
throw new BizError(ERRORENUM.密码不允许有特殊字符);
}
let fuhuaqiInfo = await fuhuaqiData.findFuHuaQiByUSCC(uscc);
if (!fuhuaqiInfo) throw new BizError(ERRORENUM.未找到数据);
let checkPwd = getPwdMd5(fuhuaqiInfo.uscc, pwd);
if (fuhuaqiInfo.pwd != checkPwd) throw new BizError("密码错误");
if (fuhuaqiInfo.pwd != checkPwd) throw new BizError(ERRORENUM.密码错误);
fuhuaqiInfo.pwd = getPwdMd5(uscc, newPwd);
await fuhuaqiInfo.save();
return {msg: "修改成功", isOk:true};
return {isSuccess:true};
}
/**
* 退出登录
* @param uscc 信用代码
* @returns
* @returns {isSuccess:true/false}
*/
export async function logout(uscc:string):Promise<object> {
if (typeof uscc != "string") throw new BizError(ERRORENUM.参数错误, uscc);
let fuhuaqiInfo = await fuhuaqiData.findFuHuaQiByUSCC(uscc);
await fuhuaqiInfo.save();
return {msg: "退出成功", isOk:true};
}
function getPwdMd5(uscc:string, pwd:string) {
return md5(uscc+pwd);
return {isSuccess:true};
}
\ No newline at end of file
......@@ -8,7 +8,14 @@ export enum ERRORENUM {
数据无更新,
该孵化器月度填报已存在,
该企业当月数据已存在,
该报表需要填写本月内容后提交
该报表需要填写本月内容后提交,
密码错误,
密码不允许有特殊字符
}
export enum ERRORCODEENUM {
省份验证失败 = 401,
}
let bizErrorMsgMap = {};
......
......@@ -27,7 +27,7 @@ const fuHuaQiSchema = new Schema({
personInChargePhone:String,//负责人联系电话
personInChargeAdd:String,//孵化场地地址
siteAcreage:Number,//孵化场地面积(㎡)
leasePrice:Number//孵化场地出租单价(㎡)
leasePrice:Number//孵化场地出租单价
});
var fuHuaQiModel;
......@@ -70,4 +70,11 @@ export async function findFuHuaQiByName(name:string) {
return await fuHuaQiModel.findOne({name}).exec();
}
\ No newline at end of file
/**
* 通过信用代码获取孵化器信息
* @param uscc 信用代码
* @returns 信用代码为uscc的孵化器信息
*/
export async function findFuHuaQiByUscc(uscc:string) {
return await fuHuaQiModel.findOne({uscc}).exec();
}
\ No newline at end of file
......@@ -62,7 +62,7 @@ export async function findmonthTableByTaskId(taskId:string) {
/**
* 孵化器月度填报 新增报表
* @param name 任务名称 系统生成
* @param fuHuaQiUscc 孵化器统一信用代码
* @param uscc 孵化器统一信用代码
* @param occupancyRate 出租率
* @param createTime 创建时间
*
......@@ -71,3 +71,11 @@ export async function addOnceReport(name:string, uscc:string, occupancyRate:numb
let monthInfo = {name, fuHuaQiUscc:uscc, occupancyRate, createTime:new Date().valueOf()}
await monthTableModel.create(monthInfo);
}
/**
* 孵化器月度填报 删除报表
* @param uscc 孵化器统一信用代码
*/
export async function deleteReport(uscc:string) {
return await monthTableModel.remove({fuHuaQiUscc:uscc}).exec();
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ async function lanuch() {
await initDB();
httpServer.createServer(systemConfig.port);
console.log('This indicates that the server is started successfully.');
await t();
// await t();
}
async function t() {
......
......@@ -10,6 +10,7 @@ export function setRouter(httpServer) {
httpServer.post('/fuhuaqi/mydata', asyncHandler(myDataInfo));
httpServer.post('/fuhuaqi/mydata/update', asyncHandler(updateMyDataInfo));
httpServer.post('/fuhuaqi/month/addreport', asyncHandler(addReport));
httpServer.post('/fuhuaqi/month/deletereport', asyncHandler(deleteReport));
}
/**
......@@ -77,12 +78,23 @@ async function updateMyDataInfo(req, res) {
}
/**
* 孵化月度填报 新增报表
* 孵化月度填报 新增报表
* @param req
* @param res
*/
async function addReport(req, res) {
let {fuHuaQiUscc, occupancyRate} = req.body;
let monthInfo = monthBiz.createReport(fuHuaQiUscc, occupancyRate)
let {uscc, occupancyRate} = req.body;
let monthInfo = monthBiz.createReport(uscc, occupancyRate)
res.success(monthInfo);
}
/**
* 孵化器月度填报 删除报表
* @param req
* @param res
*/
async function deleteReport(req, res) {
let {uscc} = req.body;
let monthInfo = monthBiz.deleteReport(uscc)
res.success(monthInfo);
}
\ No newline at end of file
import { ERRORENUM } from "../config/errorEnum";
import { BizError } from "./bizError";
const md5 = require("md5");
/**
* 生成任务id
......@@ -70,4 +71,14 @@ export function checkChange(newObj, oldObj) {
if (`${newObj[newKey]}` != `${oldObj[newKey]}`) changeKeyList.push(newKey);
}
return changeKeyList;
}
/**
* 密码加密
* @param uscc 信用代码
* @param pwd 密码
* @returns md5后的密码
*/
export function getPwdMd5(uscc:string, pwd:string) {
return md5(uscc+pwd);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment