Commit bdf32f7b25ef02d94135d435e88e8ec23026fdb3

Authored by 王言钊
1 parent befde78d

活动管理优化2

src/main/java/com/cnlive/shenhe/controller/ShyActivityController.java
... ... @@ -63,12 +63,10 @@ public class ShyActivityController {
63 63 }
64 64  
65 65 @GetMapping("/page")
66   - public String getShyActivity(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize, Model model, String activity, String exempt_from_trial) {
  66 + public String getShyActivity(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize, Model model, String activity, Integer exempt_from_trial) {
67 67 PageInfo<ShyActivity> shyActivityPageInfo = shyActivityImpl.selectByExample(pageNum, pageSize, activity, exempt_from_trial);
68 68 List<ShyActivity> list = shyActivityPageInfo.getList();
69   - for (ShyActivity shyActivity : list) {
70   - model.addAttribute("shyActivity",shyActivity);
71   - }
  69 + model.addAttribute("exempt_from_trial",exempt_from_trial);
72 70 model.addAttribute("ShyActivitylist", shyActivityPageInfo);
73 71 return "page/activity.html";
74 72 }
... ...
src/main/java/com/cnlive/shenhe/serviceImpl/ShyActivityImpl.java
... ... @@ -72,7 +72,7 @@ public class ShyActivityImpl {
72 72 * @param pageSize
73 73 * @return
74 74 */
75   - public PageInfo<ShyActivity> selectByExample(Integer pageNum, Integer pageSize, String activity, String exempt_from_trial) {
  75 + public PageInfo<ShyActivity> selectByExample(Integer pageNum, Integer pageSize, String activity, Integer exempt_from_trial) {
76 76 Example example = new Example(ShyActivity.class);
77 77 //如果为空 按照倒序排序 分页查询所有
78 78 //以创建时间为条件进行倒序
... ... @@ -81,7 +81,7 @@ public class ShyActivityImpl {
81 81 Example.Criteria criteria = example.createCriteria();
82 82  
83 83 // 如果查询条件不为空 按照条件走模糊查询
84   - if (CommonUtils.isNotEmpty(exempt_from_trial)) {
  84 + if (exempt_from_trial != null) {
85 85 criteria.andLike("exempt_from_trial", "%" + exempt_from_trial + "%");
86 86 }
87 87 // 如果查询条件不为空 按照条件走模糊查询
... ...
src/main/resources/templates/page/activity.html
... ... @@ -118,9 +118,9 @@
118 118 <div class="col-sm-7" style="padding: 0;">
119 119 <select class="form-control" id="exempt_from_trial_query"
120 120 name="exempt_from_trial">
121   - <option value="" th:selected="selected">--全部审免类型--</option>
122   - <option value="0" name="未审核" th:selected="${shyActivity.exempt_from_trial}==0" >未审免</option>
123   - <option value="1" name="已经审核" th:selected="${shyActivity.exempt_from_trial}==1" >已经审免</option>
  121 + <option value="">--全部审免类型--</option>
  122 + <option value="0" name="未审核" th:selected="${exempt_from_trial ==0}" >未审免</option>
  123 + <option value="1" name="已经审核" th:selected="${exempt_from_trial ==1}" >已经审免</option>
124 124 </select>
125 125 </div>
126 126 </div>
... ... @@ -364,6 +364,7 @@
364 364 </div>
365 365  
366 366 <script>
  367 +
367 368 // 添加事件
368 369 function submitAdd() {
369 370 var id1 = $("#id1").val();
... ... @@ -480,9 +481,12 @@
480 481 }
481 482  
482 483 //搜索事件
  484 + // $("#exempt_from_trial_query").val("").selected = true;
  485 +
483 486 $('#QueryAll').click(function () {
484 487 var activity = $("#activity_query").val();
485 488 var exempt_from_trial = $("#exempt_from_trial_query").val();
  489 + // exempt_from_trial.selected = true;
486 490 var pageSize = $("#pageSize").val();
487 491 window.location.href = "/activity/page?activity=" + activity + "&exempt_from_trial=" + exempt_from_trial + "&pageSize=" + pageSize;
488 492 });
... ...