MainController.java 2.04 KB
package com.viontech.match.controller;

import com.viontech.keliu.model.FaceFeature;
import com.viontech.keliu.model.Person;
import com.viontech.match.entity.vo.RequestVo;
import com.viontech.match.entity.vo.ResponseVo;
import com.viontech.match.service.PersonService;
import com.viontech.match.service.PoolService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

/**
 * .
 *
 * @author 谢明辉
 * @date 2020/11/23
 */
@RestController
@RequestMapping("/alg")
@Slf4j
public class MainController {

    @Resource
    private PersonService personService;
    @Resource
    private PoolService poolService;

    @PostMapping
    public ResponseVo all(@RequestBody RequestVo requestVo) throws Exception {
        String rid = requestVo.getRid();
        try {
            switch (requestVo.getCommand()) {
                case AddPersonPool:
                    return poolService.createPool(requestVo);
                case DelPersonPool:
                    return poolService.deletePool(requestVo);
                case ModifyPersonPool:
                    return poolService.modifyPool(requestVo);
                case QueryPersonPool:
                    return poolService.queryPool(requestVo);
                case MatchPerson:
                    return personService.matchPerson(requestVo);
                case UpdatePerson:
                    return personService.updatePerson(requestVo);
                default:
                    return ResponseVo.commandNotFound(rid);
            }
        } catch (Exception e) {
            log.error("", e);
            return ResponseVo.error(rid, e.getMessage());
        }
    }

    @GetMapping("/pools")
    public Object getPools() {
        try {
            return poolService.queryPoolInfo(null);
        } catch (IOException e) {
            return ResponseVo.error("error", e.getMessage());
        }
    }
}