PersonnelController.java
3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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") String 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<String, Object> map) {
String id = (String) 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<String, Object> map) {
try {
String[] ids = (String[]) 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<SyPersonnel> pagePara
PageResult page = personnelService.findPage(fid, name, currentpage, pagevolume);
if (page.gettotal() == 0) {
return CommonResult.failed("无符合条件的数据");
}
return CommonResult.success(page);
}
}