|
@@ -6,9 +6,10 @@ import com.huimv.apiservice.service.PigService;
|
|
|
import com.huimv.common.utils.PageUtils;
|
|
|
import com.huimv.common.utils.R;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.Email;
|
|
|
import javax.validation.constraints.NotBlank;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
@@ -20,6 +21,7 @@ import java.util.Objects;
|
|
|
@CrossOrigin
|
|
|
@RestController
|
|
|
@RequestMapping("/pig")
|
|
|
+@Validated
|
|
|
public class PigController {
|
|
|
|
|
|
@Autowired
|
|
@@ -35,7 +37,7 @@ public class PigController {
|
|
|
//@Limit(key = "pig_getPigInfo",name = "pig/getPigInfo",prefix = "apiservice")
|
|
|
@GetMapping("/getPigInfo")
|
|
|
public R getPigInfo(@RequestParam(value = "accessToken") String accessToken,
|
|
|
- @RequestParam("pigEarTagNo") String pigEarTagNo) {
|
|
|
+ @NotBlank(message = "耳标号不能为空!") @RequestParam("pigEarTagNo") String pigEarTagNo) {
|
|
|
Map<String, Object> map = pigService.getPigInfoByEarTagNo(pigEarTagNo);
|
|
|
return Objects.requireNonNull(R.ok().put("code", 1000)).put("data", map);
|
|
|
}
|
|
@@ -50,7 +52,7 @@ public class PigController {
|
|
|
*/
|
|
|
@GetMapping("/getImage")
|
|
|
public R getImage(@RequestParam(value = "accessToken") String accessToken,
|
|
|
- @Valid @NotBlank @RequestParam("pigEarTagNo") String pigEarTagNo) {
|
|
|
+ @NotBlank(message = "耳标号111不能为空!") @RequestParam("pigEarTagNo") String pigEarTagNo) {
|
|
|
PigImageVo pigImageVo = pigService.getImageByEarTagNo(pigEarTagNo);
|
|
|
return Objects.requireNonNull(R.ok().put("code", 1000)).put("data", pigImageVo);
|
|
|
}
|
|
@@ -64,7 +66,7 @@ public class PigController {
|
|
|
*/
|
|
|
@GetMapping("/getListByBreed")
|
|
|
public R getListByBreed(@RequestParam(value = "accessToken") String accessToken,
|
|
|
- @RequestParam("breedName") String breedName) {
|
|
|
+ @RequestParam("breedName") @NotBlank(message = "品种名称不能为空!") String breedName) {
|
|
|
PageUtils page = pigService.getListByBreed(breedName);
|
|
|
return Objects.requireNonNull(R.ok().put("code", 1000)).put("page", page);
|
|
|
}
|
|
@@ -78,7 +80,7 @@ public class PigController {
|
|
|
*/
|
|
|
@GetMapping("/getIndoorEnv")
|
|
|
public R getIndoorEnv(@RequestParam(value = "accessToken") String accessToken,
|
|
|
- @RequestParam("pigEarTagNo") String pigEarTagNo) {
|
|
|
+ @NotBlank(message = "耳标号不能为空!") @RequestParam("pigEarTagNo") String pigEarTagNo) {
|
|
|
EnvVo envVo = pigService.getIndoorEnv(pigEarTagNo);
|
|
|
return Objects.requireNonNull(R.ok().put("code", 1000)).put("data", envVo);
|
|
|
}
|
|
@@ -92,7 +94,7 @@ public class PigController {
|
|
|
*/
|
|
|
@GetMapping("/adopt")
|
|
|
public R adopt(@RequestParam(value = "accessToken") String accessToken,
|
|
|
- @RequestParam("pigEarTagNo") String pigEarTagNo) {
|
|
|
+ @RequestParam("pigEarTagNo") @NotBlank(message = "耳标号不能为空!") String pigEarTagNo) {
|
|
|
pigService.adopt(pigEarTagNo);
|
|
|
return Objects.requireNonNull(R.ok().put("code", 1000)).put("msg", "认养成功!");
|
|
|
}
|
|
@@ -106,7 +108,7 @@ public class PigController {
|
|
|
*/
|
|
|
@GetMapping("/outFence")
|
|
|
public R outFence(@RequestParam(value = "accessToken", required = false) String accessToken,
|
|
|
- @RequestParam("pigEarTagNo") String pigEarTagNo,
|
|
|
+ @RequestParam("pigEarTagNo") @NotBlank(message = "耳标号不能为空!") String pigEarTagNo,
|
|
|
@RequestParam("status") Integer status) {
|
|
|
pigService.outFence(pigEarTagNo,status);
|
|
|
return Objects.requireNonNull(R.ok().put("code", 1000)).put("msg", "更新出栏状态成功!");
|