diff --git a/src/main/java/com/aos/fileidentify/common/ResultDTO.java b/src/main/java/com/aos/fileidentify/common/ResultDTO.java new file mode 100644 index 0000000..6e5a975 --- /dev/null +++ b/src/main/java/com/aos/fileidentify/common/ResultDTO.java @@ -0,0 +1,46 @@ +package com.aos.fileidentify.common; + +import lombok.Data; +import lombok.experimental.SuperBuilder; + +@Data +@SuperBuilder +public class ResultDTO { + + + private boolean success; + private int code; + private T data; + private String msg; + + public ResultDTO() { + } + + public ResultDTO(boolean success, T data) { + this.success = success; + this.data = data; + } + + public ResultDTO(boolean success, int code, T data, String msg) { + this.success = success; + this.code = code; + this.data = data; + this.msg = msg; + } + + public ResultDTO(boolean success, int code, String msg) { + this.success = success; + this.code = code; + this.msg = msg; + } + + public ResultDTO(boolean success, String msg) { + this.success = success; + this.msg = msg; + } + + public boolean isSuccess() { + return success; + } + +} diff --git a/src/main/java/com/aos/fileidentify/controller/EmployeeController.java b/src/main/java/com/aos/fileidentify/controller/EmployeeController.java index 7ef1ee5..a0caa92 100644 --- a/src/main/java/com/aos/fileidentify/controller/EmployeeController.java +++ b/src/main/java/com/aos/fileidentify/controller/EmployeeController.java @@ -1,5 +1,6 @@ package com.aos.fileidentify.controller; +import com.aos.fileidentify.common.ResultDTO; import com.aos.fileidentify.entity.Employee; import com.aos.fileidentify.service.EmployeeService; @@ -41,7 +42,7 @@ public class EmployeeController { */ @ApiOperation(value = "员工所有数据查询") @GetMapping(value = "/list") - public List getAllEmployee() { + public ResultDTO> getAllEmployee() { return this.employeeService.getAllEmployee(); } diff --git a/src/main/java/com/aos/fileidentify/service/EmployeeService.java b/src/main/java/com/aos/fileidentify/service/EmployeeService.java index 0d0c1db..5bed169 100644 --- a/src/main/java/com/aos/fileidentify/service/EmployeeService.java +++ b/src/main/java/com/aos/fileidentify/service/EmployeeService.java @@ -1,5 +1,6 @@ package com.aos.fileidentify.service; +import com.aos.fileidentify.common.ResultDTO; import com.aos.fileidentify.entity.Employee; import java.util.List; @@ -21,5 +22,5 @@ public interface EmployeeService { * @return the all employee * @since 0.0.1 */ - List getAllEmployee(); + ResultDTO> getAllEmployee(); } diff --git a/src/main/java/com/aos/fileidentify/service/impl/EmployeeServiceImpl.java b/src/main/java/com/aos/fileidentify/service/impl/EmployeeServiceImpl.java index 1cd4384..2358294 100644 --- a/src/main/java/com/aos/fileidentify/service/impl/EmployeeServiceImpl.java +++ b/src/main/java/com/aos/fileidentify/service/impl/EmployeeServiceImpl.java @@ -1,10 +1,12 @@ package com.aos.fileidentify.service.impl; +import com.aos.fileidentify.common.ResultDTO; import com.aos.fileidentify.entity.Employee; import com.aos.fileidentify.mapper.EmployeeMapper; import com.aos.fileidentify.service.EmployeeService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.sun.net.httpserver.Authenticator; import org.springframework.stereotype.Service; import java.util.List; @@ -30,8 +32,7 @@ public class EmployeeServiceImpl implements EmployeeService { private final EmployeeMapper employeeMapper; @Override - public List getAllEmployee() { - QueryWrapper queryWrapper = new QueryWrapper<>(); - return employeeMapper.selectList(queryWrapper.lambda().eq(Employee::getEmployeeKey, "1f1c8258ba2226e6a6851e62741418d7")); + public ResultDTO> getAllEmployee() { + return new ResultDTO<>(true, 20000, employeeMapper.selectList(new QueryWrapper<>()), null); } }