diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/aspect/LogAspect.java b/cloudutil/src/main/java/com/ccsens/cloudutil/aspect/LogAspect.java new file mode 100644 index 00000000..374a3141 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/aspect/LogAspect.java @@ -0,0 +1,133 @@ +package com.ccsens.cloudutil.aspect; + +import cn.hutool.core.util.ZipUtil; +import com.ccsens.cloudutil.bean.tall.dto.LogDto; +import com.ccsens.cloudutil.feign.TallFeignClient; +import com.ccsens.util.CodeEnum; +import com.ccsens.util.UploadFileUtil_Servlet3; +import com.ccsens.util.WebConstant; +import com.ccsens.util.exception.BaseException; +import io.jsonwebtoken.Claims; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.Part; +import java.lang.reflect.Method; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/10 10:06 + */ +@Order(1) +@Slf4j +@Aspect +@Component +public class LogAspect { + + @Autowired + private TallFeignClient tallFeignClient; + + + @Pointcut("execution(* com.ccsens.tall.web..*(..)) || execution(* com.ccsens.ht.api..*(..))") + public void logAdvice(){ + + } + + @Around("logAdvice()") + public Object around(ProceedingJoinPoint pjp){ + LogDto logDto = initLog(pjp); + + + Object result; + try { + result = pjp.proceed(); + } catch (Throwable throwable) { + log.error("方法运行异常", throwable); + if (logDto != null) { + String message = throwable.getMessage(); + logDto.setResult(message.length() > 1000 ? message.substring(0,1000) : message); + tallFeignClient.log(logDto); + } + + throw new BaseException(CodeEnum.SYS_ERROR); + } + if (logDto != null) { + String message = result == null ? null : result.toString().length() > 1000 ? result.toString().substring(0, 1000) : result.toString(); + logDto.setResult(message); + tallFeignClient.log(logDto); + } + + return result; + } + + /** + * 获取方法路径、描述、参数 + * @param pjp + * @return + */ + private LogDto initLog(ProceedingJoinPoint pjp) { + + //路径 + HttpServletRequest request = ((ServletRequestAttributes) + RequestContextHolder.getRequestAttributes()).getRequest(); + String url = request.getServletPath(); + System.out.println("url:" + url); + String logUrl = "/log/operation"; + if (logUrl.equalsIgnoreCase(url)){ + log.info("保存日志,不进行记录"); + return null; + } + + LogDto dto = new LogDto(); + dto.setUrl(url); + //参数 + Object[] args = pjp.getArgs(); + StringBuilder param = new StringBuilder(); + //方法注解 + + Class[] argTypes = new Class[args.length]; + for (int i = 0; i < args.length; i++) { + //参数类型 + argTypes[i] = args[i].getClass(); + //参数值 + if (args[i] instanceof ServletResponse) { + continue; + } else if (args[i] instanceof ServletRequest) { + Object claims = request.getAttribute(WebConstant.REQUEST_KEY_CLAIMS); + String userId = claims == null ? null : ((Claims) claims).getSubject(); + if (userId != null) { + param.append("userId:").append(userId).append("--"); + } + } else if (args[i] instanceof Part) { + param.append("file:").append(UploadFileUtil_Servlet3.getFileNameByPart((Part)args[i])).append("--"); + }else { + param.append(args[i]).append("--"); + } + + } + dto.setParams(param.length() > 1000 ? param.substring(0, 1000) : param.toString()); + try { + Method method = pjp.getTarget().getClass().getMethod(pjp.getSignature().getName(), argTypes); + ApiOperation annotation = method.getAnnotation(ApiOperation.class); + dto.setMethodDesc(annotation == null ? "" : annotation.value()); + } catch (Exception e) { + log.error("获取方法时异常",e); + } + + return dto; + } + +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/LogDto.java b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/LogDto.java new file mode 100644 index 00000000..c0089813 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/LogDto.java @@ -0,0 +1,27 @@ +package com.ccsens.cloudutil.bean.tall.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/09 18:01 + */ +@Data +@ApiModel +public class LogDto { + + private Long id; + @ApiModelProperty("接口地址") + private String url; + @ApiModelProperty("接口参数") + private String params; + @ApiModelProperty("接口描述") + private String methodDesc; + @ApiModelProperty("接口返回值(或异常)") + private String result; +} diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/feign/TallFeignClient.java b/cloudutil/src/main/java/com/ccsens/cloudutil/feign/TallFeignClient.java index 74190fc9..882c8d86 100644 --- a/cloudutil/src/main/java/com/ccsens/cloudutil/feign/TallFeignClient.java +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/feign/TallFeignClient.java @@ -1,6 +1,7 @@ package com.ccsens.cloudutil.feign; import com.ccsens.cloudutil.bean.QueryParam; +import com.ccsens.cloudutil.bean.tall.dto.LogDto; import com.ccsens.cloudutil.bean.tall.dto.MemberRoleDto; import com.ccsens.cloudutil.bean.tall.dto.UserDto; import com.ccsens.cloudutil.bean.tall.vo.UserVo; @@ -64,7 +65,13 @@ public interface TallFeignClient { @GetMapping("users/token") JsonResponse getUserIdByToken(@RequestParam(required = true, name = "token") String token); - + /** + * 记录操作日志 + * @param logDto + * @return + */ + @RequestMapping("/log/operation") + JsonResponse log(LogDto logDto); } @Slf4j @@ -102,6 +109,11 @@ class TallFeignClientFallBack implements FallbackFactory { public JsonResponse getUserIdByToken(String token) { return JsonResponse.newInstance().fail(); } + + @Override + public JsonResponse log(LogDto logDto) { + return JsonResponse.newInstance().fail(); + } }; } diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/interceptor/LogInterceptor.java b/cloudutil/src/main/java/com/ccsens/cloudutil/interceptor/LogInterceptor.java new file mode 100644 index 00000000..248468c2 --- /dev/null +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/interceptor/LogInterceptor.java @@ -0,0 +1,31 @@ +package com.ccsens.cloudutil.interceptor; + +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/09 18:24 + */ +public class LogInterceptor implements HandlerInterceptor { + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + //路径 + String path = request.getContextPath(); + return false; + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { + + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + + } +} diff --git a/cloudutil/src/main/resources/application-util-dev.yml b/cloudutil/src/main/resources/application-util-dev.yml index 28cdd13c..997b9a7d 100644 --- a/cloudutil/src/main/resources/application-util-dev.yml +++ b/cloudutil/src/main/resources/application-util-dev.yml @@ -30,6 +30,9 @@ eureka: home-page-url-path: ${server.servlet.context-path}/ status-page-url-path: ${server.servlet.context-path}/actuator/info health-check-url-path: ${server.servlet.context-path}/actuator/health +ribbon: + ConnectTimeout: 5000 + ReadTimeout: 5000 feign: client: config: diff --git a/ht/src/main/java/com/ccsens/ht/api/DoctorController.java b/ht/src/main/java/com/ccsens/ht/api/DoctorController.java index ca04f7a7..303c0957 100644 --- a/ht/src/main/java/com/ccsens/ht/api/DoctorController.java +++ b/ht/src/main/java/com/ccsens/ht/api/DoctorController.java @@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import javax.validation.Valid; + /** * @program: ptpro * @description: @@ -39,7 +41,7 @@ public class DoctorController { @ApiImplicitParam(name = "json", value = "医生基本信息", required = true) }) @RequestMapping(value = "/doctorSubmit", method = RequestMethod.POST) - public JsonResponse doctorSubmit(@RequestBody @ApiParam @Validated QueryDto params) { + public JsonResponse doctorSubmit(@RequestBody @ApiParam @Valid QueryDto params) { log.info("资格认证参数:{}", params); DoctorDto.Submit submit = params.getParam(); return doctorService.doctorSubmit(submit, params.getUserId()); @@ -53,7 +55,7 @@ public class DoctorController { @ApiImplicitParam(name = "json", value = "医生查询条件", required = true) }) @RequestMapping(value = "/queryDoctors", method = RequestMethod.POST) - public JsonResponse queryDoctors(@RequestBody @ApiParam @Validated QueryDto params) { + public JsonResponse queryDoctors(@RequestBody @ApiParam @Valid QueryDto params) { log.info("资格认证列表:{}", params); PageInfo dtos = doctorService.queryDoctors(params.getParam(), params.getUserId()); return JsonResponse.newInstance().ok(CodeEnum.SUCCESS, dtos); @@ -66,7 +68,7 @@ public class DoctorController { @ApiImplicitParam(name = "json", value = "医生基本信息", required = true) }) @RequestMapping(value = "/doctorAudit", method = RequestMethod.POST) - public JsonResponse doctorAudit(@RequestBody @ApiParam @Validated QueryDto params) throws Exception { + public JsonResponse doctorAudit(@RequestBody @ApiParam @Valid QueryDto params) throws Exception { log.info("资格审核:{}", params); DoctorDto.Audit audit = params.getParam(); diff --git a/ht/src/main/java/com/ccsens/ht/api/PatientController.java b/ht/src/main/java/com/ccsens/ht/api/PatientController.java index 98b6f3b8..16be6995 100644 --- a/ht/src/main/java/com/ccsens/ht/api/PatientController.java +++ b/ht/src/main/java/com/ccsens/ht/api/PatientController.java @@ -15,12 +15,12 @@ import io.swagger.annotations.*; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import javax.validation.Valid; import java.util.List; /** @@ -51,7 +51,7 @@ public class PatientController { @ApiImplicitParam(name = "json", value = "病友基础信息", required = true) }) @RequestMapping(value="/queryPatient", method = RequestMethod.POST) - public JsonResponse query(@RequestBody @ApiParam @Validated QueryDto params) { + public JsonResponse query(@RequestBody @ApiParam @Valid QueryDto params) { log.info("病友信息查询:{}", params); PatientDto.Query patient = params.getParam(); @@ -75,7 +75,7 @@ public class PatientController { @ApiImplicitParam(name = "json", value = "病友基础信息", required = true) }) @RequestMapping(value="/editPatient", method = RequestMethod.POST) - public JsonResponse edit(@RequestBody @ApiParam @Validated QueryDtoparams) { + public JsonResponse edit(@RequestBody @ApiParam @Valid QueryDtoparams) { log.info("病友信息编辑:{}", params); PatientDto.Edit patient = params.getParam(); if(StringUtils.isEmpty(patient.getMobile()) || StringUtils.isEmpty(patient.getName())) { @@ -113,7 +113,7 @@ public class PatientController { @ApiImplicitParam(name = "json", value = "病友其他信息查询", required = true) }) @RequestMapping(value="/queryPatientOtherMsg", method = RequestMethod.POST) - public JsonResponse queryPatientOtherMsg(@RequestBody @ApiParam @Validated QueryDto params) { + public JsonResponse queryPatientOtherMsg(@RequestBody @ApiParam @Valid QueryDto params) { log.info("查询其他信息请求参数:{}", params); List list = patientService.queryPatientOtherMsg(params.getParam(), params.getUserId()); return JsonResponse.newInstance().ok(list); @@ -126,7 +126,7 @@ public class PatientController { @ApiImplicitParam(name = "json", value = "编辑其他病友信息", required = true) }) @RequestMapping(value="/editPatientOtherMsg", method = RequestMethod.POST) - public JsonResponse editPatientOtherMsg(@RequestBody @ApiParam @Validated QueryDto params) { + public JsonResponse editPatientOtherMsg(@RequestBody @ApiParam @Valid QueryDto params) { log.info("查询其他信息请求参数:{}", params); CodeEnum codeEnum = patientService.editPatientOtherMsg(params.getParam(), params.getUserId()); return JsonResponse.newInstance().ok(codeEnum); diff --git a/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java b/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java index f8cf27a7..24f03c73 100644 --- a/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java +++ b/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java @@ -13,12 +13,13 @@ import com.github.pagehelper.PageInfo; import io.swagger.annotations.*; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import javax.validation.Valid; + /** * @program: ptpro * @description:病人报告单 @@ -40,7 +41,7 @@ public class PatientReportController { @ApiImplicitParam(name = "json", value = "报告单信息", required = true) }) @RequestMapping(value="/generatePatientReport", method = RequestMethod.POST) - public JsonResponse generate(@RequestBody @ApiParam @Validated QueryDto dto){ + public JsonResponse generate(@RequestBody @ApiParam @Valid QueryDto dto){ log.info("生成报告单请求参数:{}", dto); PatientReportDto.Generate patientReport = dto.getParam(); if (patientReport == null || patientReport.getPatientId() == null || patientReport.getPatientId() == 0) { @@ -58,7 +59,7 @@ public class PatientReportController { @ApiImplicitParam(name = "json", value = "编辑报告单信息", required = true) }) @RequestMapping(value="/editPatientReport", method = RequestMethod.POST) - public JsonResponse edit(@RequestBody @ApiParam @Validated QueryDto param){ + public JsonResponse edit(@RequestBody @ApiParam @Valid QueryDto param){ //编辑报告单信息 log.info("编辑报告单:{}", param); @@ -73,7 +74,7 @@ public class PatientReportController { @ApiImplicitParam(name = "json", value = "编辑报告单信息", required = true) }) @RequestMapping(value="/queryReports", method = RequestMethod.POST) - public JsonResponse queryReports(@RequestBody @ApiParam @Validated QueryDto param){ + public JsonResponse queryReports(@RequestBody @ApiParam @Valid QueryDto param){ //编辑报告单信息 log.info("查询报告单列表:{}", param); @@ -87,7 +88,7 @@ public class PatientReportController { @ApiImplicitParam(name = "json", value = "查询报告单详情", required = true) }) @RequestMapping(value="/queryReportDetail", method = RequestMethod.POST) - public JsonResponse queryReportDetail(@RequestBody @ApiParam @Validated QueryDto param){ + public JsonResponse queryReportDetail(@RequestBody @ApiParam @Valid QueryDto param){ //查询报告单信息 log.info("查询报告单详情:{}", param); PatientReportVo.ReprotDetail detail = patientReportService.queryReportDetail(param.getParam(), param.getUserId()); @@ -101,7 +102,7 @@ public class PatientReportController { @ApiImplicitParam(name = "json", value = "报告单ID", required = true) }) @RequestMapping(value="/queryAuthority", method = RequestMethod.POST) - public JsonResponse queryAuthority(@RequestBody @ApiParam @Validated QueryDto param){ + public JsonResponse queryAuthority(@RequestBody @ApiParam @Valid QueryDto param){ //查询报告单信息 log.info("查询医生对报告单的权限:{}", param); PatientReportVo.Authority authority = patientReportService.queryReportAuthority(param.getParam(), param.getUserId()); diff --git a/ht/src/main/java/com/ccsens/ht/api/PositionController.java b/ht/src/main/java/com/ccsens/ht/api/PositionController.java index d36e36c9..ff07f8e4 100644 --- a/ht/src/main/java/com/ccsens/ht/api/PositionController.java +++ b/ht/src/main/java/com/ccsens/ht/api/PositionController.java @@ -9,12 +9,12 @@ import com.ccsens.util.JsonResponse; import io.swagger.annotations.*; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import javax.validation.Valid; import java.util.List; /** @@ -36,7 +36,7 @@ public class PositionController { @ApiImplicitParam(name = "json", value = "医院/部门/职务查询", required = true) }) @RequestMapping(value="/queryPosition", method = RequestMethod.POST) - public JsonResponse queryPosition(@RequestBody @ApiParam @Validated QueryDto params){ + public JsonResponse queryPosition(@RequestBody @ApiParam @Valid QueryDto params){ log.info("查询职务:{}", params); List positions = positionService.queryPosition(params.getParam(), params.getUserId()); return JsonResponse.newInstance().ok(positions); @@ -48,8 +48,8 @@ public class PositionController { @ApiImplicitParam(name = "json", value = "职称查询", required = true) }) @RequestMapping(value="/queryTitle", method = RequestMethod.POST) - public JsonResponse queryTitle(@RequestBody @ApiParam @Validated QueryDto params){ - log.info("查询职称:{}", params); + public JsonResponse queryTitle(){ + log.info("查询职称"); List titles = positionService.queryTitles(); return JsonResponse.newInstance().ok(titles); } diff --git a/ht/src/main/java/com/ccsens/ht/api/QuestionController.java b/ht/src/main/java/com/ccsens/ht/api/QuestionController.java index 3e6d6e58..57bf2902 100644 --- a/ht/src/main/java/com/ccsens/ht/api/QuestionController.java +++ b/ht/src/main/java/com/ccsens/ht/api/QuestionController.java @@ -13,12 +13,12 @@ import com.ccsens.util.NotSupportedFileTypeException; import io.swagger.annotations.*; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import javax.validation.Valid; import java.io.IOException; /** @@ -41,7 +41,7 @@ public class QuestionController { @ApiImplicitParam(name = "json", value = "测评试题查询信息", required = true) }) @RequestMapping(value="/queryQuestion", method = RequestMethod.POST) - public JsonResponse query(@RequestBody @ApiParam @Validated QueryDto queryDto){ + public JsonResponse query(@RequestBody @ApiParam @Valid QueryDto queryDto){ log.info("查询试题:{}", queryDto); QuestionVo.Query query = questionService.queryQuestion(queryDto.getParam(), queryDto.getUserId()); log.info("查询试题结果:{}", query); @@ -55,7 +55,7 @@ public class QuestionController { @ApiImplicitParam(name = "json", value = "试题得分情况", required = true) }) @RequestMapping(value="/saveScore", method = RequestMethod.POST) - public JsonResponse saveScore(@RequestBody @ApiParam @Validated QueryDto queryDto) throws IOException, NotSupportedFileTypeException { + public JsonResponse saveScore(@RequestBody @ApiParam @Valid QueryDto queryDto) throws IOException, NotSupportedFileTypeException { log.info("保存试题得分:{}", queryDto); CodeEnum codeEnum = questionService.saveScore(queryDto.getParam(), queryDto.getUserId()); log.info("保存试题得分结果:{}", codeEnum); diff --git a/ht/src/main/java/com/ccsens/ht/aspect/MustLoginAspect.java b/ht/src/main/java/com/ccsens/ht/aspect/MustLoginAspect.java index f29b13bb..0a997ea7 100644 --- a/ht/src/main/java/com/ccsens/ht/aspect/MustLoginAspect.java +++ b/ht/src/main/java/com/ccsens/ht/aspect/MustLoginAspect.java @@ -29,7 +29,7 @@ import java.util.Arrays; * @author: wuHuiJuan * @create: 2019/12/09 09:54 */ -@Order(1) +@Order(0) @Slf4j @Aspect @Component @@ -48,8 +48,7 @@ public class MustLoginAspect { final String authHeader = request.getHeader(WebConstant.HEADER_KEY_TOKEN); Object[] args = pjp.getArgs(); - QueryDto dto = (QueryDto) args[0]; -// final String authHeader = dto.getToken(); + QueryDto dto = args == null || args.length < 1 ? null : (QueryDto) args[0]; JsonResponse response = tallFeignClient.getUserIdByToken(authHeader); log.info("{}获取userId:{}", authHeader, response); @@ -65,8 +64,10 @@ public class MustLoginAspect { return JsonResponse.newInstance().ok(CodeEnum.NOT_LOGIN); } + if (dto != null) { + dto.setUserId(userId); + } - dto.setUserId(userId); Object result; try { result = pjp.proceed(); diff --git a/ht/src/main/java/com/ccsens/ht/bean/dto/DoctorDto.java b/ht/src/main/java/com/ccsens/ht/bean/dto/DoctorDto.java index 7ec02d40..6f3a6686 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/dto/DoctorDto.java +++ b/ht/src/main/java/com/ccsens/ht/bean/dto/DoctorDto.java @@ -24,10 +24,10 @@ public class DoctorDto { @NotNull private Long positionId; @ApiModelProperty("职称ID") - @NotNull + @NotNull() private Long titleId; @ApiModelProperty("姓名") - @NotNull + @NotNull(message = "姓名不能为空") private String name; @ApiModelProperty("性别(0:男 1:女)") @NotNull diff --git a/ht/src/main/java/com/ccsens/ht/bean/dto/QueryDto.java b/ht/src/main/java/com/ccsens/ht/bean/dto/QueryDto.java index 23431c8c..3412122d 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/dto/QueryDto.java +++ b/ht/src/main/java/com/ccsens/ht/bean/dto/QueryDto.java @@ -3,6 +3,10 @@ package com.ccsens.ht.bean.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; /** * @program: ptpro @@ -14,9 +18,8 @@ import lombok.Data; @Data public class QueryDto { @ApiModelProperty("真正的请求参数") + @Valid private T param; @ApiModelProperty("登录用户ID 前端不为userId赋值") private Long userId; - @ApiModelProperty("token") - private String token; } diff --git a/ht/src/main/java/com/ccsens/ht/service/DoctorService.java b/ht/src/main/java/com/ccsens/ht/service/DoctorService.java index 8b2c012e..56b92b97 100644 --- a/ht/src/main/java/com/ccsens/ht/service/DoctorService.java +++ b/ht/src/main/java/com/ccsens/ht/service/DoctorService.java @@ -21,6 +21,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import org.springframework.validation.annotation.Validated; import java.util.ArrayList; import java.util.Date; @@ -93,7 +94,7 @@ public class DoctorService implements IDoctorService { htDoctor.setUserId(userId); htDoctor.setAuditorId((long)Constant.Ht.NUMBER_DEFAULT); htDoctor.setAuditState(Constant.Ht.Doctor.CHECK_WAIT); - htDoctorMapper.insert(htDoctor); + htDoctorMapper.insertSelective(htDoctor); } diff --git a/ht/src/main/resources/logback-spring.xml b/ht/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..95019edc --- /dev/null +++ b/ht/src/main/resources/logback-spring.xml @@ -0,0 +1,196 @@ + + + + + + + + + + logback + + + + + + + + + + + + + + + + + info + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + + + ${log.path}/log_debug.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + debug + ACCEPT + DENY + + + + + + + ${log.path}/log_info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + info + ACCEPT + DENY + + + + + + + ${log.path}/log_warn.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + warn + ACCEPT + DENY + + + + + + + + ${log.path}/log_error.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tall/src/main/java/com/ccsens/tall/TallApplication.java b/tall/src/main/java/com/ccsens/tall/TallApplication.java index 95e9a564..4115321d 100644 --- a/tall/src/main/java/com/ccsens/tall/TallApplication.java +++ b/tall/src/main/java/com/ccsens/tall/TallApplication.java @@ -6,6 +6,8 @@ import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; +import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.scheduling.annotation.EnableAsync; import java.io.File; @@ -18,6 +20,9 @@ import java.io.File; @MapperScan(basePackages = {"com.ccsens.tall.persist.*"}) @ServletComponentScan @EnableAsync +//开启断路器功能 +@EnableCircuitBreaker +@EnableFeignClients(basePackages = "com.ccsens.cloudutil.feign") @SpringBootApplication(scanBasePackages = "com.ccsens") public class TallApplication implements CommandLineRunner { public static void main(String[] args) { diff --git a/tall/src/main/java/com/ccsens/tall/bean/po/SysLog.java b/tall/src/main/java/com/ccsens/tall/bean/po/SysLog.java new file mode 100644 index 00000000..9f2f1ea5 --- /dev/null +++ b/tall/src/main/java/com/ccsens/tall/bean/po/SysLog.java @@ -0,0 +1,106 @@ +package com.ccsens.tall.bean.po; + +import java.io.Serializable; +import java.util.Date; + +public class SysLog implements Serializable { + private Long id; + + private String url; + + private String methodDesc; + + private String params; + + private String result; + + private Date createdAt; + + private Date updatedAt; + + private Byte recStatus; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url == null ? null : url.trim(); + } + + public String getMethodDesc() { + return methodDesc; + } + + public void setMethodDesc(String methodDesc) { + this.methodDesc = methodDesc == null ? null : methodDesc.trim(); + } + + public String getParams() { + return params; + } + + public void setParams(String params) { + this.params = params == null ? null : params.trim(); + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result == null ? null : result.trim(); + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public Byte getRecStatus() { + return recStatus; + } + + public void setRecStatus(Byte recStatus) { + this.recStatus = recStatus; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", url=").append(url); + sb.append(", methodDesc=").append(methodDesc); + sb.append(", params=").append(params); + sb.append(", result=").append(result); + sb.append(", createdAt=").append(createdAt); + sb.append(", updatedAt=").append(updatedAt); + sb.append(", recStatus=").append(recStatus); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/tall/src/main/java/com/ccsens/tall/bean/po/SysLogExample.java b/tall/src/main/java/com/ccsens/tall/bean/po/SysLogExample.java new file mode 100644 index 00000000..1aae3f62 --- /dev/null +++ b/tall/src/main/java/com/ccsens/tall/bean/po/SysLogExample.java @@ -0,0 +1,721 @@ +package com.ccsens.tall.bean.po; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class SysLogExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public SysLogExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andUrlIsNull() { + addCriterion("url is null"); + return (Criteria) this; + } + + public Criteria andUrlIsNotNull() { + addCriterion("url is not null"); + return (Criteria) this; + } + + public Criteria andUrlEqualTo(String value) { + addCriterion("url =", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlNotEqualTo(String value) { + addCriterion("url <>", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlGreaterThan(String value) { + addCriterion("url >", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlGreaterThanOrEqualTo(String value) { + addCriterion("url >=", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlLessThan(String value) { + addCriterion("url <", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlLessThanOrEqualTo(String value) { + addCriterion("url <=", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlLike(String value) { + addCriterion("url like", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlNotLike(String value) { + addCriterion("url not like", value, "url"); + return (Criteria) this; + } + + public Criteria andUrlIn(List values) { + addCriterion("url in", values, "url"); + return (Criteria) this; + } + + public Criteria andUrlNotIn(List values) { + addCriterion("url not in", values, "url"); + return (Criteria) this; + } + + public Criteria andUrlBetween(String value1, String value2) { + addCriterion("url between", value1, value2, "url"); + return (Criteria) this; + } + + public Criteria andUrlNotBetween(String value1, String value2) { + addCriterion("url not between", value1, value2, "url"); + return (Criteria) this; + } + + public Criteria andMethodDescIsNull() { + addCriterion("method_desc is null"); + return (Criteria) this; + } + + public Criteria andMethodDescIsNotNull() { + addCriterion("method_desc is not null"); + return (Criteria) this; + } + + public Criteria andMethodDescEqualTo(String value) { + addCriterion("method_desc =", value, "methodDesc"); + return (Criteria) this; + } + + public Criteria andMethodDescNotEqualTo(String value) { + addCriterion("method_desc <>", value, "methodDesc"); + return (Criteria) this; + } + + public Criteria andMethodDescGreaterThan(String value) { + addCriterion("method_desc >", value, "methodDesc"); + return (Criteria) this; + } + + public Criteria andMethodDescGreaterThanOrEqualTo(String value) { + addCriterion("method_desc >=", value, "methodDesc"); + return (Criteria) this; + } + + public Criteria andMethodDescLessThan(String value) { + addCriterion("method_desc <", value, "methodDesc"); + return (Criteria) this; + } + + public Criteria andMethodDescLessThanOrEqualTo(String value) { + addCriterion("method_desc <=", value, "methodDesc"); + return (Criteria) this; + } + + public Criteria andMethodDescLike(String value) { + addCriterion("method_desc like", value, "methodDesc"); + return (Criteria) this; + } + + public Criteria andMethodDescNotLike(String value) { + addCriterion("method_desc not like", value, "methodDesc"); + return (Criteria) this; + } + + public Criteria andMethodDescIn(List values) { + addCriterion("method_desc in", values, "methodDesc"); + return (Criteria) this; + } + + public Criteria andMethodDescNotIn(List values) { + addCriterion("method_desc not in", values, "methodDesc"); + return (Criteria) this; + } + + public Criteria andMethodDescBetween(String value1, String value2) { + addCriterion("method_desc between", value1, value2, "methodDesc"); + return (Criteria) this; + } + + public Criteria andMethodDescNotBetween(String value1, String value2) { + addCriterion("method_desc not between", value1, value2, "methodDesc"); + return (Criteria) this; + } + + public Criteria andParamsIsNull() { + addCriterion("params is null"); + return (Criteria) this; + } + + public Criteria andParamsIsNotNull() { + addCriterion("params is not null"); + return (Criteria) this; + } + + public Criteria andParamsEqualTo(String value) { + addCriterion("params =", value, "params"); + return (Criteria) this; + } + + public Criteria andParamsNotEqualTo(String value) { + addCriterion("params <>", value, "params"); + return (Criteria) this; + } + + public Criteria andParamsGreaterThan(String value) { + addCriterion("params >", value, "params"); + return (Criteria) this; + } + + public Criteria andParamsGreaterThanOrEqualTo(String value) { + addCriterion("params >=", value, "params"); + return (Criteria) this; + } + + public Criteria andParamsLessThan(String value) { + addCriterion("params <", value, "params"); + return (Criteria) this; + } + + public Criteria andParamsLessThanOrEqualTo(String value) { + addCriterion("params <=", value, "params"); + return (Criteria) this; + } + + public Criteria andParamsLike(String value) { + addCriterion("params like", value, "params"); + return (Criteria) this; + } + + public Criteria andParamsNotLike(String value) { + addCriterion("params not like", value, "params"); + return (Criteria) this; + } + + public Criteria andParamsIn(List values) { + addCriterion("params in", values, "params"); + return (Criteria) this; + } + + public Criteria andParamsNotIn(List values) { + addCriterion("params not in", values, "params"); + return (Criteria) this; + } + + public Criteria andParamsBetween(String value1, String value2) { + addCriterion("params between", value1, value2, "params"); + return (Criteria) this; + } + + public Criteria andParamsNotBetween(String value1, String value2) { + addCriterion("params not between", value1, value2, "params"); + return (Criteria) this; + } + + public Criteria andResultIsNull() { + addCriterion("result is null"); + return (Criteria) this; + } + + public Criteria andResultIsNotNull() { + addCriterion("result is not null"); + return (Criteria) this; + } + + public Criteria andResultEqualTo(String value) { + addCriterion("result =", value, "result"); + return (Criteria) this; + } + + public Criteria andResultNotEqualTo(String value) { + addCriterion("result <>", value, "result"); + return (Criteria) this; + } + + public Criteria andResultGreaterThan(String value) { + addCriterion("result >", value, "result"); + return (Criteria) this; + } + + public Criteria andResultGreaterThanOrEqualTo(String value) { + addCriterion("result >=", value, "result"); + return (Criteria) this; + } + + public Criteria andResultLessThan(String value) { + addCriterion("result <", value, "result"); + return (Criteria) this; + } + + public Criteria andResultLessThanOrEqualTo(String value) { + addCriterion("result <=", value, "result"); + return (Criteria) this; + } + + public Criteria andResultLike(String value) { + addCriterion("result like", value, "result"); + return (Criteria) this; + } + + public Criteria andResultNotLike(String value) { + addCriterion("result not like", value, "result"); + return (Criteria) this; + } + + public Criteria andResultIn(List values) { + addCriterion("result in", values, "result"); + return (Criteria) this; + } + + public Criteria andResultNotIn(List values) { + addCriterion("result not in", values, "result"); + return (Criteria) this; + } + + public Criteria andResultBetween(String value1, String value2) { + addCriterion("result between", value1, value2, "result"); + return (Criteria) this; + } + + public Criteria andResultNotBetween(String value1, String value2) { + addCriterion("result not between", value1, value2, "result"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNull() { + addCriterion("created_at is null"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNotNull() { + addCriterion("created_at is not null"); + return (Criteria) this; + } + + public Criteria andCreatedAtEqualTo(Date value) { + addCriterion("created_at =", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotEqualTo(Date value) { + addCriterion("created_at <>", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThan(Date value) { + addCriterion("created_at >", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThanOrEqualTo(Date value) { + addCriterion("created_at >=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThan(Date value) { + addCriterion("created_at <", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThanOrEqualTo(Date value) { + addCriterion("created_at <=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtIn(List values) { + addCriterion("created_at in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotIn(List values) { + addCriterion("created_at not in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtBetween(Date value1, Date value2) { + addCriterion("created_at between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotBetween(Date value1, Date value2) { + addCriterion("created_at not between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNull() { + addCriterion("updated_at is null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNotNull() { + addCriterion("updated_at is not null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtEqualTo(Date value) { + addCriterion("updated_at =", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotEqualTo(Date value) { + addCriterion("updated_at <>", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThan(Date value) { + addCriterion("updated_at >", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThanOrEqualTo(Date value) { + addCriterion("updated_at >=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThan(Date value) { + addCriterion("updated_at <", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThanOrEqualTo(Date value) { + addCriterion("updated_at <=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIn(List values) { + addCriterion("updated_at in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotIn(List values) { + addCriterion("updated_at not in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtBetween(Date value1, Date value2) { + addCriterion("updated_at between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotBetween(Date value1, Date value2) { + addCriterion("updated_at not between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andRecStatusIsNull() { + addCriterion("rec_status is null"); + return (Criteria) this; + } + + public Criteria andRecStatusIsNotNull() { + addCriterion("rec_status is not null"); + return (Criteria) this; + } + + public Criteria andRecStatusEqualTo(Byte value) { + addCriterion("rec_status =", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotEqualTo(Byte value) { + addCriterion("rec_status <>", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusGreaterThan(Byte value) { + addCriterion("rec_status >", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusGreaterThanOrEqualTo(Byte value) { + addCriterion("rec_status >=", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusLessThan(Byte value) { + addCriterion("rec_status <", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusLessThanOrEqualTo(Byte value) { + addCriterion("rec_status <=", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusIn(List values) { + addCriterion("rec_status in", values, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotIn(List values) { + addCriterion("rec_status not in", values, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusBetween(Byte value1, Byte value2) { + addCriterion("rec_status between", value1, value2, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotBetween(Byte value1, Byte value2) { + addCriterion("rec_status not between", value1, value2, "recStatus"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/tall/src/main/java/com/ccsens/tall/persist/mapper/SysLogMapper.java b/tall/src/main/java/com/ccsens/tall/persist/mapper/SysLogMapper.java new file mode 100644 index 00000000..5152631e --- /dev/null +++ b/tall/src/main/java/com/ccsens/tall/persist/mapper/SysLogMapper.java @@ -0,0 +1,30 @@ +package com.ccsens.tall.persist.mapper; + +import com.ccsens.tall.bean.po.SysLog; +import com.ccsens.tall.bean.po.SysLogExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface SysLogMapper { + long countByExample(SysLogExample example); + + int deleteByExample(SysLogExample example); + + int deleteByPrimaryKey(Long id); + + int insert(SysLog record); + + int insertSelective(SysLog record); + + List selectByExample(SysLogExample example); + + SysLog selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") SysLog record, @Param("example") SysLogExample example); + + int updateByExample(@Param("record") SysLog record, @Param("example") SysLogExample example); + + int updateByPrimaryKeySelective(SysLog record); + + int updateByPrimaryKey(SysLog record); +} \ No newline at end of file diff --git a/tall/src/main/java/com/ccsens/tall/web/LogController.java b/tall/src/main/java/com/ccsens/tall/web/LogController.java new file mode 100644 index 00000000..873bffd6 --- /dev/null +++ b/tall/src/main/java/com/ccsens/tall/web/LogController.java @@ -0,0 +1,44 @@ +package com.ccsens.tall.web; + +import cn.hutool.core.lang.Snowflake; +import com.ccsens.cloudutil.bean.tall.dto.LogDto; +import com.ccsens.tall.bean.po.SysLog; +import com.ccsens.tall.persist.mapper.SysLogMapper; +import com.ccsens.util.CodeEnum; +import com.ccsens.util.JsonResponse; +import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/09 18:04 + */ +@Slf4j +@Api(tags = "接口调用日志" ) +@RestController +public class LogController { + + @Autowired + private SysLogMapper sysLogMapper; + @Autowired + private Snowflake snowflake; + + @RequestMapping("/log/operation") + public JsonResponse log(@RequestBody LogDto logDto) { + + SysLog log = new SysLog(); + BeanUtils.copyProperties(logDto, log); + log.setId(snowflake.nextId()); + sysLogMapper.insertSelective(log); + + + return JsonResponse.newInstance().ok(); + } + +} diff --git a/tall/src/main/resources/logback-spring.xml b/tall/src/main/resources/logback-spring.xml index 24a4ffa0..12977b28 100644 --- a/tall/src/main/resources/logback-spring.xml +++ b/tall/src/main/resources/logback-spring.xml @@ -9,7 +9,7 @@ logback - + diff --git a/tall/src/main/resources/mapper_raw/SysLogMapper.xml b/tall/src/main/resources/mapper_raw/SysLogMapper.xml new file mode 100644 index 00000000..a101e01f --- /dev/null +++ b/tall/src/main/resources/mapper_raw/SysLogMapper.xml @@ -0,0 +1,258 @@ + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, url, method_desc, params, result, created_at, updated_at, rec_status + + + + + delete from t_sys_log + where id = #{id,jdbcType=BIGINT} + + + delete from t_sys_log + + + + + + insert into t_sys_log (id, url, method_desc, + params, result, created_at, + updated_at, rec_status) + values (#{id,jdbcType=BIGINT}, #{url,jdbcType=VARCHAR}, #{methodDesc,jdbcType=VARCHAR}, + #{params,jdbcType=VARCHAR}, #{result,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, + #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT}) + + + insert into t_sys_log + + + id, + + + url, + + + method_desc, + + + params, + + + result, + + + created_at, + + + updated_at, + + + rec_status, + + + + + #{id,jdbcType=BIGINT}, + + + #{url,jdbcType=VARCHAR}, + + + #{methodDesc,jdbcType=VARCHAR}, + + + #{params,jdbcType=VARCHAR}, + + + #{result,jdbcType=VARCHAR}, + + + #{createdAt,jdbcType=TIMESTAMP}, + + + #{updatedAt,jdbcType=TIMESTAMP}, + + + #{recStatus,jdbcType=TINYINT}, + + + + + + update t_sys_log + + + id = #{record.id,jdbcType=BIGINT}, + + + url = #{record.url,jdbcType=VARCHAR}, + + + method_desc = #{record.methodDesc,jdbcType=VARCHAR}, + + + params = #{record.params,jdbcType=VARCHAR}, + + + result = #{record.result,jdbcType=VARCHAR}, + + + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, + + + updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, + + + rec_status = #{record.recStatus,jdbcType=TINYINT}, + + + + + + + + update t_sys_log + set id = #{record.id,jdbcType=BIGINT}, + url = #{record.url,jdbcType=VARCHAR}, + method_desc = #{record.methodDesc,jdbcType=VARCHAR}, + params = #{record.params,jdbcType=VARCHAR}, + result = #{record.result,jdbcType=VARCHAR}, + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, + updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, + rec_status = #{record.recStatus,jdbcType=TINYINT} + + + + + + update t_sys_log + + + url = #{url,jdbcType=VARCHAR}, + + + method_desc = #{methodDesc,jdbcType=VARCHAR}, + + + params = #{params,jdbcType=VARCHAR}, + + + result = #{result,jdbcType=VARCHAR}, + + + created_at = #{createdAt,jdbcType=TIMESTAMP}, + + + updated_at = #{updatedAt,jdbcType=TIMESTAMP}, + + + rec_status = #{recStatus,jdbcType=TINYINT}, + + + where id = #{id,jdbcType=BIGINT} + + + update t_sys_log + set url = #{url,jdbcType=VARCHAR}, + method_desc = #{methodDesc,jdbcType=VARCHAR}, + params = #{params,jdbcType=VARCHAR}, + result = #{result,jdbcType=VARCHAR}, + created_at = #{createdAt,jdbcType=TIMESTAMP}, + updated_at = #{updatedAt,jdbcType=TIMESTAMP}, + rec_status = #{recStatus,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/util/src/test/java/com/ccsens/util/ZipTest.java b/util/src/test/java/com/ccsens/util/ZipTest.java new file mode 100644 index 00000000..123330a0 --- /dev/null +++ b/util/src/test/java/com/ccsens/util/ZipTest.java @@ -0,0 +1,28 @@ +package com.ccsens.util; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.util.ZipUtil; +import org.junit.Test; + +import java.io.UnsupportedEncodingException; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/10 15:44 + */ +public class ZipTest { + @Test + public void gzip() throws UnsupportedEncodingException { + String content = "QueryDto(param=DoctorDto.Submit(positionId=1204239831257976832, titleId=1204239838740615168, name=李院长, sex=0, age=38), userId=1202064120040525824, token=null)--"; + System.out.println("content长度" + content.length()); + byte[] gzip = ZipUtil.gzip(content, "UTF-8"); + String encode = Base64.encode(gzip); + System.out.println("encode长度:" + encode.length()); + String zipContent = new String(gzip); + System.out.println(zipContent); + byte[] bytes = ZipUtil.unGzip(Base64.decode(encode)); + System.out.println("ungzip:" + new String(bytes, "UTF-8") ); + System.out.println("length:" + new String(bytes, "UTF-8").length()); + } +}