Commit c7d8974a19796011464b70056857418199562654
1 parent
510ea862
提交用户白名单
Showing
7 changed files
with
117 additions
and
104 deletions
src/main/java/com/cnlive/shenhe/controller/UsersFreeController.java
| ... | ... | @@ -100,13 +100,14 @@ public class UsersFreeController { |
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | @PostMapping(value = "/write") |
| 103 | - public String write(String userId,String userMobile, String[] write_business, HttpSession session, String redirect_url) { | |
| 103 | + public String write(String userId,String userMobile,Integer spId, String[] write_business, HttpSession session, String redirect_url) { | |
| 104 | 104 | if(CommonUtils.isEmpty(userId)&&CommonUtils.isEmpty(userMobile)){ |
| 105 | 105 | return "error.html"; |
| 106 | 106 | } |
| 107 | 107 | if(CommonUtils.isNull(write_business)){ |
| 108 | 108 | return "error.html"; |
| 109 | 109 | } |
| 110 | + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); | |
| 110 | 111 | String write = ""; |
| 111 | 112 | if (CommonUtils.isNotNull(write_business) && write_business.length > 0) { |
| 112 | 113 | for (String w : write_business) { |
| ... | ... | @@ -114,7 +115,7 @@ public class UsersFreeController { |
| 114 | 115 | } |
| 115 | 116 | write = write.substring(1); |
| 116 | 117 | } |
| 117 | - boolean success = usersfreeService.update(userId,userMobile,write); | |
| 118 | + boolean success = usersfreeService.update(userId,userMobile,write,spId,sessionUser.getUserId()); | |
| 118 | 119 | if (success) { |
| 119 | 120 | return "redirect:" + redirect_url; |
| 120 | 121 | } else { | ... | ... |
src/main/java/com/cnlive/shenhe/entity/ShyUsersfree.java
| ... | ... | @@ -50,6 +50,16 @@ public class ShyUsersfree { |
| 50 | 50 | private String category_name; |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | + * 是否删除,0:未删除,1:已删除 | |
| 54 | + */ | |
| 55 | + private Boolean is_delete; | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * 更新人 | |
| 59 | + */ | |
| 60 | + private String updater; | |
| 61 | + | |
| 62 | + /** | |
| 53 | 63 | * 创建时间 |
| 54 | 64 | */ |
| 55 | 65 | private Date created_at; |
| ... | ... | @@ -203,6 +213,42 @@ public class ShyUsersfree { |
| 203 | 213 | return sp_desc; |
| 204 | 214 | } |
| 205 | 215 | /** |
| 216 | + * 获取是否删除,0:未删除,1:已删除 | |
| 217 | + * | |
| 218 | + * @return is_delete - 是否删除,0:未删除,1:已删除 | |
| 219 | + */ | |
| 220 | + public Boolean getIs_delete() { | |
| 221 | + return is_delete; | |
| 222 | + } | |
| 223 | + | |
| 224 | + /** | |
| 225 | + * 设置是否删除,0:未删除,1:已删除 | |
| 226 | + * | |
| 227 | + * @param is_delete 是否删除,0:未删除,1:已删除 | |
| 228 | + */ | |
| 229 | + public void setIs_delete(Boolean is_delete) { | |
| 230 | + this.is_delete = is_delete; | |
| 231 | + } | |
| 232 | + | |
| 233 | + /** | |
| 234 | + * 获取更新人 | |
| 235 | + * | |
| 236 | + * @return updater - 更新人 | |
| 237 | + */ | |
| 238 | + public String getUpdater() { | |
| 239 | + return updater; | |
| 240 | + } | |
| 241 | + | |
| 242 | + /** | |
| 243 | + * 设置更新人 | |
| 244 | + * | |
| 245 | + * @param updater 更新人 | |
| 246 | + */ | |
| 247 | + public void setUpdater(String updater) { | |
| 248 | + this.updater = updater; | |
| 249 | + } | |
| 250 | + | |
| 251 | + /** | |
| 206 | 252 | * 获取创建时间 |
| 207 | 253 | * |
| 208 | 254 | * @return created_at - 创建时间 | ... | ... |
src/main/java/com/cnlive/shenhe/serviceImpl/UsersfreeServiceImpl.java
| ... | ... | @@ -77,13 +77,17 @@ public class UsersfreeServiceImpl { |
| 77 | 77 | public ShyUsersfree selectUser(Integer sp_id,String category,String user_id) { |
| 78 | 78 | ShyUsersfree shyUserfree=new ShyUsersfree(); |
| 79 | 79 | shyUserfree.setSp_id(sp_id); |
| 80 | - shyUserfree.setCategory(category); | |
| 80 | +// shyUserfree.setCategory(category); | |
| 81 | 81 | shyUserfree.setUser_id(user_id); |
| 82 | 82 | shyUserfree.setIs_enable(true); |
| 83 | - return shyUsersfreeMapper.selectOne(shyUserfree); | |
| 83 | + ShyUsersfree shyUserfree1 = shyUsersfreeMapper.selectOne(shyUserfree); | |
| 84 | + if(shyUserfree1.getCategory().contains(category)){ | |
| 85 | + return shyUserfree1; | |
| 86 | + } | |
| 87 | + return null; | |
| 84 | 88 | } |
| 85 | 89 | |
| 86 | - public boolean update(String userId, String userMobile, String write) { | |
| 90 | + public boolean update(String userId, String userMobile, String write,Integer spId,String updater) { | |
| 87 | 91 | JSONObject result = new JSONObject(); |
| 88 | 92 | try { |
| 89 | 93 | result = Pass.queryUser(userId,userMobile); |
| ... | ... | @@ -100,27 +104,47 @@ public class UsersfreeServiceImpl { |
| 100 | 104 | logger.error("用户白名单返回code值为,errorCode:{},errorMessage:{},userId:{},userMobile:{}", code, result.getString("errorMessage"), userId,userMobile); |
| 101 | 105 | return false; |
| 102 | 106 | } |
| 103 | - Integer state=1;//1、更新 2、添加 | |
| 104 | 107 | JSONObject jsonData =result.getJSONObject("data"); |
| 105 | 108 | String mobile=jsonData.getString("mobile"); |
| 106 | 109 | String user_id=jsonData.getString("uid"); |
| 110 | + String user_name=jsonData.getString("nickName"); | |
| 111 | + String email=jsonData.getString("email"); | |
| 112 | + | |
| 107 | 113 | ShyUsersfree shyUserfree=new ShyUsersfree(); |
| 108 | 114 | shyUserfree.setUser_id(user_id); |
| 109 | - shyUserfree = shyUsersfreeMapper.selectOne(shyUserfree); | |
| 110 | - if(shyUserfree==null){ | |
| 111 | - state=2; | |
| 115 | + ShyUsersfree shyUserfree1 = shyUsersfreeMapper.selectOne(shyUserfree); | |
| 116 | + | |
| 117 | + if(shyUserfree1 != null){ | |
| 118 | + shyUserfree1.setMobile(mobile); | |
| 119 | + shyUserfree1.setCategory(write); | |
| 120 | + shyUserfree1.setUser_name(user_name); | |
| 121 | + shyUserfree1.setEmail(email); | |
| 122 | + shyUserfree1.setSp_id(spId); | |
| 123 | + shyUserfree1.setUpdated_at(CommonUtils.getCurrentTime()); | |
| 124 | + shyUserfree1.setUpdater(updater); | |
| 125 | + shyUserfree1.setIs_delete(false); | |
| 126 | + shyUserfree1.setIs_enable(true); | |
| 127 | + int re = shyUsersfreeMapper.updateByPrimaryKeySelective(shyUserfree1); | |
| 128 | + if (re != 1) { | |
| 129 | + return false; | |
| 130 | + } | |
| 131 | + }else{ | |
| 132 | + shyUserfree.setMobile(mobile); | |
| 133 | + shyUserfree.setCategory(write); | |
| 134 | + shyUserfree.setUser_name(user_name); | |
| 135 | + shyUserfree.setEmail(email); | |
| 136 | + shyUserfree.setSp_id(spId); | |
| 112 | 137 | shyUserfree.setCreated_at(CommonUtils.getCurrentTime()); |
| 138 | + shyUserfree.setUpdated_at(CommonUtils.getCurrentTime()); | |
| 139 | + shyUserfree.setUpdater(updater); | |
| 140 | + shyUserfree.setIs_delete(false); | |
| 141 | + shyUserfree.setIs_enable(true); | |
| 142 | + | |
| 143 | + int re = shyUsersfreeMapper.insertSelective(shyUserfree); | |
| 144 | + if (re != 1) { | |
| 145 | + return false; | |
| 146 | + } | |
| 113 | 147 | } |
| 114 | - shyUserfree.setMobile(mobile); | |
| 115 | - shyUserfree.setCategory(write); | |
| 116 | - shyUserfree.setUser_name(jsonData.getString("nickName")); | |
| 117 | - shyUserfree.setEmail(jsonData.getString("email")); | |
| 118 | - shyUserfree.setUpdated_at(CommonUtils.getCurrentTime()); | |
| 119 | - | |
| 120 | - int i = shyUsersfreeMapper.updateByPrimaryKeySelective(shyUserfree); | |
| 121 | - if (i != 1) { | |
| 122 | - return false; | |
| 123 | - } | |
| 124 | 148 | } |
| 125 | 149 | |
| 126 | 150 | return true; | ... | ... |
src/main/resources/mapper/ShyUsersfreeMapper.xml
| ... | ... | @@ -12,7 +12,9 @@ |
| 12 | 12 | <result column="email" jdbcType="VARCHAR" property="email" /> |
| 13 | 13 | <result column="sp_id" jdbcType="INTEGER" property="sp_id" /> |
| 14 | 14 | <result column="category" jdbcType="VARCHAR" property="category" /> |
| 15 | - <result column="is_enable" jdbcType="INTEGER" property="is_enable" /> | |
| 15 | + <result column="is_enable" jdbcType="BIT" property="is_enable" /> | |
| 16 | + <result column="is_delete" jdbcType="BIT" property="is_delete" /> | |
| 17 | + <result column="updater" jdbcType="VARCHAR" property="updater" /> | |
| 16 | 18 | <result column="created_at" jdbcType="TIMESTAMP" property="created_at" /> |
| 17 | 19 | <result column="updated_at" jdbcType="TIMESTAMP" property="updated_at" /> |
| 18 | 20 | </resultMap> | ... | ... |
src/main/resources/templates/common/frame.html
| ... | ... | @@ -82,7 +82,7 @@ line-height: 2em; margin: 0 auto;font-size: 2em" th:text="${session.sessionUser. |
| 82 | 82 | </a> |
| 83 | 83 | <ul class="treeview-menu"> |
| 84 | 84 | <li><a href="/users/page" id="/users/page"> 审核云用户管理</a></li> |
| 85 | - <li><a href="/sites/page" id="/sites/page"> 站点白名单管理</a></li> | |
| 85 | + <li><a href="/sites/page" id="/sites/page"> SP白名单管理</a></li> | |
| 86 | 86 | <li><a href="/usersFree/page" id="/usersFree/page"> 用户白名单管理</a></li> |
| 87 | 87 | </ul> |
| 88 | 88 | </li> | ... | ... |
src/main/resources/templates/logging/logging.html deleted
100644 → 0
| 1 | -<!DOCTYPE> | |
| 2 | -<!--解决idea thymeleaf 表达式模板报红波浪线--> | |
| 3 | -<!--suppress ALL --> | |
| 4 | -<html xmlns:th="http://www.thymeleaf.org"> | |
| 5 | -<head> | |
| 6 | - <meta charset="UTF-8"> | |
| 7 | - <title>实时日志</title> | |
| 8 | - <!-- jquery --> | |
| 9 | - <script th:src="@{../../static/js/jquery.min.js}"></script> | |
| 10 | -<!-- <script src="../../static/js/jquery-1.9.1.min.js"></script> --> | |
| 11 | -</head> | |
| 12 | -<body> | |
| 13 | -<!-- 标题 --> | |
| 14 | -<h1 style="text-align: center;">实时日志</h1> | |
| 15 | - | |
| 16 | -<!-- 显示区 --> | |
| 17 | -<div id="loggingText" contenteditable="true" | |
| 18 | - style="width:100%;height: 600px;background-color: ghostwhite; overflow: auto;"></div> | |
| 19 | - | |
| 20 | -<!-- 操作栏 --> | |
| 21 | -<div style="text-align: center;"> | |
| 22 | - <button onclick="$('#loggingText').text('')" style="color: green; height: 35px;">清屏</button> | |
| 23 | - <button onclick="$('#loggingText').animate({scrollTop:$('#loggingText')[0].scrollHeight});" | |
| 24 | - style="color: green; height: 35px;">滚动至底部 | |
| 25 | - </button> | |
| 26 | - <button onclick="if(window.loggingAutoBottom){$(this).text('开启自动滚动');}else{$(this).text('关闭自动滚动');};window.loggingAutoBottom = !window.loggingAutoBottom" | |
| 27 | - style="color: green; height: 35px; ">开启自动滚动 | |
| 28 | - </button> | |
| 29 | -</div> | |
| 30 | -</body> | |
| 31 | -<script th:inline="javascript"> | |
| 32 | - //websocket对象 | |
| 33 | - let websocket = null; | |
| 34 | - var re=location.origin.replace("http://", ""); | |
| 35 | - console.log(re); | |
| 36 | - //判断当前浏览器是否支持WebSocket | |
| 37 | - if ('WebSocket' in window) { | |
| 38 | - websocket = new WebSocket("ws://"+re+"/logging/websocket"); | |
| 39 | - } else { | |
| 40 | - console.error("不支持WebSocket"); | |
| 41 | - } | |
| 42 | - | |
| 43 | - //连接发生错误的回调方法 | |
| 44 | - websocket.onerror = function (e) { | |
| 45 | - console.error("WebSocket连接发生错误"); | |
| 46 | - }; | |
| 47 | - | |
| 48 | - //连接成功建立的回调方法 | |
| 49 | - websocket.onopen = function () { | |
| 50 | - console.log("WebSocket连接成功") | |
| 51 | - }; | |
| 52 | - | |
| 53 | - //接收到消息的回调方法 | |
| 54 | - websocket.onmessage = function (event) { | |
| 55 | - //追加 | |
| 56 | - if (event.data) { | |
| 57 | - | |
| 58 | - //日志内容 | |
| 59 | - let $loggingText = $("#loggingText"); | |
| 60 | - $loggingText.append(event.data); | |
| 61 | - | |
| 62 | - //是否开启自动底部 | |
| 63 | - if (window.loggingAutoBottom) { | |
| 64 | - //滚动条自动到最底部 | |
| 65 | - $loggingText.scrollTop($loggingText[0].scrollHeight); | |
| 66 | - } | |
| 67 | - } | |
| 68 | - } | |
| 69 | - | |
| 70 | - //连接关闭的回调方法 | |
| 71 | - websocket.onclose = function () { | |
| 72 | - console.log("WebSocket连接关闭") | |
| 73 | - }; | |
| 74 | -</script> | |
| 75 | -</html> | |
| 76 | 0 | \ No newline at end of file |
src/main/resources/templates/page/usersFree.html
| ... | ... | @@ -167,7 +167,7 @@ input:checked + .slider:before { |
| 167 | 167 | <td style="text-align: center; width: 8%;" th:text="${users.mobile}">用户名</td> |
| 168 | 168 | <td style="text-align: center; width: 12%;" th:text="${users.email}">邮箱</td> |
| 169 | 169 | <td style="text-align: center; width: 10%;" th:text="${users.sp_desc}">手机号</td> |
| 170 | - <td style="text-align: center; width: 6%;" th:text="${users.category}"></td> | |
| 170 | + <td style="text-align: center; width: 6%;" th:text="${users.category_name}"></td> | |
| 171 | 171 | <!-- <td style="text-align: center; width: 6%;" th:if="${users.is_enable==true}"> --> |
| 172 | 172 | <!-- <span class="label label-success">正常</span></td> --> |
| 173 | 173 | <!-- <td style="text-align: center; width: 6%;" th:if="${users.is_enable==false}"> --> |
| ... | ... | @@ -184,8 +184,8 @@ input:checked + .slider:before { |
| 184 | 184 | 14:27:17</td> |
| 185 | 185 | <td style="text-align: center; width: 10%;"> |
| 186 | 186 | <span> </span> |
| 187 | - <a class="edit" th:href="'javascript:edit('+${users.id}+')'"> | |
| 188 | - <button class="btn btn-primary btn-xs">同步</button> | |
| 187 | + <a class="edit" th:href="'javascript:edit('+${users.user_id}+',\''+${users.mobile}+'\',\''+${users.sp_id}+'\',\''+${users.category} +'\')'"> | |
| 188 | + <button class="btn btn-primary btn-xs">修改</button> | |
| 189 | 189 | </a><span> </span><span> </span></td> |
| 190 | 190 | </tr> |
| 191 | 191 | |
| ... | ... | @@ -266,10 +266,10 @@ input:checked + .slider:before { |
| 266 | 266 | <div class="modal-body"> |
| 267 | 267 | <form action="/usersFree/write" method="post" id="editWrite"> |
| 268 | 268 | <input type="text" name="redirect_url" value="" class="hide" id="redirect_url"/> |
| 269 | - <div class="form-group hide" > | |
| 269 | + <div class="form-group hide"> | |
| 270 | 270 | <label class="control-label col-sm-3" style="font-size: 15px;" >用户Id:</label> |
| 271 | 271 | <div class="col-sm-9" style="margin-top: -5px;margin-bottom: 20px;"> |
| 272 | - <input class="form-control" style="width:40%;" type="text" value="" id="userId" name="userId"> | |
| 272 | + <input class="form-control" style="width:30%;" type="text" value="" id="userId" name="userId"> | |
| 273 | 273 | </div> |
| 274 | 274 | </div> |
| 275 | 275 | <div class="form-group"> |
| ... | ... | @@ -278,6 +278,12 @@ input:checked + .slider:before { |
| 278 | 278 | <input class="form-control" style="width:40%;" type="text" value="" id="userMobile" name="userMobile"> |
| 279 | 279 | </div> |
| 280 | 280 | </div> |
| 281 | + <div class="form-group"> | |
| 282 | + <label class="control-label col-sm-3" style="font-size: 15px;">站点Id:</label> | |
| 283 | + <div class="col-sm-9" style="margin-top: -5px;margin-bottom: 20px;"> | |
| 284 | + <input class="form-control" style="width:20%;" type="text" value="" id="spId" name="spId"> | |
| 285 | + </div> | |
| 286 | + </div> | |
| 281 | 287 | |
| 282 | 288 | <div class="form-group"> |
| 283 | 289 | <label class="control-label col-sm-3" style="font-size: 15px;">免审业务:</label> |
| ... | ... | @@ -301,9 +307,12 @@ input:checked + .slider:before { |
| 301 | 307 | <!-- /.modal --> |
| 302 | 308 | <script> |
| 303 | 309 | //打开编辑窗口 |
| 304 | - function edit(id,company,write_business){ | |
| 305 | - $("#edit_company").text(company); | |
| 306 | - $("#edit_id").val(id); | |
| 310 | + function edit(userId,mobile,spId,write_business){ | |
| 311 | + $("#myModalLabel").text("修改免审用户"); | |
| 312 | + $("#userId").val(userId); | |
| 313 | + $("#userMobile").val(mobile); | |
| 314 | + $("#userMobile").attr("readonly","true"); | |
| 315 | + $("#spId").val(spId); | |
| 307 | 316 | $("#redirect_url").val(location.pathname+location.search); |
| 308 | 317 | $(".write_check input").prop("checked",false); |
| 309 | 318 | if($.trim(write_business)!=''){ |
| ... | ... | @@ -317,6 +326,12 @@ input:checked + .slider:before { |
| 317 | 326 | |
| 318 | 327 | //添加免审用户 |
| 319 | 328 | function add(){ |
| 329 | + $("#userId").val(""); | |
| 330 | + $("#userMobile").val(""); | |
| 331 | + $("#userMobile").removeAttr("readonly"); | |
| 332 | + $("#spId").val(""); | |
| 333 | + $(".write_check input").prop("checked",false); | |
| 334 | + | |
| 320 | 335 | $("#redirect_url").val(location.pathname+location.search); |
| 321 | 336 | $("#myModalLabel").text("添加免审用户"); |
| 322 | 337 | $('#editModal').modal('show'); | ... | ... |