Commit 28f0071f by lixinming

党建动态

parent 8f0e139e
/**
* 党建动态表
*/
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 } from "../config/enum/enum";
import { changeEnumValue, eccEnumValue } from "../tools/eccEnum";
import { datechangeToStr, monthDateChangeToStr } from "../util/piecemeal";
import { eccFormParam } from "../tools/eccParam";
import { CreateDynamicConfig, UpdateDynamicConfig } from "../config/eccParam/eccParamConfig";
/**
* 党建动态表列表
* @param userInfo
* @param month
* @param title
* @param pageNumber
* @returns
*/
export async function getDynamicList(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;
}
}else selectParam.bId = 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 = ["pbId", "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 {pbId, theme, dataMonth, fileType, uploadTime} = info;
let dataMonthStr = monthDateChangeToStr(dataMonth);
let fileTypeStr = changeEnumValue(FILETYPE, fileType);
let uploadTimeStr = datechangeToStr(uploadTime);
dataList.push({
pbId, theme:theme, dataMonth:dataMonthStr, fileType:fileTypeStr, uploadTime:uploadTimeStr
})
})
return {dataList, dataCount};
}
/**
* 创建党建动态
* @param userInfo
* @param param
*/
export async function addDynamicInfo(userInfo, param) {
const FuncName = "添加党建动态";
eccFormParam(FuncName, CreateDynamicConfig, 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 updateDynamicInfo(userInfo, pbId:number, param) {
const FuncName = "修改党建动态";
eccFormParam(FuncName, UpdateDynamicConfig, 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, {pbId} );
return {isSuccess:true};
}
/**
* 删除党建动态
* @param userInfo
* @param pbId
* @returns
*/
export async function delDynamicInfo(userInfo, pbId:number) {
let onceDataInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.党建动态表, {pbId}, ["pbId", "bId"] );
if (!onceDataInfo || !onceDataInfo.pbId) throw new BizError(ERRORENUM.目标数据不存在, `不存在${pbId}的党建动态`);
if (!userInfo.isSuperAdmin && userInfo.branch != onceDataInfo.bId) {
throw new BizError(ERRORENUM.权限不足, `${userInfo.userId}无法删除非本支部的党建动态`);
}
await operationalData(OPERATIONALDATATYPE.删除, TABLENAME.党建动态表, {}, {pbId} );
return {isSuccess:true};
}
/**
* 回显
* @param userInfo
* @param pbId
* @returns
*/
export async function getDynamicInfo(userInfo, pbId:number) {
let orgLifeInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.党建动态表, {pbId}, ["pbId", "bId", "theme", "dataMonth", "fileName"] );
if (!orgLifeInfo || !orgLifeInfo.pbId) throw new BizError(ERRORENUM.目标数据不存在, `不存在${pbId}的组织生活`);
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};
}
......@@ -23,7 +23,7 @@ import { CreateOrgLifeConfig, UpdateOrgLifeConfig } from "../config/eccParam/ecc
* @param pageNumber
* @returns
*/
export async function getOrgLifeList(userInfo, month:number, theme:string, branch:number, pageNumber:number) {
export async function getOrgLifeList(userInfo, month:number, title:string, branch:number, pageNumber:number) {
/**组合查询条件 */
let selectParam:any = {};
if (!userInfo.isSuperAdmin ) {
......@@ -31,14 +31,14 @@ export async function getOrgLifeList(userInfo, month:number, theme:string, branc
else {
selectParam.bId = userInfo.branch;
}
}
} else selectParam.bId = 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 (theme) {
selectParam.theme = {"%like%":theme};
if (title) {
selectParam.theme = {"%like%":title};
}
let column = ["oId", "theme", "themeType", "dataMonth", "fileType", "uploadTime", "bId"];
......
......@@ -30,7 +30,7 @@ export async function getThematicActivitiesList(userInfo, month:number, title:st
else {
selectParam.bId = userInfo.branch;
}
}
}else selectParam.bId = branch;
if (month) {
let stTime = moment(month).startOf("month").valueOf();
let etTime = moment(month).endOf('month').valueOf();
......@@ -40,7 +40,7 @@ export async function getThematicActivitiesList(userInfo, month:number, title:st
selectParam.theme = {"%like%":title};
}
let column = ["taId", "theme", "dataMonth", "fileType", "uploadTime"];
let column = ["taId", "theme", "dataMonth", "uploadTime"];
let dbList = await selectData(OPERATIONALDATATYPE.分页查询, TABLENAME.专题活动表, selectParam, column, pageNumber, 10);
let dataCount = await selectData(OPERATIONALDATATYPE.查询数据量, TABLENAME.专题活动表, selectParam, null);
......@@ -92,7 +92,7 @@ export async function addThematicActivitiesInfo(userInfo, param) {
*/
export async function updateThematicActivitiesInfo(userInfo, taId:number, param) {
const FuncName = "修改专题活动";
eccFormParam(FuncName, CreateThematicActivitiesConfig, param);
eccFormParam(FuncName, UpdateThematicActivitiesConfig, param);
eccEnumValue(FuncName, "bId", BRANCHNAME, param.bId);
if (!userInfo.isSuperAdmin && userInfo.branch != param.bId) {
......
......@@ -146,3 +146,25 @@ export const UpdateThematicActivitiesConfig = {
dataMonth:{type:"Number"},
fileName:{type:"[String]"}
}
/**
* 创建党建动态
*/
export const CreateDynamicConfig = {
bId:{type:"Number"},
theme:{type:"String"},
dataMonth:{type:"Number"},
fileName:{type:"[String]"}
}
/**
* 修改党建动态
*/
export const UpdateDynamicConfig = {
bId:{type:"Number"},
theme:{type:"String"},
dataMonth:{type:"Number"},
fileName:{type:"[String]"}
}
/**
* 党建动态
*/
import * as asyncHandler from 'express-async-handler';
import * as dynamicBiz from '../biz/dynamic';
import { checkToken } from '../middleware/user';
import { eccReqParamater } from '../tools/eccParam';
export function setRouter(httpServer) {
httpServer.post('/yfs/admin/dynamic/list', checkToken, asyncHandler(dynamicList));
httpServer.post('/yfs/admin/dynamic/add', checkToken, asyncHandler(addDynamic));
httpServer.post('/yfs/admin/dynamic/update', checkToken, asyncHandler(updateDynamic));
httpServer.post('/yfs/admin/dynamic/del', checkToken, asyncHandler(delDynamic));
httpServer.post('/yfs/admin/dynamic/info', checkToken, asyncHandler(dynamicInfo));
}
/**
* 党建动态列表
* @param req
* @param res
*/
async function dynamicList(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 dynamicBiz.getDynamicList(userInfo, month, theme, branch, pageNumber);
res.success(result);
}
/**
* 添加
* @param req
* @param res
*/
async function addDynamic(req, res) {
let userInfo = req.userInfo;
let reqConf = {param:'Object'};
let { param } = eccReqParamater(reqConf, req.body, []);
let result = await dynamicBiz.addDynamicInfo(userInfo, param);
res.success(result);
}
/**
* 修改
* @param req
* @param res
*/
async function updateDynamic(req, res) {
let userInfo = req.userInfo;
let reqConf = {param:'Object', pbId:"Number"};
let { param, pbId } = eccReqParamater(reqConf, req.body, []);
let result = await dynamicBiz.updateDynamicInfo(userInfo, pbId, param);
res.success(result);
}
/**
* 删除
* @param req
* @param res
*/
async function delDynamic(req, res) {
let userInfo = req.userInfo;
let reqConf = { pbId:"Number" };
let { pbId } = eccReqParamater(reqConf, req.body, []);
let result = await dynamicBiz.delDynamicInfo(userInfo, pbId);
res.success(result);
}
/**
* 回显
* @param req
* @param res
*/
async function dynamicInfo(req, res) {
let userInfo = req.userInfo;
let reqConf = { pbId:"Number" };
let { pbId } = eccReqParamater(reqConf, req.body, []);
let result = await dynamicBiz.getDynamicInfo(userInfo, pbId);
res.success(result);
}
......@@ -11,6 +11,7 @@ let publicRouterConfig = {
"administrativeposition":enumConfig.ADMINISTRATIVEPOSITION,//行政职务
"partypositions":enumConfig.PARTYPOSITIONS,//党内职务
"dedpartment":enumConfig.DEDPARTMENT,//所属科室
"thmetype":enumConfig.THEMETYPE,//主题类型
}
export function setRouter(httpServer) {
......
......@@ -5,6 +5,7 @@ import * as organizationRouter from "./organization";
import * as branchSystemRouter from "./branchSystem";
import * as organizationalLifeRouter from "./organizationalLife";
import * as thematicActivitiesRouter from "./thematicActivities";
import * as dynamicRouter from "./dynamic";
export function setRouter(httpServer) {
......@@ -15,4 +16,5 @@ export function setRouter(httpServer) {
branchSystemRouter.setRouter(httpServer);
organizationalLifeRouter.setRouter(httpServer);
thematicActivitiesRouter.setRouter(httpServer);
dynamicRouter.setRouter(httpServer);
}
\ 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