Commit bdf32f7b25ef02d94135d435e88e8ec23026fdb3
1 parent
befde78d
活动管理优化2
Showing
3 changed files
with
11 additions
and
9 deletions
src/main/java/com/cnlive/shenhe/controller/ShyActivityController.java
| @@ -63,12 +63,10 @@ public class ShyActivityController { | @@ -63,12 +63,10 @@ public class ShyActivityController { | ||
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | @GetMapping("/page") | 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 | PageInfo<ShyActivity> shyActivityPageInfo = shyActivityImpl.selectByExample(pageNum, pageSize, activity, exempt_from_trial); | 67 | PageInfo<ShyActivity> shyActivityPageInfo = shyActivityImpl.selectByExample(pageNum, pageSize, activity, exempt_from_trial); |
| 68 | List<ShyActivity> list = shyActivityPageInfo.getList(); | 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 | model.addAttribute("ShyActivitylist", shyActivityPageInfo); | 70 | model.addAttribute("ShyActivitylist", shyActivityPageInfo); |
| 73 | return "page/activity.html"; | 71 | return "page/activity.html"; |
| 74 | } | 72 | } |
src/main/java/com/cnlive/shenhe/serviceImpl/ShyActivityImpl.java
| @@ -72,7 +72,7 @@ public class ShyActivityImpl { | @@ -72,7 +72,7 @@ public class ShyActivityImpl { | ||
| 72 | * @param pageSize | 72 | * @param pageSize |
| 73 | * @return | 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 | Example example = new Example(ShyActivity.class); | 76 | Example example = new Example(ShyActivity.class); |
| 77 | //如果为空 按照倒序排序 分页查询所有 | 77 | //如果为空 按照倒序排序 分页查询所有 |
| 78 | //以创建时间为条件进行倒序 | 78 | //以创建时间为条件进行倒序 |
| @@ -81,7 +81,7 @@ public class ShyActivityImpl { | @@ -81,7 +81,7 @@ public class ShyActivityImpl { | ||
| 81 | Example.Criteria criteria = example.createCriteria(); | 81 | Example.Criteria criteria = example.createCriteria(); |
| 82 | 82 | ||
| 83 | // 如果查询条件不为空 按照条件走模糊查询 | 83 | // 如果查询条件不为空 按照条件走模糊查询 |
| 84 | - if (CommonUtils.isNotEmpty(exempt_from_trial)) { | 84 | + if (exempt_from_trial != null) { |
| 85 | criteria.andLike("exempt_from_trial", "%" + exempt_from_trial + "%"); | 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,9 +118,9 @@ | ||
| 118 | <div class="col-sm-7" style="padding: 0;"> | 118 | <div class="col-sm-7" style="padding: 0;"> |
| 119 | <select class="form-control" id="exempt_from_trial_query" | 119 | <select class="form-control" id="exempt_from_trial_query" |
| 120 | name="exempt_from_trial"> | 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 | </select> | 124 | </select> |
| 125 | </div> | 125 | </div> |
| 126 | </div> | 126 | </div> |
| @@ -364,6 +364,7 @@ | @@ -364,6 +364,7 @@ | ||
| 364 | </div> | 364 | </div> |
| 365 | 365 | ||
| 366 | <script> | 366 | <script> |
| 367 | + | ||
| 367 | // 添加事件 | 368 | // 添加事件 |
| 368 | function submitAdd() { | 369 | function submitAdd() { |
| 369 | var id1 = $("#id1").val(); | 370 | var id1 = $("#id1").val(); |
| @@ -480,9 +481,12 @@ | @@ -480,9 +481,12 @@ | ||
| 480 | } | 481 | } |
| 481 | 482 | ||
| 482 | //搜索事件 | 483 | //搜索事件 |
| 484 | + // $("#exempt_from_trial_query").val("").selected = true; | ||
| 485 | + | ||
| 483 | $('#QueryAll').click(function () { | 486 | $('#QueryAll').click(function () { |
| 484 | var activity = $("#activity_query").val(); | 487 | var activity = $("#activity_query").val(); |
| 485 | var exempt_from_trial = $("#exempt_from_trial_query").val(); | 488 | var exempt_from_trial = $("#exempt_from_trial_query").val(); |
| 489 | + // exempt_from_trial.selected = true; | ||
| 486 | var pageSize = $("#pageSize").val(); | 490 | var pageSize = $("#pageSize").val(); |
| 487 | window.location.href = "/activity/page?activity=" + activity + "&exempt_from_trial=" + exempt_from_trial + "&pageSize=" + pageSize; | 491 | window.location.href = "/activity/page?activity=" + activity + "&exempt_from_trial=" + exempt_from_trial + "&pageSize=" + pageSize; |
| 488 | }); | 492 | }); |