Commit 6d72db50 authored by Quxl's avatar Quxl

x

parent da02c65a
package com.egolm.shop.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -29,27 +28,29 @@ public class CategoryController {
@Autowired
private CategoryService categoryService;
@ApiOperation("分类列表")
@ApiOperation("分类列表(按Level查询)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "orgNO", dataType = "String", required = true, value = "组织机构", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "level", dataType = "int", required = true, value = "级别", defaultValue = "3"),
@ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true, value = "组织机构", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "scopeTypeID", dataType = "String", required = true, value = "店铺类型", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/queryCategory",method=RequestMethod.GET)
public String queryCategory(HttpServletRequest request, HttpServletResponse response) {
Map<String,Object> params=new HashMap<>();
params.put("orgNO", request.getParameter("orgNO"));
params.put("scopeTypeID", request.getParameter("scopeTypeID"));
params.put("langID", request.getParameter("langID")==null?936:request.getParameter("langID"));
return categoryService.queryCategory(params);
@RequestMapping(value = "/queryCategoryByLevel",method=RequestMethod.GET)
public String queryCategoryByLevel(String orgNo, String scopeTypeID, Integer level, HttpServletRequest request, HttpServletResponse response) {
List<Map<String, Object>> list = categoryService.queryCategoryByLevel(orgNo, scopeTypeID, level);
List<String> cs = new ArrayList<String>();
for(Map<String, Object> map : list) {
cs.add((String)map.get("sCategoryDesc"));
}
return Rjx.jsonOk().set("keys", cs).set("list", list).toJson();
}
@ApiOperation("分类列表")
@ApiOperation("分类列表(按上级分类查询)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "level", dataType = "int", required = true, value = "级别", defaultValue = "3"),
@ApiImplicitParam(paramType = "query", name = "upCategoryNo", dataType = "int", required = true, value = "上级分类编码", defaultValue = "3"),
@ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true, value = "组织机构", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "scopeTypeID", dataType = "String", required = true, value = "店铺类型", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
......@@ -57,9 +58,9 @@ public class CategoryController {
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/queryCategoryByLevel",method=RequestMethod.GET)
public String queryCategoryByLevel(String orgNo, String scopeTypeID, Integer level, HttpServletRequest request, HttpServletResponse response) {
List<Map<String, Object>> list = categoryService.queryCategoryByLevel(orgNo, scopeTypeID, level);
@RequestMapping(value = "/queryCategory",method=RequestMethod.GET)
public String queryCategory(String orgNo, String scopeTypeID, Integer level, String upCategoryNo, HttpServletRequest request, HttpServletResponse response) {
List<Map<String, Object>> list = categoryService.queryCategory(orgNo, scopeTypeID, upCategoryNo);
List<String> cs = new ArrayList<String>();
for(Map<String, Object> map : list) {
cs.add((String)map.get("sCategoryDesc"));
......@@ -67,4 +68,5 @@ public class CategoryController {
return Rjx.jsonOk().set("keys", cs).set("list", list).toJson();
}
}
......@@ -4,6 +4,6 @@ import java.util.List;
import java.util.Map;
public interface CategoryService {
public String queryCategory(Map<String,Object> params);
public List<Map<String, Object>> queryCategoryByLevel(String orgNO, String scopeTypeID, Integer level);
public List<Map<String, Object>> queryCategory(String orgNO, String scopeTypeID, String upCategoryNo);
}
package com.egolm.shop.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.shop.service.CategoryService;
import com.egolm.shop.util.I18NUtils;
@Service
public class CategoryServiceImpl implements CategoryService {
private static final Log logger = LogFactory.getLog(CategoryServiceImpl.class);
@Autowired
private JdbcTemplate jdbcTemplate;
/**
* 查询分类
* <p>Title: queryCategory</p>
* <p>Description: </p>
* @param params
* @return
* @see com.egolm.shop.service.CategoryService#queryCategory(java.util.Map)
*/
public String queryCategory(Map<String,Object> params) {
String orgNO = params.get("orgNO")+"";
String scopeTypeID = params.get("scopeTypeID")+"";
String langID = params.get("langID")+"";
String one="select categoryID=sCategoryNO,categoryName=sCategoryDesc,parentID=sUpCategoryNO from tOrgCategory where sOrgNO='"+orgNO+"' and sScopeTypeID='"+scopeTypeID+"' and nCategoryLevel='3'";
String two="select categoryID=sCategoryNO,categoryName=sCategoryDesc,parentID=sUpCategoryNO from tOrgCategory where sOrgNO='"+orgNO+"' and sScopeTypeID='"+scopeTypeID+"' and nCategoryLevel='2'";
String three="select categoryID=sCategoryNO,categoryName=sCategoryDesc,parentID=sUpCategoryNO from tOrgCategory where sOrgNO='"+orgNO+"' and sScopeTypeID='"+scopeTypeID+"' and nCategoryLevel='1'";
try{
//返回树形结构结果
List<Map<String,Object>> list1=jdbcTemplate.queryForList(one);
List<Map<String,Object>> list2=jdbcTemplate.queryForList(two);
List<Map<String,Object>> list3=jdbcTemplate.queryForList(three);
for(Map<String,Object> map1:list1){
List<Map<String,Object>> temp2=new ArrayList<Map<String,Object>>();
for(Map<String,Object> map2:list2){
List<Map<String,Object>> temp3=new ArrayList<Map<String,Object>>();
for(Map<String,Object> map3:list3){
if(map2.get("categoryID").equals(map3.get("parentID"))){
temp3.add(map3);
}
}
map2.put("sonList", temp3);
if(map1.get("categoryID").equals(map2.get("parentID"))){
temp2.add(map2);
}
}
map1.put("sonList", temp2);
}
return Rjx.jsonOk().setData(list1).toJson();
}catch(Exception e) {
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Catefory_queryError")).toJson();
}
}
public List<Map<String, Object>> queryCategoryByLevel(String orgNO, String scopeTypeID, Integer level) {
if(level == null) {
level = jdbcTemplate.queryForInt("select GoodsCategoryLevel = isnull((select Convert(int,sValue1) from tSystemCtrl where sCode = 'GoodsCategoryLevel'),0)");
......@@ -74,4 +24,10 @@ public class CategoryServiceImpl implements CategoryService {
return list3;
}
public List<Map<String, Object>> queryCategory(String orgNO, String scopeTypeID, String upCategoryNo) {
String three="select sCategoryNO, sCategoryDesc, sUpCategoryNO from tOrgCategory where sOrgNO = ? and sUpCategoryNO = ? and nTag&1 = 0 order by nSort desc";
List<Map<String,Object>> list3=jdbcTemplate.queryForList(three, orgNO, upCategoryNo);
return list3;
}
}
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