Commit 2e8893bd authored by 赵啸非's avatar 赵啸非

修改部分接口返回参数

parent 08b0e4c7
package com.lilosoft.api.controller;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lilosoft.api.api.RobotApi;
import com.lilosoft.api.bean.RobotCaseRecord;
import com.lilosoft.api.bean.receive.ReceiveMsgInfo;
import com.lilosoft.api.service.ComplexService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.HashMap;
@RestController
@Slf4j
@RequestMapping("complex")
public class ReceiveMsgController {
@Autowired
private ComplexService complexService;
@Autowired
private RobotApi robotApi;
@PostMapping("receiveMessage")
public String refreshMessage(@RequestBody HashMap<String, String> text) {
JSONObject jsonObject = new JSONObject();
RobotCaseRecord caseRecord = new RobotCaseRecord();
caseRecord.setId(IdUtil.simpleUUID());
caseRecord.setContent(text.get("content"));
caseRecord.setSendFlag("0");
caseRecord.setUpdateTime(new Date());
try {
robotApi.saveRecord(caseRecord);
String content = text.get("content");
ReceiveMsgInfo receiveMsgInfo = JSON.parseObject(content, ReceiveMsgInfo.class);
complexService.windowApply(receiveMsgInfo);
robotApi.saveRecord(caseRecord);
jsonObject.put("code", 1);
jsonObject.put("msg", "成功");
} catch (Exception e) {
caseRecord.setSendFlag("1");
caseRecord.setMsg(e.getMessage());
robotApi.saveRecord(caseRecord);
log.error(e.getMessage());
jsonObject.put("code", -1);
jsonObject.put("msg", e.getMessage());
}
return jsonObject.toJSONString();
}
}
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