jz.kai 5 years ago
parent
commit
22d22f4b64

+ 102 - 2
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java

@@ -44,6 +44,105 @@ public class PersonInfoController {
     @Autowired
     private UserService userService;
 
+    @ApiOperation(value="创建空记录")
+    @GetMapping("create")
+    public MessageResult<PersonInfo> create(){
+        MessageResult<PersonInfo> msgResult = new MessageResult<>();
+
+        PersonInfo personInfo = new PersonInfo();
+
+        msgResult.setData(personInfo);
+        msgResult.setResult(true);
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="添加信息")
+    @PostMapping("add")
+    public MessageResult<PersonInfo> add(@RequestBody PersonInfo personInfo,@RequestAttribute String subject){
+        MessageResult<PersonInfo> msgResult = new MessageResult<>();
+
+        try {
+//            personInfo.setId(UUID.randomUUID().toString());
+            personInfo.setDelFlag(false);
+            personInfo.setCreateBy(subject);
+            personInfo.setCreateTime(new Date());
+
+            int affectCount = personInfoService.insert(personInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(personInfo);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库添加失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="获取信息")
+    @GetMapping("edit/{id}")
+    public MessageResult<PersonInfo> edit(@PathVariable("id") String id){
+        MessageResult<PersonInfo> msgResult = new MessageResult<>();
+
+        try {
+            PersonInfo personInfo = personInfoService.get(id);
+
+            if (personInfo != null) {
+                msgResult.setResult(true);
+                msgResult.setData(personInfo);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="更新用户")
+    @PostMapping("update")
+    public MessageResult<PersonInfo> update(@RequestBody PersonInfo personInfo,@RequestAttribute String subject){
+        MessageResult<PersonInfo> msgResult = new MessageResult<>();
+
+        try {
+            personInfo.setUpdateBy(subject);
+            personInfo.setUpdateTime(new Date());
+
+            int affectCount = personInfoService.update(personInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(personInfo);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库更新失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
     @ApiOperation(value="保存信息")
     @PostMapping("save")
     public MessageResult<PersonInfo> save(@RequestBody PersonInfo personInfo,@RequestAttribute String subject){
@@ -446,9 +545,10 @@ public class PersonInfoController {
                     }
 
                     Map<String, Object> searchParams = new HashMap<>();
-                    searchParams.put("companyId", companyId);
-                    searchParams.put("idCard", idCard);
+//                    searchParams.put("companyId", companyId);
+//                    searchParams.put("idCard", idCard);
                     List<Sort> sortList = new ArrayList<>();
+                    sortList.add(new Sort("id_","asc"));
                     Page<PersonInfo> page = personInfoService.pageSearch(searchParams, 1, 1,false, sortList);
 
                     if (page.size() > 0) {

+ 3 - 3
web/src/main/resources/application-dev.yml

@@ -5,9 +5,9 @@ server:
 
 spring:
   datasource:
-    url: jdbc:log4jdbc:mysql://127.0.0.1:3306/smart-community?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
-    username: root
-    password: root
+    url: jdbc:log4jdbc:mysql://192.168.33.20:3306/smart-community?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+    username: smart
+    password: smart
   devtools:
     add-properties: false
     restart:

+ 3 - 0
web/src/main/resources/mapper/base/PersonInfo.xml

@@ -151,6 +151,9 @@
             <if test="searchParams.id != null">
                 and ID_ like #{searchParams.id}
             </if>
+            <if test="searchParams.companyId != null">
+                and company_id like #{searchParams.companyId}
+            </if>
             <if test="searchParams.name != null">
                 and name_ like #{searchParams.name}
             </if>