zlisen 4 years ago
parent
commit
0e30eb200e

+ 8
- 3
src/main/java/com/yunzhi/demo/controller/TdSchoolController.java View File

@@ -7,6 +7,7 @@ import com.yunzhi.demo.common.BaseController;
7 7
 import com.yunzhi.demo.common.Constants;
8 8
 import com.yunzhi.demo.common.ResponseBean;
9 9
 import com.yunzhi.demo.common.StringUtils;
10
+import com.yunzhi.demo.entity.TaPost;
10 11
 import io.swagger.annotations.Api;
11 12
 import io.swagger.annotations.ApiOperation;
12 13
 import io.swagger.annotations.ApiParam;
@@ -76,11 +77,15 @@ public class TdSchoolController extends BaseController {
76 77
     @RequestMapping(value="/admin/school",method= RequestMethod.GET)
77 78
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
78 79
     public ResponseBean schoolList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
79
-                                     @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
80
+                                     @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
81
+                                   @ApiParam("名称") @RequestParam(value = "name", required = false) String name,
82
+                                   @ApiParam("状态") @RequestParam(value = "status", required = false) String status) throws Exception{
80 83
 
81 84
         IPage<TdSchool> pg = new Page<>(pageNum, pageSize);
82
-        QueryWrapper<TdSchool> queryWrapper = new QueryWrapper<>();
83
-        queryWrapper.orderByDesc("create_date");
85
+        QueryWrapper<TdSchool> queryWrapper = new QueryWrapper<TdSchool>()
86
+                .like(!StringUtils.isEmpty(name), "name", name)
87
+                .eq(null != status, "status", status)
88
+                .orderByDesc("create_date");
84 89
 
85 90
         IPage<TdSchool> result = iTdSchoolService.page(pg, queryWrapper);
86 91
         return ResponseBean.success(result);

+ 54
- 1
src/main/java/com/yunzhi/demo/controller/TdSpecialtyController.java View File

@@ -69,6 +69,29 @@ public class TdSpecialtyController extends BaseController {
69 69
             return ResponseBean.success(result);
70 70
     }
71 71
 
72
+    /**
73
+     * 分页查询列表
74
+     * @return
75
+     */
76
+    @RequestMapping(value="/admin/specialty",method= RequestMethod.GET)
77
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
78
+    public ResponseBean adminSpecialtyList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
79
+                                           @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
80
+                                           @ApiParam(value = "学校ID", required = false) @RequestParam(value ="schoolId", required = false) String schoolId,
81
+                                           @ApiParam(value = "名称", required = false) @RequestParam(value ="name", required = false) String name) throws Exception {
82
+
83
+        IPage<TdSpecialty> pg = new Page<>(pageNum, pageSize);
84
+        QueryWrapper<TdSpecialty> queryWrapper = new QueryWrapper<TdSpecialty>()
85
+                .eq(!StringUtils.isEmpty(schoolId),"schoolId", schoolId)
86
+                .like(!StringUtils.isEmpty(name), "name", "%"+name+"%")
87
+                .eq("status", Constants.STATUS_NORMAL)
88
+                .orderByAsc("sort_no")
89
+                .orderByDesc("create_date");
90
+
91
+        IPage<TdSpecialty> result = iTdSpecialtyService.page(pg, queryWrapper);
92
+        return ResponseBean.success(result);
93
+    }
94
+
72 95
     /**
73 96
      * 保存对象
74 97
      * @param tdSpecialty 实体对象
@@ -85,13 +108,43 @@ public class TdSpecialtyController extends BaseController {
85 108
         }
86 109
     }
87 110
 
111
+    /**
112
+     * 保存对象
113
+     * @param tdSpecialty 实体对象
114
+     * @return
115
+     */
116
+    @RequestMapping(value="/admin/specialty",method= RequestMethod.POST)
117
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
118
+    public ResponseBean specialtyAdd(@ApiParam("保存内容") @RequestBody TdSpecialty tdSpecialty) throws Exception{
119
+
120
+        if (iTdSpecialtyService.save(tdSpecialty)){
121
+            return ResponseBean.success(tdSpecialty);
122
+        }else {
123
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
124
+        }
125
+    }
126
+
88 127
     /**
89 128
      * 根据id删除对象
90 129
      * @param id  实体ID
91 130
      */
92 131
     @RequestMapping(value="/tdSpecialty/{id}", method= RequestMethod.DELETE)
93 132
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
94
-    public ResponseBean tdSpecialtyDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
133
+    public ResponseBean tdSpecialtyDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
134
+        if(iTdSpecialtyService.removeById(id)){
135
+            return ResponseBean.success("success");
136
+        }else {
137
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
138
+        }
139
+    }
140
+
141
+    /**
142
+     * 根据id删除对象
143
+     * @param id  实体ID
144
+     */
145
+    @RequestMapping(value="/admin/specialty/{id}", method= RequestMethod.DELETE)
146
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
147
+    public ResponseBean specialtyDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
95 148
         if(iTdSpecialtyService.removeById(id)){
96 149
             return ResponseBean.success("success");
97 150
         }else {

+ 1
- 1
src/main/java/com/yunzhi/demo/entity/TdSpecialty.java View File

@@ -27,7 +27,7 @@ public class TdSpecialty implements Serializable {
27 27
     private static final long serialVersionUID = 1L;
28 28
 
29 29
     @ApiModelProperty(value = "主键")
30
-    @TableId(value = "specialty_id", type = IdType.INPUT)
30
+    @TableId(value = "specialty_id", type = IdType.UUID)
31 31
     private String specialtyId;
32 32
 
33 33
     @ApiModelProperty(value = "名称")