package com.example.web.controller; import com.example.web.service.FollowUpService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/api/followup") public class FollowupController { @Autowired private FollowUpService followUpService; /** * 根据电话号码获取跟进信息 * @param phoneNumber 电话号码 * @param dataSource 数据源(primary或wechat) * @return 跟进信息 */ @GetMapping("/get") public ResponseEntity getFollowUp( @RequestParam String phoneNumber) { try { String followup = followUpService.getFollowUpByPhone(phoneNumber); return ResponseEntity.ok(followup); } catch (Exception e) { return ResponseEntity.internalServerError().body("获取跟进信息失败:" + e.getMessage()); } } /** * 保存跟进信息 * @param phoneNumber 电话号码 * @param followup 跟进信息 * @return 保存结果 */ @PostMapping("/save") public ResponseEntity saveFollowUp( @RequestParam String phoneNumber, @RequestParam String followup) { try { boolean result = followUpService.saveFollowUp(phoneNumber, followup); if (result) { return ResponseEntity.ok("跟进信息保存成功"); } else { return ResponseEntity.badRequest().body("跟进信息保存失败"); } } catch (Exception e) { return ResponseEntity.internalServerError().body("保存跟进信息失败:" + e.getMessage()); } } }