Commit 6aff576f by 陶光胜

init

parents
# maven ignore
target/
*.jar
!.mvn/wrapper/*
*.war
*.zip
*.tar
*.tar.gz
.flattened-pom.xml
# eclipse ignore
.settings/
.project
.classpath
# idea ignore
.idea/
*.ipr
*.iml
*.iws
# temp ignore
*.log
*.cache
*.diff
*.patch
*.tmp
dubbo.cache*
# system ignore
.DS_Store
Thumbs.db
*.orig
<?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">
<parent>
<artifactId>gic-pom-base</artifactId>
<groupId>com.gic</groupId>
<version>4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gic-platform-auth-api</artifactId>
<version>${libraryVersion}</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<libraryVersion>4.0-SNAPSHOT</libraryVersion>
</properties>
<dependencies>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-base-api</artifactId>
<version>${gic-base-api}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-enterprise-base-api</artifactId>
<version>${gic-enterprise-base-api}</version>
</dependency>
<!--参数验证-->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.16.Final</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b09</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<flattenMode>defaults</flattenMode>
</configuration>
<executions>
<!-- enable flattening -->
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<!-- ensure proper cleanup -->
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package com.gic.auth.constant;
/**
* @author zhiwj
* @date 2019/7/4
*/
public interface Constants {
String STORE_BATCH_IMPORT_MQ_KEY = "storeBulkImport";
// String STORE_BATCH_IMPORT_MQ_KEY = "tmpStoreBatchImportTaskMq4.0";
Integer STORE_BATCH_IMPORT_TASK_TYPE = 6;
String dateformat = "YYYY-MM-dd HH:mm:ss";
}
package com.gic.auth.dto;
import java.io.Serializable;
import java.util.Date;
/**
* tab_city
*/
public class CityDTO implements Serializable {
/**
* 城市id
*/
private String cityId;
/**
* 城市名称
*/
private String cityName;
/**
* 省份id
*/
private String provinceId;
/**
* 城市拼音
*/
private String cityPy;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public String getCityId() {
return cityId;
}
public void setCityId(String cityId) {
this.cityId = cityId;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public String getProvinceId() {
return provinceId;
}
public void setProvinceId(String provinceId) {
this.provinceId = provinceId;
}
public String getCityPy() {
return cityPy;
}
public void setCityPy(String cityPy) {
this.cityPy = cityPy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
package com.gic.auth.exception;
/**
* @author guojx
* @date 2019/6/26 2:03 PM
*/
public class StoreException extends RuntimeException{
private String errorCode;
public StoreException(String errorCode, String message) {
super(message);
this.errorCode = errorCode;
}
public String getErrorCode() {
return errorCode;
}
}
package com.gic.auth.service;
import com.gic.api.base.commons.ServiceResponse;
import java.util.List;
public interface ProvincesApiService {
}
package com.gic.auth.utils;
/**
* @author zhiwj
* @date 2019/6/26
*/
public enum MoveType {
// 排序类型
MOVE_UP(1, "上移"),
MOVE_DOWN(2, "下移"),
TOPPING(3, "置顶"),
BOTTOM(4, "置底");
private Integer code;
private String description;
MoveType(Integer code, String description) {
this.code = code;
this.description = description;
}
public Integer getCode() {
return code;
}
public String getDescription() {
return description;
}
}
package com.gic;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* Unit test for simple App.
*/
public class AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}
<?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">
<parent>
<groupId>com.gic</groupId>
<artifactId>gic-pom-base</artifactId>
<version>4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gic-platform-auth-service</artifactId>
<version>${libraryVersion}</version>
<name>${project.artifactId}</name>
<url>http://www.demogic.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<libraryVersion>4.0-SNAPSHOT</libraryVersion>
<gic-sharding-sdk>3.1-SNAPSHOT</gic-sharding-sdk>
<!-- api依赖,正式版会在 gic-pom-base 里生成 -->
<gic-store-api>4.0-SNAPSHOT</gic-store-api>
<gic-redis-data>4.0-SNAPSHOT</gic-redis-data>
<gic-bizdict-api>4.0.0-SNAPSHOT</gic-bizdict-api>
</properties>
<dependencies>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-commons</artifactId>
<version>${gic-commons}</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<artifactId>dubbo</artifactId>
<groupId>com.alibaba</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-platform-config</artifactId>
<version>${gic-platform-config}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-sharding-sdk</artifactId>
<version>${gic-sharding-sdk}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.9</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-store-api</artifactId>
<version>${gic-store-api}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.1.7.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.gic </groupId>
<artifactId>gic-redis-data </artifactId>
<version>${gic-redis-data} </version>
</dependency>
<dependency>
<groupId>com.gic.bizdict</groupId>
<artifactId>gic-bizdict-api</artifactId>
<version>${gic-bizdict-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-enterprise-base-api</artifactId>
<version>${gic-enterprise-base-api}</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classesDirectory>target/classes/</classesDirectory>
<archive>
<manifest>
<mainClass>com.gic.commons.DubboMain</mainClass>
<!-- 打包时 MANIFEST.MF文件不记录的时间戳版本 -->
<useUniqueVersions>false</useUniqueVersions>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<type>jar</type>
<includeTypes>jar</includeTypes>
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.gic.enterprise.dao.mapper;
import com.gic.store.entity.TabCity;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TabCityMapper {
/**
* 根据主键删除
*
* @param cityId 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(String cityId);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabCity record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabCity record);
/**
* 根据主键查询
*
* @param cityId 主键
* @return 实体对象
*/
TabCity selectByPrimaryKey(String cityId);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabCity record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabCity record);
/**
* 查询所有城市
* @return
*/
List<TabCity> selectAllCity();
List<TabCity> queryCity(@Param("search")String search);
}
\ No newline at end of file
package com.gic.enterprise.entity;
import java.util.Date;
/**
* tab_city
*/
public class TabCity {
/**
* 城市id
*/
private String cityId;
/**
* 城市名称
*/
private String cityName;
/**
* 省份id
*/
private String provinceId;
/**
* 城市拼音
*/
private String cityPy;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public String getCityId() {
return cityId;
}
public void setCityId(String cityId) {
this.cityId = cityId;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public String getProvinceId() {
return provinceId;
}
public void setProvinceId(String provinceId) {
this.provinceId = provinceId;
}
public String getCityPy() {
return cityPy;
}
public void setCityPy(String cityPy) {
this.cityPy = cityPy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
package com.gic.enterprise.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("provincesService")
public class ProvincesServiceImpl {
}
package com.gic.enterprise.service.outer;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Service("provincesApiService")
public class ProvincesApiServiceImpl {
}
package com.gic.enterprise.utils;
import com.gic.log.api.dto.SystemSetLogDTO;
import com.gic.log.api.service.LogApiService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.beans.PropertyDescriptor;
import java.util.Date;
/**
* @author zhiwj
* @date 2019/7/10
*/
@Component
public class LogUtils {
private static LogApiService logApiService;
public static <T> void saveAddLog(T obj) {
saveLog(obj, 1);
}
public static <T> void saveUpdateLog(T obj) {
saveLog(obj, 2);
}
@Autowired
public void setLogApiService(LogApiService logApiService) {
LogUtils.logApiService = logApiService;
}
public static <T> void saveLog(T obj, Integer type) {
// 日志
SystemSetLogDTO systemSetLogDTO = new SystemSetLogDTO();
// systemSetLogDTO.setEnterpriesId(storeBrandDTO.getEnterpriseId() + "");
systemSetLogDTO.setLogTime(new Date());
// systemSetLogDTO.setInterfaceName("com.gic.store.service.StoreBrandApiService.saveOrUpdateStoreBrand");
StringBuilder content = new StringBuilder();
getContent(obj, type, content);
systemSetLogDTO.setContent(content.toString());
// System.out.println(systemSetLogDTO.getContent());
logApiService.saveSystemSetLog(systemSetLogDTO);
}
private static <T> void getContent(T obj, Integer type, StringBuilder content) {
final BeanWrapper dtoBean = new BeanWrapperImpl(obj);
PropertyDescriptor[] pds = dtoBean.getPropertyDescriptors();
for (PropertyDescriptor pd : pds) {
String name = PropertyNameMap.get(pd.getName());
if (StringUtils.isNotBlank(name)) {
Object value = dtoBean.getPropertyValue(pd.getName());
if (value != null) {
if (value instanceof Iterable) {
for (Object o : (Iterable) value) {
getContent(o, type, content);
}
} else {
if (type == 1) {
content.append(name).append(" 新增 ").append(value).append("<br/>");
} else if (type == 2) {
content.append(name).append(" 修改为 ").append(value).append("<br/>");
}
}
}
}
}
}
}
package com.gic.enterprise.utils;
import java.util.HashMap;
import java.util.Map;
/**
* @author zhiwj
* @date 2019/7/11
*/
public class PropertyNameMap {
/**
* 暂时放这里测试下, 以后移到enterprise_base_api里去
*/
private static final Map<String, String> map = new HashMap<>();
static {
map.put("regionName", "门店域名称");
map.put("regionCode", "门店域code");
map.put("storeBrandCode", "品牌code");
map.put("storeBrandName", "品牌名称");
map.put("storeBrandCategory", "经营类目");
map.put("storeSupport", "门店适用");
map.put("goodsSupport", "商品适用");
map.put("storeName", "门店名称");
map.put("conactsPhone", "门店电话");
map.put("address", "门店详细地址");
map.put("brandIds", "关联门店品牌id,多个用逗号分隔");
map.put("longitude", "经度");
map.put("latitude", "纬度");
// map.put("status", "门店启用状态");
map.put("erpStatus", "erp门店状态");
map.put("storeType", "门店类型");
map.put("weekday", "营业时间");
map.put("businessTimeList", "营业时间");
}
private PropertyNameMap() {
}
public static String get(String name) {
return map.get(name);
}
}
package com.gic.enterprise.utils.log;
import com.gic.store.utils.LogUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
/**
* @author guojx
* @date 2019/7/12 10:26 AM
*/
@Aspect
public class LogAspect {
private static final Logger logger = LoggerFactory.getLogger(LogAspect.class);
@Pointcut("execution(* com.gic.store.service.outer.*.save*(..))")
public void saveCell() {
}
@Pointcut("execution(public * com.gic.store.service.outer.*.edit*(..))")
public void updateCell() {
}
@Pointcut("execution(* com.gic.store.service.outer.*.delete*(..))")
public void deleteCell() {
}
@AfterReturning(value = "saveCell()", argNames = "joinPoint,object", returning = "object")
public void saveLog(JoinPoint joinPoint, Object object) {
if (joinPoint.getArgs() == null) {
return;
}
String methodName = joinPoint.getSignature().getName();
String operContent = "";
logger.info("aspectLog:{}", joinPoint.getArgs());
LogUtils.saveAddLog(arrToList(joinPoint.getArgs()));
}
@AfterReturning(value = "updateCell()", argNames = "joinPoint,object", returning = "object")
public void updateLog(JoinPoint joinPoint, Object object) {
if (joinPoint.getArgs() == null) {
return;
}
String methodName = joinPoint.getSignature().getName();
String operContent = "";
logger.info("aspectLog:{}", joinPoint.getArgs());
LogUtils.saveUpdateLog(arrToList(joinPoint.getArgs()));
}
private List<Object> arrToList(Object[] args) {
List<Object> resultList = new ArrayList<>(args.length);
for (Object obj : args) {
resultList.add(obj);
}
return resultList;
}
}
custom=com.gic.store.utils.custom.CustomValidation
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<import resource="classpath:applicationContext-init.xml"/>
<import resource="classpath:dubbo-gic-platform-auth-service.xml"/>
<import resource="classpath*:dubbo-setting.xml"/>
<import resource="classpath:jdbc-gic-platform-auth-service.xml"/>
<import resource="classpath*:redis-init.xml" />
</beans>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<context:component-scan base-package="com.gic.enterprise.*"/>
<!-- 应用名称 -->
<dubbo:application name="gic-platform-auth-service"/>
<dubbo:protocol name="dubbo" port="20320"/>
<!--门店域-->
<dubbo:service interface="com.gic.store.service.StoreRegionApiService" ref="storeRegionApiService" timeout="60000" />
<!--门店品牌-->
<dubbo:service interface="com.gic.store.service.StoreBrandApiService" ref="storeBrandApiService" timeout="60000" />
<dubbo:service interface="com.gic.store.service.StoreDictApiService" ref="storeDictApiService" timeout="6000" />
<dubbo:reference interface="com.gic.bizdict.api.service.BizdictService" id="bizdictService " timeout="6000" retries="0"/>
<!--分组-->
<dubbo:service interface="com.gic.store.service.StoreGroupApiService" ref="storeGroupApiService" timeout="60000" />
<!--自定义域字段-->
<dubbo:service interface="com.gic.store.service.StoreFieldApiService" ref="storeFieldApiService" timeout="60000" />
<dubbo:service interface="com.gic.store.service.StoreFieldSelectApiService" ref="storeFieldSelectApiService" timeout="60000" />
<!--门店-->
<dubbo:service interface="com.gic.store.service.StoreApiService" ref="storeApiService" timeout="60000" />
<dubbo:service interface="com.gic.store.service.ProvincesApiService" ref="provincesApiService" timeout="60000" />
<!--分组策略-->
<dubbo:service interface="com.gic.store.service.StoreStrategyApiService" ref="storeStrategyApiService" timeout="60000"/>
<!--门店导入-->
<dubbo:service interface="com.gic.store.service.StoreImportApiService" ref="storeImportApiService" timeout="60000" />
<dubbo:service interface="com.gic.store.service.StoreTaskApiService" ref="storeTaskApiService" timeout="60000" />
<dubbo:service interface="com.gic.store.service.StoreStatusSettingApiService" ref="storeStatusSettingApiService" timeout="60000" />
<dubbo:reference interface="com.gic.log.api.service.LogApiService" id="logApiService" timeout="60000" />
</beans>
dubbo.registry.file=gic-platform-auth-service
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:apollo="http://www.ctrip.com/schema/apollo"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.ctrip.com/schema/apollo
http://www.ctrip.com/schema/apollo.xsd">
<context:annotation-config/>
<!-- 启动对@AspectJ注解的支持 -->
<aop:aspectj-autoproxy />
<bean class="com.gic.store.utils.log.LogAspect"></bean>
<!--<apollo:config namespaces="COMMON.sharding,COMMON.4.0-jdbc"/>-->
<!--<bean id="dataSource" class="com.gic.sharding.sdk.ShardingDatasource" init-method="init">-->
<!--<property name="shardingId" value="${sharding.shardingId}"/>-->
<!--<property name="maxSize" value="${jdbc.maxsize}"/>-->
<!--<property name="urlType" value="${sharding.urlType:inner}"/>-->
<!--</bean>-->
<import resource="classpath:applicationContext-db-only.xml"/>
<bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlSessionFactory">
<property name="dataSource" ref="dataSource"/>
<property name="typeAliasesPackage" value="com.gic.auth.**.entity"/>
<property name="mapperLocations" value="classpath*:mapper/*.xml"/>
<property name="plugins">
<array>
<!-- 自动生成id -->
<bean class="com.gic.commons.plugin.mybatis.AutoIdInterceptor"/>
<!-- 分页插件 -->
<bean class="com.github.pagehelper.PageInterceptor">
<property name="properties">
<value>
helperDialect=mysql
</value>
</property>
</bean>
</array>
</property>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.gic.auth.**.dao.mapper"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
<bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- 事务管理器 -->
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:annotation-driven transaction-manager="txManager"/>
</beans>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="error" packages="com.gic.commons.log">
<appenders>
<!--这个输出控制台的配置-->
<Console name="Console" target="SYSTEM_OUT">
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
<ThresholdFilter level="trace" onMatch="ACCEPT" onMismatch="DENY" />
<!--这个都知道是输出日志的格式-->
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c:%L] [%traceId] %m%n" />
</Console>
</appenders>
<loggers>
<!--建立一个默认的root的logger-->
<Logger name="com.gic" level="DEBUG"/>
<Logger name="org.springframework" level="INFO"/>
<logger name="Sharding-JDBC-SQL" level="INFO"/>
<logger name="org.hibernate.SQL" level="DEBUG"/>
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="DEBUG"/>
<Root level="WARN">
<!--<Root level="DEBUG">-->
<AppenderRef ref="Console" />
</Root>
</loggers>
</configuration>
CREATE TABLE `tab_gic_demo_enterprise`
(
`enterprise_id` char(32) NOT NULL COMMENT '企业id',
`enterprise_name` varchar(50) NOT NULL COMMENT '企业名称',
`enterprise_code` varchar(20) DEFAULT NULL COMMENT '企业编码',
`brand_name` varchar(30) DEFAULT NULL COMMENT '品牌名称',
`logo_url` varchar(256) DEFAULT NULL COMMENT 'LOGO_url地址',
`enterprise_description` varchar(256) DEFAULT NULL COMMENT '企业简介',
`license_number` varchar(50) DEFAULT NULL COMMENT '营业执照注册号',
`country_id` varchar(10) DEFAULT NULL COMMENT '国家',
`province_id` varchar(10) DEFAULT NULL COMMENT '省',
`city_id` varchar(10) DEFAULT NULL COMMENT '市',
`area_id` varchar(10) DEFAULT NULL COMMENT '县/区',
`register_address` varchar(256) DEFAULT NULL COMMENT '详细地址',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`status` int(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(0:已删除,1:正常 )',
PRIMARY KEY (`enterprise_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8 COMMENT ='企业表';
CREATE TABLE `tab_gic_demo_store`
(
`store_id` char(32) NOT NULL COMMENT '门店id',
`enterprise_id` char(32) DEFAULT NULL COMMENT '企业id',
`store_name` varchar(32) NOT NULL COMMENT '门店名称',
`post_address` varchar(256) DEFAULT NULL COMMENT '详细地址',
`status` int(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(0:待审核,1:正常,2:审核失败,3:停业整顿 ,4:回收站 ,5:删除)',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`store_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8 COMMENT ='门店表';
CREATE TABLE tab_gic_demo_store_test like tab_gic_demo_store;
DROP PROCEDURE IF EXISTS copyTable;
CREATE PROCEDURE copyTable(in tableName varchar(64), in beginNum int, in endNum int)
BEGIN
DECLARE i INT;
SET i = beginNum;
WHILE i <= endNum DO
SET @sql = CONCAT('CREATE TABLE ', tableName, '_', i, ' like ', tableName);
PREPARE create_stmt FROM @sql;
EXECUTE create_stmt;
SET i = i + 1;
END WHILE;
END;
call copyTable('tab_gic_demo_store', 0, 9);
{
"_id": "gic_demo_dev",
"datagroupConfigList": [
{
"datagroupName": "ds_0",
"defaultSource": true,
"enterpriseIds": [ ],
"masterDatasource": {
"database": "test",
"databaseId": "db_dev",
"datasourceName": "sharding_0"
},
"slaveDatasources": [ ]
}
],
"tableConfigs": [
{
"dbTable": "tab_gic_demo_store_",
"logicTable": "tab_gic_demo_store",
"shardingColumn": "store_id",
"shardingType": 3,
"shardingValue": "10"
}
],
"tableList": [
"tab_gic_demo_store"
]
}
<?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">
<parent>
<groupId>com.gic</groupId>
<artifactId>gic-pom-base</artifactId>
<version>4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gic-platform-auth-web</artifactId>
<version>${libraryVersion}</version>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<url>http://www.demogic.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<libraryVersion>4.0-SNAPSHOT</libraryVersion>
<!-- api依赖,正式版会在 gic-pom-base 里生成 -->
<gic-store-api>4.0-SNAPSHOT</gic-store-api>
<gic-redis-data>4.0-SNAPSHOT</gic-redis-data>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-commons</artifactId>
<version>${gic-commons}</version>
<exclusions>
<exclusion>
<artifactId>dubbo</artifactId>
<groupId>com.alibaba</groupId>
</exclusion>
<exclusion>
<artifactId>logback-core</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
<exclusion>
<artifactId>spring-data-redis</artifactId>
<groupId>org.springframework.data</groupId>
</exclusion>
<exclusion>
<artifactId>servlet-api</artifactId>
<groupId>javax.servlet</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.23.2-GA</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-platform-config</artifactId>
<version>${gic-platform-config}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-store-api</artifactId>
<version>${gic-store-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-enterprise-common</artifactId>
<version>${gic-enterprise-common}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-enterprise-base-api</artifactId>
<version>${gic-enterprise-base-api}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.5.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.9</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.23</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>com.gic </groupId>
<artifactId>gic-redis-data </artifactId>
<version>${gic-redis-data} </version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.5.RELEASE</version>
<configuration>
<mainClass>com.gic.auth.web.Main</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.gic.enterprise.web;
import com.gic.dubbo.util.DubboContextUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ImportResource;
/**
* Spring Boot Web 启动类
*
* @author zhurz
*/
@SpringBootApplication(
scanBasePackages = "com.gic",
exclude = {
RedisAutoConfiguration.class,
RedisRepositoriesAutoConfiguration.class,
QuartzAutoConfiguration.class
}
)
@ImportResource(value = {
"classpath*:applicationContext-init.xml",
"classpath*:dubbo-setting.xml",
"classpath*:dubbo-gic-platform-enterprise-web.xml",
"classpath*:spring-interceptor.xml",
"classpath*:redis-init.xml"
})
public class Main {
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(Main.class, args);
DubboContextUtil.setApplicationContext(context);
}
}
\ No newline at end of file
package com.gic.auth.web.controller;
import org.springframework.web.bind.annotation.RestController;
/**
* @author zhiwj
* @date 2019/6/27
*/
@RestController
public class StoreBrandController {
}
package com.gic.auth.web.exception;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.store.constant.StoreGroupErrorEnum;
import com.gic.store.exception.StoreException;
import com.gic.store.exception.StoreGroupException;
import com.gic.store.utils.ErrorCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindException;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Set;
/**
* 全局异常处理类
*
* @author hua
*/
@ControllerAdvice
public class GlobalExceptionHandler {
private static Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
@ResponseBody
@ExceptionHandler(Exception.class)
public RestResponse controllerException(HttpServletResponse response, Exception ex) {
logger.error("err", ex);
RestResponse failureResponse = getRestResponse(ErrorCode.ERR_3.getCode(), ErrorCode.ERR_3.getMsg());
StringBuilder sb = new StringBuilder();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (PrintWriter printWriter = new PrintWriter(baos)) {
ex.printStackTrace(printWriter);
}
try {
sb.append(baos.toString());
} catch (Exception ignored) {
}
if (sb.length() == 0) {
sb.append(ex.getMessage());
}
// 输出详细错误信息,便于调试
failureResponse.setDetailError(sb.toString());
return failureResponse;
}
/**
* 参数校验异常统一处理
* @param e
* @return
*/
@ResponseBody
@ExceptionHandler(BindException.class)
public RestResponse customException(BindException e) {
List<FieldError> fieldErrors = e.getFieldErrors();
StringBuilder errorMessage = new StringBuilder();
fieldErrors.forEach(fieldError -> {
errorMessage
.append(fieldError.getDefaultMessage())
.append(",");
});
return getRestResponse(StoreGroupErrorEnum.Error.getCode(), errorMessage.toString());
}
@ResponseBody
@ExceptionHandler(ConstraintViolationException.class)
public RestResponse constraintViolationException(ConstraintViolationException e) {
Set<ConstraintViolation<?>> constraintViolations = e.getConstraintViolations();
String paramName = constraintViolations.iterator().next().getPropertyPath().toString();
String paramError = constraintViolations.iterator().next().getMessage();
return getRestResponse(com.gic.enterprise.error.ErrorCode.ERR_5.getCode(), getFailFastMsg(paramName, paramError));
}
/**
* 自定义异常统一处理
* @param e
* @return
*/
@ResponseBody
@ExceptionHandler(StoreGroupException.class)
public RestResponse customException(StoreGroupException e) {
return getRestResponse(e.getErrorCode(), e.getMessage());
}
@ResponseBody
@ExceptionHandler(StoreException.class)
public RestResponse customException(StoreException e) {
return getRestResponse(e.getErrorCode(), e.getMessage());
}
private RestResponse getRestResponse(String errorCode, String message) {
return RestResponse.failure(errorCode, message);
}
private static String getFailFastMsg(String paramName, String paramError) {
return String.format("%s:%s", paramName, paramError);
}
}
package com.gic.auth.web.qo;
import java.io.Serializable;
/**
* 分页查询
*
* @author zhurz
*/
public class PageQO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 页码
*/
private Integer currentPage=1;
/**
* 分页大小
*/
private Integer pageSize=20;
public Integer getCurrentPage() {
return currentPage;
}
public void setCurrentPage(Integer currentPage) {
this.currentPage = currentPage;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}
package com.gic.auth.web.vo;
import java.io.Serializable;
import java.util.Date;
/**
* tab_store_dict
*/
public class StoreDictVO implements Serializable {
private String value;
private String key;
private Integer checked=0;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public Integer getChecked() {
return checked;
}
public void setChecked(Integer checked) {
this.checked = checked;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}
\ No newline at end of file
server:
port: 8330
servlet:
context-path: /gic-auth-web
tomcat:
uri-encoding: UTF-8
spring:
jackson:
serialization:
# 以时间戳返回日期
write-dates-as-timestamps: true
http:
encoding:
charset: UTF-8
enabled: true
force: true
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<context:component-scan base-package="com.gic.auth"/>
<!-- 应用名称 -->
<dubbo:application name="gic-platform-auth-web"/>
<dubbo:reference interface="com.gic.store.service.StoreRegionApiService" id="storeRegionApiService" timeout="6000" retries="0"/>
<dubbo:reference interface="com.gic.store.service.StoreBrandApiService" id="storeBrandApiService" timeout="60000" retries="0"/>
<dubbo:reference interface="com.gic.store.service.StoreDictApiService" id="storeDictApiService" timeout="6000" retries="0"/>
<!--分组服务-->
<dubbo:reference interface="com.gic.store.service.StoreGroupApiService" id="storeGroupApiService" timeout="60000" retries="0"/>
<!--自定义域字段-->
<dubbo:reference interface="com.gic.store.service.StoreFieldApiService" id="storeFieldApiService" timeout="60000" retries="0"/>
<dubbo:reference interface="com.gic.store.service.StoreFieldSelectApiService" id="storeFieldSelectApiService" timeout="60000" retries="0"/>
<!--门店-->
<dubbo:reference interface="com.gic.store.service.StoreApiService" id="storeApiService" timeout="60000" retries="0"/>
<!--分组策略-->
<dubbo:reference interface="com.gic.store.service.StoreStrategyApiService" id="storeStrategyApiService" timeout="60000" retries="0"/>
<!--门店导入-->
<dubbo:reference interface="com.gic.store.service.StoreImportApiService" id="storeImportApiService" timeout="60000" />
<dubbo:reference interface="com.gic.store.service.ProvincesApiService" id="provincesApiService" timeout="60000" />
<dubbo:reference interface="com.gic.store.service.StoreStatusSettingApiService" id="storeStatusSettingApiService" timeout="60000" />
<dubbo:reference interface="com.gic.log.api.service.LogApiService" id="logApiService" timeout="60000" />
</beans>
\ No newline at end of file
dubbo.registry.file=gic-platform-auth-web
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<mvc:interceptors>
<bean class="com.gic.commons.interceptor.HeaderTagInterceptor"/>
</mvc:interceptors>
</beans>
\ No newline at end of file
<?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.gic</groupId>
<artifactId>gic-platform-auth</artifactId>
<packaging>pom</packaging>
<version>4.0-SNAPSHOT</version>
<modules>
<module>gic-platform-auth-api</module>
<module>gic-platform-auth-service</module>
<module>gic-platform-auth-web</module>
</modules>
</project>
\ 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