package com.objecteye.controller; import com.objecteye.common.CommonResult; import com.objecteye.entity.PageResult; import com.objecteye.entity.SyPersonnel; import com.objecteye.service.PersonnelService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.util.Map; /** * controller * * @author Administrator */ @RestController @RequestMapping("/personnel") @Api(tags = "PersonnelController", description = "人像库人像管理") @CrossOrigin public class PersonnelController { @Autowired private PersonnelService personnelService; /** * 上传图片 * * @param uploadFiles * @param featureId * @return */ @ApiOperation("人像库上传多条数据") @RequestMapping(value = "/uploadfiles", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult uploadfiles(MultipartFile[] uploadFiles, @RequestParam(name = "featureId") int featureId) { String msg = personnelService.uploadFiles(uploadFiles, featureId); if (uploadFiles != null && uploadFiles.length > 0) { if (null != msg) { return CommonResult.success("操作成功", msg); } else { return null; } } return CommonResult.failed("上传文件不能为空"); } /** * 修改 * * @param personnel * @return */ @ApiOperation("更新单条人像信息") @RequestMapping(value = "/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult update(@RequestBody SyPersonnel personnel) { try { personnelService.update(personnel); return CommonResult.success("操作成功"); } catch (Exception e) { e.printStackTrace(); return CommonResult.failed(); } } /** * 获取实体 * * @return */ @ApiOperation("查找单条人像信息") @RequestMapping(value = "/findOne", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult findOne(@RequestBody Map map) { Integer id = map.get("id"); SyPersonnel one = personnelService.findOne(id); if (one != null) { return CommonResult.success(one); } return CommonResult.success("", "id无效"); } /** * 批量删除 * * @param map * @return */ @ApiOperation("批量删除") @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult delete(@RequestBody Map map) { try { int[] ids = map.get("ids"); personnelService.delete(ids); return CommonResult.success("操作成功"); } catch (Exception e) { e.printStackTrace(); return CommonResult.failed(); } } /** * 查询+分页 * * @param * @return */ @ApiOperation("根据人像库、人像名、人像创建时间进行分页查询人像底库数据") @RequestMapping(value = "/search", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public CommonResult search(@RequestParam int currentpage, @RequestParam int pagevolume, @RequestParam int fid, @RequestParam String name) {//@RequestBody PagePara pagePara PageResult page = personnelService.findPage(fid, name, currentpage, pagevolume); /*if (page != null) { return CommonResult.success(page); } return CommonResult.success("", "无符合条件的数据");*/ if (page.gettotal() == 0) { return CommonResult.failed("无符合条件的数据"); } return CommonResult.success(page); } }