Commit 1d0873fa by chenjinjing

no message

parent 70712e50
...@@ -6,6 +6,7 @@ import { OPERATIONALDATATYPE, TABLENAME } from "../config/dbEnum"; ...@@ -6,6 +6,7 @@ import { OPERATIONALDATATYPE, TABLENAME } from "../config/dbEnum";
import { ERRORENUM } from "../config/errorEnum"; import { ERRORENUM } from "../config/errorEnum";
import { systemConfig } from "../config/systemConfig"; import { systemConfig } from "../config/systemConfig";
import { selectData } from "../middleware/databaseSuccess"; import { selectData } from "../middleware/databaseSuccess";
import { getFileUrl } from "../middleware/getUrl";
import { BizError } from "../util/bizError"; import { BizError } from "../util/bizError";
...@@ -35,12 +36,7 @@ export async function branchSystemDetsils(bsId:number, token:string, userid:stri ...@@ -35,12 +36,7 @@ export async function branchSystemDetsils(bsId:number, token:string, userid:stri
let clomun = ["bsId", "systemTitle", "fileName"]; let clomun = ["bsId", "systemTitle", "fileName"];
let branchSystemInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.支部制度表, {bsId}, clomun); let branchSystemInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.支部制度表, {bsId}, clomun);
if(!branchSystemInfo || !branchSystemInfo.bsId) throw new BizError(ERRORENUM.库中不存在对应数据, `制度细则中不存在id=${bsId}的数据`); if(!branchSystemInfo || !branchSystemInfo.bsId) throw new BizError(ERRORENUM.库中不存在对应数据, `制度细则中不存在id=${bsId}的数据`);
let fileNameInfo = JSON.parse(branchSystemInfo.fileName); let fileNameList = getFileUrl(branchSystemInfo.fileName, token, userid);
let fileNameList = [];
for(let i = 0; i < fileNameInfo.length; i++) {
let fileType = fileNameInfo[i].slice(0, 1);
fileNameList.push(`${systemConfig.fileIP}/yfs/files/${fileType}/${fileNameInfo[i]}?token=${token}&userid=${userid}`);
}
branchSystemInfo.fileName = fileNameList; branchSystemInfo.fileName = fileNameList;
return branchSystemInfo; return branchSystemInfo;
} }
......
...@@ -10,6 +10,7 @@ import moment = require("moment"); ...@@ -10,6 +10,7 @@ import moment = require("moment");
import * as verificationEnumTools from "../util/verificationEnum"; import * as verificationEnumTools from "../util/verificationEnum";
import * as configEnum from "../config/enum"; import * as configEnum from "../config/enum";
import { systemConfig } from "../config/systemConfig"; import { systemConfig } from "../config/systemConfig";
import { getFileUrl } from "../middleware/getUrl";
/** /**
...@@ -20,7 +21,7 @@ import { systemConfig } from "../config/systemConfig"; ...@@ -20,7 +21,7 @@ import { systemConfig } from "../config/systemConfig";
* @param contentTitle 课程标题 * @param contentTitle 课程标题
* @returns rateLearningList:[{"contentTitle":"学习课题名称", "fileName":["视频地址", ......], "rateOfLearning":0, "learningCompleted":0}] * @returns rateLearningList:[{"contentTitle":"学习课题名称", "fileName":["视频地址", ......], "rateOfLearning":0, "learningCompleted":0}]
*/ */
export async function memberLearningList(pmId:string, courseEntryType:number, courseTypeName:number, contentTitle:string) { export async function memberLearningList(pmId:string, courseEntryType:number, courseTypeName:number, contentTitle:string, token:string, userid:string) {
let rateColumn = ["rlId", "mlId", "rateOfLearning", "learningCompleted"]; let rateColumn = ["rlId", "mlId", "rateOfLearning", "learningCompleted"];
let rateLearningInfo = await selectData(OPERATIONALDATATYPE.查询多个, TABLENAME.学习进度表, {pmId}, rateColumn); let rateLearningInfo = await selectData(OPERATIONALDATATYPE.查询多个, TABLENAME.学习进度表, {pmId}, rateColumn);
let rateLearningList = []; let rateLearningList = [];
...@@ -55,11 +56,7 @@ export async function memberLearningList(pmId:string, courseEntryType:number, co ...@@ -55,11 +56,7 @@ export async function memberLearningList(pmId:string, courseEntryType:number, co
let filename; let filename;
if (courseEntryType == 2) { if (courseEntryType == 2) {
let fileNameInfo = JSON.parse(fileName); filename = getFileUrl(fileName, token, userid);
filename = [];
for(let i = 0; i < fileNameInfo.length; i++) {
filename.push(`${systemConfig.fileIP}/${fileNameInfo[i]}`);
}
} else { } else {
filename = JSON.parse(filename); filename = JSON.parse(filename);
} }
......
...@@ -11,6 +11,7 @@ import { extractData } from "../util/piecemeal"; ...@@ -11,6 +11,7 @@ import { extractData } from "../util/piecemeal";
import * as splitResultConfig from "../config/splitResultConfig"; import * as splitResultConfig from "../config/splitResultConfig";
import * as verificationEnumTools from "../util/verificationEnum"; import * as verificationEnumTools from "../util/verificationEnum";
import * as configEnum from "../config/enum"; import * as configEnum from "../config/enum";
import { getFileUrl } from "../middleware/getUrl";
/** /**
...@@ -50,14 +51,14 @@ export async function organizationalLifeList(bId:number, theme:string, themeType ...@@ -50,14 +51,14 @@ export async function organizationalLifeList(bId:number, theme:string, themeType
* @param oId 组织生活id * @param oId 组织生活id
* @returns orgLifeInfo:{"oId":1, "theme":"活动主题", "themeType":"活动类型", "fileName":["活动文件名称", ......]} * @returns orgLifeInfo:{"oId":1, "theme":"活动主题", "themeType":"活动类型", "fileName":["活动文件名称", ......]}
*/ */
export async function organlzationalLifeListDetsils(oId:number) { export async function organlzationalLifeListDetsils(oId:number, token:string, userid:string) {
let clomun = ["oId", "theme", "themeType", "dataMonth", "fileName"]; let clomun = ["oId", "theme", "themeType", "dataMonth", "fileName"];
let orgLifeInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.组织生活表, {oId}, clomun); let orgLifeInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.组织生活表, {oId}, clomun);
if(!orgLifeInfo || !orgLifeInfo.oId) throw new BizError(ERRORENUM.未找到数据, `库中找不到id为${oId}的组织生活详情`); if(!orgLifeInfo || !orgLifeInfo.oId) throw new BizError(ERRORENUM.未找到数据, `库中找不到id为${oId}的组织生活详情`);
orgLifeInfo.themeType = verificationEnumTools.changeEnumValue(configEnum.THEMETYPE, orgLifeInfo.themeType); orgLifeInfo.themeType = verificationEnumTools.changeEnumValue(configEnum.THEMETYPE, orgLifeInfo.themeType);
orgLifeInfo.dataMonth = moment(orgLifeInfo.dataMonth).format("YYYY-MM-DD"); orgLifeInfo.dataMonth = moment(orgLifeInfo.dataMonth).format("YYYY-MM-DD");
orgLifeInfo.fileName = JSON.parse(orgLifeInfo.fileName); orgLifeInfo.fileName = getFileUrl(orgLifeInfo.fileName, token, userid);
return orgLifeInfo; return orgLifeInfo;
} }
......
...@@ -9,6 +9,7 @@ import * as splitResultConfig from "../config/splitResultConfig"; ...@@ -9,6 +9,7 @@ import * as splitResultConfig from "../config/splitResultConfig";
import moment = require("moment"); import moment = require("moment");
import { PBTYPE } from "../config/enum"; import { PBTYPE } from "../config/enum";
import { systemConfig } from "../config/systemConfig"; import { systemConfig } from "../config/systemConfig";
import { getFileUrl } from "../middleware/getUrl";
/** /**
...@@ -56,19 +57,15 @@ export async function partyBuildingDynamicList(bId:number, theme:string, activit ...@@ -56,19 +57,15 @@ export async function partyBuildingDynamicList(bId:number, theme:string, activit
* @param pbId * @param pbId
* @returns partyBuildingDynamicInfo:{ "theme":"党建动态主题", "dataMonth":"数据月份", "fileName":["党建动态文件名称", ......] } * @returns partyBuildingDynamicInfo:{ "theme":"党建动态主题", "dataMonth":"数据月份", "fileName":["党建动态文件名称", ......] }
*/ */
export async function partyBuildingDynamicDetsils(pbId:number, pbType:number) { export async function partyBuildingDynamicDetsils(pbId:number, pbType:number, token:string, userid:string) {
let clomun = ["theme", "dataMonth", "fileName"]; let clomun = ["theme", "dataMonth", "fileName"];
let partyBuildingDynamicInfo:any = {}; let partyBuildingDynamicInfo:any = {};
if (pbType == PBTYPE.党建资讯) partyBuildingDynamicInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.专题活动表, {taId: pbId}, clomun); if (pbType == PBTYPE.党建资讯) partyBuildingDynamicInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.专题活动表, {taId: pbId}, clomun);
if (pbType == PBTYPE.党建动态) partyBuildingDynamicInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.党建动态表, {pbId}, clomun); if (pbType == PBTYPE.党建动态) partyBuildingDynamicInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.党建动态表, {pbId}, clomun);
partyBuildingDynamicInfo.dataMonth = moment(partyBuildingDynamicInfo.dataMonth).format("YYYY-MM-DD"); partyBuildingDynamicInfo.dataMonth = moment(partyBuildingDynamicInfo.dataMonth).format("YYYY-MM-DD");
let fileNameInfo = JSON.parse(partyBuildingDynamicInfo.fileName); let fileNameList = getFileUrl(partyBuildingDynamicInfo.fileName, token, userid);
let fileName = []; partyBuildingDynamicInfo.fileName = fileNameList;
for(let i = 0; i < fileNameInfo.length; i++) {
fileName.push(`${systemConfig.fileIP}/${fileNameInfo[i]}`);
}
partyBuildingDynamicInfo.fileName = fileName;
return partyBuildingDynamicInfo; return partyBuildingDynamicInfo;
} }
......
...@@ -18,4 +18,24 @@ export enum urlEnum { ...@@ -18,4 +18,24 @@ export enum urlEnum {
export function getUrl(url, urlName) { export function getUrl(url, urlName) {
return `${url}${urlName}` return `${url}${urlName}`
} }
\ No newline at end of file
/**
* 获取文件预览地址
* @param data
* @param token
* @param userid
* @returns
*/
export function getFileUrl(data, token, userid) {
let fileNameInfo = JSON.parse(data.fileName);
let fileNameList = [];
for(let i = 0; i < fileNameInfo.length; i++) {
let fileType = fileNameInfo[i].slice(0, 1);
fileNameList.push(`${systemConfig.fileIP}/yfs/files/${fileType}/${fileNameInfo[i]}?token=${token}&userid=${userid}`);
}
return fileNameList;
}
...@@ -24,4 +24,4 @@ export async function checkAppletToken(req, res, next) { ...@@ -24,4 +24,4 @@ export async function checkAppletToken(req, res, next) {
req.headers.userid = partyMemberInfo.pmId; req.headers.userid = partyMemberInfo.pmId;
next(); next();
} }
\ No newline at end of file
...@@ -25,7 +25,10 @@ async function getMemberLearning(req, res) { ...@@ -25,7 +25,10 @@ async function getMemberLearning(req, res) {
let reqConf = {courseEntryType:'Number', courseTypeName:'Number', contentTitle:'String'}; let reqConf = {courseEntryType:'Number', courseTypeName:'Number', contentTitle:'String'};
let {courseEntryType, courseTypeName, contentTitle} = eccReqParamater(reqConf, req.body); let {courseEntryType, courseTypeName, contentTitle} = eccReqParamater(reqConf, req.body);
let result = await memberLearningBiz.memberLearningList(pmId, courseEntryType, courseTypeName, contentTitle); let token = req.headers.token;
let userid = req.headers.userid;
let result = await memberLearningBiz.memberLearningList(pmId, courseEntryType, courseTypeName, contentTitle, token, userid);
res.success(result); res.success(result);
} }
......
...@@ -36,7 +36,10 @@ async function detailsList(req, res) { ...@@ -36,7 +36,10 @@ async function detailsList(req, res) {
let reqConf = {oId: 'Number' }; let reqConf = {oId: 'Number' };
let {oId} = eccReqParamater(reqConf, req.body); let {oId} = eccReqParamater(reqConf, req.body);
let result = await organizationalLifeBiz.organlzationalLifeListDetsils(oId); let token = req.headers.token;
let userid = req.headers.userid;
let result = await organizationalLifeBiz.organlzationalLifeListDetsils(oId, token, userid);
res.success(result); res.success(result);
} }
...@@ -36,7 +36,10 @@ async function detailsList(req, res) { ...@@ -36,7 +36,10 @@ async function detailsList(req, res) {
let reqConf = {pbId: 'Number', pbType: 'Number'}; let reqConf = {pbId: 'Number', pbType: 'Number'};
let {pbId, pbType} = eccReqParamater(reqConf, req.body); let {pbId, pbType} = eccReqParamater(reqConf, req.body);
let result = await partyBuildingDynamicBiz.partyBuildingDynamicDetsils(pbId, pbType); let token = req.headers.token;
let userid = req.headers.userid;
let result = await partyBuildingDynamicBiz.partyBuildingDynamicDetsils(pbId, pbType, token, userid);
res.success(result); res.success(result);
} }
......
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