Commit 2f56f603 authored by 张永's avatar 张永

需求 #14165

parent 9d5d3d2f
package com.egolm.shop.api;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.shop.api.service.CommonService;
import com.egolm.shop.common.XException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api(tags={"公共数据接口"})
@RestController
@RequestMapping("common")
public class CommonController {
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private CommonService commonService;
@ApiOperation("组织构购获取省市区")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "orgNO", 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 = "/queryDistrictByOrgNO",method=RequestMethod.GET)
public String queryDistrictByOrgNO(HttpServletRequest request) {
String orgNO = request.getParameter("orgNO");
String langID = request.getParameter("langID");
return commonService.queryDistrictByOrgNO(orgNO, langID);
}
@ApiOperation("获取已开通的城市")
@ApiImplicitParams({
@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 = "/getOpenCity",method=RequestMethod.GET)
public String getOpenCity(HttpServletRequest request) {
String langID = request.getParameter("langID");
return commonService.getOpenCity(langID);
}
@ApiOperation("获取共同参数")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "commonNo", dataType = "String", required = false, value = "参数名"),
@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 = "/getCommonArgs",method=RequestMethod.GET)
public String getCommonArgs(HttpServletRequest request) {
String langID = request.getParameter("langID");
String commonNo = request.getParameter("commonNo");
List<Map<String, Object>> list = commonService.getCommonArgs(langID, commonNo);
return Rjx.jsonOk().set("list", list).toJson();
}
@ApiOperation("获取省市区数据")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "regionNo", dataType = "String"),
@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 = "/getRegionList",method=RequestMethod.GET)
public String getCityListByProvince(String regionNo) {
if(StringUtil.isBlank(regionNo)) {
regionNo = "000000";
}
List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from tRegion where sUpRegionNO = ?", regionNo);
return Rjx.jsonOk().set("list", list).toJson();
}
@ApiOperation("获取配置信息")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "appId", dataType = "String"),
@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 = "/getConfig",method=RequestMethod.GET)
public Object getConfig(String appId) {
Map<String, Object> map = null;
try {
map = jdbcTemplate.queryForMap("select sOrgNO, sOrgDesc, sOrgPicUrl from tOrg where sAppID = ? and nTag&1 = 0", appId);
} catch (EmptyResultDataAccessException e) {
throw new XException("配置不存在", e);
}
String sOrgNO = (String)map.get("sOrgNO");
String ossSql = "" +
" declare @ChoiceOssKEY varchar(20) " +
" select @ChoiceOssKEY=sValue1 from tSystemCtrl " +
" where sCode = 'ChoiceOssKEY' " +
" select sChoiceOssKEY=@ChoiceOssKEY,sDesc,sValue1,sValue2,Value3=sValue3,sValue4,sValue5,sMemo " +
" from tSystemCtrl " +
" where sCode = @ChoiceOssKEY";
Map<String, Object> omap = jdbcTemplate.queryForMap(ossSql.replaceAll("\\s+", " "));
Map<String, Object> cmap = jdbcTemplate.queryForMap("select sDesc,sValue1 from tSystemCtrl where sCode = 'ExemptCheck'");
List<Map<String, Object>> payTypes = jdbcTemplate.queryForList("select sSalesOrderPayTypeID, sSalesOrderPayType from tOrgPayType where sOrgNO = ? and nTag&1=0 order by nSort desc", sOrgNO);
List<Map<String, Object>> goodsTags = jdbcTemplate.queryForList("select sGoodsTagID, sGoodsTag from tOrgGoodsTag where sOrgNO = ? and nTag&1 = 0", sOrgNO);
Map<String, Object> shareInfo = new HashMap<String, Object>();
try {
String sql = ""
+ "SELECT "
+ "SharePicUrl = sPicUrl, "
+ "ShareTitle = sShareTitle "
+ "FROM "
+ "tOrg "
+ "WHERE "
+ "sOrgNO = ? "
+ "AND sAppID = ?";
shareInfo = jdbcTemplate.queryForMap(sql, sOrgNO, appId);
} catch (EmptyResultDataAccessException e) {}
Map<String, Object> AppSystemInfo = new HashMap<String, Object>();
try {
String sql = ""
+ "SELECT "
+ "IsAppCustService = convert(BIT, CASE WHEN nIsAppCustService = 1 THEN 1 ELSE 0 END), "
+ "IsExemptCheck = convert(BIT, CASE WHEN nIsExemptCheck = 1 THEN 1 ELSE 0 END) "
+ "FROM "
+ "tOrg "
+ "WHERE "
+ "sOrgNO = ? "
+ "AND sAppID = ?";
AppSystemInfo = jdbcTemplate.queryForMap(sql, sOrgNO, appId);
} catch (EmptyResultDataAccessException e) {}
return Rjx.jsonOk().set("OrgInfo", map).set("PicInfo", omap).set("ExemptCheck", cmap).set("payTypes", payTypes).set("goodsTags", goodsTags).set("AppSystemInfo", AppSystemInfo).set("shareInfo", shareInfo).toJson();
}
}
package com.egolm.shop.api;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.shop.api.service.CommonService;
import com.egolm.shop.common.XException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api(tags={"公共数据接口"})
@RestController
@RequestMapping("common")
public class CommonController {
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private CommonService commonService;
@ApiOperation("组织构购获取省市区")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "orgNO", 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 = "/queryDistrictByOrgNO",method=RequestMethod.GET)
public String queryDistrictByOrgNO(HttpServletRequest request) {
String orgNO = request.getParameter("orgNO");
String langID = request.getParameter("langID");
return commonService.queryDistrictByOrgNO(orgNO, langID);
}
@ApiOperation("获取已开通的城市")
@ApiImplicitParams({
@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 = "/getOpenCity",method=RequestMethod.GET)
public String getOpenCity(HttpServletRequest request) {
String langID = request.getParameter("langID");
return commonService.getOpenCity(langID);
}
@ApiOperation("获取共同参数")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "commonNo", dataType = "String", required = false, value = "参数名"),
@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 = "/getCommonArgs",method=RequestMethod.GET)
public String getCommonArgs(HttpServletRequest request) {
String langID = request.getParameter("langID");
String commonNo = request.getParameter("commonNo");
List<Map<String, Object>> list = commonService.getCommonArgs(langID, commonNo);
return Rjx.jsonOk().set("list", list).toJson();
}
@ApiOperation("获取省市区数据")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "regionNo", dataType = "String"),
@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 = "/getRegionList",method=RequestMethod.GET)
public String getCityListByProvince(String regionNo) {
if(StringUtil.isBlank(regionNo)) {
regionNo = "000000";
}
List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from tRegion where sUpRegionNO = ?", regionNo);
return Rjx.jsonOk().set("list", list).toJson();
}
@ApiOperation("获取配置信息")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "appId", dataType = "String"),
@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 = "/getConfig",method=RequestMethod.GET)
public Object getConfig(String appId) {
Map<String, Object> map = null;
try {
map = jdbcTemplate.queryForMap("select sOrgNO, sOrgDesc, sOrgPicUrl from tOrg where sAppID = ? and nTag&1 = 0", appId);
} catch (EmptyResultDataAccessException e) {
throw new XException("配置不存在", e);
}
String sOrgNO = (String)map.get("sOrgNO");
String ossSql = "" +
" declare @ChoiceOssKEY varchar(20) " +
" select @ChoiceOssKEY=sValue1 from tSystemCtrl " +
" where sCode = 'ChoiceOssKEY' " +
" select sChoiceOssKEY=@ChoiceOssKEY,sDesc,sValue1,sValue2,Value3=sValue3,sValue4,sValue5,sMemo " +
" from tSystemCtrl " +
" where sCode = @ChoiceOssKEY";
Map<String, Object> omap = jdbcTemplate.queryForMap(ossSql.replaceAll("\\s+", " "));
Map<String, Object> cmap = jdbcTemplate.queryForMap("select sDesc,sValue1 from tSystemCtrl where sCode = 'ExemptCheck'");
Map<String, Object> bmap = jdbcTemplate.queryForMap("select sDesc,sValue1 from tSystemCtrl where sCode = 'B2BBusinessModel'");
List<Map<String, Object>> payTypes = jdbcTemplate.queryForList("select sSalesOrderPayTypeID, sSalesOrderPayType from tOrgPayType where sOrgNO = ? and nTag&1=0 order by nSort desc", sOrgNO);
List<Map<String, Object>> goodsTags = jdbcTemplate.queryForList("select sGoodsTagID, sGoodsTag from tOrgGoodsTag where sOrgNO = ? and nTag&1 = 0", sOrgNO);
Map<String, Object> shareInfo = new HashMap<String, Object>();
try {
String sql = ""
+ "SELECT "
+ "SharePicUrl = sPicUrl, "
+ "ShareTitle = sShareTitle "
+ "FROM "
+ "tOrg "
+ "WHERE "
+ "sOrgNO = ? "
+ "AND sAppID = ?";
shareInfo = jdbcTemplate.queryForMap(sql, sOrgNO, appId);
} catch (EmptyResultDataAccessException e) {}
Map<String, Object> AppSystemInfo = new HashMap<String, Object>();
try {
String sql = ""
+ "SELECT "
+ "IsAppCustService = convert(BIT, CASE WHEN nIsAppCustService = 1 THEN 1 ELSE 0 END), "
+ "IsExemptCheck = convert(BIT, CASE WHEN nIsExemptCheck = 1 THEN 1 ELSE 0 END) "
+ "FROM "
+ "tOrg "
+ "WHERE "
+ "sOrgNO = ? "
+ "AND sAppID = ?";
AppSystemInfo = jdbcTemplate.queryForMap(sql, sOrgNO, appId);
} catch (EmptyResultDataAccessException e) {}
return Rjx.jsonOk().set("OrgInfo", map).set("PicInfo", omap).set("ExemptCheck", cmap).set("BusinessModel", bmap).set("payTypes", payTypes).set("goodsTags", goodsTags).set("AppSystemInfo", AppSystemInfo).set("shareInfo", shareInfo).toJson();
}
}
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