You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wx-dump-MeiFox/wx-dump-admin/src/main/java/com/xcs/wx/controller/ContactController.java

72 lines
2.8 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.xcs.wx.controller; // 定义了控制器所在的包名
import com.xcs.wx.domain.dto.ContactDTO; // 导入联系人数据传输对象
import com.xcs.wx.domain.vo.*; // 导入所有联系人相关的视图对象VO
import com.xcs.wx.service.ContactService; // 导入联系人服务接口
import lombok.RequiredArgsConstructor; // 导入Lombok提供的注解用于自动生成final字段的构造器
import org.springframework.web.bind.annotation.GetMapping; // 导入用于定义GET请求的注解
import org.springframework.web.bind.annotation.RequestMapping; // 导入用于定义请求映射的注解
import org.springframework.web.bind.annotation.RestController; // 导入用于定义REST控制器的注解
import java.util.List; // 导入List接口
/**
* 联系人 Controller
*
* @author xcs
* @date 2023年12月22日 14时16分
**/
@RestController // 定义一个REST风格的控制器返回的数据会自动转换为JSON格式
@RequiredArgsConstructor // 使用Lombok注解自动生成包含所有final字段的构造函数
@RequestMapping("/api/contact") // 定义类级别的请求映射所有方法的URL都会以/api/contact开头
public class ContactController {
private final ContactService contactService; // 注入ContactService用于业务逻辑处理
/**
* 查询联系人
*
* @param contactDTO 请求参数
* @return ResponseVO
*/
@GetMapping("/list") // 定义GET请求的映射访问路径为/api/contact/list
public ResponseVO<List<ContactVO>> list(ContactDTO contactDTO) {
// 调用contactService的方法查询联系人
PageVO<ContactVO> pageVO = contactService.queryContact(contactDTO);
// 返回包含联系人列表和分页信息的响应对象
return ResponseVO.ok(pageVO.getRecords(), pageVO.getCurrent(), pageVO.getTotal());
}
/**
* 查询所有联系人
*
* @return ResponseVO
*/
@GetMapping("/all") // 定义GET请求的映射访问路径为/api/contact/all
public ResponseVO<List<AllContactVO>> all() {
// 调用contactService的方法查询所有联系人
return ResponseVO.ok(contactService.queryAllContact());
}
/**
* 联系人标签
*
* @return ContactLabelVO
*/
@GetMapping("/label") // 定义GET请求的映射访问路径为/api/contact/label
public ResponseVO<List<ContactLabelVO>> label() {
// 调用contactService的方法查询联系人标签
return ResponseVO.ok(contactService.queryContactLabel());
}
/**
* 导出联系人
*
* @return ResponseVO
*/
@GetMapping("/export") // 定义GET请求的映射访问路径为/api/contact/export
public ResponseVO<String> export() {
// 调用contactService的方法导出联系人
return ResponseVO.ok(contactService.exportContact());
}
}