Browse Source

修改代码,测试功能

wanghaicheng 5 years ago
parent
commit
f08108d8e3

+ 16 - 10
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/custom/controller/PropertyContactController.java

@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.AllArgsConstructor;
 import org.springframework.web.bind.annotation.*;
 
+import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.util.List;
 
 @RestController
@@ -22,16 +24,18 @@ import java.util.List;
 public class PropertyContactController {
     private final PropertyContactServiceImpl propertyContactService;
 
-    @GetMapping("")
+    @GetMapping("/list")
     /**
-     * @description 根据客户id分页查所属联系人
-     * @date 2019/11/27 11:22
-     * @param [id, current, size]
-     * @return cn.com.xwy.boot.web.dto.RestResponse
-     */
-    public RestResponse propertyContacts(@RequestParam Integer ppCompanyId, @RequestParam Integer userId, Integer pageNum, Integer pageSize) {
+         * @description 根据客户id分页查它的联系人
+         * @date 2019/11/29 8:21
+         * @param [ppCompanyId, userId, pageNum, pageSize]
+         * @return cn.com.xwy.boot.web.dto.RestResponse
+         */
+    public RestResponse propertyContacts(@RequestParam Long ppCompanyId, @RequestParam Long userId, Integer pageNum, Integer pageSize) {
         Page<PropertyContact> page = new Page<>(pageNum, pageSize);
-        List<PropertyContact> records = propertyContactService.page(page, new QueryWrapper<PropertyContact>().eq("pp_company_id", ppCompanyId).eq("user_id",userId)).getRecords();
+        List<PropertyContact> records = propertyContactService.page(page, new QueryWrapper<PropertyContact>()
+                .select("id","pp_company_id","name","dept","job","telephone","gender","age","remarks","status","user_id")
+                .eq("pp_company_id", ppCompanyId).eq("user_id",userId)).getRecords();
         if (!records.isEmpty()) {
             return RestResponse.ok(records,"查询成功");
         } else {
@@ -39,14 +43,16 @@ public class PropertyContactController {
         }
     }
 
-    @PostMapping("/save")
+    @PostMapping("/add")
     /**
      * @description 根据客户id,新增联系人
      * @date 2019/11/27 11:23
      * @param [propertyContact]
      * @return cn.com.xwy.boot.web.dto.RestResponse
      */
-    public RestResponse save(@RequestBody PropertyContact propertyContact) {
+    public RestResponse add(@RequestBody PropertyContact propertyContact) {
+        propertyContact.setCreateDate(LocalDateTime.now());
+        System.out.println(propertyContact.getPpCompanyId());
         if (propertyContactService.save(propertyContact)) {
             return RestResponse.ok(null, "新增成功");
         } else {

+ 2 - 2
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/custom/dao/entity/PropertyContact.java

@@ -29,13 +29,13 @@ public class PropertyContact implements Serializable {
     /**
      * 联系人id
      */
-    @TableField("id")
+    @TableId(value = "id",type = IdType.AUTO)
     private Long id;
 
     /**
      * 甲方公司id
      */
-    @TableId(value = "pp_company_id",type = IdType.AUTO)
+    @TableId(value = "pp_company_id")
     private Long ppCompanyId;
 
     /**

+ 9 - 9
lift-system-service/src/main/java/cn/com/ty/lift/system/faq/controller/FaqController.java

@@ -7,7 +7,6 @@ import cn.com.xwy.boot.web.dto.RestResponse;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 
 import lombok.AllArgsConstructor;
-import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -23,7 +22,7 @@ import java.util.List;
 public class FaqController {
     private final FaqServiceImpl faqService;
 
-    @GetMapping("/one")
+    @GetMapping("/list/one")
     /**
      * @description 查询一级分类
      * @date 2019/11/27 10:19
@@ -34,7 +33,7 @@ public class FaqController {
         return RestResponse.ok(faqService.list(new QueryWrapper<Faq>().eq("type", 1).eq("parent_id", 0).orderByAsc("serial")), "查询成功");
     }
 
-    @GetMapping("/child")
+    @GetMapping("/list/child")
     /**
      * @description 根据父分类id查询子分类
      * @date 2019/11/27 10:19
@@ -45,7 +44,7 @@ public class FaqController {
         return RestResponse.ok(faqService.list(new QueryWrapper<Faq>().eq("type", 1).eq("parent_id", parentId).orderByAsc("serial")), "查询成功");
     }
 
-    @GetMapping("/question")
+    @GetMapping("/list/question")
     /**
      * @description 根据分类id查询问题标题列表
      * @date 2019/11/27 10:25
@@ -53,7 +52,12 @@ public class FaqController {
      * @return cn.com.xwy.boot.web.dto.RestResponse
      */
     public RestResponse question(@RequestParam Integer parentId) {
-        return RestResponse.ok(faqService.list(new QueryWrapper<Faq>().eq("type", 2).eq("parent_id", parentId).orderByAsc("serial")), "查询成功");
+        List<Faq> list = faqService.list(new QueryWrapper<Faq>().eq("type", 2).eq("parent_id", parentId).orderByAsc("serial"));
+        if (!list.isEmpty()) {
+            return RestResponse.ok(list, "查询成功");
+        }else {
+            return RestResponse.ok(null, "无数据");
+        }
     }
 
     @GetMapping("/answer")
@@ -75,7 +79,6 @@ public class FaqController {
      * @return cn.com.xwy.boot.web.dto.RestResponse
      */
     public RestResponse addOne(@RequestBody Faq faq) {
-        //@RequestParam String title, @RequestParam String description
         return RestResponse.ok(null, faqService.addOne(faq.getContent(), faq.getDescription()));
     }
 
@@ -87,7 +90,6 @@ public class FaqController {
      * @return cn.com.xwy.boot.web.dto.RestResponse
      */
     public RestResponse addChild(@RequestBody Faq faq) {
-        //@RequestParam int parentId, @RequestParam String title, @RequestParam String description
         return RestResponse.ok(null, faqService.addChild(faq.getParentId(), faq.getContent(), faq.getDescription()));
     }
 
@@ -99,7 +101,6 @@ public class FaqController {
      * @return cn.com.xwy.boot.web.dto.RestResponse
      */
     public RestResponse addQuestion(@RequestBody Faq faq) {
-        //@RequestParam int parentId, @RequestParam String title, @RequestParam String description
         return RestResponse.ok(null, faqService.addQuestion(faq.getParentId(), faq.getContent(), faq.getDescription()));
     }
 
@@ -111,7 +112,6 @@ public class FaqController {
      * @return cn.com.xwy.boot.web.dto.RestResponse
      */
     public RestResponse addAnswer(@RequestBody Faq faq) {
-        //@RequestParam int parentId, @RequestParam String content, @RequestParam String description
         return RestResponse.ok(null, faqService.addAnswer(faq.getParentId(), faq.getContent(), faq.getDescription()));
     }
 

+ 3 - 3
lift-system-service/src/main/java/cn/com/ty/lift/system/faq/service/impl/FaqServiceImpl.java

@@ -27,7 +27,7 @@ public class FaqServiceImpl extends ServiceImpl<FaqMapper, Faq> implements FaqSe
     public String  addOne(String title, String description) {
         Faq faq = new Faq();
         faq.setContent(title).setType(1).setParentId(0).setDescription(description);
-        faq.setSerial(this.list(new QueryWrapper<Faq>().eq("type", 1).eq("parent_id", 0)).size() + 1);
+        faq.setSerial(this.count(new QueryWrapper<Faq>().eq("type", 1).eq("parent_id", 0)) + 1);
         if (this.save(faq)) {
             return "新增一级分类成功";
         } else {
@@ -40,9 +40,9 @@ public class FaqServiceImpl extends ServiceImpl<FaqMapper, Faq> implements FaqSe
         faq.setContent(title).setType(1).setParentId(parentId).setDescription(description);
         faq.setSerial(this.list(new QueryWrapper<Faq>().eq("type", 1).eq("parent_id", parentId)).size() + 1);
         if (this.save(faq)) {
-            return "新增一级分类成功";
+            return "新增分类成功";
         } else {
-            return "新增一级分类失败";
+            return "新增分类失败";
         }
     }