| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- const {searchHandle} = require('../tools/searchSql');
- const {handle} = require('../tools/handle');
- const d_solution = require("../database/d_solution");
- const codeMap = require("../map/rcodeMap");
- const log = require("../logger").logger("c_solution","info")
- /**
- * 加载解决方案
- * @param key
- * @param p
- * @param l
- * @returns {Promise<*[]>}
- */
- async function loadSolution(key,p,l){
- p = p || 1;
- l = l || 10;
- let [err,res] = await handle(d_solution.loadSolution(key, p, l));
- if(err){
- console.log(err);
- return [err,null];
- }
- return [null,res];
- }
- async function getSolutionInfo(id)
- {
- let [err,res] = await handle(d_solution.getSolutionInfo(id));
- if(err){
- return [err,null];
- }
- let data = {};
- if(res.length){
- data = res[0];
- }else{
- return [
- {
- eCode:codeMap.NotFound,
- eMsg:`无法找到对应产品`
- },null]
- }
- return [null,data];
- }
- async function searchSolution(type, key, p, l)
- {
- p = p || 1;
- l = l || 10;
- let _params = {
- parentType: 1,
- }
- if(type !== 'all'){
- _params.type = type;
- }
- if(key){
- _params.key = key
- }
- return await searchHandle(
- '搜索产品失败',
- d_solution.searchSolution,
- _params,
- p,
- l);
- }
- async function searchNews(type, key, p, l)
- {
- p = p || 1;
- l = l || 10;
- let _params = {
- parentType: 2,
- }
- if(type !== 'all'){
- _params.type = type;
- }
- if(key){
- _params.key = key
- }
- return await searchHandle(
- '搜索新闻失败',
- d_solution.searchSolution,
- _params,
- p,
- l);
- }
- module.exports = {
- loadSolution,
- searchSolution,
- searchNews,
- getSolutionInfo
- }
|