Commit 8f0e139e by lixinming

no message

parent 97edce31
......@@ -6,7 +6,7 @@ import { BRANCHNAME, OPERATIONALDATATYPE, TABLENAME } from "../config/enum/enum"
import { ERRORENUM } from "../config/enum/errorEnum";
import { operationalData, selectData } from "../data/operationalData";
import { changeEnumValue, eccEnumValue } from "../tools/eccEnum";
import { getMySqlMs } from "../tools/systemTools";
import { getFileType, getMySqlMs } from "../tools/systemTools";
import { BizError } from "../util/bizError";
import { dataListItemTimeChangeToTimeStr, datechangeToStr } from "../util/piecemeal";
......@@ -50,9 +50,9 @@ export async function getBranchSystemList(userInfo, title:string, pageNumber:num
* @param userInfo
* @param title
* @param branchList
* @param filesNameList
* @param fileName
*/
export async function addBranchSystemInfo(userInfo, title:string, branchList, filesNameList) {
export async function addBranchSystemInfo(userInfo, title:string, branchList, fileName) {
let funName = "添加支部制度";
eccEnumValue(funName, 'branchList', BRANCHNAME, branchList);
if (userInfo.branch && branchList.indexOf(userInfo.branch) == -1) {
......@@ -64,8 +64,8 @@ export async function addBranchSystemInfo(userInfo, title:string, branchList, fi
bId:JSON.stringify(branchList),
isUse:true,
releaseTime:getMySqlMs(),
fileName:filesNameList,
fileType:'pdf',
fileName:JSON.stringify(fileName),
fileType:getFileType(fileName),
uploadTime:getMySqlMs()
};
......@@ -76,25 +76,26 @@ export async function addBranchSystemInfo(userInfo, title:string, branchList, fi
/**
* 修改
* 修改
* 交互逻辑如下:文件列表删除不代表删除,需要点击保存才可以 2023年9月8日
* @param userInfo
* @param bsId
* @param title
* @param branchList
* @param filesNameList
* @param fileName
*/
export async function updateBranchSystemInfo(userInfo, bsId:number, title:string, branchList, filesNameList) {
export async function updateBranchSystemInfo(userInfo, bsId:number, title:string, branchList, fileName) {
let funName = "修改支部制度";
eccEnumValue(funName, 'branchList', BRANCHNAME, branchList);
if (userInfo.branch && branchList.indexOf(userInfo.branch) == -1) {
throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}${funName}但是制度范围不包含他所在的支部`);
}
//todo 这里有争议 修改时不知道怎么处理文件 修改先没处理文件
let updateInfo = {
systemTitle:title,
bId:JSON.stringify(branchList)
bId:JSON.stringify(branchList),
fileName:JSON.stringify(fileName),
fileType:getFileType(fileName)
};
await operationalData(OPERATIONALDATATYPE.修改, TABLENAME.支部制度表, updateInfo, {bsId});
......@@ -111,15 +112,17 @@ export async function updateBranchSystemInfo(userInfo, bsId:number, title:string
export async function getBranchSystemInfo(userInfo, bsId) {
let funName = "回显支部制度";
let column = ["systemTitle", "bsId", "bId"];
let column = ["systemTitle", "bsId", "bId", "fileName"];
let dataInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.支部制度表, {bsId}, column);
let branch = JSON.parse(dataInfo.bId);
let fileName = JSON.parse(dataInfo.fileName||"[]");
if (userInfo.branch && branch.indexOf(userInfo.branch) == -1 ) {
throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}${funName}但是制度范围不包含他所在的支部`);
}
return {title:dataInfo.systemTitle, branch };
return {title:dataInfo.systemTitle, branch, fileName };
}
......@@ -153,8 +156,6 @@ export async function delBranchSystemData(userInfo, bsId:number) {
throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}${funName}但是制度范围不包含他所在的支部`);
}
//todo 这里还要先删除相关文件
await operationalData(OPERATIONALDATATYPE.删除, TABLENAME.支部制度表, {}, {bsId});
return {isSuccess:true};
......
......@@ -3,12 +3,15 @@
*/
import moment = require("moment");
import { selectData } from "../data/operationalData";
import { operationalData, selectData } from "../data/operationalData";
import { BRANCHNAME, FILETYPE, OPERATIONALDATATYPE, TABLENAME, THEMETYPE } from "../config/enum/enum";
import { changeEnumValue, eccEnumValue } from "../tools/eccEnum";
import { datechangeToStr } from "../util/piecemeal";
import { BizError } from "../util/bizError";
import { ERRORENUM } from "../config/enum/errorEnum";
import { getClientMs, getFileType, getMySqlMs } from "../tools/systemTools";
import { eccFormParam } from "../tools/eccParam";
import { CreateOrgLifeConfig, UpdateOrgLifeConfig } from "../config/eccParam/eccParamConfig";
......@@ -20,47 +23,38 @@ import { ERRORENUM } from "../config/enum/errorEnum";
* @param pageNumber
* @returns
*/
export async function getOrgLifeList(userInfo, month:number, title:string, pageNumber:number) {
export async function getOrgLifeList(userInfo, month:number, theme:string, branch:number, pageNumber:number) {
/**组合查询条件 */
let selectParam:any = {};
if (userInfo.userId == "admin") { //admin登录
if (userInfo.branch) {
selectParam.bId = {"%like%": userInfo.branch};
if (!userInfo.isSuperAdmin ) {
if (userInfo.branch != branch) throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}无法查看非本支部的组织生活列表`);
else {
selectParam.bId = userInfo.branch;
}
} else { //其他用户登录
if (userInfo.branch) {
selectParam.bId = {"%like%": userInfo.branch};
}
}
if (userInfo.branch) {
selectParam.bId = {"%like%": userInfo.branch};
}
if (month) {
let stTime = moment(month).startOf("month").format("YYYY-MM-DD HH:mm:ss");
let etTime = moment(month).endOf('month').format("YYYY-MM-DD HH:mm:ss");
selectParam.dataMonth = {"%between%": [stTime, etTime]};
let stTime = moment(month).startOf("month").valueOf();
let etTime = moment(month).endOf('month').valueOf();
selectParam.dataMonth = {"%between%": [getMySqlMs(stTime), getMySqlMs(etTime)]};
}
if (title) {
selectParam.theme = {"%like%":title};
if (theme) {
selectParam.theme = {"%like%":theme};
}
let column = ["oId", "theme", "themeType", "dataMonth", "fileType", "uploadTime", "bId"];
let dbList = await selectData(OPERATIONALDATATYPE.分页查询, TABLENAME.组织生活表, selectParam, column, pageNumber, 10);
let dataCount = await selectData(OPERATIONALDATATYPE.查询数据量, TABLENAME.组织生活表, selectParam, null);
let dataList = {};
let dataList = [];
dbList.forEach( info => {
let {oId, theme, themeType, dataMonth, fileType, uploadTime, bId} = info;
let {oId, theme, themeType, dataMonth, fileType, uploadTime} = info;
let dataMonthStr = moment(dataMonth).format("YYYY-MM");
let titleTypeStr = changeEnumValue(THEMETYPE, themeType);
let fileTypeStr = changeEnumValue(FILETYPE, fileType);
let uploadTimeStr = datechangeToStr(uploadTime);
let branch = changeEnumValue(BRANCHNAME, JSON.parse(bId));
if (!dataList[branch]) dataList[branch] = [];
dataList[branch].push({
oId, title:theme, titleType:titleTypeStr, dataMonth:dataMonthStr, fileType:fileTypeStr, uploadTime:uploadTimeStr
dataList.push({
oId, theme:theme, themeType:titleTypeStr, dataMonth:dataMonthStr, fileType:fileTypeStr, uploadTime:uploadTimeStr
})
})
......@@ -68,25 +62,94 @@ export async function getOrgLifeList(userInfo, month:number, title:string, pageN
}
/**
* 创建组织生活
* @param userInfo
* @param param
*/
export async function addOrgLifeInfo(userInfo, param) {
const FuncName = "添加组织生活";
eccFormParam(FuncName, CreateOrgLifeConfig, param);
eccEnumValue(FuncName, "themeType", THEMETYPE, param.themeType);
eccEnumValue(FuncName, "bId", BRANCHNAME, param.bId);
if (!userInfo.isSuperAdmin && userInfo.branch != param.bId) {
throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}无法添加非本支部的组织生活`);
}
param.uploadTime = getMySqlMs();
param.dataMonth = getMySqlMs(param.dataMonth);
param.fileType = getFileType(param.fileName);
param.fileName = JSON.stringify(param.fileName);
await operationalData(OPERATIONALDATATYPE.增加, TABLENAME.组织生活表, param, {} );
return {isSuccess:true};
}
export async function addOrgLifeInfo(userInfo, bId, title, titleType, dataMonth, uploadTime, filesNameList) {
let funName = "添加组织生活";
if (userInfo.branch == -1) {
throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}${funName}但是制度范围不包含他所在的支部`);
/**
* 修改
* @param userInfo
* @param param
*/
export async function updateOrgLifeInfo(userInfo, oId:number, param) {
const FuncName = "修改组织生活";
eccFormParam(FuncName, UpdateOrgLifeConfig, param);
eccEnumValue(FuncName, "themeType", THEMETYPE, param.themeType);
eccEnumValue(FuncName, "bId", BRANCHNAME, param.bId);
if (!userInfo.isSuperAdmin && userInfo.branch != param.bId) {
throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}无法修改非本支部的组织生活`);
}
eccEnumValue(funName, "titleType", THEMETYPE, titleType);
let addParam = {
theme: title,
themeType: titleType,
dataMonth: moment(dataMonth).format("YYYY-MM-DD HH:mm:ss"),
bId,
param.uploadTime = getMySqlMs();
param.dataMonth = getMySqlMs(param.dataMonth);
param.fileType = getFileType(param.fileName);
param.fileName = JSON.stringify(param.fileName);
await operationalData(OPERATIONALDATATYPE.修改, TABLENAME.组织生活表, param, {oId} );
return {isSuccess:true};
}
/**
* 删除组织生活
* @param userInfo
* @param oId
* @returns
*/
export async function delOrgLifeInfo(userInfo, oId:number) {
let onceOrgLifeInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.组织生活表, {oId}, ["oId", "bId"] );
if (!onceOrgLifeInfo || !onceOrgLifeInfo.oId) throw new BizError(ERRORENUM.目标数据不存在, `不存在${oId}的组织生活`);
if (!userInfo.isSuperAdmin && userInfo.branch != onceOrgLifeInfo.bId) {
throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}无法删除非本支部的组织生活`);
}
await operationalData(OPERATIONALDATATYPE.删除, TABLENAME.组织生活表, {}, {oId} );
return {isSuccess:true};
}
/**
* 回显
* @param userInfo
* @param oId
* @returns
*/
export async function getOrgLifeInfo(userInfo, oId:number) {
let orgLifeInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.组织生活表, {oId}, ["oId", "bId", "theme", "themeType", "dataMonth", "fileName"] );
if (!orgLifeInfo || !orgLifeInfo.oId) throw new BizError(ERRORENUM.目标数据不存在, `不存在${oId}的组织生活`);
if (!userInfo.isSuperAdmin && userInfo.branch != orgLifeInfo.bId) {
throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}无法查看非本支部的组织生活`);
}
orgLifeInfo.dataMonth = getClientMs(orgLifeInfo.dataMonth);
orgLifeInfo.fileName =JSON.parse(orgLifeInfo.fileName);
return {orgLifeInfo};
}
......
/**
* 专题活动
*/
import moment = require("moment");
import { ERRORENUM } from "../config/enum/errorEnum";
import { BizError } from "../util/bizError";
import { getClientMs, getFileType, getMySqlMs } from "../tools/systemTools";
import { operationalData, selectData } from "../data/operationalData";
import { BRANCHNAME, FILETYPE, OPERATIONALDATATYPE, TABLENAME, THEMETYPE } from "../config/enum/enum";
import { changeEnumValue, eccEnumValue } from "../tools/eccEnum";
import { datechangeToStr, monthDateChangeToStr } from "../util/piecemeal";
import { eccFormParam } from "../tools/eccParam";
import { CreateThematicActivitiesConfig, UpdateThematicActivitiesConfig } from "../config/eccParam/eccParamConfig";
/**
* 专题活动表列表
* @param userInfo
* @param month
* @param title
* @param pageNumber
* @returns
*/
export async function getThematicActivitiesList(userInfo, month:number, title:string, branch:number, pageNumber:number) {
/**组合查询条件 */
let selectParam:any = {};
if (!userInfo.isSuperAdmin ) {
if (userInfo.branch != branch) throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}无法查看非本支部的专题活动列表`);
else {
selectParam.bId = userInfo.branch;
}
}
if (month) {
let stTime = moment(month).startOf("month").valueOf();
let etTime = moment(month).endOf('month').valueOf();
selectParam.dataMonth = {"%between%": [getMySqlMs(stTime), getMySqlMs(etTime)]};
}
if (title) {
selectParam.theme = {"%like%":title};
}
let column = ["taId", "theme", "dataMonth", "fileType", "uploadTime"];
let dbList = await selectData(OPERATIONALDATATYPE.分页查询, TABLENAME.专题活动表, selectParam, column, pageNumber, 10);
let dataCount = await selectData(OPERATIONALDATATYPE.查询数据量, TABLENAME.专题活动表, selectParam, null);
let dataList = [];
dbList.forEach( info => {
let {taId, theme, dataMonth, fileType, uploadTime} = info;
let dataMonthStr = monthDateChangeToStr(dataMonth);
let fileTypeStr = changeEnumValue(FILETYPE, fileType);
let uploadTimeStr = datechangeToStr(uploadTime);
dataList.push({
taId, theme:theme, dataMonth:dataMonthStr, fileType:fileTypeStr, uploadTime:uploadTimeStr
})
})
return {dataList, dataCount};
}
/**
* 创建专题活动
* @param userInfo
* @param param
*/
export async function addThematicActivitiesInfo(userInfo, param) {
const FuncName = "添加专题活动";
eccFormParam(FuncName, CreateThematicActivitiesConfig, param);
eccEnumValue(FuncName, "bId", BRANCHNAME, param.bId);
if (!userInfo.isSuperAdmin && userInfo.branch != param.bId) {
throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}无法添加非本支部的专题活动`);
}
param.uploadTime = getMySqlMs();
param.dataMonth = getMySqlMs(param.dataMonth);
param.fileType = getFileType(param.fileName);
param.fileName = JSON.stringify(param.fileName);
await operationalData(OPERATIONALDATATYPE.增加, TABLENAME.专题活动表, param, {} );
return {isSuccess:true};
}
/**
* 修改
* @param userInfo
* @param param
*/
export async function updateThematicActivitiesInfo(userInfo, taId:number, param) {
const FuncName = "修改专题活动";
eccFormParam(FuncName, CreateThematicActivitiesConfig, param);
eccEnumValue(FuncName, "bId", BRANCHNAME, param.bId);
if (!userInfo.isSuperAdmin && userInfo.branch != param.bId) {
throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}无法添加非本支部的专题活动`);
}
param.uploadTime = getMySqlMs();
param.dataMonth = getMySqlMs(param.dataMonth);
param.fileType = getFileType(param.fileName);
param.fileName = JSON.stringify(param.fileName);
await operationalData(OPERATIONALDATATYPE.修改, TABLENAME.专题活动表, param, {taId} );
return {isSuccess:true};
}
/**
* 删除专题活动
* @param userInfo
* @param taId
* @returns
*/
export async function delThematicActivitiesInfo(userInfo, taId:number) {
let onceDataInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.专题活动表, {taId}, ["taId", "bId"] );
if (!onceDataInfo || !onceDataInfo.taId) throw new BizError(ERRORENUM.目标数据不存在, `不存在${taId}的专题活动`);
if (!userInfo.isSuperAdmin && userInfo.branch != onceDataInfo.bId) {
throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}无法删除非本支部的专题活动`);
}
await operationalData(OPERATIONALDATATYPE.删除, TABLENAME.专题活动表, {}, {taId} );
return {isSuccess:true};
}
/**
* 回显
* @param userInfo
* @param oId
* @returns
*/
export async function getThematicActivitiesInfo(userInfo, taId:number) {
let orgLifeInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.专题活动表, {taId}, ["taId", "bId", "theme", "dataMonth", "fileName"] );
if (!orgLifeInfo || !orgLifeInfo.taId) throw new BizError(ERRORENUM.目标数据不存在, `不存在${taId}的组织生活`);
if (!userInfo.isSuperAdmin && userInfo.branch != orgLifeInfo.bId) {
throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}无法查看非本支部的专题活动`);
}
orgLifeInfo.dataMonth = getClientMs(orgLifeInfo.dataMonth);
orgLifeInfo.fileName = JSON.parse(orgLifeInfo.fileName);
return {orgLifeInfo};
}
......@@ -10,7 +10,7 @@ import { BizError } from "../util/bizError";
export async function loginAdminSys(loginId:string, pwd:string) {
let resultInfo = {branch:-1, token:'', userId:'', isAdmin:false};
if (loginId == "admin") { /**超级管理员 */
if (loginId == "admin" || loginId == "admin2") { /**超级管理员 */
let userInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.后台用户表, {loginId}, null);
if (!userInfo || !userInfo.uId) throw new BizError(ERRORENUM.用户不存在, `不存在loginId=${loginId}的用户`);
if (userInfo.pwd != pwd) throw new BizError(ERRORENUM.密码错误);
......
......@@ -101,4 +101,48 @@ export const CreatePartyCandidateMemberConfig = {
talkTime:{type:"Number" },//谈话时间
administrativePositionName:{type:"Number" },//行政职务id
departmentName:{type:"[Number]" },//所属科室表id
}
/**
* 添加组织生活
*/
export const CreateOrgLifeConfig = {
bId:{type:"Number"},
theme:{type:"String"},
themeType:{type:"Number"},
dataMonth:{type:"Number"},
fileName:{type:"[String]"}
}
/**
* 修改组织生活
*/
export const UpdateOrgLifeConfig = {
bId:{type:"Number"},
theme:{type:"String"},
themeType:{type:"Number"},
dataMonth:{type:"Number"},
fileName:{type:"[String]"}
}
/**
* 添加专题活动
*/
export const CreateThematicActivitiesConfig = {
bId:{type:"Number"},
theme:{type:"String"},
dataMonth:{type:"Number"},
fileName:{type:"[String]"}
}
/**
* 修改专题活动
*/
export const UpdateThematicActivitiesConfig = {
bId:{type:"Number"},
theme:{type:"String"},
dataMonth:{type:"Number"},
fileName:{type:"[String]"}
}
\ No newline at end of file
......@@ -19,7 +19,8 @@ export enum ERRORENUM {
目标用户不是正式党员,
管理员不可被删除,
权限不足,
目标数据不存在
目标数据不存在,
文件不存在
}
export enum ERRORCODEENUM {
......
......@@ -17,7 +17,7 @@ export async function checkToken(req, res, next) {
if (!userId || !token) return next(new BizError(ERRORENUM.非法登录));
if (userId == "admin") {
if (userId == "admin" || userId == "admin2") {
let userInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.后台用户表, {uId:userId}, null);
if (!userInfo || !userInfo.uId) return next(new BizError(ERRORENUM.身份验证失败));
if (!userInfo.token || userInfo.token != token) return next(new BizError(ERRORENUM.身份验证过期));
......
......@@ -43,10 +43,10 @@ async function branchSystemList(req, res) {
async function addBranchSystem(req, res) {
let userInfo = req.userInfo;
let reqConf = {title:'String', branch:'[Number]', filesNameList:'[String]' };
let { title, branch, filesNameList } = eccReqParamater(reqConf, req.body, ["filesNameList"]);
let reqConf = {title:'String', branch:'[Number]', fileName:'[String]' };
let { title, branch, fileName } = eccReqParamater(reqConf, req.body);
let result = await branchSystemBiz.addBranchSystemInfo(userInfo, title, branch, filesNameList);
let result = await branchSystemBiz.addBranchSystemInfo(userInfo, title, branch, fileName);
res.success(result);
}
......@@ -60,10 +60,10 @@ async function addBranchSystem(req, res) {
async function updateBranchSystem(req, res) {
let userInfo = req.userInfo;
let reqConf = {title:'String', branch:'[Number]', filesNameList:'[String]', bsId:'Number' };
let { title, branch, filesNameList, bsId } = eccReqParamater(reqConf, req.body, ["filesNameList"]);
let reqConf = {title:'String', branch:'[Number]', fileName:'[String]', bsId:'Number' };
let { title, branch, fileName, bsId } = eccReqParamater(reqConf, req.body);
let result = await branchSystemBiz.updateBranchSystemInfo(userInfo, bsId, title, branch, filesNameList);
let result = await branchSystemBiz.updateBranchSystemInfo(userInfo, bsId, title, branch, fileName);
res.success(result);
}
......
......@@ -9,6 +9,10 @@ import { eccReqParamater } from '../tools/eccParam';
export function setRouter(httpServer) {
httpServer.post('/yfs/admin/organizationallife/list', checkToken, asyncHandler(organizationalLifeList));
httpServer.post('/yfs/admin/organizationallife/add', checkToken, asyncHandler(addOrganizationalLife));
httpServer.post('/yfs/admin/organizationallife/update', checkToken, asyncHandler(updateOrganizationalLife));
httpServer.post('/yfs/admin/organizationallife/del', checkToken, asyncHandler(delOrganizationalLife));
httpServer.post('/yfs/admin/organizationallife/info', checkToken, asyncHandler(organizationalLifeInfo));
}
......@@ -20,10 +24,80 @@ export function setRouter(httpServer) {
async function organizationalLifeList(req, res) {
let userInfo = req.userInfo;
let reqConf = {month:'Number', title:'String', pageNumber:'Number'};
let { month, title, pageNumber } = eccReqParamater(reqConf, req.body, ["month", "title"]);
let reqConf = {month:'Number', theme:'String', pageNumber:'Number', branch:"Number"};
let { month, theme, pageNumber, branch } = eccReqParamater(reqConf, req.body, ["month", "theme"]);
let result = await organizationalLifeBiz.getOrgLifeList(userInfo, month, title, pageNumber);
let result = await organizationalLifeBiz.getOrgLifeList(userInfo, month, theme, branch, pageNumber);
res.success(result);
}
\ No newline at end of file
}
/**
* 添加
* @param req
* @param res
*/
async function addOrganizationalLife(req, res) {
let userInfo = req.userInfo;
let reqConf = {param:'Object'};
let { param } = eccReqParamater(reqConf, req.body, []);
let result = await organizationalLifeBiz.addOrgLifeInfo(userInfo, param);
res.success(result);
}
/**
* 修改
* @param req
* @param res
*/
async function updateOrganizationalLife(req, res) {
let userInfo = req.userInfo;
let reqConf = {param:'Object', oId:"Number"};
let { param, oId } = eccReqParamater(reqConf, req.body, []);
let result = await organizationalLifeBiz.updateOrgLifeInfo(userInfo, oId, param);
res.success(result);
}
/**
* 删除
* @param req
* @param res
*/
async function delOrganizationalLife(req, res) {
let userInfo = req.userInfo;
let reqConf = { oId:"Number" };
let { oId } = eccReqParamater(reqConf, req.body, []);
let result = await organizationalLifeBiz.delOrgLifeInfo(userInfo, oId);
res.success(result);
}
/**
* 回显
* @param req
* @param res
*/
async function organizationalLifeInfo(req, res) {
let userInfo = req.userInfo;
let reqConf = { oId:"Number" };
let { oId } = eccReqParamater(reqConf, req.body, []);
let result = await organizationalLifeBiz.getOrgLifeInfo(userInfo, oId);
res.success(result);
}
......@@ -4,6 +4,7 @@ import * as publicRouter from "./public";
import * as organizationRouter from "./organization";
import * as branchSystemRouter from "./branchSystem";
import * as organizationalLifeRouter from "./organizationalLife";
import * as thematicActivitiesRouter from "./thematicActivities";
export function setRouter(httpServer) {
......@@ -13,4 +14,5 @@ export function setRouter(httpServer) {
organizationRouter.setRouter(httpServer);
branchSystemRouter.setRouter(httpServer);
organizationalLifeRouter.setRouter(httpServer);
thematicActivitiesRouter.setRouter(httpServer);
}
\ No newline at end of file
/**
* 专题活动
*/
import * as asyncHandler from 'express-async-handler';
import * as thematicActivitiesBiz from '../biz/thematicActivities';
import { checkToken } from '../middleware/user';
import { eccReqParamater } from '../tools/eccParam';
export function setRouter(httpServer) {
httpServer.post('/yfs/admin/thematicactivities/list', checkToken, asyncHandler(thematicActivitiesList));
httpServer.post('/yfs/admin/thematicactivities/add', checkToken, asyncHandler(addThematicActivities));
httpServer.post('/yfs/admin/thematicactivities/update', checkToken, asyncHandler(updateThematicActivities));
httpServer.post('/yfs/admin/thematicactivities/del', checkToken, asyncHandler(delThematicActivities));
httpServer.post('/yfs/admin/thematicactivities/info', checkToken, asyncHandler(thematicActivitiesInfo));
}
/**
* 专题活动列表
* @param req
* @param res
*/
async function thematicActivitiesList(req, res) {
let userInfo = req.userInfo;
let reqConf = {month:'Number', theme:'String', pageNumber:'Number', branch:"Number"};
let { month, theme, pageNumber, branch } = eccReqParamater(reqConf, req.body, ["month", "theme"]);
let result = await thematicActivitiesBiz.getThematicActivitiesList(userInfo, month, theme, branch, pageNumber);
res.success(result);
}
/**
* 添加
* @param req
* @param res
*/
async function addThematicActivities(req, res) {
let userInfo = req.userInfo;
let reqConf = {param:'Object'};
let { param } = eccReqParamater(reqConf, req.body, []);
let result = await thematicActivitiesBiz.addThematicActivitiesInfo(userInfo, param);
res.success(result);
}
/**
* 修改
* @param req
* @param res
*/
async function updateThematicActivities(req, res) {
let userInfo = req.userInfo;
let reqConf = {param:'Object', taId:"Number"};
let { param, taId } = eccReqParamater(reqConf, req.body, []);
let result = await thematicActivitiesBiz.updateThematicActivitiesInfo(userInfo, taId, param);
res.success(result);
}
/**
* 删除
* @param req
* @param res
*/
async function delThematicActivities(req, res) {
let userInfo = req.userInfo;
let reqConf = { taId:"Number" };
let { taId } = eccReqParamater(reqConf, req.body, []);
let result = await thematicActivitiesBiz.delThematicActivitiesInfo(userInfo, taId);
res.success(result);
}
/**
* 回显
* @param req
* @param res
*/
async function thematicActivitiesInfo(req, res) {
let userInfo = req.userInfo;
let reqConf = { taId:"Number" };
let { taId } = eccReqParamater(reqConf, req.body, []);
let result = await thematicActivitiesBiz.getThematicActivitiesInfo(userInfo, taId);
res.success(result);
}
......@@ -61,6 +61,16 @@ export function eccFormParam(name:string, keyTypeConf:object, param:object) {
}
}
break;
case '[String]':
if ( !Array.isArray(param[key]) ) isError = true;
for (let i =0; i < param[key].length; i++) {
let item = param[key][i];
if ( typeof item != 'string' ) {
isError = true;
errorStr = `${key}应是String型数组其中下标${i}${typeof item}`;
}
}
break;
case '[Object]':
if ( !Array.isArray(param[key]) ) isError = true;
for (let i =0; i < param[key].length; i++) {
......@@ -168,6 +178,16 @@ export function eccReqParamater(conf:object, param, skipKeys?) {
}
}
break;
case '[String]':
if ( !Array.isArray(param[key]) ) isError = true;
for (let i =0; i < param[key].length; i++) {
let item = param[key][i];
if ( typeof item != 'string' ) {
isError = true;
errorStr = `${key}应是String型数组其中下标${i}${typeof item}`;
}
}
break;
case '[Object]':
if ( !Array.isArray(param[key]) ) isError = true;
for (let i =0; i < param[key].length; i++) {
......
import moment = require("moment");
import { ERRORENUM } from "../config/enum/errorEnum";
import { BizError } from "../util/bizError";
import { FILETYPE } from "../config/enum/enum";
const md5 = require("md5");
......@@ -22,4 +25,25 @@ export function getPartyMemberId(param) {
export function getDefPwd(phone:string) {
return md5(`${phone.slice(5, 11)}`);
}
\ No newline at end of file
}
export function getFileType(fileName) {
let fileType = 0;
fileName.forEach(info => {
let type = info.split("_")[1];
if (!type) throw new BizError(ERRORENUM.文件不存在, `文件名 ${info}`);
let typeNum = 0;
switch(type) {
case 'pdf': typeNum = FILETYPE.pdf; break;
case 'doc':
case 'docx': typeNum = FILETYPE.word; break;
case 'jpg':
case 'png': typeNum = FILETYPE.图片; break;
};
if (typeNum) {
if (!fileType) fileType = typeNum;
else if (fileType != typeNum) fileType = FILETYPE.多类型
}
});
return fileType
}
......@@ -75,6 +75,11 @@ export function datechangeToStr(timeMs) {
return moment(timeMs).format("YYYY-MM-DD")
}
export function monthDateChangeToStr(timeMs) {
return moment(timeMs).format("YYYY-MM")
}
export function dataListItemTimeChangeToTimeStr(dataList, checkList) {
dataList.forEach(info => {
......
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