Commit 14782c26 by linboxuan

lin add productType

parent 29588d1c
......@@ -2,87 +2,96 @@ var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class OpProductAPI extends APIBase {
constructor() {
super();
this.productSve = system.getObject("service.dbproduct.productSve");
this.producttypeSve = system.getObject("service.dbproduct.producttypeSve");
constructor() {
super();
this.productSve = system.getObject("service.dbproduct.productSve");
this.producttypeSve = system.getObject("service.dbproduct.producttypeSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "getProductList"://通过产品类别编码获取产品列表
opResult = await this.productSve.getProductList(pobj.actionBody, pobj.appInfo);
break;
case "getProductDetail"://获取产品详情
opResult = await this.productSve.getProductDetail(pobj.actionBody, pobj.appInfo);
break;
case "getProductInterface"://获取产品接口信息
opResult = await this.productSve.getProductInterface(pobj, pobj.actionBody);
break;
case "getAppInterface"://获取应用接口信息
opResult = await this.productSve.getAppInterface(pobj, pobj.actionBody);
break;
case "getaliicProduce"://阿里工商获取产品信息
opResult = await this.productSve.getaliicProduce(pobj.actionBody);
break;
case "getaliicpProduce"://阿里icp获取产品信息
opResult = await this.productSve.getaliicpProduce(pobj.actionBody,pobj.appInfo);
break;
case "getIcpProduce"://获取ICP产品信息
opResult = await this.productSve.getIcpProduce(pobj.actionBody,pobj.appInfo);
break;
case "getProductTypeInfo"://阿里工商获取需求類型
opResult = await this.producttypeSve.getProductTypeInfo(pobj.actionBody, pobj.appInfo);
break;
case "getProductPrice"://询价
opResult = await this.productSve.getProductPrice(pobj.actionBody);
break;
case "getMinPrice"://最低价
opResult = await this.productSve.getMinPrice(pobj);
break;
case "getProductRecommend":
opResult = await this.productSve.getProductRecommend(pobj.actionBody,pobj.appInfo);
break;
case "updateProductPrice":
opResult = await this.productSve.updateProductPrice(pobj.actionBody,pobj.appInfo);
break;
//2020-12-17 baidu reg start -----------------
case "getRegProducePrice"://获取reg产品price
opResult = await this.productSve.getRegProducePrice(pobj.actionBody);
break;
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "getProductList"://通过产品类别编码获取产品列表
opResult = await this.productSve.getProductList(pobj.actionBody, pobj.appInfo);
break;
case "getProductDetail"://获取产品详情
opResult = await this.productSve.getProductDetail(pobj.actionBody, pobj.appInfo);
break;
case "getProductInterface"://获取产品接口信息
opResult = await this.productSve.getProductInterface(pobj, pobj.actionBody);
break;
case "getAppInterface"://获取应用接口信息
opResult = await this.productSve.getAppInterface(pobj, pobj.actionBody);
break;
case "getaliicProduce"://阿里工商获取产品信息
opResult = await this.productSve.getaliicProduce(pobj.actionBody);
break;
case "getaliicpProduce"://阿里icp获取产品信息
opResult = await this.productSve.getaliicpProduce(pobj.actionBody, pobj.appInfo);
break;
case "getIcpProduce"://获取ICP产品信息
opResult = await this.productSve.getIcpProduce(pobj.actionBody, pobj.appInfo);
break;
case "getProductTypeInfo"://阿里工商获取需求類型
opResult = await this.producttypeSve.getProductTypeInfo(pobj.actionBody, pobj.appInfo);
break;
case "getProductPrice"://询价
opResult = await this.productSve.getProductPrice(pobj.actionBody);
break;
case "getMinPrice"://最低价
opResult = await this.productSve.getMinPrice(pobj);
break;
case "getProductRecommend":
opResult = await this.productSve.getProductRecommend(pobj.actionBody, pobj.appInfo);
break;
case "updateProductPrice":
opResult = await this.productSve.updateProductPrice(pobj.actionBody, pobj.appInfo);
break;
//2020-12-17 baidu reg start -----------------
case "getRegProducePrice"://获取reg产品price
opResult = await this.productSve.getRegProducePrice(pobj.actionBody);
break;
//2020-12-17 baidu reg end -----------------
case "getAllProducts":
opResult = await this.productSve.getAllProducts();
break;
case "getProductByWhere":
opResult = await this.productSve.getProductByWhere(pobj.actionBody);
break;
case "getymicpProduce"://易名icp获取产品信息
opResult = await this.productSve.getymicpProduce(pobj.actionBody,pobj.appInfo);
break;
case "getAllPathName":
opResult = await this.productSve.getAllPathName();
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
//2020-12-17 baidu reg end -----------------
case "getAllProducts":
opResult = await this.productSve.getAllProducts();
break;
case "getProductByWhere":
opResult = await this.productSve.getProductByWhere(pobj.actionBody);
break;
case "getymicpProduce"://易名icp获取产品信息
opResult = await this.productSve.getymicpProduce(pobj.actionBody, pobj.appInfo);
break;
case "getAllPathName":
opResult = await this.productSve.getAllPathName();
break;
case "getAllProductType":// 获取全部产品大类
opResult = await this.producttypeSve.getAllProductType(pobj.actionBody);
break;
case "submitProductType":// 创建产品大类
opResult = await this.producttypeSve.submitProductType(pobj.actionBody);
break;
case "editProductType":// 修改产品大类
opResult = await this.producttypeSve.editProductType(pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
......
......@@ -7,16 +7,57 @@ class ProductTypeService extends ServiceBase {
super("dbproduct", ServiceBase.getDaoName(ProductTypeService));
}
async getProductTypeInfo(actionBody,appInfo){
if(!actionBody.type){
async getProductTypeInfo(actionBody, appInfo) {
if (!actionBody.type) {
return system.getResult(null, "channelCode item is data empty !");
}
if(!appInfo){
if (!appInfo) {
return system.getResult(null, "appInfo item is data empty !");
}
var producttypeinfo=await this.findOne({"channel_type_code":actionBody.type,"uapp_id":appInfo.uapp_id});
var producttypeinfo = await this.findOne({ "channel_type_code": actionBody.type, "uapp_id": appInfo.uapp_id });
return system.getResultSuccess(producttypeinfo);
}
/**
* 获取全部产品大类
* @returns {Promise<void>}
*/
async getAllProductType(actionBody) {
var tmpWhere = {
pageInfo: {}
};
if (actionBody) {
if (actionBody.pageSize) {
tmpWhere.limit = actionBody.pageSize;
}
if (actionBody.current) {
let current = actionBody.current;
tmpWhere.offset = (current - 1) * actionBody.pageSize;
}
}
let result = await this.dao.model.findAndCountAll(tmpWhere)
return system.getResultSuccess(result);
}
/**
* 创建产品大类
* @returns {Promise<void>}
*/
async submitProductType(actionBody) {
let result = await this.dao.model.create(actionBody)
return system.getResultSuccess(result);
}
/**
* 修改产品大类
* @returns {Promise<void>}
*/
async editProductType(actionBody) {
if (actionBody) {
let result = await this.dao.update(actionBody)
return system.getResultSuccess(result);
}
return;
}
}
module.exports = ProductTypeService;
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