| | |
| | | |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.system.domain.Employee; |
| | | import com.ruoyi.system.domain.SysVisitorMachine; |
| | | import com.ruoyi.system.dto.ApiVisitorMachineRequest; |
| | | import com.ruoyi.system.dto.CardVerifyRequest; |
| | | import com.ruoyi.system.dto.EmployeeDto; |
| | | import com.ruoyi.system.dto.SysVisitorMachineDetailRequest; |
| | | import com.ruoyi.system.mapper.EmployeeMapper; |
| | | import com.ruoyi.system.mapper.SysVisitorMachineMapper; |
| | | import com.ruoyi.system.service.EmployeeVerifyService; |
| | | import com.ruoyi.system.service.ISysVisitorMachineService; |
| | | import com.ruoyi.system.vo.SysVisitorMachineVO; |
| | | import com.ruoyi.web.controller.tool.ImageUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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 javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 接待人(被访者)刷卡验证接口。 |
| | | * 数据源:t_employee 员工管理表(含内部员工及已授权的外部人员)。 |
| | | */ |
| | | @Api(tags = "接待人验证接口") |
| | | @Api(tags = "接待人验证接口-查询所有员工接口") |
| | | @RestController |
| | | @RequestMapping("/api/employee/verify") |
| | | public class EmployeeVerifyController extends BaseController { |
| | | |
| | | @Resource |
| | | private EmployeeVerifyService employeeVerifyService; |
| | | @Resource |
| | | private EmployeeMapper employeeMapper; |
| | | @Autowired |
| | | private SysVisitorMachineMapper visitorMachineMapper; |
| | | |
| | | /** |
| | | * 刷卡验证:现场读卡器读取卡号后调用本接口,与接待人绑定的卡号比对。 |
| | |
| | | public AjaxResult verifyByCard(@RequestBody @Valid CardVerifyRequest request) { |
| | | return employeeVerifyService.verifyByCard(request); |
| | | } |
| | | |
| | | /** |
| | | * 刷卡验证:现场读卡器读取卡号后调用本接口,与接待人绑定的卡号比对。 |
| | | */ |
| | | @PostMapping("/allEmployee") |
| | | @ApiOperation(value = "查询所有员工接口", notes = "必传设备ID") |
| | | public AjaxResult getAllEmployee(@RequestBody @Valid ApiVisitorMachineRequest request) { |
| | | SysVisitorMachine detail = visitorMachineMapper.checkDeviceIdUnique(request.getMachineId(),null); |
| | | if (detail == null || !detail.getEnabled()) { |
| | | throw new ServiceException("未找到有效设备"); |
| | | } |
| | | |
| | | List<Employee> employees = employeeMapper.selectAllEnabled(); |
| | | if (employees == null || employees.isEmpty()) { |
| | | return success(new ArrayList<>()); |
| | | } |
| | | |
| | | List<EmployeeDto> employeeDtoList = employees.stream() |
| | | .map(employee -> { |
| | | EmployeeDto dto = new EmployeeDto(); |
| | | BeanUtils.copyProperties(employee, dto); |
| | | |
| | | // 将图片地址转为 Base64 |
| | | if (StringUtils.isNotEmpty(employee.getFaceImage())) { |
| | | String base64 = ImageUtil.imageUrlToBase64(employee.getFaceImage()); |
| | | dto.setFaceImage(base64); |
| | | } |
| | | |
| | | return dto; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | |
| | | return success(employeeDtoList); |
| | | } |
| | | } |