瀏覽代碼

待办事项接口:添加待办 完成待办

tags/24080901
wangrenkang 11 月之前
父節點
當前提交
b1495ca1b2
共有 3 個文件被更改,包括 138 次插入0 次删除
  1. +83
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/todo/TodoServiceClient.java
  2. +32
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/AddSingleWkHandleDTO.java
  3. +23
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/TodoDto.java

+ 83
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/todo/TodoServiceClient.java 查看文件

@@ -0,0 +1,83 @@
package com.hz.pm.api.external.todo;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.http.Method;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.hz.pm.api.external.todo.dto.AddSingleWkHandleDTO;
import com.hz.pm.api.external.todo.dto.TodoDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
* @author 王仁康
* @date 2024-01-02 16:55:51
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class TodoServiceClient {

/**
* 外部系统域名
*/
@Value("${sms.client-url:}")
private String todoUrl;

// 发送待办
public static final String TODO_ADD = "/single_wk_handle/addWkhandle";

// 完成待办
public static final String TODO_COMPLETE = "/single_wk_handle/completeHandle";


/**
* 添加待办方法
* @param addSingleWkHandleDTO
* @return 接口返回待办ID
*/
public TodoDto addTodo(AddSingleWkHandleDTO addSingleWkHandleDTO) {
String url = todoUrl + TODO_ADD;
Map<String,Object> map = new HashMap<>();
JSONObject json = (JSONObject) JSONObject.toJSON(addSingleWkHandleDTO.getParams());
String jsonString = JSON.toJSONString(json);
map.put("params", jsonString);
map.put("wkContent",addSingleWkHandleDTO.getWkContent());
map.put("wkType",addSingleWkHandleDTO.getWkType());
map.put("wkUser",addSingleWkHandleDTO.getWkUser());
String responseResult = HttpUtil.post(url, JSON.toJSONString(map));
TodoDto todoDto = JSON.parseObject(responseResult, new TypeReference<TodoDto>() {
});
// return JSON.parseObject(responseResult, new TypeReference<HashMap<String, String>>() {
// }).get("data");
return todoDto;
}

/**
* 完成待办
* @param wkhandleId 待办ID
*/
public TodoDto completeTodo(String wkhandleId){
String url = todoUrl + TODO_COMPLETE;
HashMap<String,Object> map = new HashMap<>();
map.put("wkhandleId",wkhandleId);
// 发送PUT请求
HttpRequest request = HttpUtil.createRequest(Method.PUT,url)
.form("wkhandleId",wkhandleId);
HttpResponse response = request.execute();
String responseBody = response.body();
TodoDto todoDto = JSON.parseObject(responseBody, new TypeReference<TodoDto>() {
});
return todoDto;
}


}

+ 32
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/AddSingleWkHandleDTO.java 查看文件

@@ -0,0 +1,32 @@
package com.hz.pm.api.external.todo.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
* @author 王仁康
* @date 2024-01-02 16:55:51
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AddSingleWkHandleDTO implements Serializable {

private static final long serialVersionUID = -2067546352159912820L;

// 待办参数,ObjectJson字符串
private Object params;

// 待办内容,默认取待办配置中的
private String wkContent;

// 待办类型
private String wkType;

// 待办用户
private String wkUser;

}

+ 23
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/TodoDto.java 查看文件

@@ -0,0 +1,23 @@
package com.hz.pm.api.external.todo.dto;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;

/**
* @author 王仁康
* @date 2024-01-02 17:04:09
*/
@AllArgsConstructor
@Data
public class TodoDto implements Serializable {

private static final long serialVersionUID = 241303725133613373L;

private Integer code;

private String msg;

private String data;
}

Loading…
取消
儲存