12 changed files with 448 additions and 307 deletions
@ -1,25 +1,25 @@ |
|||
//package com.ccsens.common;
|
|||
//
|
|||
//import org.mybatis.spring.annotation.MapperScan;
|
|||
//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;
|
|||
//
|
|||
///**
|
|||
// * @author ma
|
|||
// */
|
|||
//@MapperScan(basePackages = {"com.ccsens.common.persist.*"})
|
|||
//@ServletComponentScan
|
|||
//@EnableAsync
|
|||
////开启断路器功能
|
|||
//@EnableCircuitBreaker
|
|||
//@EnableFeignClients(basePackages = "com.ccsens.cloudutil.feign")
|
|||
//@SpringBootApplication(scanBasePackages = "com.ccsens")
|
|||
//public class CommonApplication {
|
|||
// public static void main(String[] args) {
|
|||
// SpringApplication.run(CommonApplication.class,args);
|
|||
// }
|
|||
//}
|
|||
package com.ccsens.common; |
|||
|
|||
import org.mybatis.spring.annotation.MapperScan; |
|||
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; |
|||
|
|||
/** |
|||
* @author ma |
|||
*/ |
|||
@MapperScan(basePackages = {"com.ccsens.common.persist.*"}) |
|||
@ServletComponentScan |
|||
@EnableAsync |
|||
//开启断路器功能
|
|||
@EnableCircuitBreaker |
|||
@EnableFeignClients(basePackages = "com.ccsens.cloudutil.feign") |
|||
@SpringBootApplication(scanBasePackages = "com.ccsens") |
|||
public class CommonApplication { |
|||
public static void main(String[] args) { |
|||
SpringApplication.run(CommonApplication.class,args); |
|||
} |
|||
} |
|||
|
@ -1,96 +1,104 @@ |
|||
//package com.ccsens.common.api;
|
|||
//
|
|||
//import com.ccsens.cloudutil.annotation.MustLogin;
|
|||
//import com.ccsens.common.bean.dto.CClockingInDto;
|
|||
//import com.ccsens.common.bean.dto.CTaskDto;
|
|||
//
|
|||
//import com.ccsens.common.bean.vo.CClockingInVo;
|
|||
//import com.ccsens.common.bean.vo.CTaskVo;
|
|||
//
|
|||
//import com.ccsens.common.service.IClockingInService;
|
|||
//import com.ccsens.common.service.ITaskService;
|
|||
//import com.ccsens.util.JsonResponse;
|
|||
//import com.ccsens.util.bean.dto.QueryDto;
|
|||
//import io.swagger.annotations.Api;
|
|||
//import io.swagger.annotations.ApiOperation;
|
|||
//import io.swagger.annotations.ApiParam;
|
|||
//import lombok.extern.slf4j.Slf4j;
|
|||
//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.annotation.Resource;
|
|||
//import java.util.List;
|
|||
//
|
|||
///**
|
|||
// * @author 逗
|
|||
// */
|
|||
//@Api(tags = "DEBUG" , description = "DebugController | ")
|
|||
//@RestController
|
|||
//@RequestMapping("/task")
|
|||
//@Slf4j
|
|||
//public class TaskController {
|
|||
//
|
|||
// @Resource
|
|||
// private ITaskService taskService;
|
|||
// @Resource
|
|||
// private IClockingInService clockingInService;
|
|||
//
|
|||
// @MustLogin
|
|||
// @ApiOperation(value = "查找永久日常任务", notes = "")
|
|||
// @RequestMapping(value = "/permanent", method = RequestMethod.POST, produces = {"application/json;charet=UTF-8"})
|
|||
// public JsonResponse<List<CTaskVo.QueryTask>> queryPermanentGlobalTask(@ApiParam @Validated @RequestBody QueryDto<CTaskDto.QueryPermanentGlobalTask> params) {
|
|||
// log.info("查找永久日常任务开始{}",params);
|
|||
// List<CTaskVo.QueryTask> permanentGlobalTaskList = taskService.queryPermanentGlobalTask(params.getParam(),params.getUserId());
|
|||
// log.info("查找永久日常任务结束{}",permanentGlobalTaskList);
|
|||
// return JsonResponse.newInstance().ok(permanentGlobalTaskList);
|
|||
// }
|
|||
//
|
|||
// @MustLogin
|
|||
// @ApiOperation(value = "查找带时间的日常任务", notes = "")
|
|||
// @RequestMapping(value = "/global", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
|
|||
// public JsonResponse<List<CTaskVo.QueryTask>> queryGlobalTask(@ApiParam @Validated @RequestBody QueryDto<CTaskDto.QueryGlobalTask> params) {
|
|||
// log.info("查找带时间的日常任务开始{}",params);
|
|||
// List<CTaskVo.QueryTask> globalTask = taskService.queryGlobalTask(params.getParam(),params.getUserId());
|
|||
// log.info("查找带时间的日常任务结束{}",globalTask);
|
|||
// return JsonResponse.newInstance().ok(globalTask);
|
|||
// }
|
|||
//
|
|||
// @MustLogin
|
|||
// @ApiOperation(value = "查找带时间的定期任务", notes = "")
|
|||
// @RequestMapping(value = "/regular", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
|
|||
// public JsonResponse<List<CTaskVo.QueryTask>> queryRegularTask(@ApiParam @Validated @RequestBody QueryDto<CTaskDto.QueryRegularTask> params) {
|
|||
// log.info("查找带时间的定期任务开始{}",params);
|
|||
// List<CTaskVo.QueryTask> regularTask = taskService.queryRegularTask(params.getParam(), params.getUserId());
|
|||
// log.info("查找带时间的定期任务结束{}",regularTask);
|
|||
// return JsonResponse.newInstance().ok(regularTask);
|
|||
// }
|
|||
//
|
|||
//
|
|||
// @MustLogin
|
|||
// @ApiOperation(value = "查询考勤信息", notes = "")
|
|||
// @RequestMapping(value = "/query", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
|
|||
// public JsonResponse<List<CClockingInVo.ClockingInInfo>> queryDeliverOfTask(@ApiParam @Validated @RequestBody QueryDto<CClockingInDto.QueryClockingIn> params) throws Exception{
|
|||
// List<CClockingInVo.ClockingInInfo> clockingInInfos = clockingInService.queryClockingIn(params.getParam(), params.getUserId());
|
|||
// return JsonResponse.newInstance().ok(clockingInInfos);
|
|||
// }
|
|||
//
|
|||
// @MustLogin
|
|||
// @ApiOperation(value = "打卡", notes = "")
|
|||
// @RequestMapping(value = "/punch", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
|
|||
// public JsonResponse punchTheClock(@ApiParam @Validated @RequestBody QueryDto<CClockingInDto.PunchTheClock> params) throws Exception{
|
|||
// clockingInService.punchTheClock(params.getParam(), params.getUserId());
|
|||
// return JsonResponse.newInstance().ok();
|
|||
// }
|
|||
//
|
|||
// @MustLogin
|
|||
// @ApiOperation(value = "导出考勤excel", notes = "")
|
|||
// @RequestMapping(value = "/export", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
|
|||
// public JsonResponse export(@ApiParam @Validated @RequestBody QueryDto<CClockingInDto.QueryClockingIn> params) throws Exception{
|
|||
// clockingInService.exportRecord(params.getParam(), params.getUserId());
|
|||
// return JsonResponse.newInstance().ok();
|
|||
// }
|
|||
//
|
|||
//}
|
|||
package com.ccsens.common.api; |
|||
|
|||
import com.ccsens.cloudutil.annotation.MustLogin; |
|||
import com.ccsens.common.bean.dto.CClockingInDto; |
|||
import com.ccsens.common.bean.dto.CTaskDto; |
|||
|
|||
import com.ccsens.common.bean.vo.CClockingInVo; |
|||
import com.ccsens.common.bean.vo.CTaskVo; |
|||
|
|||
import com.ccsens.common.service.IClockingInService; |
|||
import com.ccsens.common.service.ITaskService; |
|||
import com.ccsens.util.JsonResponse; |
|||
import com.ccsens.util.bean.dto.QueryDto; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiParam; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
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.annotation.Resource; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author 逗 |
|||
*/ |
|||
@Api(tags = "DEBUG" , description = "DebugController | ") |
|||
@RestController |
|||
@RequestMapping("/task") |
|||
@Slf4j |
|||
public class TaskController { |
|||
|
|||
@Resource |
|||
private ITaskService taskService; |
|||
@Resource |
|||
private IClockingInService clockingInService; |
|||
|
|||
@MustLogin |
|||
@ApiOperation(value = "查找永久日常任务", notes = "") |
|||
@RequestMapping(value = "/permanent", method = RequestMethod.POST, produces = {"application/json;charet=UTF-8"}) |
|||
public JsonResponse<List<CTaskVo.QueryTask>> queryPermanentGlobalTask(@ApiParam @Validated @RequestBody QueryDto<CTaskDto.QueryPermanentGlobalTask> params) { |
|||
log.info("查找永久日常任务开始{}",params); |
|||
List<CTaskVo.QueryTask> permanentGlobalTaskList = taskService.queryPermanentGlobalTask(params.getParam(),params.getUserId()); |
|||
log.info("查找永久日常任务结束{}",permanentGlobalTaskList); |
|||
return JsonResponse.newInstance().ok(permanentGlobalTaskList); |
|||
} |
|||
|
|||
@MustLogin |
|||
@ApiOperation(value = "查找带时间的日常任务", notes = "") |
|||
@RequestMapping(value = "/global", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse<List<CTaskVo.QueryTask>> queryGlobalTask(@ApiParam @Validated @RequestBody QueryDto<CTaskDto.QueryGlobalTask> params) { |
|||
log.info("查找带时间的日常任务开始{}",params); |
|||
List<CTaskVo.QueryTask> globalTask = taskService.queryGlobalTask(params.getParam(),params.getUserId()); |
|||
log.info("查找带时间的日常任务结束{}",globalTask); |
|||
return JsonResponse.newInstance().ok(globalTask); |
|||
} |
|||
|
|||
@MustLogin |
|||
@ApiOperation(value = "查找带时间的定期任务", notes = "") |
|||
@RequestMapping(value = "/regular", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse<List<CTaskVo.QueryTask>> queryRegularTask(@ApiParam @Validated @RequestBody QueryDto<CTaskDto.QueryRegularTask> params) { |
|||
log.info("查找带时间的定期任务开始{}",params); |
|||
List<CTaskVo.QueryTask> regularTask = taskService.queryRegularTask(params.getParam(), params.getUserId()); |
|||
log.info("查找带时间的定期任务结束{}",regularTask); |
|||
return JsonResponse.newInstance().ok(regularTask); |
|||
} |
|||
|
|||
|
|||
@MustLogin |
|||
@ApiOperation(value = "查询考勤信息", notes = "") |
|||
@RequestMapping(value = "/query", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse<List<CClockingInVo.ClockingInInfo>> queryDeliverOfTask(@ApiParam @Validated @RequestBody QueryDto<CClockingInDto.QueryClockingIn> params) throws Exception{ |
|||
List<CClockingInVo.ClockingInInfo> clockingInInfos = clockingInService.queryClockingIn(params.getParam(), params.getUserId()); |
|||
return JsonResponse.newInstance().ok(clockingInInfos); |
|||
} |
|||
|
|||
@MustLogin |
|||
@ApiOperation(value = "打卡", notes = "") |
|||
@RequestMapping(value = "/punch", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse punchTheClock(@ApiParam @Validated @RequestBody QueryDto<CClockingInDto.PunchTheClock> params) throws Exception{ |
|||
clockingInService.punchTheClock(params.getParam(), params.getUserId()); |
|||
return JsonResponse.newInstance().ok(); |
|||
} |
|||
|
|||
@MustLogin |
|||
@ApiOperation(value = "导出考勤excel", notes = "") |
|||
@RequestMapping(value = "/export", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse export(@ApiParam @Validated @RequestBody QueryDto<CClockingInDto.QueryClockingIn> params) throws Exception{ |
|||
clockingInService.exportRecord(params.getParam(), params.getUserId()); |
|||
return JsonResponse.newInstance().ok(); |
|||
} |
|||
|
|||
@ApiOperation(value = "添加任务", notes = "") |
|||
@RequestMapping(value = "/save", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse<List<CTaskVo.QueryTask>> saveTask(@ApiParam @Validated @RequestBody QueryDto<CTaskDto.SaveTask> params) throws Exception { |
|||
log.info("添加任务开始"); |
|||
List<CTaskVo.QueryTask> taskList = taskService.saveTask(params.getParam(), params.getUserId()); |
|||
log.info("添加任务结束{}",taskList); |
|||
return JsonResponse.newInstance().ok(taskList); |
|||
} |
|||
} |
|||
|
@ -1,22 +1,22 @@ |
|||
//package com.ccsens.common.config;
|
|||
//
|
|||
//import com.ccsens.common.intercept.MybatisInterceptor;
|
|||
//import org.springframework.context.annotation.Bean;
|
|||
//import org.springframework.context.annotation.Configuration;
|
|||
//
|
|||
///**
|
|||
// * @description:
|
|||
// * @author: wuHuiJuan
|
|||
// * @create: 2019/12/11 10:59
|
|||
// */
|
|||
//@Configuration
|
|||
//public class BeanConfig {
|
|||
// /**
|
|||
// * 注册拦截器
|
|||
// */
|
|||
// @Bean
|
|||
// public MybatisInterceptor mybatisInterceptor() {
|
|||
// MybatisInterceptor interceptor = new MybatisInterceptor();
|
|||
// return interceptor;
|
|||
// }
|
|||
//}
|
|||
package com.ccsens.common.config; |
|||
|
|||
import com.ccsens.common.intercept.MybatisInterceptor; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: wuHuiJuan |
|||
* @create: 2019/12/11 10:59 |
|||
*/ |
|||
@Configuration |
|||
public class BeanConfig { |
|||
/** |
|||
* 注册拦截器 |
|||
*/ |
|||
@Bean |
|||
public MybatisInterceptor mybatisInterceptor() { |
|||
MybatisInterceptor interceptor = new MybatisInterceptor(); |
|||
return interceptor; |
|||
} |
|||
} |
|||
|
@ -1,98 +1,98 @@ |
|||
//package com.ccsens.common.config;
|
|||
//
|
|||
//
|
|||
//import cn.hutool.core.lang.Snowflake;
|
|||
//import cn.hutool.core.util.IdUtil;
|
|||
//import com.ccsens.util.config.DruidProps;
|
|||
//import com.fasterxml.jackson.databind.DeserializationFeature;
|
|||
//import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
//import com.fasterxml.jackson.databind.module.SimpleModule;
|
|||
//import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
|||
//import org.springframework.beans.factory.annotation.Autowired;
|
|||
//import org.springframework.beans.factory.annotation.Value;
|
|||
//import org.springframework.context.annotation.Bean;
|
|||
//import org.springframework.context.annotation.Configuration;
|
|||
//import org.springframework.http.MediaType;
|
|||
//import org.springframework.http.converter.HttpMessageConverter;
|
|||
//import org.springframework.http.converter.StringHttpMessageConverter;
|
|||
//import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
|||
//import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
|
|||
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|||
//import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|||
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||
//
|
|||
//import javax.sql.DataSource;
|
|||
//import java.nio.charset.Charset;
|
|||
//import java.util.ArrayList;
|
|||
//import java.util.List;
|
|||
//
|
|||
//@Configuration
|
|||
////public class SpringConfig extends WebMvcConfigurationSupport {
|
|||
//public class SpringConfig implements WebMvcConfigurer {
|
|||
// @Autowired
|
|||
// private DruidProps druidPropsUtil;
|
|||
// @Value("${spring.snowflake.workerId}")
|
|||
// private String workerId;
|
|||
// @Value("${spring.snowflake.datacenterId}")
|
|||
// private String datacenterId;
|
|||
//
|
|||
// /**
|
|||
// * 配置Converter
|
|||
// * @return
|
|||
// */
|
|||
// @Bean
|
|||
// public HttpMessageConverter<String> responseStringConverter() {
|
|||
// StringHttpMessageConverter converter = new StringHttpMessageConverter(
|
|||
// Charset.forName("UTF-8"));
|
|||
// return converter;
|
|||
// }
|
|||
//
|
|||
// @Bean
|
|||
// public HttpMessageConverter<Object> responseJsonConverter(){
|
|||
// MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
|||
// List<MediaType> mediaTypeList = new ArrayList<>();
|
|||
// mediaTypeList.add(MediaType.TEXT_HTML);
|
|||
// mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8);
|
|||
// converter.setSupportedMediaTypes(mediaTypeList);
|
|||
//
|
|||
// ObjectMapper objectMapper = new ObjectMapper();
|
|||
// SimpleModule simpleModule = new SimpleModule();
|
|||
// simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
|||
// simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
|
|||
// objectMapper.registerModule(simpleModule);
|
|||
// objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|||
// converter.setObjectMapper(objectMapper);
|
|||
//
|
|||
// return converter;
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
|||
// converters.add(responseStringConverter());
|
|||
// converters.add(responseJsonConverter());
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
|||
// configurer.favorPathExtension(false);
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 配置数据源(单数据源)
|
|||
// */
|
|||
// @Bean
|
|||
// public DataSource dataSource(){
|
|||
// return druidPropsUtil.createDruidDataSource();
|
|||
// }
|
|||
//
|
|||
// @Bean
|
|||
// public Snowflake snowflake(){
|
|||
// return IdUtil.createSnowflake(Long.valueOf(workerId),Long.valueOf(datacenterId));
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|||
// registry.addResourceHandler("/uploads/**")
|
|||
// .addResourceLocations("file:///home/cloud/ht/uploads/");
|
|||
// }
|
|||
//}
|
|||
package com.ccsens.common.config; |
|||
|
|||
|
|||
import cn.hutool.core.lang.Snowflake; |
|||
import cn.hutool.core.util.IdUtil; |
|||
import com.ccsens.util.config.DruidProps; |
|||
import com.fasterxml.jackson.databind.DeserializationFeature; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import com.fasterxml.jackson.databind.module.SimpleModule; |
|||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.http.converter.HttpMessageConverter; |
|||
import org.springframework.http.converter.StringHttpMessageConverter; |
|||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
|||
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer; |
|||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
|||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
|||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|||
|
|||
import javax.sql.DataSource; |
|||
import java.nio.charset.Charset; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
@Configuration |
|||
//public class SpringConfig extends WebMvcConfigurationSupport {
|
|||
public class SpringConfig implements WebMvcConfigurer { |
|||
@Autowired |
|||
private DruidProps druidPropsUtil; |
|||
@Value("${spring.snowflake.workerId}") |
|||
private String workerId; |
|||
@Value("${spring.snowflake.datacenterId}") |
|||
private String datacenterId; |
|||
|
|||
/** |
|||
* 配置Converter |
|||
* @return |
|||
*/ |
|||
@Bean |
|||
public HttpMessageConverter<String> responseStringConverter() { |
|||
StringHttpMessageConverter converter = new StringHttpMessageConverter( |
|||
Charset.forName("UTF-8")); |
|||
return converter; |
|||
} |
|||
|
|||
@Bean |
|||
public HttpMessageConverter<Object> responseJsonConverter(){ |
|||
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); |
|||
List<MediaType> mediaTypeList = new ArrayList<>(); |
|||
mediaTypeList.add(MediaType.TEXT_HTML); |
|||
mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8); |
|||
converter.setSupportedMediaTypes(mediaTypeList); |
|||
|
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
SimpleModule simpleModule = new SimpleModule(); |
|||
simpleModule.addSerializer(Long.class, ToStringSerializer.instance); |
|||
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); |
|||
objectMapper.registerModule(simpleModule); |
|||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
|||
converter.setObjectMapper(objectMapper); |
|||
|
|||
return converter; |
|||
} |
|||
|
|||
@Override |
|||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { |
|||
converters.add(responseStringConverter()); |
|||
converters.add(responseJsonConverter()); |
|||
} |
|||
|
|||
@Override |
|||
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { |
|||
configurer.favorPathExtension(false); |
|||
} |
|||
|
|||
/** |
|||
* 配置数据源(单数据源) |
|||
*/ |
|||
@Bean |
|||
public DataSource dataSource(){ |
|||
return druidPropsUtil.createDruidDataSource(); |
|||
} |
|||
|
|||
@Bean |
|||
public Snowflake snowflake(){ |
|||
return IdUtil.createSnowflake(Long.valueOf(workerId),Long.valueOf(datacenterId)); |
|||
} |
|||
|
|||
@Override |
|||
public void addResourceHandlers(ResourceHandlerRegistry registry) { |
|||
registry.addResourceHandler("/uploads/**") |
|||
.addResourceLocations("file:///home/cloud/ht/uploads/"); |
|||
} |
|||
} |
@ -1,56 +1,56 @@ |
|||
//package com.ccsens.common.config;
|
|||
//
|
|||
//import com.ccsens.util.WebConstant;
|
|||
//import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
|||
//import org.springframework.context.annotation.Bean;
|
|||
//import org.springframework.context.annotation.Configuration;
|
|||
//import springfox.documentation.builders.ParameterBuilder;
|
|||
//import springfox.documentation.builders.RequestHandlerSelectors;
|
|||
//import springfox.documentation.schema.ModelRef;
|
|||
//import springfox.documentation.service.ApiInfo;
|
|||
//import springfox.documentation.service.Parameter;
|
|||
//import springfox.documentation.spi.DocumentationType;
|
|||
//import springfox.documentation.spring.web.plugins.Docket;
|
|||
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|||
//
|
|||
//import java.util.ArrayList;
|
|||
//import java.util.List;
|
|||
//
|
|||
//@Configuration
|
|||
//@EnableSwagger2
|
|||
//@ConditionalOnExpression("${swagger.enable}")
|
|||
////public class SwaggerConfigure extends WebMvcConfigurationSupport {
|
|||
//public class SwaggerConfigure /*implements WebMvcConfigurer*/ {
|
|||
// @Bean
|
|||
// public Docket customDocket() {
|
|||
// //
|
|||
// return new Docket(DocumentationType.SWAGGER_2)
|
|||
// .apiInfo(apiInfo())
|
|||
// .select()
|
|||
// .apis(RequestHandlerSelectors
|
|||
// .basePackage("com.ccsens.common.api"))
|
|||
// .build()
|
|||
// .globalOperationParameters(setHeaderToken());
|
|||
// }
|
|||
//
|
|||
// private ApiInfo apiInfo() {
|
|||
// return new ApiInfo("Swagger Tall-ptpro",//大标题 title
|
|||
// "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",//小标题
|
|||
// "1.0.0",//版本
|
|||
// "http://swagger.io/terms/",//termsOfServiceUrl
|
|||
// "zhangsan",//作者
|
|||
// "Apache 2.0",//链接显示文字
|
|||
// "http://www.apache.org/licenses/LICENSE-2.0.html"//网站链接
|
|||
// );
|
|||
// }
|
|||
//
|
|||
// private List<Parameter> setHeaderToken() {
|
|||
// ParameterBuilder tokenPar = new ParameterBuilder();
|
|||
// List<Parameter> pars = new ArrayList<>();
|
|||
// tokenPar.name(WebConstant.HEADER_KEY_TOKEN).description("token")
|
|||
// .defaultValue(WebConstant.HEADER_KEY_TOKEN_PREFIX)
|
|||
// .modelRef(new ModelRef("string")).parameterType("header").required(false).build();
|
|||
// pars.add(tokenPar.build());
|
|||
// return pars;
|
|||
// }
|
|||
//}
|
|||
package com.ccsens.common.config; |
|||
|
|||
import com.ccsens.util.WebConstant; |
|||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import springfox.documentation.builders.ParameterBuilder; |
|||
import springfox.documentation.builders.RequestHandlerSelectors; |
|||
import springfox.documentation.schema.ModelRef; |
|||
import springfox.documentation.service.ApiInfo; |
|||
import springfox.documentation.service.Parameter; |
|||
import springfox.documentation.spi.DocumentationType; |
|||
import springfox.documentation.spring.web.plugins.Docket; |
|||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
@Configuration |
|||
@EnableSwagger2 |
|||
@ConditionalOnExpression("${swagger.enable}") |
|||
//public class SwaggerConfigure extends WebMvcConfigurationSupport {
|
|||
public class SwaggerConfigure /*implements WebMvcConfigurer*/ { |
|||
@Bean |
|||
public Docket customDocket() { |
|||
//
|
|||
return new Docket(DocumentationType.SWAGGER_2) |
|||
.apiInfo(apiInfo()) |
|||
.select() |
|||
.apis(RequestHandlerSelectors |
|||
.basePackage("com.ccsens.common.api")) |
|||
.build() |
|||
.globalOperationParameters(setHeaderToken()); |
|||
} |
|||
|
|||
private ApiInfo apiInfo() { |
|||
return new ApiInfo("Swagger Tall-ptpro",//大标题 title
|
|||
"This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",//小标题
|
|||
"1.0.0",//版本
|
|||
"http://swagger.io/terms/",//termsOfServiceUrl
|
|||
"zhangsan",//作者
|
|||
"Apache 2.0",//链接显示文字
|
|||
"http://www.apache.org/licenses/LICENSE-2.0.html"//网站链接
|
|||
); |
|||
} |
|||
|
|||
private List<Parameter> setHeaderToken() { |
|||
ParameterBuilder tokenPar = new ParameterBuilder(); |
|||
List<Parameter> pars = new ArrayList<>(); |
|||
tokenPar.name(WebConstant.HEADER_KEY_TOKEN).description("token") |
|||
.defaultValue(WebConstant.HEADER_KEY_TOKEN_PREFIX) |
|||
.modelRef(new ModelRef("string")).parameterType("header").required(false).build(); |
|||
pars.add(tokenPar.build()); |
|||
return pars; |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue