Commit e6084817 by 孙香冬

no message

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