|
@@ -1,13 +1,25 @@
|
|
|
package com.huimv.guowei.admin.controller;
|
|
|
|
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.huimv.guowei.admin.common.utils.Result;
|
|
|
+import com.huimv.guowei.admin.common.utils.ResultCode;
|
|
|
+import com.huimv.guowei.admin.entity.BaseDuckInfo;
|
|
|
+import com.huimv.guowei.admin.service.IBaseDuckInfoService;
|
|
|
+import com.huimv.guowei.admin.utils.UploadImage;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 前端控制器
|
|
|
+ * 前端控制器
|
|
|
* </p>
|
|
|
*
|
|
|
* @author author
|
|
@@ -15,6 +27,84 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/base-duck-info")
|
|
|
+@CrossOrigin
|
|
|
public class BaseDuckInfoController {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IBaseDuckInfoService duckInfoService;
|
|
|
+ @Autowired
|
|
|
+ private UploadImage uploadImage;
|
|
|
+
|
|
|
+ @RequestMapping("/listDuck")
|
|
|
+ public Result listDuck(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
|
|
|
+ return new Result(ResultCode.SUCCESS, duckInfoService.listDuck(httpServletRequest, paramsMap));
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/deleteDuck")
|
|
|
+ public Result deleteDuck(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
|
|
|
+ String id = paramsMap.get("id");
|
|
|
+ QueryWrapper<BaseDuckInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("id", id);
|
|
|
+ BaseDuckInfo one = duckInfoService.getOne(queryWrapper);
|
|
|
+ if (one.getIsCage() == 1) {
|
|
|
+ duckInfoService.removeById(paramsMap.get("id"));
|
|
|
+ return new Result(10000, "删除成功!", true);
|
|
|
+ } else {
|
|
|
+ return new Result(10001, "鸭子未出笼,不可删除!", false);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/addDuck")
|
|
|
+ public void addDuck(HttpServletRequest httpServletRequest, @RequestParam(name = "imgUrl") MultipartFile imgUrl,
|
|
|
+ @RequestParam(name = "id") String id,
|
|
|
+ @RequestParam(name = "duckBreed") String duckBreed,
|
|
|
+ @RequestParam(name = "duckSex") String duckSex,
|
|
|
+ @RequestParam(name = "duckBirthPlace") String duckBirthPlace,
|
|
|
+ @RequestParam(name = "duckBirthDay") String duckBirthDay,
|
|
|
+ @RequestParam(name = "genotype") String genotype,
|
|
|
+ @RequestParam(name = "nowWeight") String nowWeight,
|
|
|
+ @RequestParam(name = "unitId") String unitId,
|
|
|
+ @RequestParam(name = "breedEnv") String breedEnv,
|
|
|
+ @RequestParam(name = "hatchRate",required = false) String hatchRate,
|
|
|
+ @RequestParam(name = "fatherNum") String fatherNum,
|
|
|
+ @RequestParam(name = "motherNum") String motherNum,
|
|
|
+ @RequestParam(name = "fatherGenotype") String fatherGenotype,
|
|
|
+ @RequestParam(name = "motherGenotype") String motherGenotype,
|
|
|
+ @RequestParam(name = "specialNeeds") String specialNeeds) throws Exception {
|
|
|
+ httpServletRequest.setCharacterEncoding("UTF-8");
|
|
|
+ String content = uploadImage.getImageCom(imgUrl);
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("id", id);
|
|
|
+ map.put("duckBreed", duckBreed);
|
|
|
+ map.put("duckSex", duckSex);
|
|
|
+ map.put("duckBirthPlace", duckBirthPlace);
|
|
|
+ map.put("duckBirthDay", duckBirthDay);
|
|
|
+ map.put("genotype", genotype);
|
|
|
+ map.put("nowWeight", nowWeight);
|
|
|
+ map.put("unitId", unitId);
|
|
|
+ map.put("breedEnv", breedEnv);
|
|
|
+ map.put("hatchRate", hatchRate);
|
|
|
+ map.put("fatherNum", fatherNum);
|
|
|
+ map.put("motherNum", motherNum);
|
|
|
+ map.put("fatherGenotype", fatherGenotype);
|
|
|
+ map.put("motherGenotype", motherGenotype);
|
|
|
+ map.put("specialNeeds", specialNeeds);
|
|
|
+ map.put("imgUrl", content);
|
|
|
+ duckInfoService.addDuck(httpServletRequest, map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/editDuck")
|
|
|
+ public Result editDuck(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
|
|
|
+ return new Result(ResultCode.SUCCESS, duckInfoService.editDuck(httpServletRequest, paramsMap));
|
|
|
+ }
|
|
|
+ @RequestMapping("/listDuckById")
|
|
|
+ public Result listDuckById(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
|
|
|
+ return new Result(ResultCode.SUCCESS, duckInfoService.listDuckById(httpServletRequest, paramsMap));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/printDuck")
|
|
|
+ public void printDuck(HttpServletRequest httpServletRequest, @RequestParam(name = "duckCode") String duckCode) {
|
|
|
+
|
|
|
+ }
|
|
|
}
|