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.utils;
import com.gic.store.constant.Constants;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @author zhiwj
* @date 2019/7/2
*/
public class ExcelUtils {
private static final short ROW_HEIGHT = 500;
private static final int COLUMN_HEIGHT = 5000;
public static XSSFWorkbook getXSSFWorkbook(String sheetName, List<List<String>> everyLines, XSSFWorkbook wb) {
if (CollectionUtils.isEmpty(everyLines)) {
return null;
}
// 第一步,创建一个XSSFWorkbook,对应一个Excel文件
if (wb == null) {
wb = new XSSFWorkbook();
}
// 第二步,在workbook中添加一个sheet,对应Excel文件中的sheet
XSSFSheet sheet = wb.createSheet(sheetName);
sheet.setDefaultRowHeight(ROW_HEIGHT);
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制
XSSFRow row = sheet.createRow(0);
// 第四步,创建单元格,并设置值表头
XSSFCellStyle style = wb.createCellStyle();
XSSFFont font = wb.createFont();
font.setFontName("微软雅黑");
style.setFont(font);
//声明列对象
XSSFCell cell = null;
//创建标题
List<String> titles = everyLines.get(0);
for (int i = 0; i < titles.size(); i++) {
cell = row.createCell(i);
cell.setCellValue(titles.get(i));
cell.setCellStyle(style);
}
//创建内容
for (int i = 1; i < everyLines.size(); i++) {
row = sheet.createRow(i);
for (int j = 0; j < everyLines.get(i).size(); j++) {
sheet.setColumnWidth(j, COLUMN_HEIGHT);
//将内容按顺序赋给对应的列对象
XSSFCell cell1 = row.createCell(j);
cell1.setCellValue(everyLines.get(i).get(j));
cell1.setCellStyle(style);
}
}
return wb;
}
public static Workbook getWorkbook(String title, List<String> rowName, List<String> description, List<List<String>> dataList, String regionIdStr) {
XSSFWorkbook workbook = new XSSFWorkbook(); // 创建工作簿对象
XSSFSheet sheet = workbook.createSheet(title); // 创建工作表
XSSFRow row1 = sheet.createRow(0);
row1.setZeroHeight(true);
XSSFCell cell1 = row1.createCell(0);
if (StringUtils.isNotBlank(regionIdStr)) {
cell1.setCellValue(regionIdStr);
}
XSSFRow rowm = sheet.createRow(1); // 产生表格标题行
XSSFCell cellTiltle = rowm.createCell(0); //创建表格标题列
// sheet样式定义; getColumnTopStyle(); getStyle()均为自定义方法 --在下面,可扩展
XSSFCellStyle columnTopStyle = ExcelUtils.getColumnTopStyle(workbook);// 获取列头样式对象
XSSFCellStyle titleStyle = ExcelUtils.getTitleStyle(workbook);// 获取列头样式对象
XSSFCellStyle style = ExcelUtils.getStyle(workbook); // 获取单元格样式对象
//合并表格标题行,合并列数为列名的长度,第一个0为起始行号,第二个1为终止行号,第三个0为起始列好,第四个参数为终止列号
sheet.addMergedRegion(new CellRangeAddress(1, 2, 0, (rowName.size() - 1)));
cellTiltle.setCellStyle(columnTopStyle); //设置标题行样式
cellTiltle.setCellValue(title); //设置标题行值
int columnNum = rowName.size(); // 定义所需列数
XSSFRow rowRowName = sheet.createRow(3); // 在索引2的位置创建行(最顶端的行开始的第二行)
// 将列头设置到sheet的单元格中
for (int n = 0; n < columnNum; n++) {
XSSFCell cellRowName = rowRowName.createCell(n); // 创建列头对应个数的单元格
cellRowName.setCellType(XSSFCell.CELL_TYPE_STRING); // 设置列头单元格的数据类型
XSSFRichTextString text = new XSSFRichTextString(rowName.get(n));
cellRowName.setCellValue(text); // 设置列头单元格的值
cellRowName.setCellStyle(titleStyle); // 设置列头单元格样式
}
// 定义数据开始的行数
int dataLine = 4;
if (CollectionUtils.isNotEmpty(description)) {
int descriptionNum = description.size(); // 定义所需列数
XSSFRow descriptionRow = sheet.createRow(dataLine); // 在索引2的位置创建行(最顶端的行开始的第二行)
dataLine++;
for (int n = 0; n < descriptionNum; n++) {
XSSFCell cellRowName = descriptionRow.createCell(n); // 创建列头对应个数的单元格
cellRowName.setCellType(XSSFCell.CELL_TYPE_STRING); // 设置列头单元格的数据类型
XSSFRichTextString text = new XSSFRichTextString(description.get(n));
cellRowName.setCellValue(text); // 设置列头单元格的值
cellRowName.setCellStyle(titleStyle); // 设置列头单元格样式
}
}
// 将查询出的数据设置到sheet对应的单元格中
for (int i = 0; i < dataList.size(); i++) {
List<String> obj = dataList.get(i); // 遍历每个对象
XSSFRow row = sheet.createRow(i + dataLine); // 创建所需的行数
for (int j = 0; j < obj.size(); j++) {
XSSFCell cell = null; // 设置单元格的数据类型
if (j == 0) {
cell = row.createCell(j, XSSFCell.CELL_TYPE_NUMERIC);
cell.setCellValue(i + 1);
} else {
cell = row.createCell(j, XSSFCell.CELL_TYPE_STRING);
if (!"".equals(obj.get(j)) && obj.get(j) != null) {
cell.setCellValue(obj.get(j)); // 设置单元格的值
}
}
cell.setCellStyle(style); // 设置单元格样式
}
}
// 让列宽随着导出的列长自动适应
for (int colNum = 0; colNum < columnNum; colNum++) {
int columnWidth = sheet.getColumnWidth(colNum) / 256;
for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) {
XSSFRow currentRow;
// 当前行未被使用过
if (sheet.getRow(rowNum) == null) {
currentRow = sheet.createRow(rowNum);
} else {
currentRow = sheet.getRow(rowNum);
}
if (currentRow.getCell(colNum) != null) {
XSSFCell currentCell = currentRow.getCell(colNum);
if (currentCell.getCellType() == XSSFCell.CELL_TYPE_STRING) {
int length = currentCell.getStringCellValue()
.getBytes().length;
if (columnWidth < length) {
columnWidth = length;
}
}
}
}
if (colNum == 0) {
sheet.setColumnWidth(colNum, (columnWidth - 2) * 256);
} else {
sheet.setColumnWidth(colNum, (columnWidth + 4) * 256);
}
}
return workbook;
}
private static XSSFCellStyle getTitleStyle(XSSFWorkbook workbook) {
XSSFCellStyle style = ExcelUtils.getColumnTopStyle(workbook);
style.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
return style;
}
/*
* 列头单元格样式
*/
private static XSSFCellStyle getColumnTopStyle(XSSFWorkbook workbook) {
// 设置字体
XSSFFont font = workbook.createFont();
// 设置字体大小
font.setFontHeightInPoints((short) 11);
// 字体加粗
font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
// 设置字体名字
font.setFontName("Courier New");
// 设置样式;
XSSFCellStyle style = workbook.createCellStyle();
// 设置底边框;
style.setBorderBottom(XSSFCellStyle.BORDER_THIN);
// 设置底边框颜色;
// style.setBottomBorderColor(XSSFColor.BLACK.index);
// 设置左边框;
style.setBorderLeft(XSSFCellStyle.BORDER_THIN);
// 设置左边框颜色;
// style.setLeftBorderColor(XSSFColor.BLACK.index);
// 设置右边框;
style.setBorderRight(XSSFCellStyle.BORDER_THIN);
// 设置右边框颜色;
// style.setRightBorderColor(XSSFColor.BLACK.index);
// 设置顶边框;
style.setBorderTop(XSSFCellStyle.BORDER_THIN);
// 设置顶边框颜色;
// style.setTopBorderColor(XSSFColor.BLACK.index);
// 在样式用应用设置的字体;
style.setFont(font);
// 设置自动换行;
style.setWrapText(false);
// 设置水平对齐的样式为居中对齐;
style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
// 设置垂直对齐的样式为居中对齐;
style.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
return style;
}
/*
* 列数据信息单元格样式
*/
private static XSSFCellStyle getStyle(XSSFWorkbook workbook) {
// 设置字体
XSSFFont font = workbook.createFont();
// 设置字体大小
// font.setFontHeightInPoints((short)10);
// 字体加粗
// font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
// 设置字体名字
font.setFontName("Courier New");
font.setColor(IndexedColors.RED.index);
// 设置样式;
XSSFCellStyle style = workbook.createCellStyle();
// 设置底边框;
style.setBorderBottom(XSSFCellStyle.BORDER_THIN);
// 设置底边框颜色;
// style.setBottomBorderColor(XSSFColor.BLACK.index);
// 设置左边框;
style.setBorderLeft(XSSFCellStyle.BORDER_THIN);
// 设置左边框颜色;
// style.setLeftBorderColor(XSSFColor.BLACK.index);
// 设置右边框;
style.setBorderRight(XSSFCellStyle.BORDER_THIN);
// 设置右边框颜色;
// style.setRightBorderColor(XSSFColor.BLACK.index);
// 设置顶边框;
style.setBorderTop(XSSFCellStyle.BORDER_THIN);
// 设置顶边框颜色;
// style.setTopBorderColor(XSSFColor.BLACK.index);
// 在样式用应用设置的字体;
style.setFont(font);
// 设置自动换行;
style.setWrapText(false);
// 设置水平对齐的样式为居中对齐;
style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
// 设置垂直对齐的样式为居中对齐;
style.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
return style;
}
public static Workbook getWorkbookFromUpload(InputStream inputStream, String fileName) throws IOException {
Workbook wb;
String fileType = fileName.substring(fileName.lastIndexOf("."));
if (".xlsx".equals(fileType)) {
wb = new XSSFWorkbook(inputStream);
} else if ("xls".equals(fileType)) {
wb = new HSSFWorkbook(inputStream);
} else {
return null;
}
return wb;
}
/**
* @param row 表示数据从第几行开始 例如:第一行为表头,第二行为数据,row的值为2
* @param fileType 文件的后缀 例如:xls xlsx
* @return
*/
public static List<Map<Integer, String>> readExcel(int row, String fileType, Workbook xssfWorkbook, Map<Integer, Boolean> dateTypeMap) {
if (fileType.equals("xlsx")) {
return readXlsx(xssfWorkbook, row, dateTypeMap);
} else {
return null;
}
}
public static List<Map<Integer, String>> readXlsx(Workbook xssfWorkbook, int row, Map<Integer, Boolean> dateTypeMap) {
List<Map<Integer, String>> result = new ArrayList<Map<Integer, String>>();
SimpleDateFormat format = new SimpleDateFormat(Constants.dateformat);
// XSSFWorkbook xssfWorkbook = new XSSFWorkbook(in);
for (int numSheet = 0; numSheet < 1; numSheet++) {
Sheet xssfSheet = xssfWorkbook.getSheetAt(numSheet);
if (xssfSheet == null || xssfSheet.getLastRowNum() == 1) {
continue;
}
for (int rowNum = row - 1; rowNum <= xssfSheet.getLastRowNum(); rowNum++) {
Row xssfRow = xssfSheet.getRow(rowNum);
if (xssfRow == null) {
continue;
}
int minColix = xssfRow.getFirstCellNum();
int maxColix = xssfRow.getLastCellNum();
Map<Integer, String> map = new HashMap<Integer, String>();
for (int colix = minColix; colix < maxColix; colix++) {
Cell xssfCell = xssfRow.getCell(colix);
if (xssfCell == null) {
map.put(colix, "");
} else {
Boolean isDate = dateTypeMap.get(colix);
if (isDate != null && isDate) {
if (xssfCell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
Date date = xssfCell.getDateCellValue();
map.put(colix, format.format(date));
} else {
xssfCell.setCellType(Cell.CELL_TYPE_STRING);
map.put(colix, xssfCell.getStringCellValue());
}
} else {
if (xssfCell.getCellType() != Cell.CELL_TYPE_STRING) {
xssfCell.setCellType(Cell.CELL_TYPE_STRING);
}
map.put(colix, xssfCell.getStringCellValue());
}
}
}
if (!isEmpty(map, minColix, maxColix)) {
result.add(map);
}
}
}
return result;
}
private static boolean isEmpty(Map<Integer, String> data, int startIndex, int endIndex) {
boolean isEmplty = true;
for (int i = startIndex + 1; i <= endIndex; i++) {
String value = data.get(i);
if (!StringUtils.isBlank(value)) {
isEmplty = false;
}
}
return isEmplty;
}
}
\ No newline at end of file
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