From 3f52160cf9d8f1b5894dc3a772d9364ed12a9db1 Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Thu, 2 Jul 2020 22:10:10 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=94=A8=E4=BA=8E?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=9A=84=E5=AE=9E=E4=BD=93=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cloudservice/ccs/entity/ApiResult.java | 30 ++++++++++++++++++ .../ccs/entity/ErrorResponse.java | 15 --------- .../ccs/exception/BaseException.java | 7 ++--- .../ccs/exception/GlobalExceptionHandler.java | 31 +++++-------------- .../com/cloudservice/ccs/util/Constant.java | 5 +++ 5 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 src/main/java/com/cloudservice/ccs/entity/ApiResult.java delete mode 100644 src/main/java/com/cloudservice/ccs/entity/ErrorResponse.java create mode 100644 src/main/java/com/cloudservice/ccs/util/Constant.java diff --git a/src/main/java/com/cloudservice/ccs/entity/ApiResult.java b/src/main/java/com/cloudservice/ccs/entity/ApiResult.java new file mode 100644 index 0000000..e089ac4 --- /dev/null +++ b/src/main/java/com/cloudservice/ccs/entity/ApiResult.java @@ -0,0 +1,30 @@ +package com.cloudservice.ccs.entity; + +import com.cloudservice.ccs.util.Constant; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class ApiResult { + + private String error; + + private Object data; + + public static ApiResult success() { + return new ApiResult(null, null); + } + + public static ApiResult successWithData(Object data) { + return new ApiResult(null, data); + } + + public static ApiResult failure() { + return new ApiResult(Constant.DEFAULT_ERROR_MESSAGE, null); + } + + public static ApiResult failureWithData(Object data) { + return new ApiResult(Constant.DEFAULT_ERROR_MESSAGE, data); + } +} diff --git a/src/main/java/com/cloudservice/ccs/entity/ErrorResponse.java b/src/main/java/com/cloudservice/ccs/entity/ErrorResponse.java deleted file mode 100644 index bad8d26..0000000 --- a/src/main/java/com/cloudservice/ccs/entity/ErrorResponse.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.cloudservice.ccs.entity; - -import com.fasterxml.jackson.annotation.JsonFormat; -import lombok.Data; - -import java.util.Date; - -@Data -public class ErrorResponse { - private Date timestamp; - private String exception; - private Integer status; - private String error; - private String message; -} diff --git a/src/main/java/com/cloudservice/ccs/exception/BaseException.java b/src/main/java/com/cloudservice/ccs/exception/BaseException.java index 8956c62..79aa4de 100644 --- a/src/main/java/com/cloudservice/ccs/exception/BaseException.java +++ b/src/main/java/com/cloudservice/ccs/exception/BaseException.java @@ -1,15 +1,12 @@ package com.cloudservice.ccs.exception; +import com.cloudservice.ccs.util.Constant; import lombok.Data; import org.springframework.http.HttpStatus; @Data public class BaseException extends RuntimeException { - private String error = "General error"; - - private Integer status = 400; - - private HttpStatus httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; + private String error = Constant.DEFAULT_ERROR_MESSAGE; public BaseException(String message) { super(message); diff --git a/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java b/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java index 8fb30ea..84f8bb6 100644 --- a/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java @@ -1,16 +1,11 @@ package com.cloudservice.ccs.exception; -import com.cloudservice.ccs.entity.ErrorResponse; -import org.apache.shiro.authc.AuthenticationException; +import com.cloudservice.ccs.entity.ApiResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; -import java.util.Date; - @RestControllerAdvice public class GlobalExceptionHandler { @@ -21,35 +16,23 @@ public class GlobalExceptionHandler { * 剩余的异常由 Spring Boot 处理 */ @ExceptionHandler(BaseException.class) - public ResponseEntity handleBaseException(BaseException e) { + public ApiResult handleBaseException(BaseException e) { if (logger.isDebugEnabled()) { - logger.debug(e.getClass().getName() + ": " + e.getMessage()); + logger.debug(e.getClass().getName() + "[" + e.getError() + "]: " + e.getMessage()); e.printStackTrace(); } - ErrorResponse errorResponse = new ErrorResponse(); - errorResponse.setTimestamp(new Date()); - errorResponse.setException(e.getClass().getName()); - errorResponse.setStatus(e.getStatus()); - errorResponse.setError(e.getError()); - errorResponse.setMessage(e.getMessage()); - return new ResponseEntity<>(errorResponse, e.getHttpStatus()); + return new ApiResult(e.getError(), e.getClass().getName() + ": " + e.getMessage()); } /** * 处理认证、鉴权相关异常并返回对应的错误响应 */ - @ExceptionHandler(AuthenticationException.class) - public ResponseEntity handleAuthenticationException(AuthenticationException e) { + @ExceptionHandler(Exception.class) + public ApiResult handleException(Exception e) { if (logger.isDebugEnabled()) { logger.debug(e.getClass().getName() + ": " + e.getMessage()); e.printStackTrace(); } - ErrorResponse errorResponse = new ErrorResponse(); - errorResponse.setTimestamp(new Date()); - errorResponse.setException(e.getClass().getName()); - errorResponse.setStatus(400); - errorResponse.setError("Authentication failure"); - errorResponse.setMessage(e.getMessage()); - return new ResponseEntity<>(errorResponse, HttpStatus.FORBIDDEN); + return ApiResult.failureWithData(e.getClass().getName() + ": " + e.getMessage()); } } diff --git a/src/main/java/com/cloudservice/ccs/util/Constant.java b/src/main/java/com/cloudservice/ccs/util/Constant.java new file mode 100644 index 0000000..e6245ab --- /dev/null +++ b/src/main/java/com/cloudservice/ccs/util/Constant.java @@ -0,0 +1,5 @@ +package com.cloudservice.ccs.util; + +public class Constant { + public static final String DEFAULT_ERROR_MESSAGE = "error"; +} -- Gitee From cbfdf59e0a68f27cb6dadb326ae89f745f7a4482 Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Thu, 2 Jul 2020 22:17:48 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=83=A8=E5=88=86=20co?= =?UTF-8?q?ntroller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AttendanceStatisticsController.java | 18 ++++++++------ .../ccs/controller/BlackListController.java | 18 ++++++++------ .../ccs/controller/CommonWordController.java | 13 +++++----- .../controller/CustomerServiceController.java | 24 +++++++++++-------- .../ccs/controller/LoginController.java | 13 ++++------ 5 files changed, 48 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/cloudservice/ccs/controller/AttendanceStatisticsController.java b/src/main/java/com/cloudservice/ccs/controller/AttendanceStatisticsController.java index ee674e1..a2d7993 100644 --- a/src/main/java/com/cloudservice/ccs/controller/AttendanceStatisticsController.java +++ b/src/main/java/com/cloudservice/ccs/controller/AttendanceStatisticsController.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.IAttendanceStatisticsBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.AttendanceStatistics; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -18,31 +19,34 @@ public class AttendanceStatisticsController { private IAttendanceStatisticsBiz attendanceStatisticsBiz; @PostMapping("/") - void save(@RequestBody AttendanceStatistics attendanceStatistics) { + ApiResult save(@RequestBody AttendanceStatistics attendanceStatistics) { // 接口问题待讨论:是否应当返回生成的 id? attendanceStatisticsBiz.save(attendanceStatistics); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody AttendanceStatistics attendanceStatistics) { + ApiResult update(@PathVariable Integer id, @RequestBody AttendanceStatistics attendanceStatistics) { attendanceStatisticsBiz.update(id, attendanceStatistics); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + ApiResult delete(@PathVariable Integer id) { attendanceStatisticsBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + ApiResult queryById(@PathVariable Integer id) { AttendanceStatistics result = attendanceStatisticsBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @GetMapping("/") - ResponseEntity>> queryAll() { + ApiResult queryAll() { Map> result = new HashMap<>(); result.put("attendance-statistics", attendanceStatisticsBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/BlackListController.java b/src/main/java/com/cloudservice/ccs/controller/BlackListController.java index e08fcf0..0ba16ee 100644 --- a/src/main/java/com/cloudservice/ccs/controller/BlackListController.java +++ b/src/main/java/com/cloudservice/ccs/controller/BlackListController.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.IBlackListBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.BlackList; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -18,31 +19,34 @@ public class BlackListController { private IBlackListBiz blackListBiz; @PostMapping("/") - void save(@RequestBody BlackList blackList) { + ApiResult save(@RequestBody BlackList blackList) { // 接口问题待讨论:是否应当返回生成的 id? blackListBiz.save(blackList); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody BlackList blackList) { + ApiResult update(@PathVariable Integer id, @RequestBody BlackList blackList) { blackListBiz.update(id, blackList); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + ApiResult delete(@PathVariable Integer id) { blackListBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + ApiResult queryById(@PathVariable Integer id) { BlackList result = blackListBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @GetMapping("/") - ResponseEntity>> queryAll() { + ApiResult queryAll() { Map> result = new HashMap<>(); result.put("black-list", blackListBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java b/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java index 2e5a5f5..b76fecf 100644 --- a/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java +++ b/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.ICommonWordBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.CommonWord; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -24,25 +25,25 @@ public class CommonWordController { } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody CommonWord commonWord) { +ApiResult update(@PathVariable Integer id, @RequestBody CommonWord commonWord) { commonWordBiz.update(id, commonWord); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + ApiResult delete(@PathVariable Integer id) { commonWordBiz.delete(id); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + ApiResult queryById(@PathVariable Integer id) { CommonWord result = commonWordBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @GetMapping("/") - ResponseEntity>> queryAll() { + ApiResult queryAll() { Map> result = new HashMap<>(); result.put("common-word", commonWordBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/CustomerServiceController.java b/src/main/java/com/cloudservice/ccs/controller/CustomerServiceController.java index ef5d7ae..1596371 100644 --- a/src/main/java/com/cloudservice/ccs/controller/CustomerServiceController.java +++ b/src/main/java/com/cloudservice/ccs/controller/CustomerServiceController.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.ICustomerServiceBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.CustomerService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -21,41 +22,44 @@ public class CustomerServiceController { // @RequiresPermissions("all") @PostMapping("/") - void save(@RequestBody CustomerService customerService) { + ApiResult save(@RequestBody CustomerService customerService) { // 接口问题待讨论:是否应当返回生成的 id? customerServiceBiz.save(customerService); + return ApiResult.success(); } // @RequiresPermissions("all") @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody CustomerService customerService) { + ApiResult update(@PathVariable Integer id, @RequestBody CustomerService customerService) { customerServiceBiz.update(id, customerService); + return ApiResult.success(); } // @RequiresPermissions("all") @PutMapping("/{id}/partial") - void partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { customerServiceBiz.partialUpdate(id, fields); + return ApiResult.success(); } // @RequiresPermissions("all") @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + ApiResult delete(@PathVariable Integer id) { customerServiceBiz.delete(id); + return ApiResult.success(); } // @RequiresPermissions("all") @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + ApiResult queryById(@PathVariable Integer id) { CustomerService result = customerServiceBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } // @RequiresPermissions("all") @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("customer-services", customerServiceBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + ApiResult queryAll() { + List result = customerServiceBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/LoginController.java b/src/main/java/com/cloudservice/ccs/controller/LoginController.java index 0d5189c..8f9597a 100644 --- a/src/main/java/com/cloudservice/ccs/controller/LoginController.java +++ b/src/main/java/com/cloudservice/ccs/controller/LoginController.java @@ -1,5 +1,6 @@ package com.cloudservice.ccs.controller; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.LoginData; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.*; @@ -17,22 +18,18 @@ import java.util.Map; @RestController public class LoginController { @PostMapping("/login") - public ResponseEntity> doLogin(@RequestBody LoginData loginData){ + public ApiResult doLogin(@RequestBody LoginData loginData){ String email = loginData.getEmail(), password = loginData.getPassword(); Subject subject = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken(email,password); subject.login(token); - Map map = new HashMap<>(1); - map.put("result", "success"); - return new ResponseEntity<>(map, HttpStatus.OK); + return ApiResult.success(); } @PostMapping("/logout") - public ResponseEntity> doLogout() { + public ApiResult doLogout() { Subject subject = SecurityUtils.getSubject(); subject.logout(); - Map map = new HashMap<>(1); - map.put("result", "success"); - return new ResponseEntity<>(map, HttpStatus.OK); + return ApiResult.success(); } } -- Gitee From 6eadd2439f3edda976f6d0e140a7fed8890d07a9 Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Fri, 3 Jul 2020 12:01:29 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=B1=82=E5=B9=B3?= =?UTF-8?q?=E5=9D=87=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WorkloadStatisticsController.java | 35 ++++++++++++++----- .../entity/WorkloadStatisticsWithAverage.java | 29 +++++++++++++++ 2 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/cloudservice/ccs/entity/WorkloadStatisticsWithAverage.java diff --git a/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java b/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java index 20dd44b..71ebc15 100644 --- a/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java +++ b/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java @@ -2,13 +2,16 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.IWorkloadStatisticsBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.WorkloadStatistics; +import com.cloudservice.ccs.entity.WorkloadStatisticsWithAverage; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -20,32 +23,46 @@ public class WorkloadStatisticsController { IWorkloadStatisticsBiz workloadStatisticsBiz; @PostMapping("/") - void save(@RequestBody WorkloadStatistics workloadStatistics) { + ApiResult save(@RequestBody WorkloadStatistics workloadStatistics) { // 接口问题待讨论:是否应当返回生成的 id? workloadStatisticsBiz.save(workloadStatistics); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody WorkloadStatistics workloadStatistics) { + ApiResult update(@PathVariable Integer id, @RequestBody WorkloadStatistics workloadStatistics) { workloadStatisticsBiz.update(id, workloadStatistics); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + ApiResult delete(@PathVariable Integer id) { workloadStatisticsBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + ApiResult queryById(@PathVariable Integer id) { WorkloadStatistics result = workloadStatisticsBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @RequiresPermissions("all") @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("workload-statistics", workloadStatisticsBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + ApiResult queryAll() { + List result = workloadStatisticsBiz.getAll(); + return ApiResult.successWithData(result); + } + + @GetMapping("/with-average") + ApiResult queryAllWithAverage() { + List workloadStatisticsList = workloadStatisticsBiz.getAll(); + List result = new ArrayList<>(); + for (WorkloadStatistics workloadStatistics : workloadStatisticsList) { + WorkloadStatisticsWithAverage item = WorkloadStatisticsWithAverage.fromWorkloadStatistics(workloadStatistics); + item.calculateAverage(); + result.add(item); + } + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/entity/WorkloadStatisticsWithAverage.java b/src/main/java/com/cloudservice/ccs/entity/WorkloadStatisticsWithAverage.java new file mode 100644 index 0000000..eff4cc7 --- /dev/null +++ b/src/main/java/com/cloudservice/ccs/entity/WorkloadStatisticsWithAverage.java @@ -0,0 +1,29 @@ +package com.cloudservice.ccs.entity; + +import lombok.Builder; +import lombok.Data; + +@Data +public class WorkloadStatisticsWithAverage extends WorkloadStatistics { + + private Integer averageSessionTime; + + private Integer averageMessageCount; + + public static WorkloadStatisticsWithAverage fromWorkloadStatistics(WorkloadStatistics workloadStatistics) { + WorkloadStatisticsWithAverage res = new WorkloadStatisticsWithAverage(); + res.setId(workloadStatistics.getId()); + res.setNickName(workloadStatistics.getNickName()); + res.setTotalMessageCount(workloadStatistics.getTotalMessageCount()); + res.setTotalSessionCount(workloadStatistics.getTotalSessionCount()); + res.setTotalEffectiveSessionCount(workloadStatistics.getTotalEffectiveSessionCount()); + res.setTotalEndSessionCount(workloadStatistics.getTotalEndSessionCount()); + res.setTotalSessionTime(workloadStatistics.getTotalSessionTime()); + return res; + } + + public void calculateAverage() { + this.setAverageSessionTime(this.getTotalSessionTime() / this.getTotalSessionCount()); + this.setAverageMessageCount(this.getTotalMessageCount() / this.getTotalSessionCount()); + } +} -- Gitee From 71a4ae48880f52d208f27b1f19b9057b7b4a67db Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Fri, 3 Jul 2020 12:56:19 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E8=BD=AC=E7=A7=BB=E8=87=B3=E4=B8=9A=E5=8A=A1=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ccs/biz/IWorkloadStatisticsBiz.java | 3 +++ .../ccs/biz/impl/WorkloadStatisticsImpl.java | 14 ++++++++++++++ .../controller/WorkloadStatisticsController.java | 13 ++++++------- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/cloudservice/ccs/biz/IWorkloadStatisticsBiz.java b/src/main/java/com/cloudservice/ccs/biz/IWorkloadStatisticsBiz.java index ab85feb..d4f282d 100644 --- a/src/main/java/com/cloudservice/ccs/biz/IWorkloadStatisticsBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/IWorkloadStatisticsBiz.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.biz; import com.cloudservice.ccs.entity.WorkloadStatistics; +import com.cloudservice.ccs.entity.WorkloadStatisticsWithAverage; import java.util.List; @@ -15,4 +16,6 @@ public interface IWorkloadStatisticsBiz { WorkloadStatistics getOne(Integer id); List getAll(); + + List getAllWithAverage(); } diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java index 1727b71..a73d656 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java @@ -2,11 +2,13 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.IWorkloadStatisticsBiz; import com.cloudservice.ccs.entity.WorkloadStatistics; +import com.cloudservice.ccs.entity.WorkloadStatisticsWithAverage; import com.cloudservice.ccs.exception.WorkloadStatisticsException; import com.cloudservice.ccs.mapper.WorkLoadStatisticsMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; @Service @@ -51,4 +53,16 @@ public class WorkloadStatisticsImpl implements IWorkloadStatisticsBiz { public List getAll() { return workLoadStatisticsMapper.getAll(); } + + @Override + public List getAllWithAverage() { + List workloadStatisticsList = workLoadStatisticsMapper.getAll(); + List result = new ArrayList<>(); + for (WorkloadStatistics workloadStatistics : workloadStatisticsList) { + WorkloadStatisticsWithAverage item = WorkloadStatisticsWithAverage.fromWorkloadStatistics(workloadStatistics); + item.calculateAverage(); + result.add(item); + } + return result; + } } diff --git a/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java b/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java index 71ebc15..b84af6b 100644 --- a/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java +++ b/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java @@ -56,13 +56,12 @@ public class WorkloadStatisticsController { @GetMapping("/with-average") ApiResult queryAllWithAverage() { - List workloadStatisticsList = workloadStatisticsBiz.getAll(); - List result = new ArrayList<>(); - for (WorkloadStatistics workloadStatistics : workloadStatisticsList) { - WorkloadStatisticsWithAverage item = WorkloadStatisticsWithAverage.fromWorkloadStatistics(workloadStatistics); - item.calculateAverage(); - result.add(item); - } + List result = workloadStatisticsBiz.getAllWithAverage(); return ApiResult.successWithData(result); } + + @GetMapping("/aggregation") + ApiResult queryAggregation() { + return ApiResult.failure(); + } } -- Gitee From b63a9bd46b745e0cf1ee89153b2a765c9fe822cb Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Fri, 3 Jul 2020 13:23:25 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E6=8E=A5=E8=BF=91=E5=AE=8C=E6=88=90=20Wo?= =?UTF-8?q?rkloadStatistics=20=E7=9A=84=E7=9B=B8=E5=85=B3=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 以及注释掉了 CommonWordController --- .../ccs/biz/IWorkloadStatisticsBiz.java | 3 + .../ccs/biz/impl/WorkloadStatisticsImpl.java | 6 ++ .../ccs/controller/CommonWordController.java | 98 +++++++++---------- .../WorkloadStatisticsController.java | 2 +- .../entity/WorkloadStatisticsAggregation.java | 9 ++ .../ccs/mapper/WorkLoadStatisticsMapper.java | 3 + .../mapper/WorkLoadStatisticsMapper.xml | 9 ++ 7 files changed, 80 insertions(+), 50 deletions(-) create mode 100644 src/main/java/com/cloudservice/ccs/entity/WorkloadStatisticsAggregation.java diff --git a/src/main/java/com/cloudservice/ccs/biz/IWorkloadStatisticsBiz.java b/src/main/java/com/cloudservice/ccs/biz/IWorkloadStatisticsBiz.java index d4f282d..08cf5b8 100644 --- a/src/main/java/com/cloudservice/ccs/biz/IWorkloadStatisticsBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/IWorkloadStatisticsBiz.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.biz; import com.cloudservice.ccs.entity.WorkloadStatistics; +import com.cloudservice.ccs.entity.WorkloadStatisticsAggregation; import com.cloudservice.ccs.entity.WorkloadStatisticsWithAverage; import java.util.List; @@ -18,4 +19,6 @@ public interface IWorkloadStatisticsBiz { List getAll(); List getAllWithAverage(); + + WorkloadStatisticsAggregation getAggregation(); } diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java index a73d656..e482ad1 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java @@ -2,6 +2,7 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.IWorkloadStatisticsBiz; import com.cloudservice.ccs.entity.WorkloadStatistics; +import com.cloudservice.ccs.entity.WorkloadStatisticsAggregation; import com.cloudservice.ccs.entity.WorkloadStatisticsWithAverage; import com.cloudservice.ccs.exception.WorkloadStatisticsException; import com.cloudservice.ccs.mapper.WorkLoadStatisticsMapper; @@ -65,4 +66,9 @@ public class WorkloadStatisticsImpl implements IWorkloadStatisticsBiz { } return result; } + + @Override + public WorkloadStatisticsAggregation getAggregation() { + return workLoadStatisticsMapper.getAggregation(); + } } diff --git a/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java b/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java index b76fecf..e78151a 100644 --- a/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java +++ b/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java @@ -1,49 +1,49 @@ -package com.cloudservice.ccs.controller; - -import com.cloudservice.ccs.biz.ICommonWordBiz; -import com.cloudservice.ccs.entity.ApiResult; -import com.cloudservice.ccs.entity.CommonWord; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@RestController -@RequestMapping("/common-word") -public class CommonWordController { - @Autowired - private ICommonWordBiz commonWordBiz; - - @PostMapping("/") - void save(@RequestBody CommonWord commonWord) { - // 接口问题待讨论:是否应当返回生成的 id? - commonWordBiz.save(commonWord); - } - -@PutMapping("/{id}") -ApiResult update(@PathVariable Integer id, @RequestBody CommonWord commonWord) { - commonWordBiz.update(id, commonWord); - } - -@DeleteMapping("/{id}") - ApiResult delete(@PathVariable Integer id) { - commonWordBiz.delete(id); - } - -@GetMapping("/{id}") - ApiResult queryById(@PathVariable Integer id) { - CommonWord result = commonWordBiz.getOne(id); - return ApiResult.successWithData(result); - } - -@GetMapping("/") - ApiResult queryAll() { - Map> result = new HashMap<>(); - result.put("common-word", commonWordBiz.getAll()); - return ApiResult.successWithData(result); - } -} +//package com.cloudservice.ccs.controller; +// +//import com.cloudservice.ccs.biz.ICommonWordBiz; +//import com.cloudservice.ccs.entity.ApiResult; +//import com.cloudservice.ccs.entity.CommonWord; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.http.HttpStatus; +//import org.springframework.http.ResponseEntity; +//import org.springframework.web.bind.annotation.*; +// +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +//@RestController +//@RequestMapping("/common-word") +//public class CommonWordController { +// @Autowired +// private ICommonWordBiz commonWordBiz; +// +// @PostMapping("/") +// void save(@RequestBody CommonWord commonWord) { +// // 接口问题待讨论:是否应当返回生成的 id? +// commonWordBiz.save(commonWord); +// } +// +//@PutMapping("/{id}") +//ApiResult update(@PathVariable Integer id, @RequestBody CommonWord commonWord) { +// commonWordBiz.update(id, commonWord); +// } +// +//@DeleteMapping("/{id}") +// ApiResult delete(@PathVariable Integer id) { +// commonWordBiz.delete(id); +// } +// +//@GetMapping("/{id}") +// ApiResult queryById(@PathVariable Integer id) { +// CommonWord result = commonWordBiz.getOne(id); +// return ApiResult.successWithData(result); +// } +// +//@GetMapping("/") +// ApiResult queryAll() { +// Map> result = new HashMap<>(); +// result.put("common-word", commonWordBiz.getAll()); +// return ApiResult.successWithData(result); +// } +//} diff --git a/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java b/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java index b84af6b..ce75a94 100644 --- a/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java +++ b/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java @@ -62,6 +62,6 @@ public class WorkloadStatisticsController { @GetMapping("/aggregation") ApiResult queryAggregation() { - return ApiResult.failure(); + return ApiResult.successWithData(workloadStatisticsBiz.getAggregation()); } } diff --git a/src/main/java/com/cloudservice/ccs/entity/WorkloadStatisticsAggregation.java b/src/main/java/com/cloudservice/ccs/entity/WorkloadStatisticsAggregation.java new file mode 100644 index 0000000..ad38aff --- /dev/null +++ b/src/main/java/com/cloudservice/ccs/entity/WorkloadStatisticsAggregation.java @@ -0,0 +1,9 @@ +package com.cloudservice.ccs.entity; + +public class WorkloadStatisticsAggregation { + public Integer totalMessageCount; + public Integer totalSessionCount; + public Integer averageMessageCount; + public Integer totalSessionTime; + public Integer averageSessionTime; +} diff --git a/src/main/java/com/cloudservice/ccs/mapper/WorkLoadStatisticsMapper.java b/src/main/java/com/cloudservice/ccs/mapper/WorkLoadStatisticsMapper.java index 502563e..8c2c7b5 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/WorkLoadStatisticsMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/WorkLoadStatisticsMapper.java @@ -3,6 +3,7 @@ package com.cloudservice.ccs.mapper; import com.cloudservice.ccs.entity.VisitorInfo; import com.cloudservice.ccs.entity.WorkloadStatistics; +import com.cloudservice.ccs.entity.WorkloadStatisticsAggregation; import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -18,4 +19,6 @@ public interface WorkLoadStatisticsMapper { WorkloadStatistics getOne(Integer id); List getAll(); + + WorkloadStatisticsAggregation getAggregation(); } diff --git a/src/main/resources/mapper/WorkLoadStatisticsMapper.xml b/src/main/resources/mapper/WorkLoadStatisticsMapper.xml index 0283717..2ddc4ad 100644 --- a/src/main/resources/mapper/WorkLoadStatisticsMapper.xml +++ b/src/main/resources/mapper/WorkLoadStatisticsMapper.xml @@ -36,4 +36,13 @@ + + \ No newline at end of file -- Gitee From 8e302edc2e017326829dbfbc9e459956353994fa Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Fri, 3 Jul 2020 17:21:08 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E8=81=9A=E5=90=88?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ccs/biz/impl/WorkloadStatisticsImpl.java | 6 +++++- .../entity/WorkloadStatisticsAggregation.java | 17 ++++++++++++----- .../ccs/mapper/WorkLoadStatisticsMapper.java | 4 +++- .../mapper/WorkLoadStatisticsMapper.xml | 11 +++++++++-- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java index e482ad1..bcaf414 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java @@ -69,6 +69,10 @@ public class WorkloadStatisticsImpl implements IWorkloadStatisticsBiz { @Override public WorkloadStatisticsAggregation getAggregation() { - return workLoadStatisticsMapper.getAggregation(); + WorkloadStatisticsAggregation part1 = workLoadStatisticsMapper.getStatisticsPartOfAggregation(), + part2 = workLoadStatisticsMapper.getSessionPartOfAggregation(); + part1.setMaxSessionTime(part2.getMaxSessionTime()); + part1.setMaxMessageCount(part2.getMaxMessageCount()); + return part1; } } diff --git a/src/main/java/com/cloudservice/ccs/entity/WorkloadStatisticsAggregation.java b/src/main/java/com/cloudservice/ccs/entity/WorkloadStatisticsAggregation.java index ad38aff..3ad99ed 100644 --- a/src/main/java/com/cloudservice/ccs/entity/WorkloadStatisticsAggregation.java +++ b/src/main/java/com/cloudservice/ccs/entity/WorkloadStatisticsAggregation.java @@ -1,9 +1,16 @@ package com.cloudservice.ccs.entity; +import lombok.Data; + +@Data public class WorkloadStatisticsAggregation { - public Integer totalMessageCount; - public Integer totalSessionCount; - public Integer averageMessageCount; - public Integer totalSessionTime; - public Integer averageSessionTime; + private Integer totalMessageCount; + private Integer totalSessionCount; + private Integer averageMessageCount; + private Integer totalSessionTime; + private Integer averageSessionTime; + private Integer totalEffectiveMessageCount; + private Integer totalEndSessionCount; + private Integer maxMessageCount; + private Integer maxSessionTime; } diff --git a/src/main/java/com/cloudservice/ccs/mapper/WorkLoadStatisticsMapper.java b/src/main/java/com/cloudservice/ccs/mapper/WorkLoadStatisticsMapper.java index 8c2c7b5..9124732 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/WorkLoadStatisticsMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/WorkLoadStatisticsMapper.java @@ -20,5 +20,7 @@ public interface WorkLoadStatisticsMapper { List getAll(); - WorkloadStatisticsAggregation getAggregation(); + WorkloadStatisticsAggregation getStatisticsPartOfAggregation(); + + WorkloadStatisticsAggregation getSessionPartOfAggregation(); } diff --git a/src/main/resources/mapper/WorkLoadStatisticsMapper.xml b/src/main/resources/mapper/WorkLoadStatisticsMapper.xml index 2ddc4ad..95f1519 100644 --- a/src/main/resources/mapper/WorkLoadStatisticsMapper.xml +++ b/src/main/resources/mapper/WorkLoadStatisticsMapper.xml @@ -37,12 +37,19 @@ SELECT * FROM workload_statistics; - SELECT SUM(totalMessageCount) AS totalMessageCount, SUM(totalSessionCount) AS totalSessionCount, SUM(totalMessageCount) / SUM(totalSessionCount) AS averageMessageCount, SUM(totalSessionTime) AS totalSessionTime, - SUM(totalSessionTime) / SUM(totalSessionCount) AS averageSessionTime + SUM(totalSessionTime) / SUM(totalSessionCount) AS averageSessionTime, + SUM(totalEndSessionCount) AS totalEndSessionCount, + SUM(totalEffectiveSessionCount) AS totalEffectiveMessageCount FROM workload_statistics; + \ No newline at end of file -- Gitee From d81baafb4822aadfd40017458032f7bd671d31aa Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Fri, 3 Jul 2020 17:50:59 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20GlobalExceptionHandl?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ccs/exception/GlobalExceptionHandler.java | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java b/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java index 84f8bb6..161956b 100644 --- a/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java @@ -1,6 +1,9 @@ package com.cloudservice.ccs.exception; import com.cloudservice.ccs.entity.ApiResult; +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.IncorrectCredentialsException; +import org.apache.shiro.authc.UnknownAccountException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.ExceptionHandler; @@ -13,26 +16,38 @@ public class GlobalExceptionHandler { /** * 处理 BaseException(以及其子类)并返回对应的错误响应 - * 剩余的异常由 Spring Boot 处理 */ @ExceptionHandler(BaseException.class) public ApiResult handleBaseException(BaseException e) { - if (logger.isDebugEnabled()) { - logger.debug(e.getClass().getName() + "[" + e.getError() + "]: " + e.getMessage()); - e.printStackTrace(); - } - return new ApiResult(e.getError(), e.getClass().getName() + ": " + e.getMessage()); + logException(e); + return new ApiResult(e.getError(), e.getMessage()); } /** * 处理认证、鉴权相关异常并返回对应的错误响应 */ + @ExceptionHandler(AuthenticationException.class) + public ApiResult handleException(AuthenticationException e) { + logException(e); + if (e instanceof UnknownAccountException) { + return ApiResult.failureWithData("未知用户"); + } else if (e instanceof IncorrectCredentialsException) { + return ApiResult.failureWithData("用户名或密码错误"); + } else { + return ApiResult.failureWithData("未知认证错误:" + e.getClass().getName() + ": " + e.getMessage()); + } + } + @ExceptionHandler(Exception.class) public ApiResult handleException(Exception e) { + logException(e); + return ApiResult.failureWithData("未知错误:" + e.getClass().getName() + ": " + e.getMessage()); + } + + private void logException(Exception e) { if (logger.isDebugEnabled()) { logger.debug(e.getClass().getName() + ": " + e.getMessage()); e.printStackTrace(); } - return ApiResult.failureWithData(e.getClass().getName() + ": " + e.getMessage()); } } -- Gitee From 6a6181c2fba0308c378ed9fb2d55681ee519d244 Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Fri, 3 Jul 2020 18:05:40 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20CustomerService=20?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=20API=20=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ccs/biz/impl/CustomerServiceImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/CustomerServiceImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/CustomerServiceImpl.java index 7142754..d979b07 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/CustomerServiceImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/CustomerServiceImpl.java @@ -24,7 +24,7 @@ public class CustomerServiceImpl implements ICustomerServiceBiz { } int result = customerServiceMapper.save(customerService); if (result == 0) { - throw new CustomerServiceException("Create CustomerService entity error"); + throw new CustomerServiceException("创建客服失败"); } } @@ -33,7 +33,7 @@ public class CustomerServiceImpl implements ICustomerServiceBiz { if (customerService.getPassword() != null) { CustomerService originalCustomerService = customerServiceMapper.getOne(id); if (originalCustomerService == null) { - throw new CustomerServiceException("CustomerService entity being updated does not exist"); + throw new CustomerServiceException("要更新的客服不存在"); } String originalPassword = originalCustomerService.getPassword(); String newPassword = customerService.getPassword(); @@ -43,7 +43,7 @@ public class CustomerServiceImpl implements ICustomerServiceBiz { } int result = customerServiceMapper.update(id, customerService); if (result == 0) { - throw new CustomerServiceException("Update CustomerService entity error"); + throw new CustomerServiceException("更新客服信息失败"); } } @@ -54,7 +54,7 @@ public class CustomerServiceImpl implements ICustomerServiceBiz { } int result = customerServiceMapper.partialUpdate(id, fields); if (result == 0) { - throw new CustomerServiceException("Partial update CustomerService entity error"); + throw new CustomerServiceException("更新客服信息失败"); } } @@ -62,7 +62,7 @@ public class CustomerServiceImpl implements ICustomerServiceBiz { public void delete(Integer id) { int result = customerServiceMapper.delete(id); if (result == 0) { - throw new CustomerServiceException("Delete CustomerService entity error"); + throw new CustomerServiceException("删除客服失败"); } } @@ -70,7 +70,7 @@ public class CustomerServiceImpl implements ICustomerServiceBiz { public CustomerService getOne(Integer id) { CustomerService customerService = customerServiceMapper.getOne(id); if (customerService == null) { - throw new CustomerServiceException("Get CustomerService entity error: no such entity"); + throw new CustomerServiceException("要查询的客服不存在"); } return customerService; } -- Gitee From 5a759c48b95f14831085f62ceefa9e86c689937c Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Fri, 3 Jul 2020 18:09:27 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=AF=B7=E6=B1=82/=E5=93=8D=E5=BA=94=E7=9A=84=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 635175f..b302dbf 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -10,3 +10,8 @@ spring: mybatis: mapper-locations: classpath:mapper/*.xml type-aliases-package: com.cloudservice.ccs.entity + +logging: + level: + root: INFO + # web: DEBUG # 将本行注释去掉以查看 Web 请求与响应等详细信息(包括请求与响应日志等) -- Gitee From d7039cac718fe6df57fe579765670286761c84dc Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Fri, 3 Jul 2020 19:52:47 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AttendanceStatisticsController.java | 13 ++- .../ccs/controller/BlackListController.java | 13 ++- .../ccs/controller/CommonWordController.java | 100 +++++++++--------- .../controller/CustomerInfoController.java | 21 ++-- .../controller/CustomerServiceController.java | 14 +-- .../ccs/controller/GroupManageController.java | 23 ++-- .../ccs/controller/NoticeController.java | 23 ++-- .../ccs/controller/RoleManageController.java | 23 ++-- .../ccs/controller/SessionController.java | 23 ++-- .../controller/SessionMessageController.java | 23 ++-- .../controller/SystemMessageController.java | 23 ++-- .../ccs/controller/TagsController.java | 23 ++-- .../controller/ViewStatisticsController.java | 23 ++-- .../ccs/controller/VisitorInfoController.java | 23 ++-- .../ccs/controller/WorkLogController.java | 26 +++-- .../ccs/controller/WorkOrderController.java | 26 +++-- .../controller/WorkOrderReplyController.java | 26 +++-- .../WorkQualityStatisticsController.java | 26 +++-- .../WorkloadStatisticsController.java | 16 +-- 19 files changed, 267 insertions(+), 221 deletions(-) diff --git a/src/main/java/com/cloudservice/ccs/controller/AttendanceStatisticsController.java b/src/main/java/com/cloudservice/ccs/controller/AttendanceStatisticsController.java index a2d7993..d0d5bd8 100644 --- a/src/main/java/com/cloudservice/ccs/controller/AttendanceStatisticsController.java +++ b/src/main/java/com/cloudservice/ccs/controller/AttendanceStatisticsController.java @@ -19,34 +19,33 @@ public class AttendanceStatisticsController { private IAttendanceStatisticsBiz attendanceStatisticsBiz; @PostMapping("/") - ApiResult save(@RequestBody AttendanceStatistics attendanceStatistics) { + public ApiResult save(@RequestBody AttendanceStatistics attendanceStatistics) { // 接口问题待讨论:是否应当返回生成的 id? attendanceStatisticsBiz.save(attendanceStatistics); return ApiResult.success(); } @PutMapping("/{id}") - ApiResult update(@PathVariable Integer id, @RequestBody AttendanceStatistics attendanceStatistics) { + public ApiResult update(@PathVariable Integer id, @RequestBody AttendanceStatistics attendanceStatistics) { attendanceStatisticsBiz.update(id, attendanceStatistics); return ApiResult.success(); } @DeleteMapping("/{id}") - ApiResult delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { attendanceStatisticsBiz.delete(id); return ApiResult.success(); } @GetMapping("/{id}") - ApiResult queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { AttendanceStatistics result = attendanceStatisticsBiz.getOne(id); return ApiResult.successWithData(result); } @GetMapping("/") - ApiResult queryAll() { - Map> result = new HashMap<>(); - result.put("attendance-statistics", attendanceStatisticsBiz.getAll()); + public ApiResult queryAll() { + List result = attendanceStatisticsBiz.getAll(); return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/BlackListController.java b/src/main/java/com/cloudservice/ccs/controller/BlackListController.java index 0ba16ee..9445704 100644 --- a/src/main/java/com/cloudservice/ccs/controller/BlackListController.java +++ b/src/main/java/com/cloudservice/ccs/controller/BlackListController.java @@ -19,34 +19,33 @@ public class BlackListController { private IBlackListBiz blackListBiz; @PostMapping("/") - ApiResult save(@RequestBody BlackList blackList) { + public ApiResult save(@RequestBody BlackList blackList) { // 接口问题待讨论:是否应当返回生成的 id? blackListBiz.save(blackList); return ApiResult.success(); } @PutMapping("/{id}") - ApiResult update(@PathVariable Integer id, @RequestBody BlackList blackList) { + public ApiResult update(@PathVariable Integer id, @RequestBody BlackList blackList) { blackListBiz.update(id, blackList); return ApiResult.success(); } @DeleteMapping("/{id}") - ApiResult delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { blackListBiz.delete(id); return ApiResult.success(); } @GetMapping("/{id}") - ApiResult queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { BlackList result = blackListBiz.getOne(id); return ApiResult.successWithData(result); } @GetMapping("/") - ApiResult queryAll() { - Map> result = new HashMap<>(); - result.put("black-list", blackListBiz.getAll()); + public ApiResult queryAll() { + List result = blackListBiz.getAll(); return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java b/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java index e78151a..5413319 100644 --- a/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java +++ b/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java @@ -1,49 +1,51 @@ -//package com.cloudservice.ccs.controller; -// -//import com.cloudservice.ccs.biz.ICommonWordBiz; -//import com.cloudservice.ccs.entity.ApiResult; -//import com.cloudservice.ccs.entity.CommonWord; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.http.HttpStatus; -//import org.springframework.http.ResponseEntity; -//import org.springframework.web.bind.annotation.*; -// -//import java.util.HashMap; -//import java.util.List; -//import java.util.Map; -// -//@RestController -//@RequestMapping("/common-word") -//public class CommonWordController { -// @Autowired -// private ICommonWordBiz commonWordBiz; -// -// @PostMapping("/") -// void save(@RequestBody CommonWord commonWord) { -// // 接口问题待讨论:是否应当返回生成的 id? -// commonWordBiz.save(commonWord); -// } -// -//@PutMapping("/{id}") -//ApiResult update(@PathVariable Integer id, @RequestBody CommonWord commonWord) { -// commonWordBiz.update(id, commonWord); -// } -// -//@DeleteMapping("/{id}") -// ApiResult delete(@PathVariable Integer id) { -// commonWordBiz.delete(id); -// } -// -//@GetMapping("/{id}") -// ApiResult queryById(@PathVariable Integer id) { -// CommonWord result = commonWordBiz.getOne(id); -// return ApiResult.successWithData(result); -// } -// -//@GetMapping("/") -// ApiResult queryAll() { -// Map> result = new HashMap<>(); -// result.put("common-word", commonWordBiz.getAll()); -// return ApiResult.successWithData(result); -// } -//} +package com.cloudservice.ccs.controller; + +import com.cloudservice.ccs.biz.ICommonWordBiz; +import com.cloudservice.ccs.entity.ApiResult; +import com.cloudservice.ccs.entity.CommonWord; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/common-word") +public class CommonWordController { + @Autowired + private ICommonWordBiz commonWordBiz; + + @PostMapping("/") + public ApiResult save(@RequestBody CommonWord commonWord) { + // 接口问题待讨论:是否应当返回生成的 id? + commonWordBiz.save(commonWord); + return ApiResult.success(); + } + + @PutMapping("/{id}") + public ApiResult update(@PathVariable Integer id, @RequestBody CommonWord commonWord) { + commonWordBiz.update(id, commonWord); + return ApiResult.success(); + } + + @DeleteMapping("/{id}") + public ApiResult delete(@PathVariable Integer id) { + commonWordBiz.delete(id); + return ApiResult.success(); + } + + @GetMapping("/{id}") + public ApiResult queryById(@PathVariable Integer id) { + CommonWord result = commonWordBiz.getOne(id); + return ApiResult.successWithData(result); + } + + @GetMapping("/") + public ApiResult queryAll() { + List result = commonWordBiz.getAll(); + return ApiResult.successWithData(result); + } +} diff --git a/src/main/java/com/cloudservice/ccs/controller/CustomerInfoController.java b/src/main/java/com/cloudservice/ccs/controller/CustomerInfoController.java index 8ff60d6..15a4e55 100644 --- a/src/main/java/com/cloudservice/ccs/controller/CustomerInfoController.java +++ b/src/main/java/com/cloudservice/ccs/controller/CustomerInfoController.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.ICustomerInfoBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.CustomerInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -18,31 +19,33 @@ public class CustomerInfoController { private ICustomerInfoBiz customerInfoBiz; @PostMapping("/") - void save(@RequestBody CustomerInfo customerInfo) { + public ApiResult save(@RequestBody CustomerInfo customerInfo) { // 接口问题待讨论:是否应当返回生成的 id? customerInfoBiz.save(customerInfo); + return ApiResult.success(); } @PutMapping("/{email}") - void update(@PathVariable String email, @RequestBody CustomerInfo customerInfo) { + public ApiResult update(@PathVariable String email, @RequestBody CustomerInfo customerInfo) { customerInfoBiz.update(email, customerInfo); + return ApiResult.success(); } @DeleteMapping("/{email}") - void delete(@PathVariable String email) { + public ApiResult delete(@PathVariable String email) { customerInfoBiz.delete(email); + return ApiResult.success(); } @GetMapping("/{email}") - ResponseEntity queryById(@PathVariable String email) { + public ApiResult queryById(@PathVariable String email) { CustomerInfo result = customerInfoBiz.getOne(email); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("customer-info", customerInfoBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + public ApiResult queryAll() { + List result = customerInfoBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/CustomerServiceController.java b/src/main/java/com/cloudservice/ccs/controller/CustomerServiceController.java index 1596371..cc74bb7 100644 --- a/src/main/java/com/cloudservice/ccs/controller/CustomerServiceController.java +++ b/src/main/java/com/cloudservice/ccs/controller/CustomerServiceController.java @@ -18,11 +18,11 @@ import java.util.Map; public class CustomerServiceController { @Autowired - ICustomerServiceBiz customerServiceBiz; + private ICustomerServiceBiz customerServiceBiz; // @RequiresPermissions("all") @PostMapping("/") - ApiResult save(@RequestBody CustomerService customerService) { + public ApiResult save(@RequestBody CustomerService customerService) { // 接口问题待讨论:是否应当返回生成的 id? customerServiceBiz.save(customerService); return ApiResult.success(); @@ -30,35 +30,35 @@ public class CustomerServiceController { // @RequiresPermissions("all") @PutMapping("/{id}") - ApiResult update(@PathVariable Integer id, @RequestBody CustomerService customerService) { + public ApiResult update(@PathVariable Integer id, @RequestBody CustomerService customerService) { customerServiceBiz.update(id, customerService); return ApiResult.success(); } // @RequiresPermissions("all") @PutMapping("/{id}/partial") - ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { customerServiceBiz.partialUpdate(id, fields); return ApiResult.success(); } // @RequiresPermissions("all") @DeleteMapping("/{id}") - ApiResult delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { customerServiceBiz.delete(id); return ApiResult.success(); } // @RequiresPermissions("all") @GetMapping("/{id}") - ApiResult queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { CustomerService result = customerServiceBiz.getOne(id); return ApiResult.successWithData(result); } // @RequiresPermissions("all") @GetMapping("/") - ApiResult queryAll() { + public ApiResult queryAll() { List result = customerServiceBiz.getAll(); return ApiResult.successWithData(result); } diff --git a/src/main/java/com/cloudservice/ccs/controller/GroupManageController.java b/src/main/java/com/cloudservice/ccs/controller/GroupManageController.java index 873c3c6..b3956c3 100644 --- a/src/main/java/com/cloudservice/ccs/controller/GroupManageController.java +++ b/src/main/java/com/cloudservice/ccs/controller/GroupManageController.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.IGroupManageBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.GroupManage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -15,33 +16,35 @@ import java.util.Map; @RequestMapping("/group-manage") public class GroupManageController { @Autowired - IGroupManageBiz groupManageBiz; + private IGroupManageBiz groupManageBiz; @PostMapping("/") - void save(@RequestBody GroupManage groupManage) { + public ApiResult save(@RequestBody GroupManage groupManage) { groupManageBiz.save(groupManage); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody GroupManage groupManage) { + public ApiResult update(@PathVariable Integer id, @RequestBody GroupManage groupManage) { groupManageBiz.update(id, groupManage); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { groupManageBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { GroupManage result = groupManageBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("group-manage", groupManageBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + public ApiResult queryAll() { + List result = groupManageBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/NoticeController.java b/src/main/java/com/cloudservice/ccs/controller/NoticeController.java index 78c8b1a..62f3175 100644 --- a/src/main/java/com/cloudservice/ccs/controller/NoticeController.java +++ b/src/main/java/com/cloudservice/ccs/controller/NoticeController.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.INoticeBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.Notice; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -16,33 +17,35 @@ import java.util.Map; public class NoticeController { @Autowired - INoticeBiz noticeBiz; + private INoticeBiz noticeBiz; @PostMapping("/") - void save(@RequestBody Notice notice) { + public ApiResult save(@RequestBody Notice notice) { noticeBiz.save(notice); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody Notice notice) { + private ApiResult update(@PathVariable Integer id, @RequestBody Notice notice) { noticeBiz.update(id, notice); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { noticeBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { Notice result = noticeBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("notice", noticeBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + public ApiResult queryAll() { + List result = noticeBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/RoleManageController.java b/src/main/java/com/cloudservice/ccs/controller/RoleManageController.java index ec57b7d..b5aefcb 100644 --- a/src/main/java/com/cloudservice/ccs/controller/RoleManageController.java +++ b/src/main/java/com/cloudservice/ccs/controller/RoleManageController.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.IRoleManageBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.RoleManage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -16,33 +17,35 @@ import java.util.Map; public class RoleManageController { @Autowired - IRoleManageBiz roleManageBiz; + private IRoleManageBiz roleManageBiz; @PostMapping("/") - void save(@RequestBody RoleManage roleManage) { + public ApiResult save(@RequestBody RoleManage roleManage) { roleManageBiz.save(roleManage); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody RoleManage roleManage) { + public ApiResult update(@PathVariable Integer id, @RequestBody RoleManage roleManage) { roleManageBiz.update(id, roleManage); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { roleManageBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { RoleManage result = roleManageBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("role-manage", roleManageBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + public ApiResult queryAll() { + List result = roleManageBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/SessionController.java b/src/main/java/com/cloudservice/ccs/controller/SessionController.java index 56d88f8..f018f0a 100644 --- a/src/main/java/com/cloudservice/ccs/controller/SessionController.java +++ b/src/main/java/com/cloudservice/ccs/controller/SessionController.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.ISessionBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.Session; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -16,33 +17,35 @@ import java.util.Map; public class SessionController { @Autowired - ISessionBiz sessionBiz; + private ISessionBiz sessionBiz; @PostMapping("/") - void save(@RequestBody Session session) { + public ApiResult save(@RequestBody Session session) { sessionBiz.save(session); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody Session session) { + public ApiResult update(@PathVariable Integer id, @RequestBody Session session) { sessionBiz.update(id, session); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { sessionBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { Session result = sessionBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("session", sessionBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + public ApiResult queryAll() { + List result = sessionBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/SessionMessageController.java b/src/main/java/com/cloudservice/ccs/controller/SessionMessageController.java index 5732685..1ee88e8 100644 --- a/src/main/java/com/cloudservice/ccs/controller/SessionMessageController.java +++ b/src/main/java/com/cloudservice/ccs/controller/SessionMessageController.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.ISessionMessageBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.SessionMessage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -16,33 +17,35 @@ import java.util.Map; public class SessionMessageController { @Autowired - ISessionMessageBiz sessionMessageBiz; + private ISessionMessageBiz sessionMessageBiz; @PostMapping("/") - void save(@RequestBody SessionMessage sessionMessage) { + public ApiResult save(@RequestBody SessionMessage sessionMessage) { sessionMessageBiz.save(sessionMessage); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody SessionMessage sessionMessage) { + public ApiResult update(@PathVariable Integer id, @RequestBody SessionMessage sessionMessage) { sessionMessageBiz.update(id, sessionMessage); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { sessionMessageBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { SessionMessage result = sessionMessageBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("session-message", sessionMessageBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + public ApiResult queryAll() { + List result = sessionMessageBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/SystemMessageController.java b/src/main/java/com/cloudservice/ccs/controller/SystemMessageController.java index 336b8a7..79963a5 100644 --- a/src/main/java/com/cloudservice/ccs/controller/SystemMessageController.java +++ b/src/main/java/com/cloudservice/ccs/controller/SystemMessageController.java @@ -2,6 +2,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.ISystemMessageBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.SystemMessage; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -17,35 +18,37 @@ import java.util.Map; @RequestMapping("/system-message") public class SystemMessageController { @Autowired - ISystemMessageBiz systemMessageBiz; + private ISystemMessageBiz systemMessageBiz; @PostMapping("/") - void save(@RequestBody SystemMessage systemMessage) { + public ApiResult save(@RequestBody SystemMessage systemMessage) { // 接口问题待讨论:是否应当返回生成的 id? systemMessageBiz.save(systemMessage); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody SystemMessage systemMessage) { + public ApiResult update(@PathVariable Integer id, @RequestBody SystemMessage systemMessage) { systemMessageBiz.update(id, systemMessage); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { systemMessageBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { SystemMessage result = systemMessageBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @RequiresPermissions("all") @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("system-message", systemMessageBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + public ApiResult queryAll() { + List result = systemMessageBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/TagsController.java b/src/main/java/com/cloudservice/ccs/controller/TagsController.java index 05e93d9..8ca53c3 100644 --- a/src/main/java/com/cloudservice/ccs/controller/TagsController.java +++ b/src/main/java/com/cloudservice/ccs/controller/TagsController.java @@ -2,6 +2,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.ITagsBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.Tags; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -17,35 +18,37 @@ import java.util.Map; @RequestMapping("/tags") public class TagsController { @Autowired - ITagsBiz tagsBiz; + private ITagsBiz tagsBiz; @PostMapping("/") - void save(@RequestBody Tags tags) { + public ApiResult save(@RequestBody Tags tags) { // 接口问题待讨论:是否应当返回生成的 id? tagsBiz.save(tags); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody Tags tags) { + public ApiResult update(@PathVariable Integer id, @RequestBody Tags tags) { tagsBiz.update(id, tags); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { tagsBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { Tags result = tagsBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @RequiresPermissions("all") @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("tags", tagsBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + public ApiResult queryAll() { + List result = tagsBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/ViewStatisticsController.java b/src/main/java/com/cloudservice/ccs/controller/ViewStatisticsController.java index eb554e8..6e19516 100644 --- a/src/main/java/com/cloudservice/ccs/controller/ViewStatisticsController.java +++ b/src/main/java/com/cloudservice/ccs/controller/ViewStatisticsController.java @@ -3,6 +3,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.ITagsBiz; import com.cloudservice.ccs.biz.IViewStatisticsBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.Tags; import com.cloudservice.ccs.entity.ViewStatistics; import org.apache.shiro.authz.annotation.RequiresPermissions; @@ -19,35 +20,37 @@ import java.util.Map; @RequestMapping("/view-statistics") public class ViewStatisticsController { @Autowired - IViewStatisticsBiz viewStatisticsBiz; + private IViewStatisticsBiz viewStatisticsBiz; @PostMapping("/") - void save(@RequestBody ViewStatistics viewStatistics) { + public ApiResult save(@RequestBody ViewStatistics viewStatistics) { // 接口问题待讨论:是否应当返回生成的 id? viewStatisticsBiz.save(viewStatistics); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody ViewStatistics viewStatistics) { + public ApiResult update(@PathVariable Integer id, @RequestBody ViewStatistics viewStatistics) { viewStatisticsBiz.update(id, viewStatistics); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { viewStatisticsBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { ViewStatistics result = viewStatisticsBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @RequiresPermissions("all") @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("view-statistics", viewStatisticsBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + public ApiResult queryAll() { + List result = viewStatisticsBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/VisitorInfoController.java b/src/main/java/com/cloudservice/ccs/controller/VisitorInfoController.java index ed0be28..52b9ec8 100644 --- a/src/main/java/com/cloudservice/ccs/controller/VisitorInfoController.java +++ b/src/main/java/com/cloudservice/ccs/controller/VisitorInfoController.java @@ -2,6 +2,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.IVisitorInfoBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.VisitorInfo; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -17,35 +18,37 @@ import java.util.Map; @RequestMapping("/visitor-info") public class VisitorInfoController { @Autowired - IVisitorInfoBiz visitorInfoBiz; + private IVisitorInfoBiz visitorInfoBiz; @PostMapping("/") - void save(@RequestBody VisitorInfo visitorInfo) { + public ApiResult save(@RequestBody VisitorInfo visitorInfo) { // 接口问题待讨论:是否应当返回生成的 id? visitorInfoBiz.save(visitorInfo); + return ApiResult.success(); } @PutMapping("/{ip}") - void update(@PathVariable String ip, @RequestBody VisitorInfo visitorInfo) { + public ApiResult update(@PathVariable String ip, @RequestBody VisitorInfo visitorInfo) { visitorInfoBiz.update(ip, visitorInfo); + return ApiResult.success(); } @DeleteMapping("/{ip}") - void delete(@PathVariable String ip) { + public ApiResult delete(@PathVariable String ip) { visitorInfoBiz.delete(ip); + return ApiResult.success(); } @GetMapping("/{ip}") - ResponseEntity queryById(@PathVariable String ip) { + public ApiResult queryById(@PathVariable String ip) { VisitorInfo result = visitorInfoBiz.getOne(ip); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @RequiresPermissions("all") @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("visitor-info", visitorInfoBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + public ApiResult queryAll() { + List result = visitorInfoBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/WorkLogController.java b/src/main/java/com/cloudservice/ccs/controller/WorkLogController.java index aeae5ff..1264661 100644 --- a/src/main/java/com/cloudservice/ccs/controller/WorkLogController.java +++ b/src/main/java/com/cloudservice/ccs/controller/WorkLogController.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.IWorkLogBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.CustomerService; import com.cloudservice.ccs.entity.WorkLog; import org.apache.shiro.authz.annotation.RequiresPermissions; @@ -16,40 +17,43 @@ import java.util.Map; @RequestMapping("work-log") public class WorkLogController { @Autowired - IWorkLogBiz workLogBiz; + private IWorkLogBiz workLogBiz; @PostMapping("/") - void save(@RequestBody WorkLog workLog) { + public ApiResult save(@RequestBody WorkLog workLog) { // 接口问题待讨论:是否应当返回生成的 id? workLogBiz.save(workLog); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody WorkLog workLog) { + public ApiResult update(@PathVariable Integer id, @RequestBody WorkLog workLog) { workLogBiz.update(id, workLog); + return ApiResult.success(); } @PutMapping("/{id}/partial") - void partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { workLogBiz.partialUpdate(id, fields); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { workLogBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { WorkLog result = workLogBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @RequiresPermissions("all") @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("customer-services", workLogBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + public ApiResult queryAll() { + List result = workLogBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/WorkOrderController.java b/src/main/java/com/cloudservice/ccs/controller/WorkOrderController.java index 5ab4ba9..5918c28 100644 --- a/src/main/java/com/cloudservice/ccs/controller/WorkOrderController.java +++ b/src/main/java/com/cloudservice/ccs/controller/WorkOrderController.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.IWorkOrderBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.WorkOrder; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -14,40 +15,43 @@ import java.util.Map; public class WorkOrderController { @Autowired - IWorkOrderBiz workOrderBiz; + private IWorkOrderBiz workOrderBiz; @PostMapping("/") - void save(@RequestBody WorkOrder workOrder) { + public ApiResult save(@RequestBody WorkOrder workOrder) { // 接口问题待讨论:是否应当返回生成的 id? workOrderBiz.save(workOrder); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody WorkOrder workOrder) { + public ApiResult update(@PathVariable Integer id, @RequestBody WorkOrder workOrder) { workOrderBiz.update(id, workOrder); + return ApiResult.success(); } @PutMapping("/{id}/partial") - void partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { workOrderBiz.partialUpdate(id, fields); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { workOrderBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { WorkOrder result = workOrderBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @RequiresPermissions("all") @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("customer-services", workOrderBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + public ApiResult queryAll() { + List result = workOrderBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/WorkOrderReplyController.java b/src/main/java/com/cloudservice/ccs/controller/WorkOrderReplyController.java index ec10235..b208c3e 100644 --- a/src/main/java/com/cloudservice/ccs/controller/WorkOrderReplyController.java +++ b/src/main/java/com/cloudservice/ccs/controller/WorkOrderReplyController.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.IWorkOrderReplyBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.WorkOrderReply; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -14,40 +15,43 @@ import java.util.Map; public class WorkOrderReplyController { @Autowired - IWorkOrderReplyBiz workOrderReplyBiz; + private IWorkOrderReplyBiz workOrderReplyBiz; @PostMapping("/") - void save(@RequestBody WorkOrderReply workOrderReply) { + public ApiResult save(@RequestBody WorkOrderReply workOrderReply) { // 接口问题待讨论:是否应当返回生成的 id? workOrderReplyBiz.save(workOrderReply); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody WorkOrderReply workOrderReply) { + public ApiResult update(@PathVariable Integer id, @RequestBody WorkOrderReply workOrderReply) { workOrderReplyBiz.update(id, workOrderReply); + return ApiResult.success(); } @PutMapping("/{id}/partial") - void partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { workOrderReplyBiz.partialUpdate(id, fields); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { workOrderReplyBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { WorkOrderReply result = workOrderReplyBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @RequiresPermissions("all") @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("customer-services", workOrderReplyBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + public ApiResult queryAll() { + List result = workOrderReplyBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/WorkQualityStatisticsController.java b/src/main/java/com/cloudservice/ccs/controller/WorkQualityStatisticsController.java index 3ee1478..55fea64 100644 --- a/src/main/java/com/cloudservice/ccs/controller/WorkQualityStatisticsController.java +++ b/src/main/java/com/cloudservice/ccs/controller/WorkQualityStatisticsController.java @@ -1,6 +1,7 @@ package com.cloudservice.ccs.controller; import com.cloudservice.ccs.biz.IWorkQualityStatisticsBiz; +import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.WorkQualityStatistics; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -14,40 +15,43 @@ import java.util.Map; public class WorkQualityStatisticsController { @Autowired - IWorkQualityStatisticsBiz workQualityStatisticsBiz; + private IWorkQualityStatisticsBiz workQualityStatisticsBiz; @PostMapping("/") - void save(@RequestBody WorkQualityStatistics workQualityStatistics) { + public ApiResult save(@RequestBody WorkQualityStatistics workQualityStatistics) { // 接口问题待讨论:是否应当返回生成的 id? workQualityStatisticsBiz.save(workQualityStatistics); + return ApiResult.success(); } @PutMapping("/{id}") - void update(@PathVariable Integer id, @RequestBody WorkQualityStatistics workQualityStatistics) { + public ApiResult update(@PathVariable Integer id, @RequestBody WorkQualityStatistics workQualityStatistics) { workQualityStatisticsBiz.update(id, workQualityStatistics); + return ApiResult.success(); } @PutMapping("/{id}/partial") - void partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { workQualityStatisticsBiz.partialUpdate(id, fields); + return ApiResult.success(); } @DeleteMapping("/{id}") - void delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { workQualityStatisticsBiz.delete(id); + return ApiResult.success(); } @GetMapping("/{id}") - ResponseEntity queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { WorkQualityStatistics result = workQualityStatisticsBiz.getOne(id); - return new ResponseEntity<>(result, HttpStatus.OK); + return ApiResult.successWithData(result); } @RequiresPermissions("all") @GetMapping("/") - ResponseEntity>> queryAll() { - Map> result = new HashMap<>(); - result.put("customer-services", workQualityStatisticsBiz.getAll()); - return new ResponseEntity<>(result, HttpStatus.OK); + public ApiResult queryAll() { + List result = workQualityStatisticsBiz.getAll(); + return ApiResult.successWithData(result); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java b/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java index ce75a94..409548b 100644 --- a/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java +++ b/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java @@ -20,48 +20,48 @@ import java.util.Map; @RequestMapping("/workload-statistics") public class WorkloadStatisticsController { @Autowired - IWorkloadStatisticsBiz workloadStatisticsBiz; + private IWorkloadStatisticsBiz workloadStatisticsBiz; @PostMapping("/") - ApiResult save(@RequestBody WorkloadStatistics workloadStatistics) { + public ApiResult save(@RequestBody WorkloadStatistics workloadStatistics) { // 接口问题待讨论:是否应当返回生成的 id? workloadStatisticsBiz.save(workloadStatistics); return ApiResult.success(); } @PutMapping("/{id}") - ApiResult update(@PathVariable Integer id, @RequestBody WorkloadStatistics workloadStatistics) { + public ApiResult update(@PathVariable Integer id, @RequestBody WorkloadStatistics workloadStatistics) { workloadStatisticsBiz.update(id, workloadStatistics); return ApiResult.success(); } @DeleteMapping("/{id}") - ApiResult delete(@PathVariable Integer id) { + public ApiResult delete(@PathVariable Integer id) { workloadStatisticsBiz.delete(id); return ApiResult.success(); } @GetMapping("/{id}") - ApiResult queryById(@PathVariable Integer id) { + public ApiResult queryById(@PathVariable Integer id) { WorkloadStatistics result = workloadStatisticsBiz.getOne(id); return ApiResult.successWithData(result); } @RequiresPermissions("all") @GetMapping("/") - ApiResult queryAll() { + public ApiResult queryAll() { List result = workloadStatisticsBiz.getAll(); return ApiResult.successWithData(result); } @GetMapping("/with-average") - ApiResult queryAllWithAverage() { + public ApiResult queryAllWithAverage() { List result = workloadStatisticsBiz.getAllWithAverage(); return ApiResult.successWithData(result); } @GetMapping("/aggregation") - ApiResult queryAggregation() { + public ApiResult queryAggregation() { return ApiResult.successWithData(workloadStatisticsBiz.getAggregation()); } } -- Gitee From 6ad75e667e0e4eee2dd007b4db7931621974728c Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Sat, 4 Jul 2020 16:54:23 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20CustomerService=20?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=20API=20=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cloudservice/ccs/exception/GlobalExceptionHandler.java | 2 +- src/main/resources/mapper/CustomerServiceMapper.xml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java b/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java index 161956b..1112156 100644 --- a/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java @@ -32,7 +32,7 @@ public class GlobalExceptionHandler { if (e instanceof UnknownAccountException) { return ApiResult.failureWithData("未知用户"); } else if (e instanceof IncorrectCredentialsException) { - return ApiResult.failureWithData("用户名或密码错误"); + return ApiResult.failureWithData("邮箱或密码错误"); } else { return ApiResult.failureWithData("未知认证错误:" + e.getClass().getName() + ": " + e.getMessage()); } diff --git a/src/main/resources/mapper/CustomerServiceMapper.xml b/src/main/resources/mapper/CustomerServiceMapper.xml index f0d80e0..557269d 100644 --- a/src/main/resources/mapper/CustomerServiceMapper.xml +++ b/src/main/resources/mapper/CustomerServiceMapper.xml @@ -13,9 +13,7 @@ UPDATE customer_service SET - phone = #{customerService.phone}, - password = #{customerService.password}, headImg = #{customerService.headImg}, email = #{customerService.email}, -- Gitee From 4f3ec3d67dc9777e7273df4d11d3ab500e4f7c4a Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Mon, 6 Jul 2020 10:15:47 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20/register?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ccs/controller/LoginController.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/cloudservice/ccs/controller/LoginController.java b/src/main/java/com/cloudservice/ccs/controller/LoginController.java index 8f9597a..24888a8 100644 --- a/src/main/java/com/cloudservice/ccs/controller/LoginController.java +++ b/src/main/java/com/cloudservice/ccs/controller/LoginController.java @@ -1,10 +1,13 @@ package com.cloudservice.ccs.controller; +import com.cloudservice.ccs.biz.ICustomerServiceBiz; import com.cloudservice.ccs.entity.ApiResult; +import com.cloudservice.ccs.entity.CustomerService; import com.cloudservice.ccs.entity.LoginData; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.*; import org.apache.shiro.subject.Subject; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; @@ -17,8 +20,11 @@ import java.util.Map; @RestController public class LoginController { + @Autowired + private ICustomerServiceBiz customerServiceBiz; + @PostMapping("/login") - public ApiResult doLogin(@RequestBody LoginData loginData){ + public ApiResult doLogin(@RequestBody LoginData loginData) { String email = loginData.getEmail(), password = loginData.getPassword(); Subject subject = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken(email,password); @@ -32,4 +38,10 @@ public class LoginController { subject.logout(); return ApiResult.success(); } + + @PostMapping("/register") + public ApiResult doRegister(@RequestBody CustomerService customerService) { + customerServiceBiz.save(customerService); + return ApiResult.success(); + } } -- Gitee From 0784685d52ce4c2d85fee574556f6336a8374ec3 Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Mon, 6 Jul 2020 12:47:02 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20/login=20API=20?= =?UTF-8?q?=E8=A1=8C=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cloudservice/ccs/config/CustomerServiceRealm.java | 8 ++++---- .../com/cloudservice/ccs/controller/LoginController.java | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/cloudservice/ccs/config/CustomerServiceRealm.java b/src/main/java/com/cloudservice/ccs/config/CustomerServiceRealm.java index 91b9c14..2b6e323 100644 --- a/src/main/java/com/cloudservice/ccs/config/CustomerServiceRealm.java +++ b/src/main/java/com/cloudservice/ccs/config/CustomerServiceRealm.java @@ -29,15 +29,15 @@ public class CustomerServiceRealm extends AuthorizingRealm { protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { String email = (String) authenticationToken.getPrincipal(); if (email == null || email.isEmpty()) { - throw new UnknownAccountException("Null account"); + throw new UnknownAccountException("未知用户"); } Map conditions = new HashMap<>(); conditions.put("email", email); List foundCustomerServices = customerServiceMapper.getWithConditions(conditions); if (foundCustomerServices == null || foundCustomerServices.isEmpty()) { - throw new UnknownAccountException("This account does not exist"); + throw new UnknownAccountException("用户不存在"); } - String correctPassword = foundCustomerServices.get(0).getPassword(); - return new SimpleAuthenticationInfo(email, correctPassword, getName()); + CustomerService foundCustomerService = foundCustomerServices.get(0); + return new SimpleAuthenticationInfo(foundCustomerService.getCustomerServiceId(), foundCustomerService.getPassword(), getName()); } } diff --git a/src/main/java/com/cloudservice/ccs/controller/LoginController.java b/src/main/java/com/cloudservice/ccs/controller/LoginController.java index 24888a8..c3ed336 100644 --- a/src/main/java/com/cloudservice/ccs/controller/LoginController.java +++ b/src/main/java/com/cloudservice/ccs/controller/LoginController.java @@ -4,6 +4,7 @@ import com.cloudservice.ccs.biz.ICustomerServiceBiz; import com.cloudservice.ccs.entity.ApiResult; import com.cloudservice.ccs.entity.CustomerService; import com.cloudservice.ccs.entity.LoginData; +import com.cloudservice.ccs.mapper.CustomerServiceMapper; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.*; import org.apache.shiro.subject.Subject; @@ -23,13 +24,18 @@ public class LoginController { @Autowired private ICustomerServiceBiz customerServiceBiz; + @Autowired + private CustomerServiceMapper customerServiceMapper; + @PostMapping("/login") public ApiResult doLogin(@RequestBody LoginData loginData) { String email = loginData.getEmail(), password = loginData.getPassword(); Subject subject = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken(email,password); subject.login(token); - return ApiResult.success(); + Map map = new HashMap<>(); + map.put("email", email); + return ApiResult.successWithData(customerServiceMapper.getWithConditions(map).get(0)); } @PostMapping("/logout") -- Gitee From f6764603a141eabed1ef03a3e424e2b8ddad02d3 Mon Sep 17 00:00:00 2001 From: Yang Hanlin Date: Mon, 6 Jul 2020 15:28:19 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E5=A4=A7=E9=87=8F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 添加部分更新 API * 适配数据库模式更改 * 等等 孙东东 --- .../ccs/biz/IAttendanceStatisticsBiz.java | 3 +++ .../cloudservice/ccs/biz/IBlackListBiz.java | 3 +++ .../cloudservice/ccs/biz/ICommonWordBiz.java | 3 +++ .../ccs/biz/ICustomerInfoBiz.java | 9 ++++--- .../cloudservice/ccs/biz/IGroupManageBiz.java | 3 +++ .../com/cloudservice/ccs/biz/INoticeBiz.java | 3 +++ .../cloudservice/ccs/biz/IRoleManageBiz.java | 3 +++ .../com/cloudservice/ccs/biz/ISessionBiz.java | 3 +++ .../ccs/biz/ISessionMessageBiz.java | 3 +++ .../ccs/biz/ISystemMessageBiz.java | 3 +++ .../com/cloudservice/ccs/biz/ITagsBiz.java | 3 +++ .../ccs/biz/IViewStatisticsBiz.java | 3 +++ .../cloudservice/ccs/biz/IVisitorInfoBiz.java | 9 ++++--- .../ccs/biz/IWorkloadStatisticsBiz.java | 3 +++ .../biz/impl/AttendanceStatisticsImpl.java | 10 ++++++++ .../ccs/biz/impl/BlackListImpl.java | 9 +++++++ .../ccs/biz/impl/CommonWordImpl.java | 11 +++++++++ .../ccs/biz/impl/CustomerInfoImpl.java | 22 ++++++++++++----- .../ccs/biz/impl/GroupManageImpl.java | 10 ++++++++ .../cloudservice/ccs/biz/impl/NoticeImpl.java | 10 ++++++++ .../ccs/biz/impl/RoleManageImpl.java | 10 ++++++++ .../ccs/biz/impl/SessionImpl.java | 10 ++++++++ .../ccs/biz/impl/SessionMessageImpl.java | 10 ++++++++ .../ccs/biz/impl/SystemMessageImpl.java | 18 ++++++++++---- .../cloudservice/ccs/biz/impl/TagsImpl.java | 18 ++++++++++---- .../ccs/biz/impl/ViewStatisticsImpl.java | 18 ++++++++++---- .../ccs/biz/impl/VisitorInfoImpl.java | 23 +++++++++++++----- .../ccs/biz/impl/WorkloadStatisticsImpl.java | 10 ++++++++ .../AttendanceStatisticsController.java | 7 ++++++ .../ccs/controller/BlackListController.java | 8 +++++++ .../ccs/controller/CommonWordController.java | 7 ++++++ .../controller/CustomerInfoController.java | 18 +++++++++----- .../ccs/controller/GroupManageController.java | 7 ++++++ .../ccs/controller/NoticeController.java | 7 ++++++ .../ccs/controller/RoleManageController.java | 7 ++++++ .../ccs/controller/SessionController.java | 7 ++++++ .../controller/SessionMessageController.java | 7 ++++++ .../controller/SystemMessageController.java | 7 ++++++ .../ccs/controller/TagsController.java | 7 ++++++ .../controller/ViewStatisticsController.java | 7 ++++++ .../ccs/controller/VisitorInfoController.java | 24 ++++++++++++------- .../WorkloadStatisticsController.java | 6 +++++ .../cloudservice/ccs/entity/BlackList.java | 1 + .../cloudservice/ccs/entity/CommonWord.java | 2 +- .../cloudservice/ccs/entity/CustomerInfo.java | 1 + .../ccs/entity/CustomerService.java | 1 - .../ccs/exception/GlobalExceptionHandler.java | 2 +- .../mapper/AttendanceStatisticsMapper.java | 3 +++ .../ccs/mapper/BlackListMapper.java | 3 +++ .../ccs/mapper/CommonWordMapper.java | 3 +++ .../ccs/mapper/CustomerInfoMapper.java | 9 ++++--- .../ccs/mapper/GroupManageMapper.java | 3 +++ .../cloudservice/ccs/mapper/NoticeMapper.java | 3 +++ .../ccs/mapper/RoleManageMapper.java | 3 +++ .../ccs/mapper/SessionMapper.java | 3 +++ .../ccs/mapper/SessionMessageMapper.java | 3 +++ .../ccs/mapper/SystemMessageMapper.java | 3 +++ .../cloudservice/ccs/mapper/TagsMapper.java | 3 +++ .../ccs/mapper/ViewStatisticsMapper.java | 3 +++ .../ccs/mapper/VisitorInfoMapper.java | 9 ++++--- .../ccs/mapper/WorkLoadStatisticsMapper.java | 2 ++ .../mapper/AttendanceStatisticsMapper.xml | 9 +++++++ src/main/resources/mapper/BlackListMapper.xml | 8 +++++++ .../resources/mapper/CommonWordMapper.xml | 14 ++++++++--- .../resources/mapper/CustomerInfoMapper.xml | 19 +++++++++++---- .../resources/mapper/GroupManageMapper.xml | 8 +++++++ src/main/resources/mapper/NoticeMapper.xml | 8 +++++++ .../resources/mapper/RoleManageMapper.xml | 8 +++++++ src/main/resources/mapper/SessionMapper.xml | 8 +++++++ .../resources/mapper/SessionMessageMapper.xml | 8 +++++++ .../resources/mapper/SystemMessageMapper.xml | 8 +++++++ src/main/resources/mapper/TagsMapper.xml | 8 +++++++ .../resources/mapper/ViewStatisticsMapper.xml | 8 +++++++ .../resources/mapper/VisitorInfoMapper.xml | 17 +++++++++---- .../mapper/WorkLoadStatisticsMapper.xml | 8 +++++++ 75 files changed, 502 insertions(+), 66 deletions(-) diff --git a/src/main/java/com/cloudservice/ccs/biz/IAttendanceStatisticsBiz.java b/src/main/java/com/cloudservice/ccs/biz/IAttendanceStatisticsBiz.java index 0b87e80..03a1df9 100644 --- a/src/main/java/com/cloudservice/ccs/biz/IAttendanceStatisticsBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/IAttendanceStatisticsBiz.java @@ -3,6 +3,7 @@ package com.cloudservice.ccs.biz; import com.cloudservice.ccs.entity.AttendanceStatistics; import java.util.List; +import java.util.Map; public interface IAttendanceStatisticsBiz { void save(AttendanceStatistics attendanceStatistics); @@ -11,6 +12,8 @@ public interface IAttendanceStatisticsBiz { void delete(Integer id); + void partialUpdate(Integer id, Map fields); + AttendanceStatistics getOne(Integer id); List getAll(); diff --git a/src/main/java/com/cloudservice/ccs/biz/IBlackListBiz.java b/src/main/java/com/cloudservice/ccs/biz/IBlackListBiz.java index 2a68581..5b888fd 100644 --- a/src/main/java/com/cloudservice/ccs/biz/IBlackListBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/IBlackListBiz.java @@ -3,6 +3,7 @@ package com.cloudservice.ccs.biz; import com.cloudservice.ccs.entity.BlackList; import java.util.List; +import java.util.Map; public interface IBlackListBiz { void save(BlackList blackList); @@ -11,6 +12,8 @@ public interface IBlackListBiz { void delete(Integer id); + void partialUpdate(Integer id, Map fields); + BlackList getOne(Integer id); List getAll(); diff --git a/src/main/java/com/cloudservice/ccs/biz/ICommonWordBiz.java b/src/main/java/com/cloudservice/ccs/biz/ICommonWordBiz.java index bd7ecc0..4b0e864 100644 --- a/src/main/java/com/cloudservice/ccs/biz/ICommonWordBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/ICommonWordBiz.java @@ -3,6 +3,7 @@ package com.cloudservice.ccs.biz; import com.cloudservice.ccs.entity.CommonWord; import java.util.List; +import java.util.Map; public interface ICommonWordBiz { void save(CommonWord commonWord); @@ -11,6 +12,8 @@ public interface ICommonWordBiz { void delete(Integer id); + void partialUpdate(Integer id, Map fields); + CommonWord getOne(Integer id); List getAll(); diff --git a/src/main/java/com/cloudservice/ccs/biz/ICustomerInfoBiz.java b/src/main/java/com/cloudservice/ccs/biz/ICustomerInfoBiz.java index 602a653..82449ff 100644 --- a/src/main/java/com/cloudservice/ccs/biz/ICustomerInfoBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/ICustomerInfoBiz.java @@ -3,15 +3,18 @@ package com.cloudservice.ccs.biz; import com.cloudservice.ccs.entity.CustomerInfo; import java.util.List; +import java.util.Map; public interface ICustomerInfoBiz { void save(CustomerInfo customerInfo); - void update(String email, CustomerInfo customerInfo); + void update(Integer id, CustomerInfo customerInfo); - void delete(String email); + void delete(Integer id); - CustomerInfo getOne(String email); + CustomerInfo getOne(Integer id); + + void partialUpdate(Integer id, Map fields); List getAll(); } diff --git a/src/main/java/com/cloudservice/ccs/biz/IGroupManageBiz.java b/src/main/java/com/cloudservice/ccs/biz/IGroupManageBiz.java index f5ceb64..3aa50f3 100644 --- a/src/main/java/com/cloudservice/ccs/biz/IGroupManageBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/IGroupManageBiz.java @@ -3,6 +3,7 @@ package com.cloudservice.ccs.biz; import com.cloudservice.ccs.entity.GroupManage; import java.util.List; +import java.util.Map; public interface IGroupManageBiz { void save( GroupManage groupManage); @@ -11,6 +12,8 @@ public interface IGroupManageBiz { void delete(Integer id); + void partialUpdate(Integer id, Map fields); + GroupManage getOne(Integer id); List getAll(); diff --git a/src/main/java/com/cloudservice/ccs/biz/INoticeBiz.java b/src/main/java/com/cloudservice/ccs/biz/INoticeBiz.java index d3b5636..84edd18 100644 --- a/src/main/java/com/cloudservice/ccs/biz/INoticeBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/INoticeBiz.java @@ -3,12 +3,15 @@ package com.cloudservice.ccs.biz; import com.cloudservice.ccs.entity.Notice; import java.util.List; +import java.util.Map; public interface INoticeBiz { void save( Notice notice); void update(Integer id, Notice notice); + void partialUpdate(Integer id, Map fields); + void delete(Integer id); Notice getOne(Integer id); diff --git a/src/main/java/com/cloudservice/ccs/biz/IRoleManageBiz.java b/src/main/java/com/cloudservice/ccs/biz/IRoleManageBiz.java index acf1351..7353413 100644 --- a/src/main/java/com/cloudservice/ccs/biz/IRoleManageBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/IRoleManageBiz.java @@ -3,12 +3,15 @@ package com.cloudservice.ccs.biz; import com.cloudservice.ccs.entity.RoleManage; import java.util.List; +import java.util.Map; public interface IRoleManageBiz { void save(RoleManage roleManage); void update(Integer id, RoleManage roleManage); + void partialUpdate(Integer id, Map fields); + void delete(Integer id); RoleManage getOne(Integer id); diff --git a/src/main/java/com/cloudservice/ccs/biz/ISessionBiz.java b/src/main/java/com/cloudservice/ccs/biz/ISessionBiz.java index 3b2ed6d..2e7acf9 100644 --- a/src/main/java/com/cloudservice/ccs/biz/ISessionBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/ISessionBiz.java @@ -4,12 +4,15 @@ import com.cloudservice.ccs.entity.Session; import com.cloudservice.ccs.mapper.SessionMapper; import java.util.List; +import java.util.Map; public interface ISessionBiz { void save(Session session); void update(Integer id, Session session); + void partialUpdate(Integer id, Map fields); + void delete(Integer id); Session getOne(Integer id); diff --git a/src/main/java/com/cloudservice/ccs/biz/ISessionMessageBiz.java b/src/main/java/com/cloudservice/ccs/biz/ISessionMessageBiz.java index 7de7475..49465a2 100644 --- a/src/main/java/com/cloudservice/ccs/biz/ISessionMessageBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/ISessionMessageBiz.java @@ -3,12 +3,15 @@ package com.cloudservice.ccs.biz; import com.cloudservice.ccs.entity.SessionMessage; import java.util.List; +import java.util.Map; public interface ISessionMessageBiz { void save(SessionMessage sessionMessage); void update(Integer id, SessionMessage sessionMessage); + void partialUpdate(Integer id, Map fields); + void delete(Integer id); SessionMessage getOne(Integer id); diff --git a/src/main/java/com/cloudservice/ccs/biz/ISystemMessageBiz.java b/src/main/java/com/cloudservice/ccs/biz/ISystemMessageBiz.java index 64cf013..ef8251d 100644 --- a/src/main/java/com/cloudservice/ccs/biz/ISystemMessageBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/ISystemMessageBiz.java @@ -3,12 +3,15 @@ package com.cloudservice.ccs.biz; import com.cloudservice.ccs.entity.SystemMessage; import java.util.List; +import java.util.Map; public interface ISystemMessageBiz { void save(SystemMessage systemMessage); void update(Integer id, SystemMessage systemMessage); + void partialUpdate(Integer id, Map fields); + void delete(Integer id); SystemMessage getOne(Integer id); diff --git a/src/main/java/com/cloudservice/ccs/biz/ITagsBiz.java b/src/main/java/com/cloudservice/ccs/biz/ITagsBiz.java index c34314a..52d6006 100644 --- a/src/main/java/com/cloudservice/ccs/biz/ITagsBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/ITagsBiz.java @@ -3,12 +3,15 @@ package com.cloudservice.ccs.biz; import com.cloudservice.ccs.entity.Tags; import java.util.List; +import java.util.Map; public interface ITagsBiz { void save(Tags tags); void update(Integer id, Tags tags); + void partialUpdate(Integer id, Map fields); + void delete(Integer id); Tags getOne(Integer id); diff --git a/src/main/java/com/cloudservice/ccs/biz/IViewStatisticsBiz.java b/src/main/java/com/cloudservice/ccs/biz/IViewStatisticsBiz.java index c2d4a1b..2fa4e47 100644 --- a/src/main/java/com/cloudservice/ccs/biz/IViewStatisticsBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/IViewStatisticsBiz.java @@ -3,12 +3,15 @@ package com.cloudservice.ccs.biz; import com.cloudservice.ccs.entity.ViewStatistics; import java.util.List; +import java.util.Map; public interface IViewStatisticsBiz { void save(ViewStatistics viewStatistics); void update(Integer id, ViewStatistics viewStatistics); + void partialUpdate(Integer id, Map fields); + void delete(Integer id); ViewStatistics getOne(Integer id); diff --git a/src/main/java/com/cloudservice/ccs/biz/IVisitorInfoBiz.java b/src/main/java/com/cloudservice/ccs/biz/IVisitorInfoBiz.java index 80e7743..6abd465 100644 --- a/src/main/java/com/cloudservice/ccs/biz/IVisitorInfoBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/IVisitorInfoBiz.java @@ -3,15 +3,18 @@ package com.cloudservice.ccs.biz; import com.cloudservice.ccs.entity.VisitorInfo; import java.util.List; +import java.util.Map; public interface IVisitorInfoBiz { void save(VisitorInfo visitorInfo); - void update(String ip, VisitorInfo visitorInfo); + void update(Integer id, VisitorInfo visitorInfo); - void delete(String ip); + void delete(Integer id); - VisitorInfo getOne(String ip); + void partialUpdate(Integer id, Map fields); + + VisitorInfo getOne(Integer id); List getAll(); } diff --git a/src/main/java/com/cloudservice/ccs/biz/IWorkloadStatisticsBiz.java b/src/main/java/com/cloudservice/ccs/biz/IWorkloadStatisticsBiz.java index 08cf5b8..8b7fcf2 100644 --- a/src/main/java/com/cloudservice/ccs/biz/IWorkloadStatisticsBiz.java +++ b/src/main/java/com/cloudservice/ccs/biz/IWorkloadStatisticsBiz.java @@ -5,6 +5,7 @@ import com.cloudservice.ccs.entity.WorkloadStatisticsAggregation; import com.cloudservice.ccs.entity.WorkloadStatisticsWithAverage; import java.util.List; +import java.util.Map; public interface IWorkloadStatisticsBiz { @@ -14,6 +15,8 @@ public interface IWorkloadStatisticsBiz { void delete(Integer id); + void partialUpdate(Integer id, Map fields); + WorkloadStatistics getOne(Integer id); List getAll(); diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/AttendanceStatisticsImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/AttendanceStatisticsImpl.java index b97c14d..1bae9a0 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/AttendanceStatisticsImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/AttendanceStatisticsImpl.java @@ -3,11 +3,13 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.IAttendanceStatisticsBiz; import com.cloudservice.ccs.entity.AttendanceStatistics; import com.cloudservice.ccs.exception.AttendanceStatisticsException; +import com.cloudservice.ccs.exception.BlackListException; import com.cloudservice.ccs.mapper.AttendanceStatisticsMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class AttendanceStatisticsImpl implements IAttendanceStatisticsBiz { @@ -29,6 +31,14 @@ public class AttendanceStatisticsImpl implements IAttendanceStatisticsBiz { } } + @Override + public void partialUpdate(Integer id, Map fields) { + int result = attendanceStatisticsMapper.partialUpdate(id, fields); + if (result == 0) { + throw new AttendanceStatisticsException("Update AttendanceStatistics entity error"); + } + } + @Override public void delete(Integer id) { int result = attendanceStatisticsMapper.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/BlackListImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/BlackListImpl.java index ba40734..bc6dae9 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/BlackListImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/BlackListImpl.java @@ -3,11 +3,13 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.IBlackListBiz; import com.cloudservice.ccs.entity.BlackList; import com.cloudservice.ccs.exception.BlackListException; +import com.cloudservice.ccs.exception.CustomerServiceException; import com.cloudservice.ccs.mapper.BlackListMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class BlackListImpl implements IBlackListBiz { @@ -29,6 +31,13 @@ public class BlackListImpl implements IBlackListBiz { } } + @Override + public void partialUpdate(Integer id, Map fields) { + int result = blackListMapper.partialUpdate(id, fields); + if (result == 0) { + throw new BlackListException("Update BlackList entity error"); + } + } @Override public void delete(Integer id) { int result = blackListMapper.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/CommonWordImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/CommonWordImpl.java index 96ecf4e..a1adf49 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/CommonWordImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/CommonWordImpl.java @@ -2,12 +2,14 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.ICommonWordBiz; import com.cloudservice.ccs.entity.CommonWord; +import com.cloudservice.ccs.exception.BlackListException; import com.cloudservice.ccs.exception.CommonWordException; import com.cloudservice.ccs.mapper.CommonWordMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class CommonWordImpl implements ICommonWordBiz { @@ -50,4 +52,13 @@ public class CommonWordImpl implements ICommonWordBiz { public List getAll() { return commonWordMapper.getAll(); } + + + @Override + public void partialUpdate(Integer id, Map fields) { + int result = commonWordMapper.partialUpdate(id, fields); + if (result == 0) { + throw new CommonWordException("Update CommonWord entity error"); + } + } } diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/CustomerInfoImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/CustomerInfoImpl.java index 8420d36..1a74b31 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/CustomerInfoImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/CustomerInfoImpl.java @@ -2,12 +2,14 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.ICustomerInfoBiz; import com.cloudservice.ccs.entity.CustomerInfo; +import com.cloudservice.ccs.exception.CommonWordException; import com.cloudservice.ccs.exception.CustomerInfoException; import com.cloudservice.ccs.mapper.CustomerInfoMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class CustomerInfoImpl implements ICustomerInfoBiz { @@ -22,24 +24,32 @@ public class CustomerInfoImpl implements ICustomerInfoBiz { } @Override - public void update(String email, CustomerInfo customerInfo) { - int result = customerInfoMapper.update(email, customerInfo); + public void partialUpdate(Integer id, Map fields) { + int result = customerInfoMapper.partialUpdate(id, fields); if (result == 0) { throw new CustomerInfoException("Update CustomerInfo entity error"); } } @Override - public void delete(String email) { - int result = customerInfoMapper.delete(email); + public void update(Integer id, CustomerInfo customerInfo) { + int result = customerInfoMapper.update(id, customerInfo); + if (result == 0) { + throw new CustomerInfoException("Update CustomerInfo entity error"); + } + } + + @Override + public void delete(Integer id) { + int result = customerInfoMapper.delete(id); if (result == 0) { throw new CustomerInfoException("Delete CustomerInfo entity error"); } } @Override - public CustomerInfo getOne(String email) { - CustomerInfo customerInfo = customerInfoMapper.getOne(email); + public CustomerInfo getOne(Integer id) { + CustomerInfo customerInfo = customerInfoMapper.getOne(id); if (customerInfo == null) { throw new CustomerInfoException("Get CustomerInfo entity error: no such entity"); } diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/GroupManageImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/GroupManageImpl.java index dff61e7..9e65852 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/GroupManageImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/GroupManageImpl.java @@ -2,12 +2,14 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.IGroupManageBiz; import com.cloudservice.ccs.entity.GroupManage; +import com.cloudservice.ccs.exception.CustomerServiceException; import com.cloudservice.ccs.exception.GroupManageException; import com.cloudservice.ccs.mapper.GroupManageMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class GroupManageImpl implements IGroupManageBiz { @@ -36,7 +38,15 @@ public class GroupManageImpl implements IGroupManageBiz { throw new GroupManageException("Delete GroupManage entity error"); } } + @Override + public void partialUpdate(Integer id, Map fields) { + + int result = groupManageMapper.partialUpdate(id, fields); + if (result == 0) { + throw new GroupManageException("Update GroupManage entity error"); + } + } @Override public GroupManage getOne(Integer id) { GroupManage groupManage = groupManageMapper.getOne(id); diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/NoticeImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/NoticeImpl.java index 78c1e05..ca8f492 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/NoticeImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/NoticeImpl.java @@ -2,12 +2,14 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.INoticeBiz; import com.cloudservice.ccs.entity.Notice; +import com.cloudservice.ccs.exception.CustomerServiceException; import com.cloudservice.ccs.exception.NoticeException; import com.cloudservice.ccs.mapper.NoticeMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class NoticeImpl implements INoticeBiz { @@ -29,6 +31,14 @@ public class NoticeImpl implements INoticeBiz { } } + @Override + public void partialUpdate(Integer id, Map fields) { + int result = noticeMapper.partialUpdate(id, fields); + if (result == 0) { + throw new NoticeException("Partial update Notice failed"); + } + } + @Override public void delete(Integer id) { int result = noticeMapper.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/RoleManageImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/RoleManageImpl.java index 625a7d8..fae6986 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/RoleManageImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/RoleManageImpl.java @@ -2,12 +2,14 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.IRoleManageBiz; import com.cloudservice.ccs.entity.RoleManage; +import com.cloudservice.ccs.exception.CustomerServiceException; import com.cloudservice.ccs.exception.RoleManageException; import com.cloudservice.ccs.mapper.RoleManageMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class RoleManageImpl implements IRoleManageBiz{ @@ -29,6 +31,14 @@ public class RoleManageImpl implements IRoleManageBiz{ } } + @Override + public void partialUpdate(Integer id, Map fields) { + int result = roleManageMapper.partialUpdate(id, fields); + if (result == 0) { + throw new RoleManageException("Partial update RoleManage failed"); + } + } + @Override public void delete(Integer id) { int result = roleManageMapper.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/SessionImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/SessionImpl.java index c751f78..da54c65 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/SessionImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/SessionImpl.java @@ -2,12 +2,14 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.ISessionBiz; import com.cloudservice.ccs.entity.Session; +import com.cloudservice.ccs.exception.RoleManageException; import com.cloudservice.ccs.exception.SessionException; import com.cloudservice.ccs.mapper.SessionMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class SessionImpl implements ISessionBiz { @@ -29,6 +31,14 @@ public class SessionImpl implements ISessionBiz { } } + @Override + public void partialUpdate(Integer id, Map fields) { + int result = sessionMapper.partialUpdate(id, fields); + if (result == 0) { + throw new SessionException("Partial update Session failed"); + } + } + @Override public void delete(Integer id) { int result = sessionMapper.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/SessionMessageImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/SessionMessageImpl.java index 559d720..572c7c3 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/SessionMessageImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/SessionMessageImpl.java @@ -2,12 +2,14 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.ISessionMessageBiz; import com.cloudservice.ccs.entity.SessionMessage; +import com.cloudservice.ccs.exception.RoleManageException; import com.cloudservice.ccs.exception.SessionMessageException; import com.cloudservice.ccs.mapper.SessionMessageMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class SessionMessageImpl implements ISessionMessageBiz { @@ -29,6 +31,14 @@ public class SessionMessageImpl implements ISessionMessageBiz { } } + @Override + public void partialUpdate(Integer id, Map fields) { + int result = sessionMessageMapper.partialUpdate(id, fields); + if (result == 0) { + throw new SessionMessageException("Partial update SessionMessage failed"); + } + } + @Override public void delete(Integer id) { int result = sessionMessageMapper.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/SystemMessageImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/SystemMessageImpl.java index bad518d..7b5d2b3 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/SystemMessageImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/SystemMessageImpl.java @@ -2,11 +2,13 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.ISystemMessageBiz; import com.cloudservice.ccs.entity.SystemMessage; +import com.cloudservice.ccs.exception.RoleManageException; import com.cloudservice.ccs.exception.SystemMessageException; import com.cloudservice.ccs.mapper.SystemMessageMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class SystemMessageImpl implements ISystemMessageBiz { @@ -18,7 +20,7 @@ public class SystemMessageImpl implements ISystemMessageBiz { public void save(SystemMessage systemMessage) { int result = systemMessageMapper.save(systemMessage); if (result == 0) { - throw new SystemMessageException("Create CustomerService entity error"); + throw new SystemMessageException("Create SystemMessage entity error"); } } @@ -26,7 +28,15 @@ public class SystemMessageImpl implements ISystemMessageBiz { public void update(Integer id, SystemMessage systemMessage) { int result = systemMessageMapper.update(id, systemMessage); if (result == 0) { - throw new SystemMessageException("Update CustomerService entity error"); + throw new SystemMessageException("Update SystemMessage entity error"); + } + } + + @Override + public void partialUpdate(Integer id, Map fields) { + int result = systemMessageMapper.partialUpdate(id, fields); + if (result == 0) { + throw new SystemMessageException("Partial update SystemMessage failed"); } } @@ -34,7 +44,7 @@ public class SystemMessageImpl implements ISystemMessageBiz { public void delete(Integer id) { int result = systemMessageMapper.delete(id); if (result == 0) { - throw new SystemMessageException("Delete CustomerService entity error"); + throw new SystemMessageException("Delete SystemMessage entity error"); } } @@ -42,7 +52,7 @@ public class SystemMessageImpl implements ISystemMessageBiz { public SystemMessage getOne(Integer id) { SystemMessage systemMessage = systemMessageMapper.getOne(id); if (systemMessage == null) { - throw new SystemMessageException("Get CustomerService entity error: no such entity"); + throw new SystemMessageException("Get SystemMessage entity error: no such entity"); } return systemMessage; } diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/TagsImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/TagsImpl.java index 80ba349..5dbbe66 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/TagsImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/TagsImpl.java @@ -2,12 +2,14 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.ITagsBiz; import com.cloudservice.ccs.entity.Tags; +import com.cloudservice.ccs.exception.RoleManageException; import com.cloudservice.ccs.exception.TagsException; import com.cloudservice.ccs.mapper.TagsMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class TagsImpl implements ITagsBiz { @@ -18,7 +20,7 @@ public class TagsImpl implements ITagsBiz { public void save(Tags tags) { int result = tagsMapper.save(tags); if (result == 0) { - throw new TagsException("Create CustomerService entity error"); + throw new TagsException("Create Tags entity error"); } } @@ -26,7 +28,15 @@ public class TagsImpl implements ITagsBiz { public void update(Integer id, Tags tags) { int result = tagsMapper.update(id, tags); if (result == 0) { - throw new TagsException("Update CustomerService entity error"); + throw new TagsException("Update Tags entity error"); + } + } + + @Override + public void partialUpdate(Integer id, Map fields) { + int result = tagsMapper.partialUpdate(id, fields); + if (result == 0) { + throw new TagsException("Partial update Tags failed"); } } @@ -34,7 +44,7 @@ public class TagsImpl implements ITagsBiz { public void delete(Integer id) { int result = tagsMapper.delete(id); if (result == 0) { - throw new TagsException("Delete CustomerService entity error"); + throw new TagsException("Delete Tags entity error"); } } @@ -42,7 +52,7 @@ public class TagsImpl implements ITagsBiz { public Tags getOne(Integer id) { Tags tags = tagsMapper.getOne(id); if (tags == null) { - throw new TagsException("Get CustomerService entity error: no such entity"); + throw new TagsException("Get Tags entity error: no such entity"); } return tags; } diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/ViewStatisticsImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/ViewStatisticsImpl.java index 0d96b4c..5404dbd 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/ViewStatisticsImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/ViewStatisticsImpl.java @@ -2,12 +2,14 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.IViewStatisticsBiz; import com.cloudservice.ccs.entity.ViewStatistics; +import com.cloudservice.ccs.exception.RoleManageException; import com.cloudservice.ccs.exception.ViewStatisticsException; import com.cloudservice.ccs.mapper.ViewStatisticsMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class ViewStatisticsImpl implements IViewStatisticsBiz { @@ -18,7 +20,7 @@ public class ViewStatisticsImpl implements IViewStatisticsBiz { public void save(ViewStatistics viewStatistics) { int result = viewStatisticsMapper.save(viewStatistics); if (result == 0) { - throw new ViewStatisticsException("Create CustomerService entity error"); + throw new ViewStatisticsException("Create ViewStatistics entity error"); } } @@ -26,7 +28,15 @@ public class ViewStatisticsImpl implements IViewStatisticsBiz { public void update(Integer id, ViewStatistics viewStatistics) { int result = viewStatisticsMapper.update(id, viewStatistics); if (result == 0) { - throw new ViewStatisticsException("Update CustomerService entity error"); + throw new ViewStatisticsException("Update ViewStatistics entity error"); + } + } + + @Override + public void partialUpdate(Integer id, Map fields) { + int result = viewStatisticsMapper.partialUpdate(id, fields); + if (result == 0) { + throw new ViewStatisticsException("Partial update ViewStatistics failed"); } } @@ -34,7 +44,7 @@ public class ViewStatisticsImpl implements IViewStatisticsBiz { public void delete(Integer id) { int result = viewStatisticsMapper.delete(id); if (result == 0) { - throw new ViewStatisticsException("Delete CustomerService entity error"); + throw new ViewStatisticsException("Delete ViewStatistics entity error"); } } @@ -42,7 +52,7 @@ public class ViewStatisticsImpl implements IViewStatisticsBiz { public ViewStatistics getOne(Integer id) { ViewStatistics viewStatistics = viewStatisticsMapper.getOne(id); if (viewStatistics == null) { - throw new ViewStatisticsException("Get CustomerService entity error: no such entity"); + throw new ViewStatisticsException("Get ViewStatistics entity error: no such entity"); } return viewStatistics; } diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/VisitorInfoImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/VisitorInfoImpl.java index bc02a67..b07bada 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/VisitorInfoImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/VisitorInfoImpl.java @@ -2,12 +2,14 @@ package com.cloudservice.ccs.biz.impl; import com.cloudservice.ccs.biz.IVisitorInfoBiz; import com.cloudservice.ccs.entity.VisitorInfo; +import com.cloudservice.ccs.exception.CustomerServiceException; import com.cloudservice.ccs.exception.VisitorInfoException; import com.cloudservice.ccs.mapper.VisitorInfoMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class VisitorInfoImpl implements IVisitorInfoBiz { @@ -23,24 +25,33 @@ public class VisitorInfoImpl implements IVisitorInfoBiz { } @Override - public void update(String ip, VisitorInfo visitorInfo) { - int result = visitorInfoMapper.update(ip, visitorInfo); + public void update(Integer id, VisitorInfo visitorInfo) { + int result = visitorInfoMapper.update(id, visitorInfo); if (result == 0) { throw new VisitorInfoException("Update CustomerService entity error"); } } @Override - public void delete(String ip) { - int result = visitorInfoMapper.delete(ip); + public void delete(Integer id) { + int result = visitorInfoMapper.delete(id); if (result == 0) { throw new VisitorInfoException("Delete CustomerService entity error"); } } @Override - public VisitorInfo getOne(String ip) { - VisitorInfo visitorInfo = visitorInfoMapper.getOne(ip); + public void partialUpdate(Integer id, Map fields) { + + int result = visitorInfoMapper.partialUpdate(id, fields); + if (result == 0) { + throw new CustomerServiceException("访客信息失败"); + } + } + + @Override + public VisitorInfo getOne(Integer id) { + VisitorInfo visitorInfo = visitorInfoMapper.getOne(id); if (visitorInfo == null) { throw new VisitorInfoException("Get CustomerService entity error: no such entity"); } diff --git a/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java b/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java index bcaf414..51746b5 100644 --- a/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java +++ b/src/main/java/com/cloudservice/ccs/biz/impl/WorkloadStatisticsImpl.java @@ -4,6 +4,7 @@ import com.cloudservice.ccs.biz.IWorkloadStatisticsBiz; import com.cloudservice.ccs.entity.WorkloadStatistics; import com.cloudservice.ccs.entity.WorkloadStatisticsAggregation; import com.cloudservice.ccs.entity.WorkloadStatisticsWithAverage; +import com.cloudservice.ccs.exception.CustomerServiceException; import com.cloudservice.ccs.exception.WorkloadStatisticsException; import com.cloudservice.ccs.mapper.WorkLoadStatisticsMapper; import org.springframework.beans.factory.annotation.Autowired; @@ -11,6 +12,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; +import java.util.Map; @Service public class WorkloadStatisticsImpl implements IWorkloadStatisticsBiz { @@ -50,6 +52,14 @@ public class WorkloadStatisticsImpl implements IWorkloadStatisticsBiz { return workloadStatistics; } + @Override + public void partialUpdate(Integer id, Map fields) { + + int result = workLoadStatisticsMapper.partialUpdate(id, fields); + if (result == 0) { + throw new CustomerServiceException("访客信息失败"); + } + } @Override public List getAll() { return workLoadStatisticsMapper.getAll(); diff --git a/src/main/java/com/cloudservice/ccs/controller/AttendanceStatisticsController.java b/src/main/java/com/cloudservice/ccs/controller/AttendanceStatisticsController.java index d0d5bd8..8e603ba 100644 --- a/src/main/java/com/cloudservice/ccs/controller/AttendanceStatisticsController.java +++ b/src/main/java/com/cloudservice/ccs/controller/AttendanceStatisticsController.java @@ -31,6 +31,13 @@ public class AttendanceStatisticsController { return ApiResult.success(); } + // @RequiresPermissions("all") + @PutMapping("/{id}/partial") + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + attendanceStatisticsBiz.partialUpdate(id, fields); + return ApiResult.success(); + } + @DeleteMapping("/{id}") public ApiResult delete(@PathVariable Integer id) { attendanceStatisticsBiz.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/controller/BlackListController.java b/src/main/java/com/cloudservice/ccs/controller/BlackListController.java index 9445704..7793a77 100644 --- a/src/main/java/com/cloudservice/ccs/controller/BlackListController.java +++ b/src/main/java/com/cloudservice/ccs/controller/BlackListController.java @@ -37,6 +37,14 @@ public class BlackListController { return ApiResult.success(); } + + // @RequiresPermissions("all") + @PutMapping("/{id}/partial") + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + blackListBiz.partialUpdate(id, fields); + return ApiResult.success(); + } + @GetMapping("/{id}") public ApiResult queryById(@PathVariable Integer id) { BlackList result = blackListBiz.getOne(id); diff --git a/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java b/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java index 5413319..b62bd44 100644 --- a/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java +++ b/src/main/java/com/cloudservice/ccs/controller/CommonWordController.java @@ -37,6 +37,13 @@ public class CommonWordController { return ApiResult.success(); } + // @RequiresPermissions("all") + @PutMapping("/{id}/partial") + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + commonWordBiz.partialUpdate(id, fields); + return ApiResult.success(); + } + @GetMapping("/{id}") public ApiResult queryById(@PathVariable Integer id) { CommonWord result = commonWordBiz.getOne(id); diff --git a/src/main/java/com/cloudservice/ccs/controller/CustomerInfoController.java b/src/main/java/com/cloudservice/ccs/controller/CustomerInfoController.java index 15a4e55..b356619 100644 --- a/src/main/java/com/cloudservice/ccs/controller/CustomerInfoController.java +++ b/src/main/java/com/cloudservice/ccs/controller/CustomerInfoController.java @@ -26,20 +26,20 @@ public class CustomerInfoController { } @PutMapping("/{email}") - public ApiResult update(@PathVariable String email, @RequestBody CustomerInfo customerInfo) { - customerInfoBiz.update(email, customerInfo); + public ApiResult update(@PathVariable Integer id, @RequestBody CustomerInfo customerInfo) { + customerInfoBiz.update(id, customerInfo); return ApiResult.success(); } @DeleteMapping("/{email}") - public ApiResult delete(@PathVariable String email) { - customerInfoBiz.delete(email); + public ApiResult delete(@PathVariable Integer id) { + customerInfoBiz.delete(id); return ApiResult.success(); } @GetMapping("/{email}") - public ApiResult queryById(@PathVariable String email) { - CustomerInfo result = customerInfoBiz.getOne(email); + public ApiResult queryById(@PathVariable Integer id) { + CustomerInfo result = customerInfoBiz.getOne(id); return ApiResult.successWithData(result); } @@ -48,4 +48,10 @@ public class CustomerInfoController { List result = customerInfoBiz.getAll(); return ApiResult.successWithData(result); } + + @PutMapping("/{id}/partial") + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + customerInfoBiz.partialUpdate(id, fields); + return ApiResult.success(); + } } diff --git a/src/main/java/com/cloudservice/ccs/controller/GroupManageController.java b/src/main/java/com/cloudservice/ccs/controller/GroupManageController.java index b3956c3..5bef465 100644 --- a/src/main/java/com/cloudservice/ccs/controller/GroupManageController.java +++ b/src/main/java/com/cloudservice/ccs/controller/GroupManageController.java @@ -47,4 +47,11 @@ public class GroupManageController { List result = groupManageBiz.getAll(); return ApiResult.successWithData(result); } + + @PutMapping("/{id}/partial") + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + groupManageBiz.partialUpdate(id, fields); + return ApiResult.success(); + } + } diff --git a/src/main/java/com/cloudservice/ccs/controller/NoticeController.java b/src/main/java/com/cloudservice/ccs/controller/NoticeController.java index 62f3175..b589f2c 100644 --- a/src/main/java/com/cloudservice/ccs/controller/NoticeController.java +++ b/src/main/java/com/cloudservice/ccs/controller/NoticeController.java @@ -31,6 +31,13 @@ public class NoticeController { return ApiResult.success(); } + // @RequiresPermissions("all") + @PutMapping("/{id}/partial") + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + noticeBiz.partialUpdate(id, fields); + return ApiResult.success(); + } + @DeleteMapping("/{id}") public ApiResult delete(@PathVariable Integer id) { noticeBiz.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/controller/RoleManageController.java b/src/main/java/com/cloudservice/ccs/controller/RoleManageController.java index b5aefcb..f975798 100644 --- a/src/main/java/com/cloudservice/ccs/controller/RoleManageController.java +++ b/src/main/java/com/cloudservice/ccs/controller/RoleManageController.java @@ -31,6 +31,13 @@ public class RoleManageController { return ApiResult.success(); } + // @RequiresPermissions("all") + @PutMapping("/{id}/partial") + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + roleManageBiz.partialUpdate(id, fields); + return ApiResult.success(); + } + @DeleteMapping("/{id}") public ApiResult delete(@PathVariable Integer id) { roleManageBiz.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/controller/SessionController.java b/src/main/java/com/cloudservice/ccs/controller/SessionController.java index f018f0a..3f720b9 100644 --- a/src/main/java/com/cloudservice/ccs/controller/SessionController.java +++ b/src/main/java/com/cloudservice/ccs/controller/SessionController.java @@ -31,6 +31,13 @@ public class SessionController { return ApiResult.success(); } + // @RequiresPermissions("all") + @PutMapping("/{id}/partial") + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + sessionBiz.partialUpdate(id, fields); + return ApiResult.success(); + } + @DeleteMapping("/{id}") public ApiResult delete(@PathVariable Integer id) { sessionBiz.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/controller/SessionMessageController.java b/src/main/java/com/cloudservice/ccs/controller/SessionMessageController.java index 1ee88e8..c81cb59 100644 --- a/src/main/java/com/cloudservice/ccs/controller/SessionMessageController.java +++ b/src/main/java/com/cloudservice/ccs/controller/SessionMessageController.java @@ -31,6 +31,13 @@ public class SessionMessageController { return ApiResult.success(); } + // @RequiresPermissions("all") + @PutMapping("/{id}/partial") + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + sessionMessageBiz.partialUpdate(id, fields); + return ApiResult.success(); + } + @DeleteMapping("/{id}") public ApiResult delete(@PathVariable Integer id) { sessionMessageBiz.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/controller/SystemMessageController.java b/src/main/java/com/cloudservice/ccs/controller/SystemMessageController.java index 79963a5..2222ad9 100644 --- a/src/main/java/com/cloudservice/ccs/controller/SystemMessageController.java +++ b/src/main/java/com/cloudservice/ccs/controller/SystemMessageController.java @@ -33,6 +33,13 @@ public class SystemMessageController { return ApiResult.success(); } + // @RequiresPermissions("all") + @PutMapping("/{id}/partial") + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + systemMessageBiz.partialUpdate(id, fields); + return ApiResult.success(); + } + @DeleteMapping("/{id}") public ApiResult delete(@PathVariable Integer id) { systemMessageBiz.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/controller/TagsController.java b/src/main/java/com/cloudservice/ccs/controller/TagsController.java index 8ca53c3..f44c22d 100644 --- a/src/main/java/com/cloudservice/ccs/controller/TagsController.java +++ b/src/main/java/com/cloudservice/ccs/controller/TagsController.java @@ -33,6 +33,13 @@ public class TagsController { return ApiResult.success(); } + // @RequiresPermissions("all") + @PutMapping("/{id}/partial") + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + tagsBiz.partialUpdate(id, fields); + return ApiResult.success(); + } + @DeleteMapping("/{id}") public ApiResult delete(@PathVariable Integer id) { tagsBiz.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/controller/ViewStatisticsController.java b/src/main/java/com/cloudservice/ccs/controller/ViewStatisticsController.java index 6e19516..3000b83 100644 --- a/src/main/java/com/cloudservice/ccs/controller/ViewStatisticsController.java +++ b/src/main/java/com/cloudservice/ccs/controller/ViewStatisticsController.java @@ -35,6 +35,13 @@ public class ViewStatisticsController { return ApiResult.success(); } + // @RequiresPermissions("all") + @PutMapping("/{id}/partial") + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + viewStatisticsBiz.partialUpdate(id, fields); + return ApiResult.success(); + } + @DeleteMapping("/{id}") public ApiResult delete(@PathVariable Integer id) { viewStatisticsBiz.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/controller/VisitorInfoController.java b/src/main/java/com/cloudservice/ccs/controller/VisitorInfoController.java index 52b9ec8..80bce27 100644 --- a/src/main/java/com/cloudservice/ccs/controller/VisitorInfoController.java +++ b/src/main/java/com/cloudservice/ccs/controller/VisitorInfoController.java @@ -27,21 +27,27 @@ public class VisitorInfoController { return ApiResult.success(); } - @PutMapping("/{ip}") - public ApiResult update(@PathVariable String ip, @RequestBody VisitorInfo visitorInfo) { - visitorInfoBiz.update(ip, visitorInfo); + @PutMapping("/{id}") + public ApiResult update(@PathVariable Integer id, @RequestBody VisitorInfo visitorInfo) { + visitorInfoBiz.update(id, visitorInfo); return ApiResult.success(); } - @DeleteMapping("/{ip}") - public ApiResult delete(@PathVariable String ip) { - visitorInfoBiz.delete(ip); + @DeleteMapping("/{id}") + public ApiResult delete(@PathVariable Integer id) { + visitorInfoBiz.delete(id); return ApiResult.success(); } - @GetMapping("/{ip}") - public ApiResult queryById(@PathVariable String ip) { - VisitorInfo result = visitorInfoBiz.getOne(ip); + @PutMapping("/{id}/partial") + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + visitorInfoBiz.partialUpdate(id, fields); + return ApiResult.success(); + } + + @GetMapping("/{id}") + public ApiResult queryById(@PathVariable Integer id) { + VisitorInfo result = visitorInfoBiz.getOne(id); return ApiResult.successWithData(result); } diff --git a/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java b/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java index 409548b..5ffdd2c 100644 --- a/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java +++ b/src/main/java/com/cloudservice/ccs/controller/WorkloadStatisticsController.java @@ -35,6 +35,12 @@ public class WorkloadStatisticsController { return ApiResult.success(); } + @PutMapping("/{id}/partial") + public ApiResult partialUpdate(@PathVariable Integer id, @RequestBody Map fields) { + workloadStatisticsBiz.partialUpdate(id, fields); + return ApiResult.success(); + } + @DeleteMapping("/{id}") public ApiResult delete(@PathVariable Integer id) { workloadStatisticsBiz.delete(id); diff --git a/src/main/java/com/cloudservice/ccs/entity/BlackList.java b/src/main/java/com/cloudservice/ccs/entity/BlackList.java index 00507fa..516dc21 100644 --- a/src/main/java/com/cloudservice/ccs/entity/BlackList.java +++ b/src/main/java/com/cloudservice/ccs/entity/BlackList.java @@ -14,4 +14,5 @@ public class BlackList { @DateTimeFormat(pattern = "yyyy-MM-dd") private Date time; private String source; + private int id; } diff --git a/src/main/java/com/cloudservice/ccs/entity/CommonWord.java b/src/main/java/com/cloudservice/ccs/entity/CommonWord.java index 61300a5..e9a821a 100644 --- a/src/main/java/com/cloudservice/ccs/entity/CommonWord.java +++ b/src/main/java/com/cloudservice/ccs/entity/CommonWord.java @@ -7,5 +7,5 @@ public class CommonWord { private String content; private String lib; private String type; - private Integer creatorId; + private Integer id; } diff --git a/src/main/java/com/cloudservice/ccs/entity/CustomerInfo.java b/src/main/java/com/cloudservice/ccs/entity/CustomerInfo.java index 67efd4d..b6704f9 100644 --- a/src/main/java/com/cloudservice/ccs/entity/CustomerInfo.java +++ b/src/main/java/com/cloudservice/ccs/entity/CustomerInfo.java @@ -7,6 +7,7 @@ import java.util.Date; @Data public class CustomerInfo { + private Integer id; private String state; private String visitorName; private String realName; diff --git a/src/main/java/com/cloudservice/ccs/entity/CustomerService.java b/src/main/java/com/cloudservice/ccs/entity/CustomerService.java index 8d15fbb..6a86387 100644 --- a/src/main/java/com/cloudservice/ccs/entity/CustomerService.java +++ b/src/main/java/com/cloudservice/ccs/entity/CustomerService.java @@ -7,7 +7,6 @@ import java.util.Date; @Data public class CustomerService { - private String phone; private String password; private String state; private String headImg; diff --git a/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java b/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java index 1112156..161956b 100644 --- a/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/cloudservice/ccs/exception/GlobalExceptionHandler.java @@ -32,7 +32,7 @@ public class GlobalExceptionHandler { if (e instanceof UnknownAccountException) { return ApiResult.failureWithData("未知用户"); } else if (e instanceof IncorrectCredentialsException) { - return ApiResult.failureWithData("邮箱或密码错误"); + return ApiResult.failureWithData("用户名或密码错误"); } else { return ApiResult.failureWithData("未知认证错误:" + e.getClass().getName() + ": " + e.getMessage()); } diff --git a/src/main/java/com/cloudservice/ccs/mapper/AttendanceStatisticsMapper.java b/src/main/java/com/cloudservice/ccs/mapper/AttendanceStatisticsMapper.java index 477799a..9e3341c 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/AttendanceStatisticsMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/AttendanceStatisticsMapper.java @@ -4,6 +4,7 @@ import com.cloudservice.ccs.entity.AttendanceStatistics; import org.apache.ibatis.annotations.Mapper; import java.util.List; +import java.util.Map; @Mapper public interface AttendanceStatisticsMapper { @@ -13,6 +14,8 @@ public interface AttendanceStatisticsMapper { int delete(Integer id); + int partialUpdate(Integer id, Map fields); + AttendanceStatistics getOne(Integer id); List getAll(); diff --git a/src/main/java/com/cloudservice/ccs/mapper/BlackListMapper.java b/src/main/java/com/cloudservice/ccs/mapper/BlackListMapper.java index cf47634..a6e3a0f 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/BlackListMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/BlackListMapper.java @@ -5,6 +5,7 @@ import com.cloudservice.ccs.entity.BlackList; import org.apache.ibatis.annotations.Mapper; import java.util.List; +import java.util.Map; @Mapper public interface BlackListMapper { @@ -14,6 +15,8 @@ public interface BlackListMapper { int delete(Integer id); + int partialUpdate(Integer id, Map fields); + BlackList getOne(Integer id); List getAll(); diff --git a/src/main/java/com/cloudservice/ccs/mapper/CommonWordMapper.java b/src/main/java/com/cloudservice/ccs/mapper/CommonWordMapper.java index 5359487..7775be8 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/CommonWordMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/CommonWordMapper.java @@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; @Mapper public interface CommonWordMapper { @@ -14,6 +15,8 @@ public interface CommonWordMapper { int delete(Integer id); + int partialUpdate(Integer id, Map fields); + CommonWord getOne(Integer id); List getAll(); diff --git a/src/main/java/com/cloudservice/ccs/mapper/CustomerInfoMapper.java b/src/main/java/com/cloudservice/ccs/mapper/CustomerInfoMapper.java index b1b3843..f02214f 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/CustomerInfoMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/CustomerInfoMapper.java @@ -5,16 +5,19 @@ import com.cloudservice.ccs.entity.CustomerInfo; import org.apache.ibatis.annotations.Mapper; import java.util.List; +import java.util.Map; @Mapper public interface CustomerInfoMapper { int save( CustomerInfo customerInfo); - int update(String email, CustomerInfo customerInfo); + int update(Integer id, CustomerInfo customerInfo); - int delete(String email); + int delete(Integer id); - CustomerInfo getOne(String email); + int partialUpdate(Integer id, Map fields); + + CustomerInfo getOne(Integer id); List getAll(); } diff --git a/src/main/java/com/cloudservice/ccs/mapper/GroupManageMapper.java b/src/main/java/com/cloudservice/ccs/mapper/GroupManageMapper.java index cc20128..5b73432 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/GroupManageMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/GroupManageMapper.java @@ -5,6 +5,7 @@ import com.cloudservice.ccs.entity.GroupManage; import org.apache.ibatis.annotations.Mapper; import java.util.List; +import java.util.Map; @Mapper public interface GroupManageMapper { @@ -14,6 +15,8 @@ public interface GroupManageMapper { int delete(Integer id); + int partialUpdate(Integer id, Map fields); + GroupManage getOne(Integer id); List getAll(); diff --git a/src/main/java/com/cloudservice/ccs/mapper/NoticeMapper.java b/src/main/java/com/cloudservice/ccs/mapper/NoticeMapper.java index 8e181ef..3b84dbd 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/NoticeMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/NoticeMapper.java @@ -5,6 +5,7 @@ import com.cloudservice.ccs.entity.Notice; import org.apache.ibatis.annotations.Mapper; import java.util.List; +import java.util.Map; @Mapper public interface NoticeMapper { @@ -12,6 +13,8 @@ public interface NoticeMapper { int update(Integer id, Notice notice); + int partialUpdate(Integer id, Map fields); + int delete(Integer id); Notice getOne(Integer id); diff --git a/src/main/java/com/cloudservice/ccs/mapper/RoleManageMapper.java b/src/main/java/com/cloudservice/ccs/mapper/RoleManageMapper.java index 2e27155..74ac967 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/RoleManageMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/RoleManageMapper.java @@ -5,6 +5,7 @@ import com.cloudservice.ccs.entity.RoleManage; import org.apache.ibatis.annotations.Mapper; import java.util.List; +import java.util.Map; @Mapper public interface RoleManageMapper { @@ -12,6 +13,8 @@ public interface RoleManageMapper { int update(Integer id, RoleManage roleManage); + int partialUpdate(Integer id, Map fields); + int delete(Integer id); RoleManage getOne(Integer id); diff --git a/src/main/java/com/cloudservice/ccs/mapper/SessionMapper.java b/src/main/java/com/cloudservice/ccs/mapper/SessionMapper.java index da915c4..04a9564 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/SessionMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/SessionMapper.java @@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper; import java.util.List; +import java.util.Map; @Mapper public interface SessionMapper { @@ -12,6 +13,8 @@ public interface SessionMapper { int update(Integer id, Session session); + int partialUpdate(Integer id, Map fields); + int delete(Integer id); Session getOne(Integer id); diff --git a/src/main/java/com/cloudservice/ccs/mapper/SessionMessageMapper.java b/src/main/java/com/cloudservice/ccs/mapper/SessionMessageMapper.java index 3e39d91..bbdbad6 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/SessionMessageMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/SessionMessageMapper.java @@ -4,6 +4,7 @@ import com.cloudservice.ccs.entity.SessionMessage; import org.apache.ibatis.annotations.Mapper; import java.util.List; +import java.util.Map; @Mapper public interface SessionMessageMapper { @@ -11,6 +12,8 @@ public interface SessionMessageMapper { int update(Integer id, SessionMessage sessionMessage); + int partialUpdate(Integer id, Map fields); + int delete(Integer id); SessionMessage getOne(Integer id); diff --git a/src/main/java/com/cloudservice/ccs/mapper/SystemMessageMapper.java b/src/main/java/com/cloudservice/ccs/mapper/SystemMessageMapper.java index 5ba0e86..165c7c6 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/SystemMessageMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/SystemMessageMapper.java @@ -4,6 +4,7 @@ import com.cloudservice.ccs.entity.SystemMessage; import org.apache.ibatis.annotations.Mapper; import java.util.List; +import java.util.Map; @Mapper public interface SystemMessageMapper { @@ -11,6 +12,8 @@ public interface SystemMessageMapper { int update(Integer id, SystemMessage systemMessage); + int partialUpdate(Integer id, Map fields); + int delete(Integer id); SystemMessage getOne(Integer id); diff --git a/src/main/java/com/cloudservice/ccs/mapper/TagsMapper.java b/src/main/java/com/cloudservice/ccs/mapper/TagsMapper.java index e2234de..9844da5 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/TagsMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/TagsMapper.java @@ -4,6 +4,7 @@ import com.cloudservice.ccs.entity.Tags; import org.apache.ibatis.annotations.Mapper; import java.util.List; +import java.util.Map; @Mapper public interface TagsMapper { @@ -11,6 +12,8 @@ public interface TagsMapper { int update(Integer id, Tags tags); + int partialUpdate(Integer id, Map fields); + int delete(Integer id); Tags getOne(Integer id); diff --git a/src/main/java/com/cloudservice/ccs/mapper/ViewStatisticsMapper.java b/src/main/java/com/cloudservice/ccs/mapper/ViewStatisticsMapper.java index 976657b..8871e2d 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/ViewStatisticsMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/ViewStatisticsMapper.java @@ -4,6 +4,7 @@ import com.cloudservice.ccs.entity.ViewStatistics; import org.apache.ibatis.annotations.Mapper; import java.util.List; +import java.util.Map; @Mapper public interface ViewStatisticsMapper { @@ -11,6 +12,8 @@ public interface ViewStatisticsMapper { int update(Integer id, ViewStatistics viewStatistics); + int partialUpdate(Integer id, Map fields); + int delete(Integer id); ViewStatistics getOne(Integer id); diff --git a/src/main/java/com/cloudservice/ccs/mapper/VisitorInfoMapper.java b/src/main/java/com/cloudservice/ccs/mapper/VisitorInfoMapper.java index cb538b7..e1c42d8 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/VisitorInfoMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/VisitorInfoMapper.java @@ -6,16 +6,19 @@ import com.cloudservice.ccs.entity.VisitorInfo; import org.apache.ibatis.annotations.Mapper; import java.util.List; +import java.util.Map; @Mapper public interface VisitorInfoMapper { int save(VisitorInfo visitorInfo); - int update(String ip, VisitorInfo visitorInfo); + int update(Integer id, VisitorInfo visitorInfo); - int delete(String ip); + int partialUpdate(Integer id, Map fields); - VisitorInfo getOne(String ip); + int delete(Integer id); + + VisitorInfo getOne(Integer id); List getAll(); } diff --git a/src/main/java/com/cloudservice/ccs/mapper/WorkLoadStatisticsMapper.java b/src/main/java/com/cloudservice/ccs/mapper/WorkLoadStatisticsMapper.java index 9124732..4759be9 100644 --- a/src/main/java/com/cloudservice/ccs/mapper/WorkLoadStatisticsMapper.java +++ b/src/main/java/com/cloudservice/ccs/mapper/WorkLoadStatisticsMapper.java @@ -7,6 +7,7 @@ import com.cloudservice.ccs.entity.WorkloadStatisticsAggregation; import org.apache.ibatis.annotations.Mapper; import java.util.List; +import java.util.Map; @Mapper public interface WorkLoadStatisticsMapper { @@ -15,6 +16,7 @@ public interface WorkLoadStatisticsMapper { int update(Integer id, WorkloadStatistics workloadStatistics); int delete(Integer id); + int partialUpdate(Integer id, Map fields); WorkloadStatistics getOne(Integer id); diff --git a/src/main/resources/mapper/AttendanceStatisticsMapper.xml b/src/main/resources/mapper/AttendanceStatisticsMapper.xml index bf8ee5f..6fdf4ff 100644 --- a/src/main/resources/mapper/AttendanceStatisticsMapper.xml +++ b/src/main/resources/mapper/AttendanceStatisticsMapper.xml @@ -33,4 +33,13 @@ + + + UPDATE attendance_statistics SET + + ${field} = #{value} + + WHERE id = #{id}; + + \ No newline at end of file diff --git a/src/main/resources/mapper/BlackListMapper.xml b/src/main/resources/mapper/BlackListMapper.xml index f98d464..3bbb88d 100644 --- a/src/main/resources/mapper/BlackListMapper.xml +++ b/src/main/resources/mapper/BlackListMapper.xml @@ -9,6 +9,14 @@ ) + + UPDATE black_list SET + + ${field} = #{value} + + WHERE id = #{id}; + + UPDATE black_list SET customerServiceId=#{blackList.customerServiceId}, diff --git a/src/main/resources/mapper/CommonWordMapper.xml b/src/main/resources/mapper/CommonWordMapper.xml index 45e766c..0f5067e 100644 --- a/src/main/resources/mapper/CommonWordMapper.xml +++ b/src/main/resources/mapper/CommonWordMapper.xml @@ -15,20 +15,28 @@ content = #{commonWord.content}, lib = #{commonWord.lib}, type = #{commonWord.type} - WHERE creatorId = #{id}; + WHERE id = #{id}; DELETE FROM common_word - WHERE creatorId = #{id}; + WHERE id = #{id}; + + + UPDATE common_word SET + + ${field} = #{value} + + WHERE id = #{id}; + \ No newline at end of file diff --git a/src/main/resources/mapper/CustomerInfoMapper.xml b/src/main/resources/mapper/CustomerInfoMapper.xml index 13a74e3..adff4fc 100644 --- a/src/main/resources/mapper/CustomerInfoMapper.xml +++ b/src/main/resources/mapper/CustomerInfoMapper.xml @@ -3,14 +3,15 @@ INSERT INTO customer_info ( - state, visitorName, realName,phone,email,company,address,level,channel,tagsId,remark,customerServiceId + id,state, visitorName, realName,phone,email,company,address,level,channel,tagsId,remark,customerServiceId ) VALUES ( - #{state}, #{visitorName}, #{realName}, #{phone}, #{email}, #{company}, #{address}, #{level}, #{channel}, #{tagsId}, #{remark}, #{customerServiceId} + #{id},#{state}, #{visitorName}, #{realName}, #{phone}, #{email}, #{company}, #{address}, #{level}, #{channel}, #{tagsId}, #{remark}, #{customerServiceId} ) UPDATE customer_info SET + id = #{id}, state = #{customerInfo.state}, visitorName = #{customerInfo.visitorName}, realName = #{customerInfo.realName}, @@ -22,20 +23,28 @@ tagsId = #{customerInfo.tagsId}, remark = #{customerInfo.remark}, customerServiceId = #{customerInfo.customerServiceId} - WHERE email = #{email}; + WHERE id = #{id}; DELETE FROM customer_info - WHERE email = #{email}; + WHERE id = #{id}; + + + UPDATE customer_info SET + + ${field} = #{value} + + WHERE id = #{id}; + \ No newline at end of file diff --git a/src/main/resources/mapper/GroupManageMapper.xml b/src/main/resources/mapper/GroupManageMapper.xml index bf3d0ac..123b915 100644 --- a/src/main/resources/mapper/GroupManageMapper.xml +++ b/src/main/resources/mapper/GroupManageMapper.xml @@ -30,4 +30,12 @@ + + + UPDATE group_manage SET + + ${field} = #{value} + + WHERE groupId = #{id}; + \ No newline at end of file diff --git a/src/main/resources/mapper/NoticeMapper.xml b/src/main/resources/mapper/NoticeMapper.xml index 8c549d8..7e78ed0 100644 --- a/src/main/resources/mapper/NoticeMapper.xml +++ b/src/main/resources/mapper/NoticeMapper.xml @@ -18,6 +18,14 @@ WHERE id = #{id}; + + UPDATE notice SET + + ${field} = #{value} + + WHERE id = #{id}; + + DELETE FROM notice WHERE id = #{id}; diff --git a/src/main/resources/mapper/RoleManageMapper.xml b/src/main/resources/mapper/RoleManageMapper.xml index ec397e2..33ec58e 100644 --- a/src/main/resources/mapper/RoleManageMapper.xml +++ b/src/main/resources/mapper/RoleManageMapper.xml @@ -18,6 +18,14 @@ where roleId = #{id} + + UPDATE role_manage SET + + ${field} = #{value} + + WHERE roleId = #{id}; + + DELETE FROM role_manage WHERE roleId = #{id}; diff --git a/src/main/resources/mapper/SessionMapper.xml b/src/main/resources/mapper/SessionMapper.xml index 1e6fef6..d428a96 100644 --- a/src/main/resources/mapper/SessionMapper.xml +++ b/src/main/resources/mapper/SessionMapper.xml @@ -25,6 +25,14 @@ where sessionId = #{id}; + + UPDATE session SET + + ${field} = #{value} + + WHERE sessionId = #{id}; + + DELETE FROM session WHERE sessionId = #{id}; diff --git a/src/main/resources/mapper/SessionMessageMapper.xml b/src/main/resources/mapper/SessionMessageMapper.xml index 5caa651..ec92e98 100644 --- a/src/main/resources/mapper/SessionMessageMapper.xml +++ b/src/main/resources/mapper/SessionMessageMapper.xml @@ -17,6 +17,14 @@ where msgSenderId = #{id} + + UPDATE session_message SET + + ${field} = #{value} + + WHERE msgSenderId = #{id}; + + DELETE FROM session_message WHERE msgSenderId = #{id}; diff --git a/src/main/resources/mapper/SystemMessageMapper.xml b/src/main/resources/mapper/SystemMessageMapper.xml index 300675d..366331e 100644 --- a/src/main/resources/mapper/SystemMessageMapper.xml +++ b/src/main/resources/mapper/SystemMessageMapper.xml @@ -16,6 +16,14 @@ where id = #{id}; + + UPDATE system_message SET + + ${field} = #{value} + + WHERE id = #{id}; + + DELETE FROM system_message WHERE id= #{id}; diff --git a/src/main/resources/mapper/TagsMapper.xml b/src/main/resources/mapper/TagsMapper.xml index c9efdc9..ec652a6 100644 --- a/src/main/resources/mapper/TagsMapper.xml +++ b/src/main/resources/mapper/TagsMapper.xml @@ -18,6 +18,14 @@ where creatorId = #{Tags.id}; + + UPDATE tags SET + + ${field} = #{value} + + WHERE creatorId = #{id}; + + DELETE FROM tags WHERE creatorId = #{id}; diff --git a/src/main/resources/mapper/ViewStatisticsMapper.xml b/src/main/resources/mapper/ViewStatisticsMapper.xml index 9a4ab70..b15f3ed 100644 --- a/src/main/resources/mapper/ViewStatisticsMapper.xml +++ b/src/main/resources/mapper/ViewStatisticsMapper.xml @@ -17,6 +17,14 @@ where id= #{id}; + + UPDATE view_statistics SET + + ${field} = #{value} + + WHERE id = #{id}; + + DELETE FROM view_statistics WHERE id= #{id}; diff --git a/src/main/resources/mapper/VisitorInfoMapper.xml b/src/main/resources/mapper/VisitorInfoMapper.xml index 39ee5a2..45c099e 100644 --- a/src/main/resources/mapper/VisitorInfoMapper.xml +++ b/src/main/resources/mapper/VisitorInfoMapper.xml @@ -5,14 +5,15 @@ INSERT INTO visitor_info ( - ip,visitorName,terminal,browser,screenSize,device,customerServiceId,state,visitDuration + id,ip,visitorName,terminal,browser,screenSize,device,customerServiceId,state,visitDuration ) VALUES ( - #{ip}, #{visitorName}, #{terminal}, #{browser}, #{screenSize}, #{device}, #{customerServiceId}, #{state}, #{visitDuration} + #{id},#{ip}, #{visitorName}, #{terminal}, #{browser}, #{screenSize}, #{device}, #{customerServiceId}, #{state}, #{visitDuration} ) UPDATE visitor_info SET + id = #{Visitor.id}, ip = #{VisitorInfo.ip}, visitorName = #{VisitorInfo.visitorName}, terminal = #{VisitorInfo.terminal}, @@ -22,7 +23,15 @@ customerServiceId = #{VisitorInfo.customerServiceId}, state = #{VisitorInfo.state}, visitDuration = #{VisitorInfo.visitDuration} - WHERE ip = #{ip}; + WHERE id = #{id}; + + + + UPDATE visitor_info SET + + ${field} = #{value} + + WHERE id = #{id}; @@ -32,7 +41,7 @@