package com.lyms.talkonlineweb.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fasterxml.jackson.databind.ser.Serializers;
import com.lyms.talkonlineweb.domain.LymsTkrecord;
import com.lyms.talkonlineweb.result.BaseResponse;
import com.lyms.talkonlineweb.service.LymsTkrecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping("com")
public class CommonController {
@Autowired
private LymsTkrecordService lymsTkrecordService;
@GetMapping("endTalk")
public BaseResponse endTalk(LymsTkrecord tkrecord){
BaseResponse baseResponse=new BaseResponse();
tkrecord.setStat(0);
baseResponse.setErrorcode(1);
int updateby=tkrecord.getUpdatedby();
tkrecord.setUpdatedby(null);
List<LymsTkrecord> tLst=lymsTkrecordService.list(Wrappers.query(tkrecord).orderByDesc("createdtime"));
if (tLst.size()>0){
tkrecord=tLst.get(0);
tkrecord.setStat(1);
tkrecord.setUpdatedtime(new Date());
tkrecord.setUpdatedby(updateby);
boolean f=lymsTkrecordService.saveOrUpdate(tkrecord);
baseResponse.setErrorcode(f==true?0:1);
}
return baseResponse;
}
}