Skip to content

Instantly share code, notes, and snippets.

@weiwosuoai
Created December 23, 2017 08:19
Show Gist options
  • Save weiwosuoai/e1128990a01cbb937d2faa7f269b2fee to your computer and use it in GitHub Desktop.
Save weiwosuoai/e1128990a01cbb937d2faa7f269b2fee to your computer and use it in GitHub Desktop.
spring boot exception
target/
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.exception</groupId>
<artifactId>question-ms</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>question-ms</name>
<description>问答ms</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<commons.lang.version>2.2</commons.lang.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-typehandlers-jsr310</artifactId>
<version>1.0.2</version>
</dependency>
<!-- mysql 开始 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- aspectjweaver 依赖 开始 -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
<!--lombok 可以简化臃肿的java代码,不要写getter和setter方法。需要安装Lombok plugin。。-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!--lombok-->
<!--guava非常好用的工具类-->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<!--druid 开始-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.19</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons.lang.version}</version>
</dependency>
<!-- dozer 开始-->
<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>5.4.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.31</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.11" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.11" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.25" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:log4j-over-slf4j:1.7.25" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.17" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:8.5.23" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-annotations-api:8.5.23" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:8.5.23" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-validator:5.3.6.Final" level="project" />
<orderEntry type="library" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.1.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.10" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.10" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.13.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:2.6.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:1.10.19" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:8.5.23" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-jdbc:8.5.23" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-juli:8.5.23" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:1.3.0" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.4.4" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:1.3.1" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis-typehandlers-jsr310:1.0.2" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.44" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.13" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.18" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:druid:1.0.19" level="project" />
<orderEntry type="module-library">
<library name="Maven: com.alibaba:jconsole:1.8.0">
<CLASSES>
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/lib/jconsole.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="Maven: com.alibaba:tools:1.8.0">
<CLASSES>
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/lib/tools.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.2" level="project" />
<orderEntry type="library" name="Maven: net.sf.dozer:dozer:5.4.0" level="project" />
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.3" level="project" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.25" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.31" level="project" />
</component>
</module>
package com.exception.question;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
@SpringBootApplication
@MapperScan("com.exception.question.domain.mapper")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
// public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
// /**
// * 序列化反序列化,更改json序列化和反序列化的方式,统一使用jackson
// *
// * @return
// */
// @Bean
// public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
// MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
// jsonConverter.setObjectMapper(OBJECT_MAPPER);
// return jsonConverter;
// }
/**
* validator
* requestParam注解的参数校验需要加上MethodValidationPostProcessor bean
*
* @return
*/
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
return new MethodValidationPostProcessor();
}
}
package com.exception.question.aspect;
import java.lang.annotation.*;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:19
* @discription
**/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@Documented
public @interface OperatorLog {
/**
* 日志方法描述
*
* @return
*/
String description() default "";
}
package com.exception.question.aspect;
import com.alibaba.druid.support.json.JSONUtils;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
import java.lang.reflect.Method;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:19
* @discription
**/
@Aspect
@Component
@Slf4j
public class OperatorLogAspect {
@Pointcut("@annotation(com.exception.question.aspect.OperatorLog)")
public void operatorLog() {
}
@Before("operatorLog()")
public void doBefore(JoinPoint joinPoint) {
try {
String description = getSystemLogDescription(joinPoint);
log.info("============<执行开始>======== " + description + "请求参数" + getSystemParam(joinPoint) + "===========================");
} catch (Exception e) {
log.error("doBefore error {}", e);
}
}
private String getSystemParam(JoinPoint joinPoint) {
return JSON.toJSONString(joinPoint.getArgs());
}
@Around("operatorLog()")
public Object doSurround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
Object[] objects = proceedingJoinPoint.getArgs();
String name = proceedingJoinPoint.getSignature().getName();
long startTime = System.currentTimeMillis();
Object result = proceedingJoinPoint.proceed();
log.warn("当前类:{}, 方法名:{}", proceedingJoinPoint.getTarget().getClass().getName(), name);
if (objects != null) {
for (int i = 0; i < objects.length; i++) {
if (null != objects[i]) {
log.warn("第" + (i + 1) + "个方法入参数{}: <{}>", objects[i].getClass().getName(), JSON.toJSONString(objects[i]));
}
}
}
log.warn("出参: <{}>", JSON.toJSONString(result));
log.warn(name + "方法的执行时间为: {}", System.currentTimeMillis() - startTime + "毫秒");
return result;
}
@After(value = "operatorLog()")
public void doAfter(JoinPoint joinPoint) {
try {
log.info("=======操作调用" + getSystemLogDescription(joinPoint) + "===<执行完成>================");
} catch (Exception e) {
log.error("doAfter error {}", e);
}
}
/**
* @param joinPoint 切点
* @return 方法描述
* @throws Exception
*/
public static String getSystemLogDescription(JoinPoint joinPoint)
throws Exception {
String targetName = joinPoint.getTarget().getClass().getName();
String methodName = joinPoint.getSignature().getName();
Object[] arguments = joinPoint.getArgs();
Class targetClass = Class.forName(targetName);
Method[] methods = targetClass.getMethods();
StringBuilder description = new StringBuilder("");
for (Method method : methods) {
if (method.getName().equals(methodName)) {
Class[] clazzs = method.getParameterTypes();
if (clazzs.length == arguments.length) {
description.append(method.getAnnotation(OperatorLog.class).description());
break;
}
}
}
return description.toString();
}
}
package com.exception.question.business;
import com.exception.question.common.BaseResponse;
import com.exception.question.common.PageQueryRequest;
import com.exception.question.common.PageQueryResponse;
import com.exception.question.dto.response.home.HomeQuestionPageQueryResponseDTO;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:19
* @discription
**/
public interface HomeBusiness {
/**
* 展示首页问题列表
* @return
*/
PageQueryResponse<HomeQuestionPageQueryResponseDTO> page(PageQueryRequest pageQueryRequest);
}
package com.exception.question.business.impl;
import com.exception.question.business.HomeBusiness;
import com.exception.question.common.BaseResponse;
import com.exception.question.common.PageQueryRequest;
import com.exception.question.common.PageQueryResponse;
import com.exception.question.dto.response.home.HomeQuestionPageQueryResponseDTO;
import com.exception.question.service.HomeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 首页
* @author jiangbing(江冰)
* @date 2017/12/20
* @time 下午3:44
* @discription
**/
@Service
@Slf4j
public class HomeBusinessImpl implements HomeBusiness {
@Autowired
private HomeService homeService;
@Override
public PageQueryResponse<HomeQuestionPageQueryResponseDTO> page(PageQueryRequest pageQueryRequest) {
int totalCount = homeService.pageCount();
if (totalCount > 0) {
}
return new PageQueryResponse().successPage(null,
pageQueryRequest.getPageIndex(),
totalCount,
pageQueryRequest.getPageSize());
}
}
package com.exception.question.common;
import com.alibaba.fastjson.JSON;
import com.exception.question.enums.QuestionResponseCodeEnum;
import com.exception.question.exception.BaseException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintViolationException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Optional;
/**
* baseController
* 封装统一的异常处理
*
* @author jiangbing(江冰)
* @date 2017/12/20
* @time 下午4:25
* @discription
**/
@Slf4j
public class BaseController {
@ExceptionHandler(Exception.class)
@ResponseBody
BaseResponse<Object> handleControllerException(HttpServletRequest request, Throwable ex) {
BaseResponse<Object> baseResponse = new BaseResponse<>();
String errorCode = null;
String message = null;
if (ex instanceof BaseException) {
BaseException bex = (BaseException) ex;
//错误码
errorCode = bex.getErrorCode();
//错误信息
message = bex.getMessage();
log.error("{} request error,errorCode, , {},errorCode {} ,errorMessage {}", request.getRequestURI(), JSON.toJSONString(baseResponse), errorCode, message);
} else if (ex instanceof BindException) {
errorCode = QuestionResponseCodeEnum.PARAM_ERROR.getErrorCode();
BindingResult result = ((BindException) ex).getBindingResult();
StringBuilder stringBuilder = new StringBuilder();
Optional.ofNullable(result.getFieldErrors()).orElse(new ArrayList<>())
.stream().forEach(f -> {
stringBuilder.append(f.getField())
.append(" ")
.append(f.getDefaultMessage())
.append(", 当前值: '")
.append(f.getRejectedValue())
.append("'; ");
});
message = stringBuilder.toString();
log.error("{} request error , {}", request.getRequestURI(), message);
} else if (ex instanceof MethodArgumentNotValidException) {
//BindException and MethodArgumentNotValidException implements BindingResult
errorCode = QuestionResponseCodeEnum.PARAM_ERROR.getErrorCode();
BindingResult result = ((MethodArgumentNotValidException) ex).getBindingResult();
StringBuilder stringBuilder = new StringBuilder();
Optional.ofNullable(result.getFieldErrors()).orElse(new ArrayList<>())
.stream().forEach(f -> {
stringBuilder.append(f.getField())
.append(" ")
.append(f.getDefaultMessage())
.append(", 当前值: '")
.append(f.getRejectedValue())
.append("'; ");
});
message = stringBuilder.toString();
log.error("{} request error , {}", request.getRequestURI(), message);
} else if (ex instanceof ConstraintViolationException) {
errorCode = QuestionResponseCodeEnum.PARAM_ERROR.getErrorCode();
ConstraintViolationException cex = (ConstraintViolationException) ex;
StringBuilder stringBuilder = new StringBuilder();
Optional.ofNullable(cex.getConstraintViolations()).orElse(new HashSet<>()).stream()
.forEach(v -> {
String invald = v.getInvalidValue() != null ? v.getInvalidValue().toString() : "null";
stringBuilder
.append(v.getPropertyPath())
.append(" ")
.append(v.getMessage())
.append(", 当前值: '")
.append(invald.length() < 50 ? invald : invald.substring(0, 47) + "...")
.append("'; ");
});
message = stringBuilder.toString();
log.error("{} request error , {}", request.getRequestURI(), message);
} else {
errorCode = QuestionResponseCodeEnum.SYSTEM_ERROR.getErrorCode();
message = QuestionResponseCodeEnum.SYSTEM_ERROR.getErrorMessage();
log.error(request.getRequestURI() + " request error , ", ex);
}
baseResponse.setErrorCode(errorCode);
baseResponse.setErrorMessage(message);
baseResponse.setSuccess(false);
return baseResponse;
}
}
package com.exception.question.common;
import lombok.Data;
import javax.validation.Valid;
import java.io.Serializable;
/**
* @author jiangbing(江冰)
* @date 2017/12/20
* @time 下午4:25
* @discription
**/
@Data
public class BaseRequest<T> implements Serializable {
@Valid
protected T data;
}
package com.exception.question.common;
import java.io.Serializable;
import com.exception.question.exception.BaseException;
import lombok.Data;
/**
* 服务响应 response
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午8:45
* @discription
**/
@Data
public class BaseResponse<T> implements Serializable {
private boolean success = false;
private String errorCode;
private String errorMessage;
private T data;
public BaseResponse<T> fail(BaseException baseException) {
this.setSuccess(false);
this.setErrorCode(baseException.getErrorCode());
this.setErrorMessage(baseException.getMessage());
return this;
}
public BaseResponse<T> success(T data) {
this.setSuccess(true);
this.setData(data);
return this;
}
public BaseResponse<T> success() {
this.setSuccess(true);
return this;
}
}
package com.exception.question.common;
import lombok.Data;
/**
* @author jiangbing(江冰)
* @date 2017/12/20
* @time 下午3:56
* @discription
**/
@Data
public class PageQueryRequest<T> extends BaseRequest<T> {
private int pageIndex = 1;
private int pageSize = 20;
private int totalCount;
private int start;
public int getPageIndex() {
return this.pageIndex <= 0 ? 1 : this.pageIndex;
}
public void setPageIndex(int pageIndex) {
this.pageIndex = pageIndex <= 0 ? 1 : pageIndex;
}
public int getPageSize() {
return this.pageSize > 0 && this.pageSize <= 500 ? this.pageSize : 20;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize <= 0 ? 20 : pageSize;
}
public int getStartPos() {
return (this.getPageIndex() - 1) * this.getPageSize();
}
public int getStart() {
return this.start;
}
public void setStart(int start) {
this.start = start;
}
}
package com.exception.question.common;
import lombok.Data;
import java.util.List;
/**
* 分页查询 response
* @author jiangbing(江冰)
* @date 2017/12/21
* @time 下午8:18
* @discription
**/
@Data
public class PageQueryResponse<T> extends BaseResponse<List<T>> {
private int pageIndex;
private int totalCount;
private int pageSize;
public PageQueryResponse<T> successPage(List<T> data, int pageIndex, int totalCount, int pageSize) {
this.setSuccess(true);
this.setData(data);
this.setPageIndex(pageIndex);
this.setTotalCount(totalCount);
this.setPageSize(pageSize);
return this;
}
public int getCurrentPage() {
return this.pageIndex < 1 ? 1 : this.pageIndex;
}
public boolean hasNext() {
int useCount = (this.getCurrentPage() - 1) * this.getPageSize() + this.getSize();
return this.totalCount > useCount;
}
public int getTotalPage() {
return this.pageSize == 0 ? 0 : (this.totalCount - 1) / this.pageSize + 1;
}
private int getSize() {
List<T> page = (List) this.getData();
return page == null ? 0 : page.size();
}
}
package com.exception.question.controller;
import com.exception.question.aspect.OperatorLog;
import com.exception.question.business.HomeBusiness;
import com.exception.question.common.BaseController;
import com.exception.question.common.BaseResponse;
import com.exception.question.common.PageQueryRequest;
import com.exception.question.common.PageQueryResponse;
import com.exception.question.dto.response.home.HomeQuestionPageQueryResponseDTO;
import com.exception.question.enums.QuestionResponseCodeEnum;
import com.exception.question.exception.BaseException;
import com.exception.question.exception.QMSException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:19
* @discription
**/
@RestController
@RequestMapping("/home")
public class HomeController extends BaseController {
@Autowired
private HomeBusiness homeBusiness;
/**
* 首页问题列表分页
* @param pageQueryRequest
* @return
*/
@GetMapping("/page")
@OperatorLog(description = "开始调用home")
public PageQueryResponse<HomeQuestionPageQueryResponseDTO> home(PageQueryRequest pageQueryRequest) {
return homeBusiness.page(pageQueryRequest);
}
}
package com.exception.question.domain.entity;
import lombok.Data;
import java.util.Date;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:19
* @discription
**/
@Data
public class Answer {
private Long id;
private Date createTime;
private Date updateTime;
private Long createUserId;
private Long questionId;
private Integer voteUp;
private Integer voteDown;
private Byte language;
private Long originalId;
private Boolean isAccepted;
private Integer voteCount;
}
package com.exception.question.domain.entity;
import lombok.Data;
import java.util.Date;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:19
* @discription
**/
@Data
public class AnswerDesc {
private Long id;
private Long answerId;
private Date createTime;
private Date updateTime;
private Long createUserId;
}
package com.exception.question.domain.entity;
import lombok.Data;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:19
* @discription
**/
@Data
public class AnswerDescWithBLOBs extends AnswerDesc {
private String description;
private String descriptionCn;
}
package com.exception.question.domain.entity;
import lombok.Data;
import java.util.Date;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:19
* @discription
**/
@Data
public class Question {
private Long id;
private String title;
private Date createTime;
private Date updateTime;
private Long createUserId;
private Integer voteUp;
private Integer voteDown;
private Byte language;
private String titleCn;
private Integer originalId;
private String originalLink;
private Integer viewNum;
private Boolean isTitleTransFinished;
private Boolean isAnswerTransFinished;
private Byte status;
}
package com.exception.question.domain.entity;
import lombok.Data;
import java.util.Date;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:19
* @discription
**/
@Data
public class QuestionDesc {
private Long id;
private Long questionId;
private Date createTime;
private Date updateTime;
private Long createUserId;
}
package com.exception.question.domain.entity;
import lombok.Data;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:19
* @discription
**/
@Data
public class QuestionDescWithBLOBs extends QuestionDesc {
private String description;
private String descriptionCh;
}
package com.exception.question.domain.entity;
import lombok.Data;
import java.util.Date;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:19
* @discription
**/
@Data
public class QuestionTagRel {
private Long id;
private Long questionId;
private Long tagId;
private Date createTime;
private Date updateTime;
}
package com.exception.question.domain.entity;
import lombok.Data;
import java.util.Date;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:19
* @discription
**/
@Data
public class Tag {
private Long id;
private String name;
private Date createTime;
private Date updateTime;
private Integer createUserId;
private Integer spiderPageNum;
}
package com.exception.question.domain.entity;
import lombok.Data;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:19
* @discription
**/
@Data
public class TagWithBLOBs extends Tag {
private String description;
private String descriptionCh;
}
package com.exception.question.domain.entity;
import lombok.Data;
import java.util.Date;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:19
* @discription
**/
@Data
public class User {
private Long id;
private String username;
private String password;
private String email;
private String phone;
private Date createTime;
private Date updateTime;
}
package com.exception.question.domain.mapper;
import com.exception.question.domain.entity.AnswerDesc;
import com.exception.question.domain.entity.AnswerDescWithBLOBs;
public interface AnswerDescMapper {
int deleteByPrimaryKey(Long id);
int insert(AnswerDescWithBLOBs record);
int insertSelective(AnswerDescWithBLOBs record);
AnswerDescWithBLOBs selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(AnswerDescWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(AnswerDescWithBLOBs record);
int updateByPrimaryKey(AnswerDesc record);
}
package com.exception.question.domain.mapper;
import com.exception.question.domain.entity.Answer;
public interface AnswerMapper {
int deleteByPrimaryKey(Long id);
int insert(Answer record);
int insertSelective(Answer record);
Answer selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(Answer record);
int updateByPrimaryKey(Answer record);
}
package com.exception.question.domain.mapper;
import com.exception.question.domain.entity.QuestionDesc;
import com.exception.question.domain.entity.QuestionDescWithBLOBs;
public interface QuestionDescMapper {
int deleteByPrimaryKey(Long id);
int insert(QuestionDescWithBLOBs record);
int insertSelective(QuestionDescWithBLOBs record);
QuestionDescWithBLOBs selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(QuestionDescWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(QuestionDescWithBLOBs record);
int updateByPrimaryKey(QuestionDesc record);
}
package com.exception.question.domain.mapper;
import com.exception.question.domain.entity.Question;
import java.util.List;
public interface QuestionMapper {
int deleteByPrimaryKey(Long id);
int insert(Question record);
int insertSelective(Question record);
Question selectByPrimaryKey(Long id);
List<Question> selectPageSelective();
int selectPageCountSelective();
int updateByPrimaryKeySelective(Question record);
int updateByPrimaryKey(Question record);
}
package com.exception.question.domain.mapper;
import com.exception.question.domain.entity.QuestionTagRel;
public interface QuestionTagRelMapper {
int deleteByPrimaryKey(Long id);
int insert(QuestionTagRel record);
int insertSelective(QuestionTagRel record);
QuestionTagRel selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(QuestionTagRel record);
int updateByPrimaryKey(QuestionTagRel record);
}
package com.exception.question.domain.mapper;
import com.exception.question.domain.entity.Tag;
import com.exception.question.domain.entity.TagWithBLOBs;
public interface TagMapper {
int deleteByPrimaryKey(Long id);
int insert(TagWithBLOBs record);
int insertSelective(TagWithBLOBs record);
TagWithBLOBs selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(TagWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(TagWithBLOBs record);
int updateByPrimaryKey(Tag record);
}
package com.exception.question.domain.mapper;
import com.exception.question.domain.entity.User;
public interface UserMapper {
int deleteByPrimaryKey(Long id);
int insert(User record);
int insertSelective(User record);
User selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(User record);
int updateByPrimaryKey(User record);
}
package com.exception.question.dto.request.home;
import lombok.Data;
import java.io.Serializable;
/**
* @author jiangbing(江冰)
* @date 2017/12/22
* @time 下午4:52
* @discription
**/
@Data
public class HomeQestionPageQueryRequestDTO implements Serializable {
}
package com.exception.question.dto.response.home;
import lombok.Data;
import java.io.Serializable;
/**
* @author jiangbing(江冰)
* @date 2017/12/22
* @time 下午4:54
* @discription
**/
@Data
public class HomeQuestionPageQueryResponseDTO implements Serializable {
}
package com.exception.question.enums;
import lombok.Getter;
/**
* qms 响应 code 枚举
* @author jiangbing(江冰)
* @date 2017/12/22
* @time 下午12:56
* @discription
**/
@Getter
public enum QuestionResponseCodeEnum {
SUCCESS("QMS000000", "成功"),
SYSTEM_ERROR("QMS100000", "出错啦,后台小哥在努力解决bug中..."),
PARAM_ERROR("QMS100001", "参数错误"),
;
private final String errorCode;
private final String errorMessage;
QuestionResponseCodeEnum(String errorCode, String errorMessage) {
this.errorCode = errorCode;
this.errorMessage = errorMessage;
}
}
package com.exception.question.exception;
import java.util.Map;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:24
* @discription
**/
public class BaseException extends RuntimeException {
private String errorCode;
private String errorTips;
private Map<String, String> errorFieldMap;
private BaseExceptionCode baseErrorCode;
public BaseException() {
}
public BaseException(String message) {
super(message);
}
public BaseException(String errorCode, String message) {
super(message);
this.errorCode = errorCode;
}
public BaseException(String errorCode, String message, String errorTips) {
super(message);
this.errorCode = errorCode;
this.errorTips = errorTips;
}
public BaseException(BaseExceptionCode baseErrorCode, String message) {
super(message);
this.baseErrorCode = baseErrorCode;
}
public BaseException(BaseExceptionCode baseErrorCode, String message, String errorTips) {
super(message);
this.baseErrorCode = baseErrorCode;
this.errorTips = errorTips;
}
public BaseException(String message, Throwable cause) {
super(message, cause);
}
public BaseException(BaseExceptionCode baseErrorCode) {
this.baseErrorCode = baseErrorCode;
}
public BaseException(BaseExceptionCode baseErrorCode, String message, Throwable cause) {
super(message, cause);
this.baseErrorCode = baseErrorCode;
}
public BaseException(String errorCode, String message, String errorTips, Throwable cause) {
super(message, cause);
this.errorCode = errorCode;
this.errorTips = errorTips;
}
public BaseException(Throwable cause) {
super(cause);
}
public BaseException(BaseExceptionCode baseErrorCode, Throwable cause) {
super(cause);
this.baseErrorCode = baseErrorCode;
}
public BaseException(BaseExceptionCode baseErrorCode, Map<String, String> errorFieldMap) {
this.baseErrorCode = baseErrorCode;
this.errorFieldMap = errorFieldMap;
}
public String getErrorCode() {
return this.errorCode;
}
public String getErrorTips() {
return this.errorTips;
}
public BaseExceptionCode getBaseErrorCode() {
return this.baseErrorCode;
}
public boolean hasFlashErrorCode() {
return this.baseErrorCode != null;
}
}
package com.exception.question.exception;
/**
* @author jiangbing(江冰)
* @date 2017/12/16
* @time 下午9:29
* @discription
**/
public interface BaseExceptionCode {
String getErrorCode();
String getErrorMsg();
}
package com.exception.question.exception;
import com.exception.question.enums.QuestionResponseCodeEnum;
/**
* @author jiangbing(江冰)
* @date 2017/12/22
* @time 下午1:11
* @discription
**/
public class QMSException extends BaseException {
public QMSException(String errorCode, String message) {
super(errorCode, message);
}
public QMSException(Throwable cause) {
super(cause);
}
public QMSException(QuestionResponseCodeEnum questionResponseCodeEnum) {
super(questionResponseCodeEnum.getErrorCode(), questionResponseCodeEnum.getErrorMessage());
}
}
package com.exception.question.service;
import com.exception.question.common.BaseResponse;
import com.exception.question.domain.entity.Question;
import java.util.List;
/**
* @author jiangbing(江冰)
* @date 2017/12/22
* @time 下午2:01
* @discription
**/
public interface HomeService {
/**
* 查询首页问题列表
* @return
*/
List<Question> page();
/**
* 查询首页问题列表总数
* @return
*/
int pageCount();
}
package com.exception.question.service.impl;
import com.exception.question.domain.entity.Question;
import com.exception.question.domain.mapper.QuestionMapper;
import com.exception.question.service.HomeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author jiangbing(江冰)
* @date 2017/12/22
* @time 下午2:04
* @discription
**/
@Service
@Slf4j
public class HomeServiceImpl implements HomeService {
@Autowired
private QuestionMapper questionMapper;
@Override
public List<Question> page() {
return questionMapper.se;
}
@Override
public int pageCount() {
return questionMapper.selectPageCountSelective();
}
}
spring:
application:
name: question-ms #服务的名字 记得修改 命名规范->服务名-ms
jackson:
default-property-inclusion: non_null #json中null字段不包含
datasource: #记得修改不同环境数据库的url、用户名、密码
url: jdbc:mysql://116.62.170.57:3306/exc?zeroDateTimeBehavior=convertToNull&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
username: root
password: Qwe123!@#
server:
port: 8081
# mybatis
mybatis:
type-aliases-package: com.exception.question.domain.entity
mapper-locations: classpath:mapper/*.xml
## log 日志配置
logging:
config: classpath:logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!--导入属性配置-->
<!--<properties resource="db.properties"></properties>-->
<!--指定特定数据库的jdbc驱动jar包的位置-->
<classPathEntry location="/Users/jiangbing/Work/apache-maven-3.5.2/localRepository/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar"/>
<context id="default" targetRuntime="MyBatis3">
<!-- optional,旨在创建class时,对注释进行控制 -->
<commentGenerator>
<property name="suppressDate" value="true"/>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://116.62.170.57:3306/exc?characterEncoding=utf-8"
userId="root"
password="Qwe123!@#">
</jdbcConnection>
<!-- 非必需,类型处理器,在数据库类型和java类型之间的转换控制-->
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径
-->
<!--<javaModelGenerator targetPackage="com.mmall.pojo" targetProject=".\src\main\java">-->
<javaModelGenerator targetPackage="com.exception.question.domain.entity" targetProject="./src/main/java">
<!-- 是否允许子包,即targetPackage.schemaName.tableName -->
<property name="enableSubPackages" value="true"/>
<!-- 是否对model添加 构造函数 -->
<property name="constructorBased" value="false"/>
<!-- 是否对类CHAR类型的列的数据进行trim操作 -->
<property name="trimStrings" value="true"/>
<!-- 建立的Model对象是否 不可改变 即生成的Model对象不会有 setter方法,只有构造方法 -->
<property name="immutable" value="false"/>
</javaModelGenerator>
<!--mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<!--<sqlMapGenerator targetPackage="mappers" targetProject=".\src\main\resources">-->
<sqlMapGenerator targetPackage="mapper" targetProject="./src/main/resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口
-->
<!-- targetPackage:mapper接口dao生成的位置 -->
<!--<javaClientGenerator type="XMLMAPPER" targetPackage="com.mmall.dao" targetProject=".\src\main\java">-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.exception.question.domain.mapper" targetProject="./src/main/java">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!--<table tableName="mmall_pay_info" domainObjectName="PayInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
<!--<table tableName="mmall_product" domainObjectName="Product" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">-->
<!--<columnOverride column="detail" jdbcType="VARCHAR" />-->
<!--<columnOverride column="sub_images" jdbcType="VARCHAR" />-->
<!--</table>-->
<!--<table tableName="t_person" domainObjectName="Person" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
<!--<table tableName="t_user"-->
<!--domainObjectName="User"-->
<!--enableCountByExample="false" enableUpdateByExample="false"-->
<!--enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
<!--<table tableName="t_question" domainObjectName="Question" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
<!--<table tableName="t_tag" domainObjectName="Tag" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
<!--<table tableName="t_question_answer_map" domainObjectName="QuestionAnswerMap" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
<table tableName="t_question" domainObjectName="Question" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="t_question_desc" domainObjectName="QuestionDesc" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="t_question_tag_rel" domainObjectName="QuestionTagRel" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="t_tag" domainObjectName="Tag" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="t_user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="t_answer" domainObjectName="Answer" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="t_answer_desc" domainObjectName="AnswerDesc" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<!-- geelynote mybatis插件的搭建 -->
</context>
</generatorConfiguration>
<?xml version="1.0" encoding="UTF-8"?>
<configuration >
<jmxConfigurator/>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property scope="context" name="appName" value="question-ms" />
<property name="LOG_FILE" value="/app/logs/${appName}/${appName}.%d{yyyy-MM-dd}"/>
<property name="LOG_FILE" value="/app/logs/${appName}/${appName}.%d{yyyy-MM-dd}"/>
<property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n"/>
<property name="CONSOLE_LOG_PATTERN" value="${FILE_LOG_PATTERN}"/>
<!-- 按照每天生成日志文件 -->
<!--<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
<!--<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
<!--&lt;!&ndash;日志文件输出的文件名&ndash;&gt;-->
<!--<FileNamePattern>${LOG_FILE}-%i.log</FileNamePattern>-->
<!--&lt;!&ndash;日志文件保留天数&ndash;&gt;-->
<!--<MaxHistory>30</MaxHistory>-->
<!--&lt;!&ndash;日志文件最大的大小&ndash;&gt;-->
<!--<TimeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">-->
<!--<maxFileSize>10MB</maxFileSize>-->
<!--</TimeBasedFileNamingAndTriggeringPolicy>-->
<!--</rollingPolicy>-->
<!--<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">-->
<!--&lt;!&ndash;格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%errorMessage:日志消息,%n是换行符&ndash;&gt;-->
<!--<pattern>${FILE_LOG_PATTERN}</pattern>-->
<!--</encoder>-->
<!--</appender>-->
<!--<springProfile name="dev">-->
<!--<include resource="org/springframework/boot/logging/logback/console-appender.xml" />-->
<!--<root level="info">-->
<!--<appender-ref ref="CONSOLE" />-->
<!--</root>-->
<!--</springProfile>-->
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<root level="info">
<appender-ref ref="CONSOLE" />
</root>
<!--<springProfile name="qa,pre,gr,prd">-->
<!--<root level="INFO">-->
<!--<appender-ref ref="FILE" />-->
<!--</root>-->
<!--</springProfile>-->
</configuration>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.exception.question.domain.mapper.AnswerDescMapper" >
<resultMap id="BaseResultMap" type="com.exception.question.domain.entity.AnswerDesc" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="answer_id" property="answerId" jdbcType="BIGINT" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="create_user_id" property="createUserId" jdbcType="BIGINT" />
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="com.exception.question.domain.entity.AnswerDescWithBLOBs" extends="BaseResultMap" >
<result column="description" property="description" jdbcType="LONGVARCHAR" />
<result column="description_cn" property="descriptionCn" jdbcType="LONGVARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, answer_id, create_time, update_time, create_user_id
</sql>
<sql id="Blob_Column_List" >
description, description_cn
</sql>
<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from t_answer_desc
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from t_answer_desc
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.exception.question.domain.entity.AnswerDescWithBLOBs" >
insert into t_answer_desc (id, answer_id, create_time,
update_time, create_user_id, description,
description_cn)
values (#{id,jdbcType=BIGINT}, #{answerId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=BIGINT}, #{description,jdbcType=LONGVARCHAR},
#{descriptionCn,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.exception.question.domain.entity.AnswerDescWithBLOBs" >
insert into t_answer_desc
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="answerId != null" >
answer_id,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
<if test="createUserId != null" >
create_user_id,
</if>
<if test="description != null" >
description,
</if>
<if test="descriptionCn != null" >
description_cn,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="answerId != null" >
#{answerId,jdbcType=BIGINT},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null" >
#{createUserId,jdbcType=BIGINT},
</if>
<if test="description != null" >
#{description,jdbcType=LONGVARCHAR},
</if>
<if test="descriptionCn != null" >
#{descriptionCn,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.exception.question.domain.entity.AnswerDescWithBLOBs" >
update t_answer_desc
<set >
<if test="answerId != null" >
answer_id = #{answerId,jdbcType=BIGINT},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null" >
create_user_id = #{createUserId,jdbcType=BIGINT},
</if>
<if test="description != null" >
description = #{description,jdbcType=LONGVARCHAR},
</if>
<if test="descriptionCn != null" >
description_cn = #{descriptionCn,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.exception.question.domain.entity.AnswerDescWithBLOBs" >
update t_answer_desc
set answer_id = #{answerId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
create_user_id = #{createUserId,jdbcType=BIGINT},
description = #{description,jdbcType=LONGVARCHAR},
description_cn = #{descriptionCn,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.exception.question.domain.entity.AnswerDesc" >
update t_answer_desc
set answer_id = #{answerId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
create_user_id = #{createUserId,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.exception.question.domain.mapper.AnswerMapper" >
<resultMap id="BaseResultMap" type="com.exception.question.domain.entity.Answer" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="create_user_id" property="createUserId" jdbcType="BIGINT" />
<result column="question_id" property="questionId" jdbcType="BIGINT" />
<result column="vote_up" property="voteUp" jdbcType="INTEGER" />
<result column="vote_down" property="voteDown" jdbcType="INTEGER" />
<result column="language" property="language" jdbcType="TINYINT" />
<result column="original_id" property="originalId" jdbcType="BIGINT" />
<result column="is_accepted" property="isAccepted" jdbcType="BIT" />
<result column="vote_count" property="voteCount" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, create_time, update_time, create_user_id, question_id, vote_up, vote_down, language,
original_id, is_accepted, vote_count
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from t_answer
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from t_answer
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.exception.question.domain.entity.Answer" >
insert into t_answer (id, create_time, update_time,
create_user_id, question_id, vote_up,
vote_down, language, original_id,
is_accepted, vote_count)
values (#{id,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{createUserId,jdbcType=BIGINT}, #{questionId,jdbcType=BIGINT}, #{voteUp,jdbcType=INTEGER},
#{voteDown,jdbcType=INTEGER}, #{language,jdbcType=TINYINT}, #{originalId,jdbcType=BIGINT},
#{isAccepted,jdbcType=BIT}, #{voteCount,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.exception.question.domain.entity.Answer" >
insert into t_answer
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
<if test="createUserId != null" >
create_user_id,
</if>
<if test="questionId != null" >
question_id,
</if>
<if test="voteUp != null" >
vote_up,
</if>
<if test="voteDown != null" >
vote_down,
</if>
<if test="language != null" >
language,
</if>
<if test="originalId != null" >
original_id,
</if>
<if test="isAccepted != null" >
is_accepted,
</if>
<if test="voteCount != null" >
vote_count,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null" >
#{createUserId,jdbcType=BIGINT},
</if>
<if test="questionId != null" >
#{questionId,jdbcType=BIGINT},
</if>
<if test="voteUp != null" >
#{voteUp,jdbcType=INTEGER},
</if>
<if test="voteDown != null" >
#{voteDown,jdbcType=INTEGER},
</if>
<if test="language != null" >
#{language,jdbcType=TINYINT},
</if>
<if test="originalId != null" >
#{originalId,jdbcType=BIGINT},
</if>
<if test="isAccepted != null" >
#{isAccepted,jdbcType=BIT},
</if>
<if test="voteCount != null" >
#{voteCount,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.exception.question.domain.entity.Answer" >
update t_answer
<set >
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null" >
create_user_id = #{createUserId,jdbcType=BIGINT},
</if>
<if test="questionId != null" >
question_id = #{questionId,jdbcType=BIGINT},
</if>
<if test="voteUp != null" >
vote_up = #{voteUp,jdbcType=INTEGER},
</if>
<if test="voteDown != null" >
vote_down = #{voteDown,jdbcType=INTEGER},
</if>
<if test="language != null" >
language = #{language,jdbcType=TINYINT},
</if>
<if test="originalId != null" >
original_id = #{originalId,jdbcType=BIGINT},
</if>
<if test="isAccepted != null" >
is_accepted = #{isAccepted,jdbcType=BIT},
</if>
<if test="voteCount != null" >
vote_count = #{voteCount,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.exception.question.domain.entity.Answer" >
update t_answer
set create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
create_user_id = #{createUserId,jdbcType=BIGINT},
question_id = #{questionId,jdbcType=BIGINT},
vote_up = #{voteUp,jdbcType=INTEGER},
vote_down = #{voteDown,jdbcType=INTEGER},
language = #{language,jdbcType=TINYINT},
original_id = #{originalId,jdbcType=BIGINT},
is_accepted = #{isAccepted,jdbcType=BIT},
vote_count = #{voteCount,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.exception.question.domain.mapper.QuestionDescMapper" >
<resultMap id="BaseResultMap" type="com.exception.question.domain.entity.QuestionDesc" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="question_id" property="questionId" jdbcType="BIGINT" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="create_user_id" property="createUserId" jdbcType="BIGINT" />
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="com.exception.question.domain.entity.QuestionDescWithBLOBs" extends="BaseResultMap" >
<result column="description" property="description" jdbcType="LONGVARCHAR" />
<result column="description_ch" property="descriptionCh" jdbcType="LONGVARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, question_id, create_time, update_time, create_user_id
</sql>
<sql id="Blob_Column_List" >
description, description_ch
</sql>
<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from t_question_desc
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from t_question_desc
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.exception.question.domain.entity.QuestionDescWithBLOBs" >
insert into t_question_desc (id, question_id, create_time,
update_time, create_user_id, description,
description_ch)
values (#{id,jdbcType=BIGINT}, #{questionId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=BIGINT}, #{description,jdbcType=LONGVARCHAR},
#{descriptionCh,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.exception.question.domain.entity.QuestionDescWithBLOBs" >
insert into t_question_desc
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="questionId != null" >
question_id,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
<if test="createUserId != null" >
create_user_id,
</if>
<if test="description != null" >
description,
</if>
<if test="descriptionCh != null" >
description_ch,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="questionId != null" >
#{questionId,jdbcType=BIGINT},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null" >
#{createUserId,jdbcType=BIGINT},
</if>
<if test="description != null" >
#{description,jdbcType=LONGVARCHAR},
</if>
<if test="descriptionCh != null" >
#{descriptionCh,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.exception.question.domain.entity.QuestionDescWithBLOBs" >
update t_question_desc
<set >
<if test="questionId != null" >
question_id = #{questionId,jdbcType=BIGINT},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null" >
create_user_id = #{createUserId,jdbcType=BIGINT},
</if>
<if test="description != null" >
description = #{description,jdbcType=LONGVARCHAR},
</if>
<if test="descriptionCh != null" >
description_ch = #{descriptionCh,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.exception.question.domain.entity.QuestionDescWithBLOBs" >
update t_question_desc
set question_id = #{questionId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
create_user_id = #{createUserId,jdbcType=BIGINT},
description = #{description,jdbcType=LONGVARCHAR},
description_ch = #{descriptionCh,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.exception.question.domain.entity.QuestionDesc" >
update t_question_desc
set question_id = #{questionId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
create_user_id = #{createUserId,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.exception.question.domain.mapper.QuestionMapper" >
<resultMap id="BaseResultMap" type="com.exception.question.domain.entity.Question" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="title" property="title" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="create_user_id" property="createUserId" jdbcType="BIGINT" />
<result column="vote_up" property="voteUp" jdbcType="INTEGER" />
<result column="vote_down" property="voteDown" jdbcType="INTEGER" />
<result column="language" property="language" jdbcType="TINYINT" />
<result column="title_cn" property="titleCn" jdbcType="VARCHAR" />
<result column="original_id" property="originalId" jdbcType="INTEGER" />
<result column="original_link" property="originalLink" jdbcType="VARCHAR" />
<result column="view_num" property="viewNum" jdbcType="INTEGER" />
<result column="is_title_trans_finished" property="isTitleTransFinished" jdbcType="BIT" />
<result column="is_answer_trans_finished" property="isAnswerTransFinished" jdbcType="BIT" />
<result column="status" property="status" jdbcType="TINYINT" />
</resultMap>
<sql id="Base_Column_List" >
id, title, create_time, update_time, create_user_id, vote_up, vote_down, language,
title_cn, original_id, original_link, view_num, is_title_trans_finished, is_answer_trans_finished,
status
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from t_question
where id = #{id,jdbcType=BIGINT}
</select>
<select id="selectPageCountSelective" resultType="int">
select COUNT(*) from t_question
</select>
<select id="selectPageSelective" resultMap="BaseResultMap" parameterMap="map">
select title_ch from t_question
order by id desc
limit
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from t_question
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.exception.question.domain.entity.Question" >
insert into t_question (id, title, create_time,
update_time, create_user_id, vote_up,
vote_down, language, title_cn,
original_id, original_link, view_num,
is_title_trans_finished, is_answer_trans_finished, status
)
values (#{id,jdbcType=BIGINT}, #{title,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=BIGINT}, #{voteUp,jdbcType=INTEGER},
#{voteDown,jdbcType=INTEGER}, #{language,jdbcType=TINYINT}, #{titleCn,jdbcType=VARCHAR},
#{originalId,jdbcType=INTEGER}, #{originalLink,jdbcType=VARCHAR}, #{viewNum,jdbcType=INTEGER},
#{isTitleTransFinished,jdbcType=BIT}, #{isAnswerTransFinished,jdbcType=BIT}, #{status,jdbcType=TINYINT}
)
</insert>
<insert id="insertSelective" parameterType="com.exception.question.domain.entity.Question" >
insert into t_question
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="title != null" >
title,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
<if test="createUserId != null" >
create_user_id,
</if>
<if test="voteUp != null" >
vote_up,
</if>
<if test="voteDown != null" >
vote_down,
</if>
<if test="language != null" >
language,
</if>
<if test="titleCn != null" >
title_cn,
</if>
<if test="originalId != null" >
original_id,
</if>
<if test="originalLink != null" >
original_link,
</if>
<if test="viewNum != null" >
view_num,
</if>
<if test="isTitleTransFinished != null" >
is_title_trans_finished,
</if>
<if test="isAnswerTransFinished != null" >
is_answer_trans_finished,
</if>
<if test="status != null" >
status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="title != null" >
#{title,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null" >
#{createUserId,jdbcType=BIGINT},
</if>
<if test="voteUp != null" >
#{voteUp,jdbcType=INTEGER},
</if>
<if test="voteDown != null" >
#{voteDown,jdbcType=INTEGER},
</if>
<if test="language != null" >
#{language,jdbcType=TINYINT},
</if>
<if test="titleCn != null" >
#{titleCn,jdbcType=VARCHAR},
</if>
<if test="originalId != null" >
#{originalId,jdbcType=INTEGER},
</if>
<if test="originalLink != null" >
#{originalLink,jdbcType=VARCHAR},
</if>
<if test="viewNum != null" >
#{viewNum,jdbcType=INTEGER},
</if>
<if test="isTitleTransFinished != null" >
#{isTitleTransFinished,jdbcType=BIT},
</if>
<if test="isAnswerTransFinished != null" >
#{isAnswerTransFinished,jdbcType=BIT},
</if>
<if test="status != null" >
#{status,jdbcType=TINYINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.exception.question.domain.entity.Question" >
update t_question
<set >
<if test="title != null" >
title = #{title,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null" >
create_user_id = #{createUserId,jdbcType=BIGINT},
</if>
<if test="voteUp != null" >
vote_up = #{voteUp,jdbcType=INTEGER},
</if>
<if test="voteDown != null" >
vote_down = #{voteDown,jdbcType=INTEGER},
</if>
<if test="language != null" >
language = #{language,jdbcType=TINYINT},
</if>
<if test="titleCn != null" >
title_cn = #{titleCn,jdbcType=VARCHAR},
</if>
<if test="originalId != null" >
original_id = #{originalId,jdbcType=INTEGER},
</if>
<if test="originalLink != null" >
original_link = #{originalLink,jdbcType=VARCHAR},
</if>
<if test="viewNum != null" >
view_num = #{viewNum,jdbcType=INTEGER},
</if>
<if test="isTitleTransFinished != null" >
is_title_trans_finished = #{isTitleTransFinished,jdbcType=BIT},
</if>
<if test="isAnswerTransFinished != null" >
is_answer_trans_finished = #{isAnswerTransFinished,jdbcType=BIT},
</if>
<if test="status != null" >
status = #{status,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.exception.question.domain.entity.Question" >
update t_question
set title = #{title,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
create_user_id = #{createUserId,jdbcType=BIGINT},
vote_up = #{voteUp,jdbcType=INTEGER},
vote_down = #{voteDown,jdbcType=INTEGER},
language = #{language,jdbcType=TINYINT},
title_cn = #{titleCn,jdbcType=VARCHAR},
original_id = #{originalId,jdbcType=INTEGER},
original_link = #{originalLink,jdbcType=VARCHAR},
view_num = #{viewNum,jdbcType=INTEGER},
is_title_trans_finished = #{isTitleTransFinished,jdbcType=BIT},
is_answer_trans_finished = #{isAnswerTransFinished,jdbcType=BIT},
status = #{status,jdbcType=TINYINT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.exception.question.domain.mapper.QuestionTagRelMapper" >
<resultMap id="BaseResultMap" type="com.exception.question.domain.entity.QuestionTagRel" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="question_id" property="questionId" jdbcType="BIGINT" />
<result column="tag_id" property="tagId" jdbcType="BIGINT" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, question_id, tag_id, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from t_question_tag_rel
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from t_question_tag_rel
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.exception.question.domain.entity.QuestionTagRel" >
insert into t_question_tag_rel (id, question_id, tag_id,
create_time, update_time)
values (#{id,jdbcType=BIGINT}, #{questionId,jdbcType=BIGINT}, #{tagId,jdbcType=BIGINT},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.exception.question.domain.entity.QuestionTagRel" >
insert into t_question_tag_rel
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="questionId != null" >
question_id,
</if>
<if test="tagId != null" >
tag_id,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="questionId != null" >
#{questionId,jdbcType=BIGINT},
</if>
<if test="tagId != null" >
#{tagId,jdbcType=BIGINT},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.exception.question.domain.entity.QuestionTagRel" >
update t_question_tag_rel
<set >
<if test="questionId != null" >
question_id = #{questionId,jdbcType=BIGINT},
</if>
<if test="tagId != null" >
tag_id = #{tagId,jdbcType=BIGINT},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.exception.question.domain.entity.QuestionTagRel" >
update t_question_tag_rel
set question_id = #{questionId,jdbcType=BIGINT},
tag_id = #{tagId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.exception.question.domain.mapper.TagMapper" >
<resultMap id="BaseResultMap" type="com.exception.question.domain.entity.Tag" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="create_user_id" property="createUserId" jdbcType="INTEGER" />
<result column="spider_page_num" property="spiderPageNum" jdbcType="INTEGER" />
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="com.exception.question.domain.entity.TagWithBLOBs" extends="BaseResultMap" >
<result column="description" property="description" jdbcType="LONGVARCHAR" />
<result column="description_ch" property="descriptionCh" jdbcType="LONGVARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, name, create_time, update_time, create_user_id, spider_page_num
</sql>
<sql id="Blob_Column_List" >
description, description_ch
</sql>
<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from t_tag
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from t_tag
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.exception.question.domain.entity.TagWithBLOBs" >
insert into t_tag (id, name, create_time,
update_time, create_user_id, spider_page_num,
description, description_ch)
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=INTEGER}, #{spiderPageNum,jdbcType=INTEGER},
#{description,jdbcType=LONGVARCHAR}, #{descriptionCh,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.exception.question.domain.entity.TagWithBLOBs" >
insert into t_tag
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="name != null" >
name,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
<if test="createUserId != null" >
create_user_id,
</if>
<if test="spiderPageNum != null" >
spider_page_num,
</if>
<if test="description != null" >
description,
</if>
<if test="descriptionCh != null" >
description_ch,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null" >
#{createUserId,jdbcType=INTEGER},
</if>
<if test="spiderPageNum != null" >
#{spiderPageNum,jdbcType=INTEGER},
</if>
<if test="description != null" >
#{description,jdbcType=LONGVARCHAR},
</if>
<if test="descriptionCh != null" >
#{descriptionCh,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.exception.question.domain.entity.TagWithBLOBs" >
update t_tag
<set >
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null" >
create_user_id = #{createUserId,jdbcType=INTEGER},
</if>
<if test="spiderPageNum != null" >
spider_page_num = #{spiderPageNum,jdbcType=INTEGER},
</if>
<if test="description != null" >
description = #{description,jdbcType=LONGVARCHAR},
</if>
<if test="descriptionCh != null" >
description_ch = #{descriptionCh,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.exception.question.domain.entity.TagWithBLOBs" >
update t_tag
set name = #{name,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
create_user_id = #{createUserId,jdbcType=INTEGER},
spider_page_num = #{spiderPageNum,jdbcType=INTEGER},
description = #{description,jdbcType=LONGVARCHAR},
description_ch = #{descriptionCh,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.exception.question.domain.entity.Tag" >
update t_tag
set name = #{name,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
create_user_id = #{createUserId,jdbcType=INTEGER},
spider_page_num = #{spiderPageNum,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.exception.question.domain.mapper.UserMapper" >
<resultMap id="BaseResultMap" type="com.exception.question.domain.entity.User" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="username" property="username" jdbcType="VARCHAR" />
<result column="password" property="password" jdbcType="VARCHAR" />
<result column="email" property="email" jdbcType="VARCHAR" />
<result column="phone" property="phone" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, username, password, email, phone, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from t_user
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from t_user
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.exception.question.domain.entity.User" >
insert into t_user (id, username, password,
email, phone, create_time,
update_time)
values (#{id,jdbcType=BIGINT}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
#{email,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.exception.question.domain.entity.User" >
insert into t_user
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="username != null" >
username,
</if>
<if test="password != null" >
password,
</if>
<if test="email != null" >
email,
</if>
<if test="phone != null" >
phone,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="username != null" >
#{username,jdbcType=VARCHAR},
</if>
<if test="password != null" >
#{password,jdbcType=VARCHAR},
</if>
<if test="email != null" >
#{email,jdbcType=VARCHAR},
</if>
<if test="phone != null" >
#{phone,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.exception.question.domain.entity.User" >
update t_user
<set >
<if test="username != null" >
username = #{username,jdbcType=VARCHAR},
</if>
<if test="password != null" >
password = #{password,jdbcType=VARCHAR},
</if>
<if test="email != null" >
email = #{email,jdbcType=VARCHAR},
</if>
<if test="phone != null" >
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.exception.question.domain.entity.User" >
update t_user
set username = #{username,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
email = #{email,jdbcType=VARCHAR},
phone = #{phone,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
package com.exception.question;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class ApplicationTests {
@Test
public void contextLoads() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment