瀏覽代碼

Merge branch 'master' of http://47.92.161.104:10080/chenwen/zl-opd-server

chenwen 2 年之前
父節點
當前提交
edfdd26bbb

+ 24 - 2
src/main/java/com/hb/proj/model/Well.java

@@ -2,11 +2,33 @@ package com.hb.proj.model;
 
 import lombok.Data;
 
+import java.util.Date;
+
 @Data
 public class Well {
+    /**
+     *井号
+     */
     private String wellId;
-
+    /**
+     *井名
+     */
     private String wellName;
-
+    /**
+     *井别
+     */
     private String wellSort;
+    /**
+     *创建时间
+     */
+    private Date createTime;
+    /**
+     *
+     *修改时间
+     */
+    private Date modifyTime;
+    /**
+     *删除标志
+     */
+    private Boolean delIf;
 }

+ 61 - 2
src/main/java/com/hb/proj/well/controller/WellController.java

@@ -1,27 +1,86 @@
 package com.hb.proj.well.controller;
 
+
 import cn.hutool.core.util.IdUtil;
 import com.hb.proj.model.Well;
+import com.hb.proj.utils.RespVO;
+import com.hb.proj.utils.RespVOBuilder;
 import com.hb.proj.well.service.WellService;
+import com.hb.xframework.dao.util.PageModel;
+import jakarta.validation.constraints.NotBlank;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * 井相关接口
+ */
 @RestController
 @RequestMapping("/api/well")
 @Validated
 public class WellController {
     @Autowired
     private WellService wellService;
+    /**
+     * 井保存
+     * @apiNote 通过传入对象保存
+     * @return 无
+     */
     @RequestMapping("/save")
     public void save(){
         Well well = new Well();
-        System.out.println("--------------------id:"+IdUtil.fastSimpleUUID());
         well.setWellId(IdUtil.fastSimpleUUID());
         well.setWellName("井名");
         well.setWellSort("测试井");
+        well.setCreateTime(new Date());
         wellService.insert(well);
-
+    }
+    /**
+     * 井修改
+     * @apiNote 修改井信息
+     * @return 无
+     */
+    @RequestMapping("/update")
+    public void update(){
+        Well well = wellService.get("c15404d0d40e442ca35544d1f36a40bf");
+        well.setModifyTime(new Date());
+        well.setWellName("修改井名");
+        wellService.update(well);
+    }
+    /**
+     * 井删除
+     * @apiNote 删除井信息
+     * @return 无
+     */
+    @RequestMapping("/delete")
+    public void delete(){
+        Well well = wellService.get("c15404d0d40e442ca35544d1f36a40bf");
+        well.setModifyTime(new Date());
+        well.setDelIf(true);
+        wellService.update(well);
+    }
+    /**
+     * 获得单个井数据.
+     *  @apiNote <p>通过指定的井编号获取数据<br>
+     * @param id
+     * @return
+     */
+    @RequestMapping("/get")
+    RespVO<Well> getUser(@NotBlank(message = "井编号【wellId】不能为空") String id) {
+        return RespVOBuilder.ok(wellService.get(id));
+    }
+    /**
+     * 查询分页井数据.
+     *  @apiNote <p>通过条件获取数据<br>
+     * @return
+     */
+    @RequestMapping("/queryPaged")
+    RespVO<PageModel<Map<String,Object>>> queryPaged() {
+        PageModel<Map<String,Object>> page= wellService.queryPagedMap();
+        return RespVOBuilder.ok(page);
     }
 }

+ 25 - 1
src/main/java/com/hb/proj/well/service/WellService.java

@@ -1,18 +1,42 @@
 package com.hb.proj.well.service;
 
 
+import com.hb.proj.auth.service.User;
 import com.hb.proj.model.Well;
 import com.hb.xframework.dao.core.SpringJdbcDAO;
+import com.hb.xframework.dao.util.PageModel;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Map;
+
 @Service
 public class WellService {
     @Autowired
     private SpringJdbcDAO springDAO;
     private String tabName="tzl_well";
     public void insert(Well well) {
+        springDAO.insert(well, tabName);
+    }
+    public boolean update(Well well) {
+        return springDAO.update(well, "tzl_well", "well_id")>0;
+    }
+    public void delete(Well well) {
+         springDAO.update(well, "tzl_well", "well_id");
 
-          springDAO.insert(well, tabName);
     }
+    public Well get(String id){
+        String sql="""
+				
+				select * from tzl_well
+				where well_id=?
+				
+				""";
+        return springDAO.queryForPojo(sql,Well.class,id);
+    }
+
+    public PageModel<Map<String,Object>> queryPagedMap(){
+        return springDAO.queryForPagedData("select * from tzl_well", 1, 10);
+    }
+
 }

+ 1 - 1
src/main/resources/smart-doc.json

@@ -1,5 +1,5 @@
 {
-	"serverUrl":"http://127.0.0.1:8080/myproj",
+	"serverUrl":"http://127.0.0.1:8080/zl",
 	
 	"outPath": "src/main/resources/static/doc",
 	"allInOne":true,