Commit 8a5d3529 by 朱瑞泽

暂定

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-demo-single-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>1.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>
<scope>test</scope>
</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.demo.single.api.dto;
import java.io.Serializable;
import java.util.Date;
/**
* tab_gic_demo_enterprise
*/
public class DemoEnterpriseDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 企业id
*/
private String enterpriseId;
/**
* 企业名称
*/
private String enterpriseName;
/**
* 企业编码
*/
private String enterpriseCode;
/**
* 品牌名称
*/
private String brandName;
/**
* LOGO_url地址
*/
private String logoUrl;
/**
* 企业简介
*/
private String enterpriseDescription;
/**
* 营业执照注册号
*/
private String licenseNumber;
/**
* 国家
*/
private String countryId;
/**
* 省
*/
private String provinceId;
/**
* 市
*/
private String cityId;
/**
* 县/区
*/
private String areaId;
/**
* 详细地址
*/
private String registerAddress;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
* 状态(0:已删除,1:正常 )
*/
private Integer status;
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getEnterpriseName() {
return enterpriseName;
}
public void setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName;
}
public String getEnterpriseCode() {
return enterpriseCode;
}
public void setEnterpriseCode(String enterpriseCode) {
this.enterpriseCode = enterpriseCode;
}
public String getBrandName() {
return brandName;
}
public void setBrandName(String brandName) {
this.brandName = brandName;
}
public String getLogoUrl() {
return logoUrl;
}
public void setLogoUrl(String logoUrl) {
this.logoUrl = logoUrl;
}
public String getEnterpriseDescription() {
return enterpriseDescription;
}
public void setEnterpriseDescription(String enterpriseDescription) {
this.enterpriseDescription = enterpriseDescription;
}
public String getLicenseNumber() {
return licenseNumber;
}
public void setLicenseNumber(String licenseNumber) {
this.licenseNumber = licenseNumber;
}
public String getCountryId() {
return countryId;
}
public void setCountryId(String countryId) {
this.countryId = countryId;
}
public String getProvinceId() {
return provinceId;
}
public void setProvinceId(String provinceId) {
this.provinceId = provinceId;
}
public String getCityId() {
return cityId;
}
public void setCityId(String cityId) {
this.cityId = cityId;
}
public String getAreaId() {
return areaId;
}
public void setAreaId(String areaId) {
this.areaId = areaId;
}
public String getRegisterAddress() {
return registerAddress;
}
public void setRegisterAddress(String registerAddress) {
this.registerAddress = registerAddress;
}
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;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}
\ No newline at end of file
package com.gic.demo.single.api.dto;
import java.io.Serializable;
import java.util.Date;
/**
* tab_gic_demo_store
*/
public class DemoStoreDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 门店id
*/
private String storeId;
/**
* 企业id
*/
private String enterpriseId;
/**
* 门店名称
*/
private String storeName;
/**
* 详细地址
*/
private String postAddress;
/**
* 状态(0:待审核,1:正常,2:审核失败,3:停业整顿 ,4:回收站 ,5:删除)
*/
private Integer status;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public String getPostAddress() {
return postAddress;
}
public void setPostAddress(String postAddress) {
this.postAddress = postAddress;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
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.demo.single.api.service;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.demo.single.api.dto.DemoStoreDTO;
/**
* @author zhurz
*/
public interface DemoStoreApiService {
/**
* 根据id查询
*
* @param storeId 门店id
* @return
*/
ServiceResponse<DemoStoreDTO> findDemoStoreById(String storeId);
}
package com.gic.demo.single.api.utils;
/**
* demo api 常量
*
* @author zhurz
*/
public class DemoSinglApiConstant {
/**
* 服务异常
*/
public static final String ERROR = "9999";
}
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-demo-pom</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gic-demo-single-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>1.0-SNAPSHOT</libraryVersion>
</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-demo-config</artifactId>
<version>${gic-demo-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-demo-project-api</artifactId>
<version>${gic-demo-project-api}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</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.demo.single.dao.mapper;
import com.gic.demo.single.entity.TabGicDemoEnterprise;
public interface DemoEnterpriseMapper {
int deleteByPrimaryKey(String enterpriseId);
int insert(TabGicDemoEnterprise record);
int insertSelective(TabGicDemoEnterprise record);
TabGicDemoEnterprise selectByPrimaryKey(String enterpriseId);
int updateByPrimaryKeySelective(TabGicDemoEnterprise record);
int updateByPrimaryKey(TabGicDemoEnterprise record);
}
\ No newline at end of file
package com.gic.demo.single.dao.mapper;
import com.gic.demo.single.entity.TabGicDemoStore;
public interface DemoStoreMapper {
int deleteByPrimaryKey(String storeId);
int insert(TabGicDemoStore record);
int insertSelective(TabGicDemoStore record);
TabGicDemoStore selectByPrimaryKey(String storeId);
int updateByPrimaryKeySelective(TabGicDemoStore record);
int updateByPrimaryKey(TabGicDemoStore record);
}
\ No newline at end of file
package com.gic.demo.single.entity;
import com.gic.commons.plugin.mybatis.InjectId;
import java.util.Date;
/**
* tab_gic_demo_enterprise
*/
public class TabGicDemoEnterprise {
/**
* 企业id
*/
@InjectId(InjectId.IdType.UUID)
private String enterpriseId;
/**
* 企业名称
*/
private String enterpriseName;
/**
* 企业编码
*/
private String enterpriseCode;
/**
* 品牌名称
*/
private String brandName;
/**
* LOGO_url地址
*/
private String logoUrl;
/**
* 企业简介
*/
private String enterpriseDescription;
/**
* 营业执照注册号
*/
private String licenseNumber;
/**
* 国家
*/
private String countryId;
/**
* 省
*/
private String provinceId;
/**
* 市
*/
private String cityId;
/**
* 县/区
*/
private String areaId;
/**
* 详细地址
*/
private String registerAddress;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
* 状态(0:已删除,1:正常 )
*/
private Integer status;
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getEnterpriseName() {
return enterpriseName;
}
public void setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName;
}
public String getEnterpriseCode() {
return enterpriseCode;
}
public void setEnterpriseCode(String enterpriseCode) {
this.enterpriseCode = enterpriseCode;
}
public String getBrandName() {
return brandName;
}
public void setBrandName(String brandName) {
this.brandName = brandName;
}
public String getLogoUrl() {
return logoUrl;
}
public void setLogoUrl(String logoUrl) {
this.logoUrl = logoUrl;
}
public String getEnterpriseDescription() {
return enterpriseDescription;
}
public void setEnterpriseDescription(String enterpriseDescription) {
this.enterpriseDescription = enterpriseDescription;
}
public String getLicenseNumber() {
return licenseNumber;
}
public void setLicenseNumber(String licenseNumber) {
this.licenseNumber = licenseNumber;
}
public String getCountryId() {
return countryId;
}
public void setCountryId(String countryId) {
this.countryId = countryId;
}
public String getProvinceId() {
return provinceId;
}
public void setProvinceId(String provinceId) {
this.provinceId = provinceId;
}
public String getCityId() {
return cityId;
}
public void setCityId(String cityId) {
this.cityId = cityId;
}
public String getAreaId() {
return areaId;
}
public void setAreaId(String areaId) {
this.areaId = areaId;
}
public String getRegisterAddress() {
return registerAddress;
}
public void setRegisterAddress(String registerAddress) {
this.registerAddress = registerAddress;
}
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;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}
\ No newline at end of file
package com.gic.demo.single.entity;
import com.gic.commons.plugin.mybatis.InjectId;
import java.util.Date;
/**
* tab_gic_demo_store
*/
public class TabGicDemoStore {
/**
* 门店id
*/
@InjectId(InjectId.IdType.SNOWFLAKE)
private String storeId;
/**
* 企业id
*/
private String enterpriseId;
/**
* 门店名称
*/
private String storeName;
/**
* 详细地址
*/
private String postAddress;
/**
* 状态(0:待审核,1:正常,2:审核失败,3:停业整顿 ,4:回收站 ,5:删除)
*/
private Integer status;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public String getPostAddress() {
return postAddress;
}
public void setPostAddress(String postAddress) {
this.postAddress = postAddress;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
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.demo.single.service;
import com.gic.demo.single.entity.TabGicDemoStore;
/**
* 门店内部服务
*
* @author zhurz
*/
public interface DemoStoreService {
/**
* 根据id查询
*
* @param storeId 门店id
* @return
*/
TabGicDemoStore findDemoStoreById(String storeId);
}
package com.gic.demo.single.service.impl;
import com.gic.demo.single.dao.mapper.DemoStoreMapper;
import com.gic.demo.single.entity.TabGicDemoStore;
import com.gic.demo.single.service.DemoStoreService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 门店内部服务
*
* @author zhurz
*/
@Service
public class DemoStoreServiceImpl implements DemoStoreService {
@Autowired
private DemoStoreMapper mapper;
/**
* 根据id查询
*
* @param storeId 门店id
* @return
*/
@Override
public TabGicDemoStore findDemoStoreById(String storeId) {
if (StringUtils.isBlank(storeId)) {
return null;
}
return mapper.selectByPrimaryKey(storeId);
}
}
package com.gic.demo.single.service.outer.impl;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.demo.project.api.dto.DemoStoreDTO;
import com.gic.demo.project.api.service.DemoStoreApiService;
import com.gic.demo.project.api.utils.DemoProjectApiConstant;
import com.gic.demo.single.entity.TabGicDemoStore;
import com.gic.demo.single.service.DemoStoreService;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author zhurz
*/
@Service
public class DemoStoreApiServiceImpl implements DemoStoreApiService {
@Autowired
private DemoStoreService localService;
/**
* 根据id查询
*
* @param storeId 门店id
* @return
*/
@Override
public ServiceResponse<DemoStoreDTO> findDemoStoreById(String storeId) {
if (RandomUtils.nextInt(0, 10) > 5) {
return ServiceResponse.failure(DemoProjectApiConstant.ERROR, "服务异常");
}
TabGicDemoStore store = localService.findDemoStoreById(storeId);
return ServiceResponse.success(EntityUtil.changeEntityByOrika(DemoStoreDTO.class, store));
}
}
<?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:gic-demo-init.xml"/>
<import resource="classpath:dubbo-gic-demo-service.xml"/>
<import resource="classpath*:dubbo-setting.xml"/>
<import resource="classpath:jdbc-gic-demo-service.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.demo.*"/>
<!-- 应用名称 -->
<dubbo:application name="gic-demo-single-service"/>
<dubbo:protocol name="dubbo" port="30102"/>
<dubbo:service interface="com.gic.demo.project.api.service.DemoStoreApiService" ref="demoStoreApiServiceImpl" timeout="60000" />
</beans>
dubbo.registry.file=gic-demo-single-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: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.ctrip.com/schema/apollo
http://www.ctrip.com/schema/apollo.xsd">
<context:annotation-config/>
<apollo:config namespaces="COMMON.sharding,COMMON.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>
<bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlSessionFactory">
<property name="dataSource" ref="dataSource"/>
<property name="typeAliasesPackage" value="com.gic.demo.**.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.demo.**.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"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gic.demo.single.dao.mapper.DemoEnterpriseMapper">
<resultMap id="BaseResultMap" type="com.gic.demo.single.entity.TabGicDemoEnterprise">
<id column="enterprise_id" jdbcType="CHAR" property="enterpriseId" />
<result column="enterprise_name" jdbcType="VARCHAR" property="enterpriseName" />
<result column="enterprise_code" jdbcType="VARCHAR" property="enterpriseCode" />
<result column="brand_name" jdbcType="VARCHAR" property="brandName" />
<result column="logo_url" jdbcType="VARCHAR" property="logoUrl" />
<result column="enterprise_description" jdbcType="VARCHAR" property="enterpriseDescription" />
<result column="license_number" jdbcType="VARCHAR" property="licenseNumber" />
<result column="country_id" jdbcType="VARCHAR" property="countryId" />
<result column="province_id" jdbcType="VARCHAR" property="provinceId" />
<result column="city_id" jdbcType="VARCHAR" property="cityId" />
<result column="area_id" jdbcType="VARCHAR" property="areaId" />
<result column="register_address" jdbcType="VARCHAR" property="registerAddress" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="status" jdbcType="INTEGER" property="status" />
</resultMap>
<sql id="Base_Column_List">
enterprise_id, enterprise_name, enterprise_code, brand_name, logo_url, enterprise_description,
license_number, country_id, province_id, city_id, area_id, register_address, create_time,
update_time, status
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_gic_demo_enterprise
where enterprise_id = #{enterpriseId,jdbcType=CHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from tab_gic_demo_enterprise
where enterprise_id = #{enterpriseId,jdbcType=CHAR}
</delete>
<insert id="insert" parameterType="com.gic.demo.single.entity.TabGicDemoEnterprise">
insert into tab_gic_demo_enterprise (enterprise_id, enterprise_name, enterprise_code,
brand_name, logo_url, enterprise_description,
license_number, country_id, province_id,
city_id, area_id, register_address,
create_time, update_time, status
)
values (#{enterpriseId,jdbcType=CHAR}, #{enterpriseName,jdbcType=VARCHAR}, #{enterpriseCode,jdbcType=VARCHAR},
#{brandName,jdbcType=VARCHAR}, #{logoUrl,jdbcType=VARCHAR}, #{enterpriseDescription,jdbcType=VARCHAR},
#{licenseNumber,jdbcType=VARCHAR}, #{countryId,jdbcType=VARCHAR}, #{provinceId,jdbcType=VARCHAR},
#{cityId,jdbcType=VARCHAR}, #{areaId,jdbcType=VARCHAR}, #{registerAddress,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.gic.demo.single.entity.TabGicDemoEnterprise">
insert into tab_gic_demo_enterprise
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="enterpriseId != null">
enterprise_id,
</if>
<if test="enterpriseName != null">
enterprise_name,
</if>
<if test="enterpriseCode != null">
enterprise_code,
</if>
<if test="brandName != null">
brand_name,
</if>
<if test="logoUrl != null">
logo_url,
</if>
<if test="enterpriseDescription != null">
enterprise_description,
</if>
<if test="licenseNumber != null">
license_number,
</if>
<if test="countryId != null">
country_id,
</if>
<if test="provinceId != null">
province_id,
</if>
<if test="cityId != null">
city_id,
</if>
<if test="areaId != null">
area_id,
</if>
<if test="registerAddress != null">
register_address,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="status != null">
status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="enterpriseId != null">
#{enterpriseId,jdbcType=CHAR},
</if>
<if test="enterpriseName != null">
#{enterpriseName,jdbcType=VARCHAR},
</if>
<if test="enterpriseCode != null">
#{enterpriseCode,jdbcType=VARCHAR},
</if>
<if test="brandName != null">
#{brandName,jdbcType=VARCHAR},
</if>
<if test="logoUrl != null">
#{logoUrl,jdbcType=VARCHAR},
</if>
<if test="enterpriseDescription != null">
#{enterpriseDescription,jdbcType=VARCHAR},
</if>
<if test="licenseNumber != null">
#{licenseNumber,jdbcType=VARCHAR},
</if>
<if test="countryId != null">
#{countryId,jdbcType=VARCHAR},
</if>
<if test="provinceId != null">
#{provinceId,jdbcType=VARCHAR},
</if>
<if test="cityId != null">
#{cityId,jdbcType=VARCHAR},
</if>
<if test="areaId != null">
#{areaId,jdbcType=VARCHAR},
</if>
<if test="registerAddress != null">
#{registerAddress,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.demo.single.entity.TabGicDemoEnterprise">
update tab_gic_demo_enterprise
<set>
<if test="enterpriseName != null">
enterprise_name = #{enterpriseName,jdbcType=VARCHAR},
</if>
<if test="enterpriseCode != null">
enterprise_code = #{enterpriseCode,jdbcType=VARCHAR},
</if>
<if test="brandName != null">
brand_name = #{brandName,jdbcType=VARCHAR},
</if>
<if test="logoUrl != null">
logo_url = #{logoUrl,jdbcType=VARCHAR},
</if>
<if test="enterpriseDescription != null">
enterprise_description = #{enterpriseDescription,jdbcType=VARCHAR},
</if>
<if test="licenseNumber != null">
license_number = #{licenseNumber,jdbcType=VARCHAR},
</if>
<if test="countryId != null">
country_id = #{countryId,jdbcType=VARCHAR},
</if>
<if test="provinceId != null">
province_id = #{provinceId,jdbcType=VARCHAR},
</if>
<if test="cityId != null">
city_id = #{cityId,jdbcType=VARCHAR},
</if>
<if test="areaId != null">
area_id = #{areaId,jdbcType=VARCHAR},
</if>
<if test="registerAddress != null">
register_address = #{registerAddress,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
</set>
where enterprise_id = #{enterpriseId,jdbcType=CHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.demo.single.entity.TabGicDemoEnterprise">
update tab_gic_demo_enterprise
set enterprise_name = #{enterpriseName,jdbcType=VARCHAR},
enterprise_code = #{enterpriseCode,jdbcType=VARCHAR},
brand_name = #{brandName,jdbcType=VARCHAR},
logo_url = #{logoUrl,jdbcType=VARCHAR},
enterprise_description = #{enterpriseDescription,jdbcType=VARCHAR},
license_number = #{licenseNumber,jdbcType=VARCHAR},
country_id = #{countryId,jdbcType=VARCHAR},
province_id = #{provinceId,jdbcType=VARCHAR},
city_id = #{cityId,jdbcType=VARCHAR},
area_id = #{areaId,jdbcType=VARCHAR},
register_address = #{registerAddress,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
status = #{status,jdbcType=INTEGER}
where enterprise_id = #{enterpriseId,jdbcType=CHAR}
</update>
</mapper>
\ 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.gic.demo.single.dao.mapper.DemoStoreMapper">
<resultMap id="BaseResultMap" type="com.gic.demo.single.entity.TabGicDemoStore">
<id column="store_id" jdbcType="CHAR" property="storeId" />
<result column="enterprise_id" jdbcType="CHAR" property="enterpriseId" />
<result column="store_name" jdbcType="VARCHAR" property="storeName" />
<result column="post_address" jdbcType="VARCHAR" property="postAddress" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
store_id, enterprise_id, store_name, post_address, status, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_gic_demo_store
where store_id = #{storeId,jdbcType=CHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from tab_gic_demo_store
where store_id = #{storeId,jdbcType=CHAR}
</delete>
<insert id="insert" parameterType="com.gic.demo.single.entity.TabGicDemoStore">
insert into tab_gic_demo_store (store_id, enterprise_id, store_name,
post_address, status, create_time,
update_time)
values (#{storeId,jdbcType=CHAR}, #{enterpriseId,jdbcType=CHAR}, #{storeName,jdbcType=VARCHAR},
#{postAddress,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.gic.demo.single.entity.TabGicDemoStore">
insert into tab_gic_demo_store
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="storeId != null">
store_id,
</if>
<if test="enterpriseId != null">
enterprise_id,
</if>
<if test="storeName != null">
store_name,
</if>
<if test="postAddress != null">
post_address,
</if>
<if test="status != null">
status,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="storeId != null">
#{storeId,jdbcType=CHAR},
</if>
<if test="enterpriseId != null">
#{enterpriseId,jdbcType=CHAR},
</if>
<if test="storeName != null">
#{storeName,jdbcType=VARCHAR},
</if>
<if test="postAddress != null">
#{postAddress,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.demo.single.entity.TabGicDemoStore">
update tab_gic_demo_store
<set>
<if test="enterpriseId != null">
enterprise_id = #{enterpriseId,jdbcType=CHAR},
</if>
<if test="storeName != null">
store_name = #{storeName,jdbcType=VARCHAR},
</if>
<if test="postAddress != null">
post_address = #{postAddress,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where store_id = #{storeId,jdbcType=CHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.demo.single.entity.TabGicDemoStore">
update tab_gic_demo_store
set enterprise_id = #{enterpriseId,jdbcType=CHAR},
store_name = #{storeName,jdbcType=VARCHAR},
post_address = #{postAddress,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where store_id = #{storeId,jdbcType=CHAR}
</update>
</mapper>
\ No newline at end of file
package com.gic;
import com.alibaba.fastjson.JSON;
import com.dexcoder.commons.utils.UUIDUtils;
import com.gic.demo.single.dao.mapper.DemoEnterpriseMapper;
import com.gic.demo.single.dao.mapper.DemoStoreMapper;
import com.gic.demo.single.entity.TabGicDemoEnterprise;
import com.gic.demo.single.entity.TabGicDemoStore;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Unit test for simple App.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:applicationContext-conf.xml"})
public class AppTest {
@Autowired
private DemoEnterpriseMapper enterpriseMapper;
@Autowired
private DemoStoreMapper storeMapper;
@Test
public void test1() {
TabGicDemoEnterprise tabGicDemoEnterprise = enterpriseMapper.selectByPrimaryKey("22323423");
System.out.println(JSON.toJSONString(tabGicDemoEnterprise, true));
}
@Test
public void test2() {
TabGicDemoStore tabGicDemoStore = storeMapper.selectByPrimaryKey("11b");
System.out.println(JSON.toJSONString(tabGicDemoStore, true));
}
@Test
public void test3() {
for (int i = 0; i < 10; i++) {
System.out.println("insert >> " + i);
TabGicDemoStore store = new TabGicDemoStore();
if (i % 2 == 0) {
store.setStoreId(UUIDUtils.getUUID32());
}
store.setStoreName(RandomStringUtils.random(10, "abcdefghigklmn0123456789"));
storeMapper.insertSelective(store);
System.out.println(JSON.toJSONString(store));
}
}
}
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-demo-pom</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gic-demo-single-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>1.0-SNAPSHOT</libraryVersion>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-demo-common</artifactId>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-demo-config</artifactId>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-demo-project-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</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>${spring-boot.version}</version>
<configuration>
<mainClass>com.gic.demo.single.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.demo.single.web;
import com.gic.dubbo.util.DubboContextUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ImportResource;
/**
* Spring Boot Web 启动类
*
* @author zhurz
*/
@SpringBootApplication
@ImportResource(value = {
"classpath*:gic-demo-init.xml",
"classpath*:dubbo-setting.xml",
"classpath*:dubbo-gic-demo-web.xml",
"classpath*:spring-interceptor.xml"
})
public class Main {
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(Main.class, args);
DubboContextUtil.setApplicationContext(context.getParent());
}
}
\ No newline at end of file
package com.gic.demo.single.web.controller;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.demo.project.api.dto.DemoStoreDTO;
import com.gic.demo.project.api.service.DemoStoreApiService;
import com.gic.demo.single.web.exception.GicDemoErrCode;
import com.gic.demo.single.web.vo.DemoStoreVO;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 指标管理接口
*
* @author zhurz
*/
@RestController
@RequestMapping("/demo")
public class DemoProjectController {
private static final Logger logger = LoggerFactory.getLogger(DemoProjectController.class);
@Autowired
private DemoStoreApiService demoStoreApiService;
/**
* 获取门店信息
*
* @param storeId 门店id
* @return
*/
@RequestMapping("/get-store-info")
public RestResponse getStoreInfo(String storeId) {
if (StringUtils.isBlank(storeId)) {
return GicDemoErrCode.ERR_2.buildFailureResponse();
}
ServiceResponse<DemoStoreDTO> response = demoStoreApiService.findDemoStoreById(storeId);
if (response.isSuccess()) {
// 转换为VO
DemoStoreVO vo = EntityUtil.changeEntityByOrika(DemoStoreVO.class, response.getResult());
return RestResponse.success(vo);
}
logger.warn("获取门店信息异常 -> {} -> {}", storeId, response.getMessage());
return GicDemoErrCode.ERR_1.buildFailureResponse();
}
}
\ No newline at end of file
package com.gic.demo.single.web.exception;
import com.gic.commons.webapi.reponse.RestResponse;
public enum GicDemoErrCode {
/**
* 操作失败
*/
ERR_1("0001", "操作失败"),
/**
* 缺少参数
*/
ERR_2("0002", "缺少参数"),
/**
* 系统异常
*/
ERR_3("0003", "系统异常"),
ERR_OTHER("9999", "未知错误code");
private String code;
private String message;
GicDemoErrCode(String code, String value) {
this.code = code;
this.message = value;
}
public String getCode() {
return code;
}
public String getMessage() {
return message;
}
public RestResponse buildFailureResponse() {
return RestResponse.failure(code, message);
}
}
package com.gic.demo.single.web.exception;
import com.gic.commons.webapi.reponse.RestResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
/**
* 全局异常处理类
*
* @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 = GicDemoErrCode.ERR_3.buildFailureResponse();
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;
}
}
package com.gic.demo.single.web.qo;
import java.io.Serializable;
/**
* 分页查询
*
* @author zhurz
*/
public class PageQO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 页码
*/
private Integer pageNum;
/**
* 分页大小
*/
private Integer pageSize;
public Integer getPageNum() {
return pageNum;
}
public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}
package com.gic.demo.single.web.vo;
import java.io.Serializable;
import java.util.Date;
/**
* tab_gic_demo_enterprise
*/
public class DemoEnterpriseVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 企业id
*/
private String enterpriseId;
/**
* 企业名称
*/
private String enterpriseName;
/**
* 企业编码
*/
private String enterpriseCode;
/**
* 品牌名称
*/
private String brandName;
/**
* LOGO_url地址
*/
private String logoUrl;
/**
* 企业简介
*/
private String enterpriseDescription;
/**
* 营业执照注册号
*/
private String licenseNumber;
/**
* 国家
*/
private String countryId;
/**
* 省
*/
private String provinceId;
/**
* 市
*/
private String cityId;
/**
* 县/区
*/
private String areaId;
/**
* 详细地址
*/
private String registerAddress;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
* 状态(0:已删除,1:正常 )
*/
private Integer status;
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getEnterpriseName() {
return enterpriseName;
}
public void setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName;
}
public String getEnterpriseCode() {
return enterpriseCode;
}
public void setEnterpriseCode(String enterpriseCode) {
this.enterpriseCode = enterpriseCode;
}
public String getBrandName() {
return brandName;
}
public void setBrandName(String brandName) {
this.brandName = brandName;
}
public String getLogoUrl() {
return logoUrl;
}
public void setLogoUrl(String logoUrl) {
this.logoUrl = logoUrl;
}
public String getEnterpriseDescription() {
return enterpriseDescription;
}
public void setEnterpriseDescription(String enterpriseDescription) {
this.enterpriseDescription = enterpriseDescription;
}
public String getLicenseNumber() {
return licenseNumber;
}
public void setLicenseNumber(String licenseNumber) {
this.licenseNumber = licenseNumber;
}
public String getCountryId() {
return countryId;
}
public void setCountryId(String countryId) {
this.countryId = countryId;
}
public String getProvinceId() {
return provinceId;
}
public void setProvinceId(String provinceId) {
this.provinceId = provinceId;
}
public String getCityId() {
return cityId;
}
public void setCityId(String cityId) {
this.cityId = cityId;
}
public String getAreaId() {
return areaId;
}
public void setAreaId(String areaId) {
this.areaId = areaId;
}
public String getRegisterAddress() {
return registerAddress;
}
public void setRegisterAddress(String registerAddress) {
this.registerAddress = registerAddress;
}
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;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}
\ No newline at end of file
package com.gic.demo.single.web.vo;
import java.io.Serializable;
import java.util.Date;
/**
* tab_gic_demo_store
*/
public class DemoStoreVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 门店id
*/
private String storeId;
/**
* 企业id
*/
private String enterpriseId;
/**
* 门店名称
*/
private String storeName;
/**
* 详细地址
*/
private String postAddress;
/**
* 状态(0:待审核,1:正常,2:审核失败,3:停业整顿 ,4:回收站 ,5:删除)
*/
private Integer status;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public String getPostAddress() {
return postAddress;
}
public void setPostAddress(String postAddress) {
this.postAddress = postAddress;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
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
server:
port: 9002
servlet:
context-path: /gic-demo-single-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.demo"/>
<!-- 应用名称 -->
<dubbo:application name="gic-demo-single-web"/>
<dubbo:reference interface="com.gic.demo.project.api.service.DemoStoreApiService" id="demoStoreApiService" timeout="60000" retries="0"/>
</beans>
\ No newline at end of file
dubbo.registry.file=gic-demo-project-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-demo-single</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>gic-demo-single-api</module>
<module>gic-demo-single-service</module>
<module>gic-demo-single-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