完善多属性模块的接口
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.jsh.erp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.MaterialAttribute;
|
||||
import com.jsh.erp.datasource.entities.Person;
|
||||
import com.jsh.erp.service.materialAttribute.MaterialAttributeService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -30,24 +32,45 @@ public class MaterialAttributeController {
|
||||
private MaterialAttributeService materialAttributeService;
|
||||
|
||||
/**
|
||||
* 获取全部商品属性
|
||||
* 获取商品属性的名称列表
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping("/getAll")
|
||||
@ApiOperation(value = "获取全部商品属性")
|
||||
public BaseResponseInfo getAll(HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
@GetMapping(value = "/getNameList")
|
||||
@ApiOperation(value = "获取商品属性的名称列表")
|
||||
public JSONArray getNameList(HttpServletRequest request)throws Exception {
|
||||
JSONArray dataArray = new JSONArray();
|
||||
try {
|
||||
JSONObject obj = materialAttributeService.getAll();
|
||||
res.code = 200;
|
||||
res.data = obj;
|
||||
List<MaterialAttribute> materialAttributeList = materialAttributeService.getMaterialAttribute();
|
||||
if (null != materialAttributeList) {
|
||||
for (MaterialAttribute materialAttribute : materialAttributeList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("value", materialAttribute.getId().toString());
|
||||
item.put("name", materialAttribute.getAttributeName());
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
return dataArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取id查询属性的值列表
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getValueListById")
|
||||
@ApiOperation(value = "获取id查询属性的值列表")
|
||||
public JSONArray getValueListById(@RequestParam("id") Long id,
|
||||
HttpServletRequest request)throws Exception {
|
||||
JSONArray dataArray = new JSONArray();
|
||||
try {
|
||||
dataArray = materialAttributeService.getValueArrById(id);
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return dataArray;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user