Commit 23e98c88 authored by mcb's avatar mcb

no message

parent 7f78a584
......@@ -96,6 +96,13 @@ public class JsonResult<T> implements Serializable {
return result;
}
public static JsonResult<Object> error(String message) {
JsonResult<Object> result = new JsonResult<>();
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
result.setMessage(message);
return result;
}
public static JsonResult<Object> error(ResultCode code, String message) {
JsonResult<Object> result = new JsonResult<>();
result.setCode(code);
......
package com.jz.common.exception;
import com.jz.common.constant.ResultCode;
public class ServiceException extends Exception {
private static final long serialVersionUID = 1859731705152111160L;
......
package com.jz.common.utils.web;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
......@@ -39,11 +40,9 @@ import java.util.*;
import java.util.Map.Entry;
/**
*
* @author hack2003
* @date 2016-10-18
* @version v1.0
*
* @date 2016-10-18
*/
public class HttpClientUtils {
......@@ -78,7 +77,7 @@ public class HttpClientUtils {
// 只允许使用TLSv1协议
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslcontext,
new String[] { "TLSv1" },
new String[]{"TLSv1"},
null,
SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
httpclient = HttpClients.custom().setSSLSocketFactory(sslsf)
......@@ -123,48 +122,44 @@ public class HttpClientUtils {
}
/**
* @discription:
* @param url 访问地址
* @param token 请求头中存放token
* @param json 请求数据体
* @return
* @discription:
* @date: 2019年10月25日
*/
public static String postJsonData(String url, String token, String json){
public static String postJsonData(String url, String token, String json) {
LOGGER.info("===================postJsonData start=======================");
LOGGER.info("url:"+url);
LOGGER.info("token:"+token);
LOGGER.info("json:"+json);
LOGGER.info("url:" + url);
LOGGER.info("token:" + token);
LOGGER.info("json:" + json);
String charset="UTF-8";
String charset = "UTF-8";
CloseableHttpClient httpClient = null;
HttpPost httpPost = null;
String result = null;
try
{
try {
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(50000).setConnectTimeout(50000).build();//设置请求和传输超时时间
httpPost.setConfig(requestConfig);
httpPost.setHeader("token", token);
StringEntity se = new StringEntity(json,"UTF-8");
StringEntity se = new StringEntity(json, "UTF-8");
se.setContentType("application/json");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpPost.setEntity(se);
LOGGER.info("请求开始时间:"+System.currentTimeMillis());
LOGGER.info("请求开始时间:" + System.currentTimeMillis());
HttpResponse response = httpClient.execute(httpPost);
LOGGER.info("请求结束时间:"+System.currentTimeMillis());
if(response != null)
{
LOGGER.info("请求结束时间:" + System.currentTimeMillis());
if (response != null) {
HttpEntity resEntity = response.getEntity();
if(resEntity != null)
{
result = EntityUtils.toString(resEntity,charset);
if (resEntity != null) {
result = EntityUtils.toString(resEntity, charset);
}
}
}catch(Exception ex)
{
LOGGER.info("异常捕捉请求结束时间:"+System.currentTimeMillis());
} catch (Exception ex) {
LOGGER.info("异常捕捉请求结束时间:" + System.currentTimeMillis());
ex.printStackTrace();
LOGGER.info(ex.getMessage());
}
......@@ -273,59 +268,57 @@ public class HttpClientUtils {
/**
* 发送 post请求访问本地应用并根据传递参数不同返回不同结果
* @return
*
* @return
* @throws IOException
* @throws ClientProtocolException
*/
public static String post(String url,String json)
{
String charset="UTF-8";
public static String post(String url, String json) {
LOGGER.info("===================POST request start=======================");
LOGGER.info("url:" + url);
LOGGER.info("json:" + json);
String charset = "UTF-8";
CloseableHttpClient httpClient = null;
HttpPost httpPost = null;
String result = null;
try
{
try {
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(50000).setConnectTimeout(50000).build();//设置请求和传输超时时间
httpPost.setConfig(requestConfig);
StringEntity se = new StringEntity(json,"UTF-8");
StringEntity se = new StringEntity(json, "UTF-8");
se.setContentType("application/json");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
System.out.println("-------------"+ JSONObject.toJSONString(se));
System.out.println("-------------" + JSONObject.toJSONString(se));
httpPost.setEntity(se);
HttpResponse response = httpClient.execute(httpPost);
if(response != null)
{
if (response != null) {
HttpEntity resEntity = response.getEntity();
if(resEntity != null)
{
result = EntityUtils.toString(resEntity,charset);
if (resEntity != null) {
result = EntityUtils.toString(resEntity, charset);
}
}
}catch(Exception ex)
{
} catch (Exception ex) {
ex.printStackTrace();
}
LOGGER.info("===================POST request end=======================");
return result;
}
/**
* 带参
*
* @param url
* @param paramName
* @param json
* @return
*/
public static String post(String url,String paramName,String json)
{
String charset="UTF-8";
public static String post(String url, String paramName, String json) {
String charset = "UTF-8";
CloseableHttpClient httpClient = null;
HttpPost httpPost = null;
String result = null;
try
{
try {
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(3000).setConnectTimeout(3000).build();//设置请求和传输超时时间
......@@ -342,16 +335,13 @@ public class HttpClientUtils {
// entityParam.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpPost.setEntity(entityParam);
HttpResponse response = httpClient.execute(httpPost);
if(response != null)
{
if (response != null) {
HttpEntity resEntity = response.getEntity();
if(resEntity != null)
{
result = EntityUtils.toString(resEntity,charset);
if (resEntity != null) {
result = EntityUtils.toString(resEntity, charset);
}
}
}catch(Exception ex)
{
} catch (Exception ex) {
ex.printStackTrace();
}
return result;
......@@ -360,48 +350,44 @@ public class HttpClientUtils {
/**
* 提交JSON参数
*
* @param url
* @param paramName
* @param json
* @return
*/
public static String postJson(String url,String paramName,String json)
{
String charset="UTF-8";
public static String postJson(String url, String paramName, String json) {
String charset = "UTF-8";
CloseableHttpClient httpClient = null;
HttpPost httpPost = null;
String result = null;
try
{
try {
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(3000).setConnectTimeout(3000).build();//设置请求和传输超时时间
httpPost.setConfig(requestConfig);
StringEntity se = new StringEntity(json,"UTF-8");
StringEntity se = new StringEntity(json, "UTF-8");
se.setContentType("application/json");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpPost.setEntity(se);
HttpResponse response = httpClient.execute(httpPost);
if(response != null)
{
if (response != null) {
HttpEntity resEntity = response.getEntity();
if(resEntity != null)
{
result = EntityUtils.toString(resEntity,charset);
if (resEntity != null) {
result = EntityUtils.toString(resEntity, charset);
}
}
}catch(Exception ex)
{
} catch (Exception ex) {
ex.printStackTrace();
}
return result;
}
public static String dopost(String url, String json) throws ClientProtocolException,IOException {
String result=null;
public static String dopost(String url, String json) throws ClientProtocolException, IOException {
String result = null;
String APPLICATION_JSON = "application/json";
String charset="UTF-8";
String charset = "UTF-8";
// 将JSON进行UTF-8编码,以便传输中文
String encoderJson = URLEncoder.encode(json, charset);
CloseableHttpClient httpclient = HttpClients.createDefault();
......@@ -409,15 +395,15 @@ public class HttpClientUtils {
httppost.addHeader(HTTP.CONTENT_TYPE, APPLICATION_JSON);
StringEntity stringEntity = new StringEntity(encoderJson);
stringEntity.setContentType("text/json");
stringEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,APPLICATION_JSON));
stringEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, APPLICATION_JSON));
httppost.setEntity(stringEntity);
//System.out.println("executing request " + httppost.getURI());
CloseableHttpResponse response = httpclient.execute(httppost);
if (response.getStatusLine().getStatusCode() == 200) {
HttpEntity httpEntity = response.getEntity();
if (httpEntity != null) {
System.out.println("Response content: "+ EntityUtils.toString(httpEntity, charset));
result = EntityUtils.toString(httpEntity,charset);
System.out.println("Response content: " + EntityUtils.toString(httpEntity, charset));
result = EntityUtils.toString(httpEntity, charset);
}
} else {
httppost.abort();
......@@ -433,24 +419,26 @@ public class HttpClientUtils {
return result;
}
/**http请求资源,json不编码
/**
* http请求资源,json不编码
*
* @param url
* @param json
* @return
* @throws ClientProtocolException
* @throws IOException
*/
public static String dopostNoEncode(String url, String json) throws ClientProtocolException,IOException {
String result=null;
public static String dopostNoEncode(String url, String json) throws ClientProtocolException, IOException {
String result = null;
String APPLICATION_JSON = "application/json";
String charset="UTF-8";
String charset = "UTF-8";
// 将JSON进行UTF-8编码,以便传输中文
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(url);
httppost.addHeader(HTTP.CONTENT_TYPE, APPLICATION_JSON);
StringEntity stringEntity = new StringEntity(json, charset);
stringEntity.setContentType("text/json");
stringEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,APPLICATION_JSON));
stringEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, APPLICATION_JSON));
httppost.setEntity(stringEntity);
//System.out.println("executing request " + httppost.getURI());
CloseableHttpResponse response = httpclient.execute(httppost);
......@@ -458,7 +446,7 @@ public class HttpClientUtils {
HttpEntity httpEntity = response.getEntity();
if (httpEntity != null) {
//System.out.println("Response content: "+ EntityUtils.toString(httpEntity, charset));
result = EntityUtils.toString(httpEntity,charset);
result = EntityUtils.toString(httpEntity, charset);
}
} else {
httppost.abort();
......@@ -477,19 +465,17 @@ public class HttpClientUtils {
/**
* 发送 post请求访问本地应用并根据传递参数不同返回不同结果
* @return
*
* @return
* @throws IOException
* @throws ClientProtocolException
*/
public static String postJson(String url, com.alibaba.fastjson.JSONObject json)
{
String charset="UTF-8";
public static String postJson(String url, com.alibaba.fastjson.JSONObject json) {
String charset = "UTF-8";
CloseableHttpClient httpClient = null;
HttpPost httpPost = null;
String result = null;
try
{
try {
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(10000).setConnectTimeout(10000).build();//设置请求和传输超时时间
......@@ -499,23 +485,19 @@ public class HttpClientUtils {
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpPost.setEntity(se);
HttpResponse response = httpClient.execute(httpPost);
if(response != null)
{
if (response != null) {
HttpEntity resEntity = response.getEntity();
if(resEntity != null)
{
result = EntityUtils.toString(resEntity,charset);
if (resEntity != null) {
result = EntityUtils.toString(resEntity, charset);
}
}
}catch(Exception ex)
{
} catch (Exception ex) {
ex.printStackTrace();
}
return result;
}
/**
* get请求,返回字节数组
*
......@@ -561,16 +543,16 @@ public class HttpClientUtils {
try {
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(httpGet);
HttpEntity resEntity=null;
HttpEntity resEntity = null;
if (response.getStatusLine().getStatusCode() == 200) { // 请求成功状态
resEntity = response.getEntity();
}
if(resEntity != null){
if (resEntity != null) {
responseContent = EntityUtils.toByteArray(resEntity);
// result = EntityUtils.toString(resEntity,charset);
}
} catch (Exception e) {
LOGGER.info("异常捕捉请求结束时间:"+System.currentTimeMillis());
LOGGER.info("异常捕捉请求结束时间:" + System.currentTimeMillis());
e.printStackTrace();
LOGGER.info(e.getMessage());
}
......@@ -580,53 +562,52 @@ public class HttpClientUtils {
/**
* @discription:
* @param url 访问地址
* @param token 请求头中存放token
* @param json 请求数据体
* @return
* @discription:
* @date: 2019年10月25日
*/
public static byte[] postJsonDataByByte(String url, String token, String json){
public static byte[] postJsonDataByByte(String url, String token, String json) {
LOGGER.info("===================postJsonDataByByte start=======================");
LOGGER.info("url:"+url);
LOGGER.info("token:"+token);
LOGGER.info("json:"+json);
LOGGER.info("url:" + url);
LOGGER.info("token:" + token);
LOGGER.info("json:" + json);
String charset="UTF-8";
String charset = "UTF-8";
CloseableHttpClient httpClient = null;
HttpPost httpPost = null;
String result = null;
byte[] responseContent = null;
try
{
try {
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(50000).setConnectTimeout(50000).build();//设置请求和传输超时时间
httpPost.setConfig(requestConfig);
httpPost.setHeader("token", token);
StringEntity se = new StringEntity(json,"UTF-8");
StringEntity se = new StringEntity(json, "UTF-8");
se.setContentType("application/json");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpPost.setEntity(se);
LOGGER.info("请求开始时间:"+System.currentTimeMillis());
LOGGER.info("请求开始时间:" + System.currentTimeMillis());
HttpResponse response = httpClient.execute(httpPost);
LOGGER.info("请求结束时间:"+System.currentTimeMillis());
if(response != null){
LOGGER.info("请求结束时间:" + System.currentTimeMillis());
if (response != null) {
HttpEntity resEntity = response.getEntity();
if(response.getStatusLine().getStatusCode() == 200) {
if(resEntity != null){
if (response.getStatusLine().getStatusCode() == 200) {
if (resEntity != null) {
responseContent = EntityUtils.toByteArray(resEntity);
}
}else {
LOGGER.info("请求失败:"+EntityUtils.toString(resEntity,charset));
} else {
LOGGER.info("请求失败:" + EntityUtils.toString(resEntity, charset));
return responseContent;
}
}
}catch(Exception ex){
LOGGER.info("异常捕捉请求结束时间:"+System.currentTimeMillis());
} catch (Exception ex) {
LOGGER.info("异常捕捉请求结束时间:" + System.currentTimeMillis());
ex.printStackTrace();
LOGGER.info(ex.getMessage());
}
......@@ -636,29 +617,39 @@ public class HttpClientUtils {
/**
* 发送 getJsonForParam请求
* @author Bellamy
*/
public static String getJsonForParam(String url, Map<String, Object> paramMap) {
LOGGER.info("===================getJsonForParam start=======================");
LOGGER.info("===================Get request getJsonForParam start=======================");
LOGGER.info("url:" + url);
LOGGER.info("json:" + paramMap);
String result = null;
StringBuilder sb = new StringBuilder();
String fh = "";
if (paramMap != null) {
if (url.indexOf("?") == -1) {
fh = "?";
}
for (Entry<String, Object> entry : paramMap.entrySet()) {
sb.append("&");
sb.append(entry.getKey());
sb.append("=");
sb.append(entry.getValue());
}
}
if (StringUtils.isNotEmpty(sb)) {
fh += sb.toString().substring(1);
}
String requestUrl = url+sb.toString();
String requestUrl = url + fh;
CloseableHttpClient httpclient = HttpClients.createDefault();
try {
// 创建httpget.
HttpGet httpget = new HttpGet(requestUrl);
System.out.println("executing request " + httpget.getURI());
System.out.println("get executing request " + httpget.getURI());
// 执行get请求.
CloseableHttpResponse response = httpclient.execute(httpget);
// 获取响应实体
......@@ -685,7 +676,6 @@ public class HttpClientUtils {
}
public static void main(String[] args) throws Exception {
// 私钥
/*String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJzAfk55exxmvy3+pXsJINZEtmwUp6eBfDSl2YnT5bdJL3nzPnSjmaWsf8x9hR4QyGnvlV/Vo0sk36X7ATcqxfIn0+6W5f8IR4XtVDhxZsD/cK8nVThqFGQagmyNAwxP/wBnAXOy+fpwZrMOgqfosYmVsmImFWbHA87C4mx0bwoJAgMBAAECgYB4tlBOVIT3ITTW0cRT1HrCJxYoc1uMxk2FKbc1ycWceTKjgiu1nQtEp2ufaYYq2hfMZOEudRIUWygT5RFRj5HxLfL6Me3y6dtgyHvOVeMDNGAG+tsn8ObQCQjZ/hVKzFFgHlrHv5i4zX44im2IdvLqnV6cEUneduJfZAQT/XTGUQJBANAZbuTqlDRj/9ObGZEvaPe95FGAPNFEiNmRvLsCsRmruJA5h2ogwx8O4Yll5LylKV6C33Vws4pgAPBHvOzGTx0CQQDA1VYU4ihNyvMknFIAmMT2ojQmQ8ASX64hVFWY9ehf5JaJ+ZD1c1BvbrmubpIo7pPci50BmXnjq6EcxVML/VbdAkAwEH/FjczXYPV4yY0ZNIsZFZoDnQvvBdZZ8khWJWQEWt5RKYh2YcTPip9bHda8H6Wzd6TnOjWt00jENr2TLqadAkEAq0TQD/xOj8mR6xJsQtttFSE78EB8d9VDc5bT7+d5XLJKgoGGnnqtFkvh32uVpYVBDsFx0dneyLfHgSZBfISmgQJADZ71qrfCDvuoYNS4aOW52OL6LMC84Qi2EnZzl5OHkUuOv5jwBoOCRLEn0N999EMP6DBg8P5kg1llTq7bMG11ug==";
......
package com.jz.dmp.modules.controller.dataService;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListDto;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageAddReq;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageListQueryReq;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageUpdateReq;
import com.jz.dmp.modules.service.DmpOrgMangeService;
import com.jz.dmp.modules.service.DvRuleTService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
/**
* 数据服务组织管理
* 数据服务组织管理--调用gateway 接口
*
* @author Bellamy
* @since 2020-12-24 10:56:18
......@@ -17,11 +29,102 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/orgMange")
@Api(tags = "数据服务-组织管理")
public class DmpOrgMangeController {
private static Logger logger = LoggerFactory.getLogger(DmpOrgMangeController.class);
/**
* 服务对象
*/
@Autowired
private DmpOrgMangeService dmpOrgMangeService;
/**
* 列表分页查询
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@ApiOperation(value = "列表分页查询", notes = "列表分页查询")
@PostMapping(value = "/listPage")
public JsonResult getOrgListPage(@RequestBody @Validated OrganizationManageListQueryReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpOrgMangeService.queryOrgListPage(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 删除组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@ApiOperation(value = "删除组织", notes = "删除组织")
@GetMapping(value = "/delOrg")
@ApiImplicitParam(name = "id",value = "组织id",required = true)
public JsonResult delOrgById(@RequestParam long id, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpOrgMangeService.delOrgById(id);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 新增组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@ApiOperation(value = "新增组织", notes = "新增组织")
@PostMapping(value = "/addOrg")
public JsonResult addOrg(@RequestBody @Validated OrganizationManageAddReq req, HttpServletRequest httpRequest) {
if (StringUtils.isEmpty(req.getOrgName())) {
return JsonResult.error(ResultCode.PARAMS_ERROR,"组织名称不能为空!");
}
if (StringUtils.isEmpty(req.getOrgType())) {
return JsonResult.error(ResultCode.PARAMS_ERROR,"组织类型不能为空!");
}
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpOrgMangeService.addOrg(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 编辑组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@ApiOperation(value = "编辑组织", notes = "编辑组织")
@PostMapping(value = "/updateOrg")
public JsonResult updateOrg(@RequestBody @Validated OrganizationManageUpdateReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpOrgMangeService.updateOrg(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
}
\ No newline at end of file
package com.jz.dmp.modules.controller.dataService.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @ClassName: OrganizationManageAddReq
* @Description: 新增组织管理请求体
* @Author: Bellamy
* @Date 2021/1/16
* @Version 1.0
*/
@Data
@ApiModel("新增组织管理详情请求体")
public class OrganizationManageAddReq implements Serializable {
private static final long serialVersionUID = 3131683881168540907L;
@ApiModelProperty(value = "组织类型:INT 内部组织 OUT 外部组织", required = true)
@NotNull(message = "组织类型不能为空!")
@NotEmpty(message = "组织类型不能为空!")
private String orgType;
@ApiModelProperty(value = "组织名称", required = true)
@NotNull(message = "组织名称不能为空")
@NotEmpty(message = "组织名称不能为空!")
private String orgName;
@ApiModelProperty(value = "组织描述", required = false)
private String orgDesc;
@ApiModelProperty(value = "组织英文名称", required = false)
private String orgCnName;
@ApiModelProperty(value = "组织邮箱", required = false)
private String orgMail;
@ApiModelProperty(value = "联系方式", required = true)
@NotEmpty(message = "联系方式不能为空!")
private String orgPhone;
@ApiModelProperty(value = "状态(NORMAL-正常 FREEZE-冻结 CANCEL-注销)", required = true)
private String status;
@ApiModelProperty(value = "联系人", required = true)
private String createUser;
}
package com.jz.dmp.modules.controller.dataService.bean;
import com.jz.common.bean.BasePageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @ClassName: DmpOrgMangeService
* @Description: 组织管理列表查询请求体
* @Author: Bellamy
* @Date 2021/1/16
* @Version 1.0
*/
@Data
@ApiModel("组织管理列表查询请求体")
public class OrganizationManageListQueryReq extends BasePageBean implements Serializable {
@ApiModelProperty(value = "组织名称")
private String orgName;
@ApiModelProperty(value = "组织编码(组织唯一标识)")
private String orgCode;
}
package com.jz.dmp.modules.controller.dataService.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @ClassName: OrganizationManageUpdateReq
* @Description: 更新组织管理请求体
* @Author: Bellamy
* @Date 2021/1/16
* @Version 1.0
*/
@Data
@ApiModel("更新组织管理请求体")
public class OrganizationManageUpdateReq implements Serializable {
@ApiModelProperty(value = "组织id",required = true)
@NotNull(message = "组织id不能为空")
private Long id;
/* @ApiModelProperty(value = "组织名称",required = true)
@NotNull(message = "组织名称不能为空")
private String orgName;*/
@ApiModelProperty(value = "组织描述",required = false)
private String orgDesc;
@ApiModelProperty(value = "状态(NORMAL-正常 FREEZE-冻结 CANCEL-注销)",required = false)
private String status;
@ApiModelProperty(value = "组织英文名称",required = false)
private String orgCnName;
@ApiModelProperty(value = "组织邮箱",required = false)
private String orgMail;
@ApiModelProperty(value = "组织电话",required = false)
private String orgPhone;
@ApiModelProperty(value = "备注",required = false)
private String remark;
@ApiModelProperty(value = "创建用户",required = false)
private String updateUser;
}
package com.jz.dmp.modules.service;
import com.jz.common.constant.JsonResult;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageAddReq;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageListQueryReq;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageUpdateReq;
/**
* @ClassName: DmpOrgMangeService
* @Description: 数据服务组织管理
......@@ -8,4 +13,40 @@ package com.jz.dmp.modules.service;
* @Version 1.0
*/
public interface DmpOrgMangeService {
/**
* 列表分页查询
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
JsonResult queryOrgListPage(OrganizationManageListQueryReq req) throws Exception;
/**
* 删除组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
JsonResult delOrgById(long id) throws Exception;
/**
* 新增组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
JsonResult addOrg(OrganizationManageAddReq req) throws Exception;
/**
* 编辑组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
JsonResult updateOrg(OrganizationManageUpdateReq req) throws Exception;
}
package com.jz.dmp.modules.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.jz.common.constant.JsonResult;
import com.jz.common.utils.web.HttpClientUtils;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageAddReq;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageListQueryReq;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageUpdateReq;
import com.jz.dmp.modules.service.DmpOrgMangeService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @ClassName: DmpOrgMangeServiceImpl
* @Description: 数据服务组织管理
......@@ -13,5 +27,119 @@ import org.springframework.stereotype.Service;
@Service("dmpOrgMangeService")
public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
private static Logger logger = LoggerFactory.getLogger(DmpOrgMangeServiceImpl.class);
//列表分页查询url
private static final String orgListPage = "/api/organization/listOrg";
//删除组织url
private static final String delOrg = "/api/organization/logoutOrg";
//新增组织url
private static final String addOrg = "/api/organization/add";
//编辑组织url
private static final String updateOrg = "/api/organization/update";
@Value("${spring.gateway-url}")
private String gatewayUrl;
/**
* 列表分页查询
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@Override
public JsonResult queryOrgListPage(OrganizationManageListQueryReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + orgListPage;
if (StringUtils.isNotEmpty(req.getOrgName())) {
req.setOrgName(req.getOrgName().trim());
}
String resultData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(resultData)) {
throw new RuntimeException("查询失败!");
}
logger.info("#################组织管理列数据{}" + resultData);
Map jsonObject = JSONObject.parseObject(resultData);
if (jsonObject != null) {
result.setData(jsonObject.get("data"));
/*Map records = JSONObject.parseObject(jsonObject.get("data").toString());
List<Map> list = (List<Map>) records.get("records");*/
}
return result;
}
/**
* 删除组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@Override
public JsonResult delOrgById(long id) throws Exception {
Map params = new HashMap();
params.put("id", id);
String url = gatewayUrl + delOrg;
String returnData = HttpClientUtils.getJsonForParam(url, params);
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("删除失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
}
return JsonResult.error("删除失败!");
}
/**
* 新增组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@Override
public JsonResult addOrg(OrganizationManageAddReq req) throws Exception {
String url = gatewayUrl + addOrg;
String returnData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("新增失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
}
logger.info(map.get("message").toString());
return JsonResult.error(map.get("message").toString());
}
/**
* 编辑组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@Override
public JsonResult updateOrg(OrganizationManageUpdateReq req) throws Exception {
String url = gatewayUrl + updateOrg;
String returnData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("编辑失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
}
logger.info(map.get("message").toString());
return JsonResult.error(map.get("message").toString());
}
}
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