Commit 0a91060e authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/base-modify' into base-modify

parents 6bc61b2d 41fd4a7a
......@@ -41,7 +41,7 @@
<module>xx-third-party</module>
<module>xx-third-party-api</module>
<module>vehicle</module>
<!-- <module>application</module>-->
<module>xx-app</module>
<module>xx-common</module>
<module>xx-order</module>
<module>xx-vehicle</module>
......
......@@ -9,12 +9,12 @@
</parent>
<groupId>com.xxfc.platform</groupId>
<modules>
<module>app-api</module>
<module>app-server</module>
<module>xx-app-api</module>
<module>xx-app-server</module>
</modules>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<artifactId>app</artifactId>
<artifactId>xx-app</artifactId>
</project>
\ No newline at end of file
......@@ -9,6 +9,6 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxfc.platform</groupId>
<artifactId>app-api</artifactId>
<artifactId>xx-app-api</artifactId>
</project>
\ No newline at end of file
package com.xxfc.platform.app.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 系统配置表
*
* @author zjw
* @email nishijjo@qq.com
* @date 2019-06-03 15:57:13
*/
@Data
@Table(name = "cofig")
public class Cofig implements Serializable {
private static final long serialVersionUID = 1L;
//主键id
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键id")
private Integer id;
//1-租车须知;2-预定须知
@Column(name = "type")
@ApiModelProperty(value = "1-租车须知;2-预定须知")
private Integer type;
//
@Column(name = "value")
@ApiModelProperty(value = "")
private String value;
//创建时间
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Long crtTime;
//更新时间
@Column(name = "upd_time")
@ApiModelProperty(value = "更新时间", hidden = true )
private Long updTime;
//是否删除;0-1正常;1-删除
@Column(name = "is_del")
@ApiModelProperty(value = "是否删除;0-1正常;1-删除")
private Integer isDel;
}
package com.xxfc.platform.app.feign;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.app.entity.Cofig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
* Created by ace on 2017/9/15.
*/
//@FeignClient(value = "${auth.serviceId}",configuration = {})
@FeignClient("xx-app")
public interface ConfigFeign {
@RequestMapping(value = "/cofig/types/{types}",method = RequestMethod.GET)
public ObjectRestResponse<Cofig> getAllByType(String types);
}
......@@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>app-server</artifactId>
<artifactId>xx-app-server</artifactId>
<properties>
<mapper.version>3.4.0</mapper.version>
......@@ -19,7 +19,7 @@
<!-- 自己项目 -->
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>app-api</artifactId>
<artifactId>xx-app-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
......
......@@ -16,8 +16,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableAceAuthClient
@EnableFeignClients({"com.github.wxiaoqi.security.auth.client.feign", "com.xxfc.platform.app.feign"})
@EnableAceCache
@MapperScan("com.xxfc.platform.app.mapper")
@EnableSwagger2Doc
@tk.mybatis.spring.annotation.MapperScan(basePackages = "com.xxfc.platform.app.mapper")
public class AppApplication {
public static void main(String[] args) {
......
package com.xxfc.platform.app.biz;
import org.springframework.stereotype.Service;
import com.xxfc.platform.app.entity.Cofig;
import com.xxfc.platform.app.mapper.CofigMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import java.util.List;
/**
* 系统配置表
*
* @author zjw
* @email nishijjo@qq.com
* @date 2019-06-03 15:57:13
*/
@Service
public class CofigBiz extends BaseBiz<CofigMapper,Cofig> {
public List<Cofig> getConfigByType(List<Integer> list){
return mapper.getAllByType(list);
}
}
\ No newline at end of file
package com.xxfc.platform.app.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* ${DESCRIPTION}
*
* @author wanghaobin
* @create 2017-06-21 8:39
*/
@Configuration
@Primary
public class RedisConfiguration {
@Bean
public RedisTemplate<String, Object> customRedisTemplate(RedisConnectionFactory factory) {
RedisTemplate redisTemplate = new RedisTemplate();
redisTemplate.setConnectionFactory(factory);
RedisSerializer<String> stringSerializer = new StringRedisSerializer();
redisTemplate.setKeySerializer(stringSerializer);
redisTemplate.setValueSerializer(stringSerializer);
redisTemplate.setHashKeySerializer(stringSerializer);
redisTemplate.setHashValueSerializer(stringSerializer);
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
}
package com.xxfc.platform.app.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestConfiguration {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
}
package com.xxfc.platform.app.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
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;
/**
* @Description : swagger配置配置
* @Author : Mars
* @Date : 2017年9月6日
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
/**
* Every Docket bean is picked up by the swagger-mvc framework - allowing for multiple
* swagger groups i.e. same code base multiple swagger resource listings.
*/
@Bean
public Docket customDocket(){
ParameterBuilder ticketPar = new ParameterBuilder();
List<Parameter> pars = new ArrayList<Parameter>();
ticketPar.name("Authorization").description("user Authorization")
.modelRef(new ModelRef("string")).parameterType("header")
.required(false).build(); //header中的ticket参数非必填,传空也可以
pars.add(ticketPar.build()); //根据每个方法名也知道当前方法在设置什么参数
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.xxfc.platform.app"))
//.apis(RequestHandlerSelectors.any())
.build()
.globalOperationParameters(pars)
.apiInfo(apiInfo());
}
ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("api swagger document")
.description("前后端联调swagger api 文档")
.version("2.1.5.5")
.build();
}
}
\ No newline at end of file
package com.xxfc.platform.app.config;
import com.github.wxiaoqi.security.auth.client.interceptor.ServiceAuthRestInterceptor;
import com.github.wxiaoqi.security.auth.client.interceptor.UserAuthRestInterceptor;
import com.github.wxiaoqi.security.common.handler.GlobalExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.ArrayList;
import java.util.Collections;
@Configuration("appWebConfig")
@Primary
public class WebConfiguration implements WebMvcConfigurer {
@Bean
GlobalExceptionHandler getGlobalExceptionHandler() {
return new GlobalExceptionHandler();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(getServiceAuthRestInterceptor()).
addPathPatterns(getIncludePathPatterns());
registry.addInterceptor(getUserAuthRestInterceptor()).
addPathPatterns(getIncludePathPatterns());
}
@Bean
ServiceAuthRestInterceptor getServiceAuthRestInterceptor() {
return new ServiceAuthRestInterceptor();
}
@Bean
UserAuthRestInterceptor getUserAuthRestInterceptor() {
return new UserAuthRestInterceptor();
}
/**
* 需要用户和服务认证判断的路径
* @return
*/
private ArrayList<String> getIncludePathPatterns() {
ArrayList<String> list = new ArrayList<>();
String[] urls = {
"/cofig/**"
};
Collections.addAll(list, urls);
return list;
}
}
package com.xxfc.platform.app.mapper;
import com.xxfc.platform.app.entity.Cofig;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* 系统配置表
*
* @author zjw
* @email nishijjo@qq.com
* @date 2019-06-03 15:57:13
*/
public interface CofigMapper extends Mapper<Cofig> {
public List<Cofig> getAllByType(@Param("typeList")List<Integer> list);
}
package com.xxfc.platform.app.rest;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.app.biz.CofigBiz;
import com.xxfc.platform.app.entity.Cofig;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("cofig")
@IgnoreClientToken
@Slf4j
public class CofigController extends BaseController<CofigBiz,Cofig> {
@RequestMapping(value ="/app/unauth/types",method = RequestMethod.GET)
@IgnoreUserToken
public ObjectRestResponse<List<Cofig>> getAllByType(@RequestParam(value = "types",defaultValue = "") String types){
if(StringUtils.isBlank(types)){
throw new BaseException(ResultCode.NULL_CODE);
}
String[] all=types.split(",");
List<Integer>list=new ArrayList<>();
for (String str:all){
if(StringUtils.isNotBlank(str)){
list.add(Integer.parseInt(str));
}
}
return new ObjectRestResponse<>().rel(true).data(baseBiz.getConfigByType(list));
}
}
\ No newline at end of file
#spring:
# application:
# name: vehicle
# cloud:
# nacos:
# config:
# server-addr: 127.0.0.1:8848
# file-extension: yaml
# profiles:
# active: dev
spring:
profiles:
active: dev
application:
name: xx-app
cloud:
nacos:
config:
file-extension: yaml
---
spring:
profiles: dev
cloud:
nacos:
config:
server-addr: 127.0.0.1:8848
---
spring:
profiles: pro
cloud:
nacos:
config:
server-addr: 10.5.52.2:8848
\ No newline at end of file
<?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="dev.properties"/>-->
<context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
<property name="beginningDelimiter" value="`"/>
<property name="endingDelimiter" value="`"/>
<property name="mergeable" value="false"></property>
<plugin type="tk.mybatis.mapper.generator.MapperPlugin">
<property name="mappers" value="tk.mybatis.mapper.common.Mapper"/>
</plugin>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/vehicle?useUnicode=true&amp;characterEncoding=UTF8"
userId="root"
password="xx2019fc">
</jdbcConnection>
<javaModelGenerator targetPackage="${targetModelPackage}" targetProject="${targetJavaProject}"/>
<sqlMapGenerator targetPackage="${targetXMLPackage}" targetProject="${targetResourcesProject}"/>
<javaClientGenerator targetPackage="${targetMapperPackage}" targetProject="${targetJavaProject}"
type="XMLMAPPER"/>
<!-- <table tableName="vehicle" domainObjectName="Vehicle">-->
<!-- </table>-->
<!-- <table tableName="vehicle_book_info" domainObjectName="VehicleBookInfo">-->
<!-- </table>-->
<!-- <table tableName="vehicle_book_record" domainObjectName="VehicleBookRecord">-->
<!-- </table>-->
<!-- <table tableName="branch_company" domainObjectName="BranchCompany">-->
<!-- </table>-->
<!-- <table tableName="branch_company_stock_info" domainObjectName="BranchCompanyStockInfo"></table>-->
<!-- <table tableName="branch_company_stock_apply_info" domainObjectName="BranchCompanyStockApplyInfo"></table>-->
<table tableName="vehicle_upkeep_item" domainObjectName="VehicleUpkeepItem"></table>
<table tableName="vehicle_upkeep_log" domainObjectName="VehicleUpkeepLog"></table>
</context>
</generatorConfiguration>
\ No newline at end of file
<?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.xxfc.platform.app.mapper.CofigMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.app.entity.Cofig" id="cofigMap">
<result property="id" column="id"/>
<result property="type" column="type"/>
<result property="value" column="value"/>
<result property="crtTime" column="crt_time"/>
<result property="updTime" column="upd_time"/>
<result property="isDel" column="is_del"/>
</resultMap>
<select id="getAllByType" resultMap="cofigMap">
select * from config
<where>
<if test="typeList!= null and typeList.size() > 0">
type IN
<foreach collection="typeList" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment