Browse Source

1、公告管理代码优化

binguoc 4 years atrás
parent
commit
89cf01b278

+ 2 - 1
src/main/java/com/chuanghai/repair/controller/LoginController.java

@@ -18,6 +18,7 @@ import org.springframework.http.*;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.client.RestTemplate;
+import springfox.documentation.annotations.ApiIgnore;
 
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
@@ -93,6 +94,7 @@ public class LoginController {
         return workIdToken;
     }
 
+    @ApiIgnore  //使该接口隐藏
     @ApiOperation("获取学生CardNumber")
     @GetMapping("/getCardNumber")
     public JSONObject getCardNumber(String wxcode, String state) {
@@ -180,7 +182,6 @@ public class LoginController {
                         cardNumber = (String) entry.getValue();
                     }
                 }
-
             }
             RepairsStudent repairsStudent = new RepairsStudent(studentId, studentName, studentSex,
                     studentPhone, studentOtherPhone, studentClazz, dormNumber,

+ 15 - 8
src/main/java/com/chuanghai/repair/controller/NoticeController.java

@@ -2,14 +2,18 @@ package com.chuanghai.repair.controller;
 
 import com.chuanghai.repair.entity.RepairsNotice;
 import com.chuanghai.repair.service.RepairsNoticeService;
+import com.chuanghai.repair.utils.CreateTokenUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import io.swagger.models.auth.In;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
@@ -30,15 +34,15 @@ public class NoticeController {
 
     @ApiOperation("添加公告")
     @PostMapping(value = "/addNotice")
-    public Boolean addNotice(@ApiParam(name = "公告内容", required = true) String noticeContent,
-                             @ApiParam(name = "发布时间") String noticeTime,
-                             @ApiParam(name = "发布管理员Id") Integer adminId) {
+    public Boolean addNotice(HttpServletRequest request,
+                             @ApiParam(name = "公告内容", required = true) String noticeContent) {
         //flag false 添加失败  true 添加成功
         Boolean flag = Boolean.FALSE;
         try {
+            Integer adminId =Integer.parseInt(CreateTokenUtil.getHeadersInfo(request))  ;
             if (adminId != null) {
                 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                noticeTime = df.format(new Date());
+                String noticeTime = df.format(new Date());
                 repairsNoticeService.addNotice(noticeContent, noticeTime, adminId);
                 flag = Boolean.TRUE;
             }
@@ -60,8 +64,9 @@ public class NoticeController {
         return repairsNotice;
     }
 
-    //    @ApiOperation("删除公告")
-//    @PostMapping(value = "/updateNotice")
+    @ApiIgnore
+    @ApiOperation("删除公告")
+    @PostMapping(value = "/updateNotice")
     public Boolean updateNotice(@ApiParam(name = "公告Id", required = true) String noticeId) {
         Boolean flag = Boolean.FALSE;
         try {
@@ -74,8 +79,10 @@ public class NoticeController {
         return flag;
     }
 
-//    @ApiOperation("修改公告")
-//    @PostMapping(value = "/alterNotice")
+
+    @ApiIgnore
+    @ApiOperation("修改公告")
+    @PostMapping(value = "/alterNotice")
     public Boolean alterNotice(@ApiParam(name = "公告内容", required = true) String noticeContent,
                                @ApiParam(name = "修改时间") String noticeTime,
                                @ApiParam(name = "公告Id", required = true) Integer noticeId) {

+ 0 - 4
src/main/java/com/chuanghai/repair/controller/OrderController.java

@@ -76,8 +76,6 @@ public class OrderController {
                 //传入时间就设置为当天时间
                 Date date = sdf.parse(time);
                 calendar.setTime(date);
-                }else {//获取当天时间
-                    calendar.setTime(calendar.getTime());
                 }
                 //获取当天的0时0分0秒
                 calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH),
@@ -193,11 +191,9 @@ public class OrderController {
             if(workId!="" && workId!=null){
                 orderList = repairsOrderService.queryAllOrderById(null,workId,campus);
             }
-
         }catch (Exception e){
             e.printStackTrace();
         }
-
         return orderList;
     }
 

+ 0 - 2
src/main/java/com/chuanghai/repair/controller/WorkController.java

@@ -44,11 +44,9 @@ public class WorkController {
             RepairsWork repairsWork = new RepairsWork(null,workName,workPassword,workPhone,"1","0",workCampus);
             RepairsWork testWork = repairsWorkService.queryByWorkName(repairsWork.getWorkName());
             if(testWork!=null){
-
                 //匹配数据库中同名同手机的用户,相同则表示用户已存在注册失败,不同则用户继续注册
                 if(repairsWork.getWorkName().equals(testWork.getWorkName()) &&
                         repairsWork.getWorkPhone().equals(testWork.getWorkPhone())){
-
                 }else {  //继续注册
                      repairsWorkService.insertWork(repairsWork);
                      flag = Boolean.TRUE;

+ 1 - 1
src/main/java/com/chuanghai/repair/entity/RepairsNotice.java

@@ -31,7 +31,7 @@ public class RepairsNotice {
     /**
      * 发布时间
      */
-    @ApiModelProperty(value = "发布时间")
+    @ApiModelProperty(value = "添加公告时间")
     @Column(name = "notice_time")
     private String noticeTime;
 

+ 2 - 50
src/main/java/com/chuanghai/repair/utils/CreateTokenUtil.java

@@ -122,7 +122,6 @@ public class CreateTokenUtil {
                     }
                 }
             }
-
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -208,55 +207,7 @@ public class CreateTokenUtil {
                     System.out.println("key:" + entry.getKey() + ":" + "value:" + entry.getValue());
                 }
             }
-//            RestTemplate restTemplate = new RestTemplate();
-//            MultiValueMap<String, String> map= new LinkedMultiValueMap<String, String>();
-//            map.add("shopid","1");
-//            HttpHeaders headers = new HttpHeaders();
-//            headers.setContentType(MediaType.APPLICATION_JSON);
-//            HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, headers);
-//            String userInfoUrl = "https://open.wecard.qq.com/connect/oauth/get-user-info?access_token=" + access_token + "&scope=snsapi_base";
-//            StringBuffer userInfoURl = new StringBuffer(userInfoUrl);
-//            URI urm = URI.create(userInfoURl.toString());
-//            ResponseEntity<String> responseEntity = restTemplate.postForEntity(urm, request, String.class);
-//            userInfoJSON = JSON.parseObject(responseEntity.getBody());
-//            for (Map.Entry<String, Object> entry : userInfoJSON.entrySet()) {
-//                Object o = entry.getValue();
-//                if (o instanceof String) {
-//                       System.out.println("key:"+entry.getKey()+":"+"value:"+entry.getValue());
-//                }
-//            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        return userInfoJSON;
-    }
-
-    /**
-     * 微校小程序H5页面  通过 access_token 获取 用户信息
-     *
-     * @param url
-     * @return
-     */
-    public static JSONObject sendNotice(String url) {
-        JSONObject userInfoJSON = null;
-        try {
-            RestTemplate restTemplate = new RestTemplate();
-            MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
-            map.add("shopid", "1");
-            HttpHeaders headers = new HttpHeaders();
-            headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
-            HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, headers);
-            ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, request, String.class);
-
-
-            userInfoJSON = JSON.parseObject(responseEntity.getBody());
-
 
-//            StringBuffer unoticeURl = new StringBuffer(url);
-//            URI urm = URI.create(unoticeURl.toString());
-//            ResponseEntity<String> responsem = restTemplate.postForEntity(urm, httpEntity, String.class);
-//            userInfoJSON = JSON.parseObject(responsem.getBody());
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -264,6 +215,7 @@ public class CreateTokenUtil {
         return userInfoJSON;
     }
 
+
     /**
      * 获取请求头中的数据
      *
@@ -281,7 +233,7 @@ public class CreateTokenUtil {
             map.put(key, value);
         }
         for (Map.Entry<String, String> entry : map.entrySet()) {
-            if (entry.getKey().equals("access_token")) {
+                if (entry.getKey().equals("access_token")) {
                 access_token = entry.getValue();
             }
         }

+ 2 - 1
src/main/resources/mapper/RepairsOrderMapper.xml

@@ -61,6 +61,7 @@
                     and od.order_commit_time BETWEEN #{tody} and #{tomorrow}
                 </if>
             </trim>
+                order by od.order_commit_time desc
         </select>
 
     <!--    通过ID查询订单信息-->
@@ -79,7 +80,7 @@
             <if test="campus!='' and campus!=null">
                 and st.student_campus = #{campus}
             </if>
-
+            order by od.order_commit_time desc
         </trim>
     </select>