用3.0脚手架
This commit is contained in:
22
pom.xml
22
pom.xml
@ -5,9 +5,9 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>2.3.2.RELEASE</version>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud</artifactId>
|
||||
<version>2.4.1-zyhy-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.chinaunicom.zyhy.supplier</groupId>
|
||||
@ -49,6 +49,11 @@
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.mall.ebtp</groupId>
|
||||
<artifactId>uboot-core</artifactId>
|
||||
<version>2.4.1-zyhy-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.commons</groupId>-->
|
||||
<!-- <artifactId>commons-pool2</artifactId>-->
|
||||
@ -60,22 +65,13 @@
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
<version>2.2.3.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
<version>2.2.3.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-openfeign</artifactId>
|
||||
<version>2.2.4.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
|
@ -1,21 +1,19 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier;
|
||||
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@SpringBootApplication(exclude = {
|
||||
DataSourceAutoConfiguration.class,
|
||||
DruidDataSourceAutoConfigure.class
|
||||
})
|
||||
@EnableFeignClients
|
||||
@EnableEurekaClient
|
||||
@EnableApolloConfig
|
||||
@ComponentScan("com.chinaunicom.mall.ebtp.common.*,com.chinaunicom.zyhy.ebtp.*")
|
||||
@MapperScan({"com.chinaunicom.zyhy.ebtp.supplier.**.dao"})
|
||||
public class BizSupplierManageApplication {
|
||||
|
||||
|
@ -2,10 +2,11 @@ package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierAptitude;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierAptitudeVO;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.service.IBizSupplierAptitudeService;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.entity.BaseResponse;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
|
@ -2,10 +2,10 @@ package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierBank;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierBankVO;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.service.IBizSupplierBankService;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.entity.BaseResponse;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierRegister;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierRegisterVO;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.service.IBizSupplierRegisterService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.entity.BaseResponse;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.dao;
|
||||
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.dao.IBaseMapper;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierAptitude;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.dao.IBaseMapper;
|
||||
|
||||
/**
|
||||
* 对数据表 biz_supplier_aptitude 操作的 dao
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.dao;
|
||||
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.dao.IBaseMapper;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierBank;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.dao.IBaseMapper;
|
||||
|
||||
/**
|
||||
* 对数据表 biz_supplier_bank 操作的 dao
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.dao;
|
||||
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.dao.IBaseMapper;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierRegister;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.dao.IBaseMapper;
|
||||
|
||||
/**
|
||||
* 对数据表 biz_supplier_register 操作的 dao
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?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.chinaunicom.zyhy.ebtp.supplier.bizsupplieraptitude.dao.BizSupplierAptitudeMapper">
|
||||
<mapper namespace="com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.dao.BizSupplierAptitudeMapper">
|
||||
<resultMap id="BaseResultMap"
|
||||
type="com.chinaunicom.zyhy.ebtp.supplier.bizsupplieraptitude.entity.BizSupplierAptitude">
|
||||
type="com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierAptitude">
|
||||
<result column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="supplier_register_id" jdbcType="VARCHAR" property="supplierRegisterId"/>
|
||||
<result column="aptitude_certificate_type" jdbcType="VARCHAR" property="aptitudeCertificateType"/>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?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.chinaunicom.zyhy.ebtp.supplier.bizsupplierbank.dao.BizSupplierBankMapper">
|
||||
<mapper namespace="com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.dao.BizSupplierBankMapper">
|
||||
<resultMap id="BaseResultMap"
|
||||
type="com.chinaunicom.zyhy.ebtp.supplier.bizsupplierbank.entity.BizSupplierBank">
|
||||
type="com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierBank">
|
||||
<result column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="interbank_number" jdbcType="VARCHAR" property="interbankNumber"/>
|
||||
<result column="bank_deposit" jdbcType="VARCHAR" property="bankDeposit"/>
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.entity.BaseEntity;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity;
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.entity.BasePageRequest;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.entity.BaseEntity;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity;
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.entity.BasePageRequest;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
@ -1,11 +1,10 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.entity.BaseEntity;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity;
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.entity.BasePageRequest;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
@ -2,9 +2,10 @@ package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.chinaunicom.mall.ebtp.common.base.service.IBaseService;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierAptitude;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierAptitudeVO;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.service.IBaseService;
|
||||
|
||||
|
||||
/**
|
||||
* 对数据表 biz_supplier_aptitude 操作的 service
|
||||
|
@ -2,9 +2,9 @@ package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.chinaunicom.mall.ebtp.common.base.service.IBaseService;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierBank;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierBankVO;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.service.IBaseService;
|
||||
|
||||
/**
|
||||
* 对数据表 biz_supplier_bank 操作的 service
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.chinaunicom.mall.ebtp.common.base.service.IBaseService;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierRegister;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierRegisterVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.service.IBaseService;
|
||||
|
||||
/**
|
||||
* 对数据表 biz_supplier_register 操作的 service
|
||||
|
@ -6,12 +6,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.dao.BizSupplierAptitudeMapper;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierAptitude;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierAptitudeVO;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.service.IBizSupplierAptitudeService;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.entity.BasePageRequest;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.service.impl.BaseServiceImpl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
@ -5,12 +5,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.dao.BizSupplierBankMapper;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierBank;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierBankVO;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.service.IBizSupplierBankService;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.entity.BasePageRequest;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.service.impl.BaseServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
@ -1,17 +1,17 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.service.impl;
|
||||
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.dao.BizSupplierRegisterMapper;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierRegister;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierRegisterVO;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.service.IBizSupplierRegisterService;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.entity.BasePageRequest;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.service.impl.BaseServiceImpl;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.dao.BizSupplierRegisterMapper;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierRegister;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.entity.BizSupplierRegisterVO;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.bizsupplierregister.service.IBizSupplierRegisterService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
@ -1,9 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.base.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/base/")
|
||||
public class BaseController {
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.base.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface IBaseMapper<T> extends BaseMapper<T> {
|
||||
|
||||
|
||||
/**
|
||||
* 逻辑删除数据
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public int deleteOff(String id);
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.base.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.config.CustomLocalDateTimeTypeHandler;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BaseEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(value = "创建者")
|
||||
private String createBy;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT, typeHandler = CustomLocalDateTimeTypeHandler.class)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private LocalDateTime createDate;
|
||||
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
@ApiModelProperty(value = "更新者")
|
||||
private String updateBy;
|
||||
|
||||
@TableField(fill = FieldFill.UPDATE, typeHandler = CustomLocalDateTimeTypeHandler.class)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private LocalDateTime updateDate;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(value = "租户标识")
|
||||
private String tenantId;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(value = "租户名称")
|
||||
private String tenantName;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(value = "逻辑删除,normal表示正常(默认),deleted表示删除")
|
||||
private String deleteFlag;
|
||||
|
||||
@TableField(fill = FieldFill.UPDATE, typeHandler = CustomLocalDateTimeTypeHandler.class)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "最后更新时间戳")
|
||||
private LocalDateTime lastUpdateTime;
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.base.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class BasePage<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 当前页,默认 1
|
||||
*
|
||||
* @return 当前页
|
||||
*/
|
||||
private long current;
|
||||
|
||||
/**
|
||||
* 当前分页总页数
|
||||
*/
|
||||
private long pages;
|
||||
|
||||
/**
|
||||
* 当前分页总页数
|
||||
*
|
||||
* @return 总页数
|
||||
*/
|
||||
private long size;
|
||||
|
||||
/**
|
||||
* 当前满足条件总行数
|
||||
*
|
||||
* @return 总条数
|
||||
*/
|
||||
private long total;
|
||||
|
||||
/**
|
||||
* 分页记录列表
|
||||
*
|
||||
* @return 分页对象记录列表
|
||||
*/
|
||||
private List<T> records;
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.base.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 返回类型FrameResponse
|
||||
*/
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel
|
||||
public class BasePageRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6769157532172136264L;
|
||||
|
||||
@ApiModelProperty("当前页")
|
||||
@NotNull
|
||||
@Min(0)
|
||||
private Integer pageNo;
|
||||
|
||||
@ApiModelProperty("每页显示条数")
|
||||
@NotNull
|
||||
@Min(0)
|
||||
private Integer pageSize;
|
||||
|
||||
public Integer getPageNo() {
|
||||
return null == pageNo ? 0 : pageNo;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return null == pageSize ? 10 : pageSize;
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.base.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.enums.ResponseEnum;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 返回类型FrameResponse
|
||||
*/
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BasePageResponse<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer code;
|
||||
|
||||
private boolean success;
|
||||
|
||||
private String message;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private IPage<T> data;
|
||||
|
||||
|
||||
public static <T> BasePageResponse<T> success(IPage<T> p) {
|
||||
return new BasePageResponse<>(ResponseEnum.SUCCESS.getCode(),
|
||||
Boolean.TRUE,
|
||||
ResponseEnum.SUCCESS.getMessage(),
|
||||
p);
|
||||
}
|
||||
|
||||
|
||||
public static <T> BasePageResponse<T> success(String message, IPage<T> p) {
|
||||
return new BasePageResponse<>(ResponseEnum.SUCCESS.getCode(),
|
||||
Boolean.TRUE,
|
||||
message,
|
||||
p);
|
||||
}
|
||||
|
||||
|
||||
public static BasePageResponse<Object> fail(String message) {
|
||||
return new BasePageResponse<>(ResponseEnum.SUCCESS.getCode(),
|
||||
Boolean.FALSE,
|
||||
message,
|
||||
null);
|
||||
}
|
||||
|
||||
|
||||
public static BasePageResponse<Object> fail(int code, String message) {
|
||||
return new BasePageResponse<>(code,
|
||||
Boolean.FALSE,
|
||||
message,
|
||||
null);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.base.entity;
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.enums.ResponseEnum;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 返回类型FrameResponse
|
||||
*/
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BaseResponse<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6769157532172136264L;
|
||||
|
||||
private Integer code;
|
||||
|
||||
private boolean success;
|
||||
|
||||
private String message;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private T data;
|
||||
|
||||
|
||||
public static BaseResponse<String> success() {
|
||||
return new BaseResponse<>(ResponseEnum.SUCCESS.getCode(),
|
||||
Boolean.TRUE,
|
||||
ResponseEnum.SUCCESS.getMessage(),
|
||||
"");
|
||||
}
|
||||
|
||||
|
||||
public static <T> BaseResponse<T> success(T data) {
|
||||
return new BaseResponse<>(ResponseEnum.SUCCESS.getCode(),
|
||||
Boolean.TRUE,
|
||||
ResponseEnum.SUCCESS.getMessage(),
|
||||
data);
|
||||
}
|
||||
|
||||
|
||||
public static <T> BaseResponse<T> success(String message, T data) {
|
||||
return new BaseResponse<>(ResponseEnum.SUCCESS.getCode(),
|
||||
Boolean.TRUE,
|
||||
message,
|
||||
data);
|
||||
}
|
||||
|
||||
|
||||
public static BaseResponse<String> fail() {
|
||||
return new BaseResponse<>(ResponseEnum.ERROR.getCode(),
|
||||
Boolean.FALSE,
|
||||
ResponseEnum.ERROR.getMessage(),
|
||||
null);
|
||||
}
|
||||
|
||||
public static BaseResponse<String> fail(String message) {
|
||||
return new BaseResponse<>(ResponseEnum.ERROR.getCode(),
|
||||
Boolean.FALSE,
|
||||
message,
|
||||
null);
|
||||
}
|
||||
|
||||
public static BaseResponse<String> fail(Integer code, String message) {
|
||||
return new BaseResponse<>(code,
|
||||
Boolean.FALSE,
|
||||
message,
|
||||
null);
|
||||
}
|
||||
|
||||
public static <T> BaseResponse<T> fail(T data) {
|
||||
return new BaseResponse<>(ResponseEnum.ERROR.getCode(),
|
||||
Boolean.FALSE,
|
||||
ResponseEnum.ERROR.getMessage(),
|
||||
null);
|
||||
}
|
||||
|
||||
public static <T> BaseResponse<T> fail(String message, T data) {
|
||||
return new BaseResponse<>(ResponseEnum.ERROR.getCode(),
|
||||
Boolean.FALSE,
|
||||
message,
|
||||
null);
|
||||
}
|
||||
|
||||
public static <T> BaseResponse<T> fail(Integer code, String message, T data) {
|
||||
return new BaseResponse<T>(code,
|
||||
Boolean.FALSE,
|
||||
message,
|
||||
null);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.base.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 实体类 DictProject
|
||||
*
|
||||
* @author daixc
|
||||
* @date 2020/11/02
|
||||
*/
|
||||
@Data
|
||||
public class DictProject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@ApiModelProperty(value = "编号")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 字典code
|
||||
*/
|
||||
@ApiModelProperty(value = "字典code")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@ApiModelProperty(value = "字典名称")
|
||||
private String dicName;
|
||||
|
||||
/**
|
||||
* 父类code
|
||||
*/
|
||||
@ApiModelProperty(value = "父类code")
|
||||
private String parentCode;
|
||||
|
||||
/**
|
||||
* 父类类型
|
||||
*/
|
||||
@ApiModelProperty(value = "父类类型")
|
||||
private String parentType;
|
||||
|
||||
/**
|
||||
* 是否应用
|
||||
*/
|
||||
@ApiModelProperty(value = "是否应用")
|
||||
private String useFlag;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer orderFlag;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String description;
|
||||
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.base.enums;
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.exception.service.BusinessExceptionAssert;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
|
||||
/**
|
||||
* 通用异常Enum
|
||||
*
|
||||
* @author 付庆吉
|
||||
* @date 2020-09-14
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ResponseEnum implements BusinessExceptionAssert {
|
||||
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESS(200, "success"),
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
ERROR(90000, "操作失败"),
|
||||
|
||||
/**
|
||||
* token not find
|
||||
*/
|
||||
TOKEN_NOT_FIND(30001, "认证不存在!"),
|
||||
/**
|
||||
* connect timeout
|
||||
*/
|
||||
CONNECT_TIMEOUT(30002, "连接超时!");
|
||||
|
||||
/**
|
||||
* 返回码
|
||||
*/
|
||||
private int code;
|
||||
/**
|
||||
* 返回消息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
|
||||
}
|
@ -1 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.base;
|
@ -1,7 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.base.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface IBaseService<T> extends IService<T> {
|
||||
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.base.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.dao.IBaseMapper;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.service.IBaseService;
|
||||
|
||||
public class BaseServiceImpl<M extends IBaseMapper<T>, T> extends ServiceImpl<M, T> implements IBaseService<T> {
|
||||
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.bizmessage.client;
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.bizmessage.entity.MessageRaw;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.bizmessage.entity.MessageResult;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.bizmessage.fallback.BizMessageClientFallback;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.constant.ServiceNameConstants;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 消息客户端
|
||||
*
|
||||
* @author ajaxfan
|
||||
*/
|
||||
@FeignClient(name = ServiceNameConstants.EXTEND_SERVICE, fallback = BizMessageClientFallback.class)
|
||||
public interface BizMessageFeignClient {
|
||||
|
||||
@PostMapping(value = "/v1/producer/")
|
||||
Optional<MessageResult> postMessage(MessageRaw raw);
|
||||
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.bizmessage.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消息原型
|
||||
*
|
||||
* @author ajaxfan
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class MessageRaw {
|
||||
|
||||
/* 消息标题 */
|
||||
private String title;
|
||||
|
||||
/* 消息类别 */
|
||||
private String category;
|
||||
|
||||
/* 消息模板编码 */
|
||||
private String templateCode;
|
||||
|
||||
/* 消息内容对象 */
|
||||
private Map<String, Object> body;
|
||||
|
||||
/* 消息附加参数 */
|
||||
private Map<String, Object> extra;
|
||||
|
||||
/* 授权用户列表 */
|
||||
private List<String> users;
|
||||
|
||||
/* 业务参数 */
|
||||
private Map<String, Object> servicecode;
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.bizmessage.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Data
|
||||
public class MessageResult {
|
||||
|
||||
/* 消息编码 */
|
||||
private String msgId;
|
||||
|
||||
/* 消息标题 */
|
||||
private String title;
|
||||
|
||||
/* 消息类别 */
|
||||
private String category;
|
||||
|
||||
/* 消息内容 */
|
||||
private String content;
|
||||
|
||||
/* 消息路由 */
|
||||
private String url;
|
||||
|
||||
/* 消息参数 */
|
||||
private String params;
|
||||
|
||||
/* 消息发布时间 */
|
||||
private Timestamp createtime;
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.bizmessage.fallback;
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.bizmessage.client.BizMessageFeignClient;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.bizmessage.entity.MessageRaw;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.bizmessage.entity.MessageResult;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
public class BizMessageClientFallback implements BizMessageFeignClient {
|
||||
|
||||
@Override
|
||||
public Optional<MessageResult> postMessage(MessageRaw raw) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.bizmessage.publish;
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.bizmessage.client.BizMessageFeignClient;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.bizmessage.entity.MessageRaw;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.bizmessage.entity.MessageResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 消息发布工具
|
||||
*
|
||||
* @author Ajaxfan
|
||||
*/
|
||||
@Component
|
||||
public class BizMessagePublisher {
|
||||
|
||||
private @Autowired
|
||||
BizMessageFeignClient client;
|
||||
|
||||
/**
|
||||
* 广播消息
|
||||
*
|
||||
* @param title 消息标题
|
||||
* @param category 消息类别
|
||||
* @param templateCode 消息模板编码
|
||||
* @param body 消息内容
|
||||
* @param params 消息参数
|
||||
* @return 消息结果
|
||||
*/
|
||||
public Optional<MessageResult> publishToAll(String title, String category, String templateCode, Map<String, Object> body,
|
||||
Map<String, Object> params) {
|
||||
return publishMessage(title, category, templateCode, body, params, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 像指定用户群发布消息
|
||||
*
|
||||
* @param title 消息标题
|
||||
* @param category 消息类别
|
||||
* @param templateCode 消息模板编码
|
||||
* @param body 消息内容
|
||||
* @param params 消息参数
|
||||
* @param grantUsers 目标用户列表
|
||||
* @return 消息结果
|
||||
*/
|
||||
public Optional<MessageResult> publishToSpecialUsers(String title, String category, String templateCode,
|
||||
Map<String, Object> body, Map<String, Object> params, List<String> grantUsers) {
|
||||
return this.publishToSpecialUsers(title, category, templateCode, body, params, grantUsers, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 像指定用户群发布消息
|
||||
*
|
||||
* @param title 消息标题
|
||||
* @param category 消息类别
|
||||
* @param templateCode 消息模板编码
|
||||
* @param body 消息内容
|
||||
* @param params 消息参数
|
||||
* @param grantUsers 目标用户列表
|
||||
* @param servicecode 业务参数
|
||||
* @return 消息结果
|
||||
*/
|
||||
public Optional<MessageResult> publishToSpecialUsers(String title, String category, String templateCode,
|
||||
Map<String, Object> body, Map<String, Object> params,
|
||||
List<String> grantUsers, Map<String, Object> servicecode) {
|
||||
return publishMessage(title, category, templateCode, body, params, grantUsers, servicecode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param title
|
||||
* @param category
|
||||
* @param templateCode
|
||||
* @param body
|
||||
* @param params
|
||||
* @param grantUsers
|
||||
* @return
|
||||
*/
|
||||
private Optional<MessageResult> publishMessage(String title, String category, String templateCode,
|
||||
Map<String, Object> body, Map<String, Object> params, List<String> grantUsers) {
|
||||
Assert.notNull(title, "消息标题为空");
|
||||
Assert.notNull(category, "消息类别编号为空");
|
||||
Assert.notNull(templateCode, "模板编号为空");
|
||||
Assert.notNull(body, "消息内容为空");
|
||||
Assert.notNull(params, "消息参数为空");
|
||||
|
||||
return this.publishMessage(title, category, templateCode, body, params, grantUsers, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param title
|
||||
* @param category
|
||||
* @param templateCode
|
||||
* @param body
|
||||
* @param params
|
||||
* @param grantUsers
|
||||
* @param servicecode 业务参数
|
||||
* @return
|
||||
*/
|
||||
private Optional<MessageResult> publishMessage(String title, String category, String templateCode,
|
||||
Map<String, Object> body, Map<String, Object> params, List<String> grantUsers,
|
||||
Map<String, Object> servicecode) {
|
||||
Assert.notNull(title, "消息标题为空");
|
||||
Assert.notNull(category, "消息类别编号为空");
|
||||
Assert.notNull(templateCode, "模板编号为空");
|
||||
Assert.notNull(body, "消息内容为空");
|
||||
Assert.notNull(params, "消息参数为空");
|
||||
Assert.notNull(servicecode, "业务参数为空");
|
||||
|
||||
return client.postMessage(new MessageRaw().setTitle(title).setCategory(category)
|
||||
.setTemplateCode(templateCode).setBody(body).setExtra(params).setUsers(grantUsers).setServicecode(servicecode));
|
||||
}
|
||||
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.config;
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.util.JsonUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* 异步线程池配置
|
||||
*
|
||||
* @author f
|
||||
* @date 2021-11-12
|
||||
*/
|
||||
@Configuration
|
||||
@EnableAsync
|
||||
@EnableConfigurationProperties(AsyncProperties.class)
|
||||
@Slf4j
|
||||
public class AsyncConfig implements AsyncConfigurer {
|
||||
|
||||
@Autowired
|
||||
private AsyncProperties asyncProperties;
|
||||
|
||||
|
||||
/**
|
||||
* 配置异步线程池
|
||||
* <p>
|
||||
* 拒绝异常处理 - 在调用线程中执行(当线程池中线程都已被占用且queue已满,则拒绝继续提交task,
|
||||
* 默认为ThreakPoolExecutor.AbortPolicy抛出异常到上层应用 - 导致异步死掉,无法再处理新任务,
|
||||
* 此处实现照搬ThreadPoolExecutor.CallerRunsPolicy且添加日志记录,
|
||||
* CallerRunsPolicy:不在新线程中执行任务,而是用调用者所在的线程来执行)
|
||||
*/
|
||||
@Override
|
||||
public Executor getAsyncExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(asyncProperties.getCoreSize());
|
||||
executor.setMaxPoolSize(asyncProperties.getMaxSize());
|
||||
executor.setQueueCapacity(asyncProperties.getQueueCapacity());
|
||||
executor.setKeepAliveSeconds(asyncProperties.getKeepAlive());
|
||||
executor.setThreadNamePrefix(asyncProperties.getThreadNamePrefix());
|
||||
// new ThreadPoolExecutor.CallerRunsPolicy();
|
||||
executor.setRejectedExecutionHandler((r, e) -> {
|
||||
log.error("Async thread pool over load - caller run - queue size:{}", e.getQueue().size());
|
||||
if (!e.isShutdown()) {
|
||||
r.run();
|
||||
}
|
||||
});
|
||||
// 等待所有任务结束后再关闭线程池
|
||||
executor.setWaitForTasksToCompleteOnShutdown(true);
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步线程池 - 全局异常处理
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
||||
return (ex, method, params) -> {
|
||||
log.info("Async method:{} has uncaught exception,params: {}", method, JsonUtils.objectToJson(params), ex);
|
||||
};
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.config;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* 异步线程池属性
|
||||
*
|
||||
* @author f
|
||||
* @date 2021-11-12
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "async.thead.pool")
|
||||
@Data
|
||||
public class AsyncProperties {
|
||||
|
||||
/**
|
||||
* 核心线程池大小
|
||||
*/
|
||||
private Integer coreSize;
|
||||
/**
|
||||
* 最大线程池大小
|
||||
*/
|
||||
private Integer maxSize;
|
||||
/**
|
||||
* 线程池队列容量(默认Integer.MAX_VALUE)
|
||||
*/
|
||||
private Integer queueCapacity;
|
||||
/**
|
||||
* 线程池空闲时间
|
||||
*/
|
||||
private Integer keepAlive;
|
||||
/**
|
||||
* 线程池名称前缀
|
||||
*/
|
||||
private String threadNamePrefix;
|
||||
|
||||
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.config;
|
||||
|
||||
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* 解决Json字段内容LocalDateTime反序列化问题
|
||||
*
|
||||
* @author dino
|
||||
* @date 2020/11/10 15:48
|
||||
*/
|
||||
@Slf4j
|
||||
@MappedTypes({Object.class})
|
||||
@MappedJdbcTypes(JdbcType.VARCHAR)
|
||||
public class CustomJacksonTypeHandler extends BaseTypeHandler<Object> {
|
||||
private static ObjectMapper objectMapper;
|
||||
private Class<Object> type;
|
||||
|
||||
static {
|
||||
objectMapper = new ObjectMapper();
|
||||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
objectMapper.registerModule(new JavaTimeModule());
|
||||
}
|
||||
|
||||
public CustomJacksonTypeHandler(Class<Object> type) {
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("JacksonTypeHandler(" + type + ")");
|
||||
}
|
||||
if (null == type) {
|
||||
throw new MybatisPlusException("Type argument cannot be null");
|
||||
}
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private Object parse(String json) {
|
||||
try {
|
||||
if (json == null || json.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
return objectMapper.readValue(json, type);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String toJsonString(Object obj) {
|
||||
try {
|
||||
return objectMapper.writeValueAsString(obj);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
return parse(rs.getString(columnName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
return parse(rs.getString(columnIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
return parse(cs.getString(columnIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int columnIndex, Object parameter, JdbcType jdbcType) throws SQLException {
|
||||
ps.setString(columnIndex, toJsonString(parameter));
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.config;
|
||||
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Component
|
||||
//定义转换器支持的JAVA类型
|
||||
@MappedTypes(LocalDateTime.class)
|
||||
//定义转换器支持的数据库类型
|
||||
@MappedJdbcTypes(value = JdbcType.TIMESTAMP, includeNullJdbcType = true)
|
||||
public class CustomLocalDateTimeTypeHandler extends BaseTypeHandler<LocalDateTime> {
|
||||
|
||||
public static final String PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
private final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(PATTERN_DATETIME);
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, LocalDateTime parameter, JdbcType jdbcType)
|
||||
throws SQLException {
|
||||
if (parameter != null) {
|
||||
ps.setString(i, dateTimeFormatter.format(parameter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
String target = rs.getString(columnName);
|
||||
if (StringUtils.isEmpty(target)) {
|
||||
return null;
|
||||
}
|
||||
return LocalDateTime.parse(target, dateTimeFormatter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
String target = rs.getString(columnIndex);
|
||||
if (StringUtils.isEmpty(target)) {
|
||||
return null;
|
||||
}
|
||||
return LocalDateTime.parse(target, dateTimeFormatter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
String target = cs.getString(columnIndex);
|
||||
if (StringUtils.isEmpty(target)) {
|
||||
return null;
|
||||
}
|
||||
return LocalDateTime.parse(target, dateTimeFormatter);
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
|
||||
@Configuration
|
||||
public class JacksonConfig {
|
||||
@Bean
|
||||
@Primary
|
||||
@ConditionalOnMissingBean(ObjectMapper.class)
|
||||
public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
|
||||
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
|
||||
// 全局配置序列化返回 JSON 处理
|
||||
SimpleModule simpleModule = new SimpleModule();
|
||||
//JSON Long ==> String
|
||||
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
||||
objectMapper.registerModule(simpleModule);
|
||||
return objectMapper;
|
||||
}
|
||||
}
|
@ -1,140 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.config;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
|
||||
//@Configuration
|
||||
//@EnableCaching
|
||||
public class RedisJedisConfig extends CachingConfigurerSupport {
|
||||
|
||||
|
||||
@Value("${spring.redis.token.host}")
|
||||
private String tokenHost;
|
||||
@Value("${spring.redis.token.password}")
|
||||
private String tokenPassword;
|
||||
@Value("${spring.redis.token.port}")
|
||||
private int tokenPort;
|
||||
@Value("${spring.redis.token.database}")
|
||||
private int tokenDatabase;
|
||||
@Value("${spring.redis.token.timeout}")
|
||||
private int tokenTimeout;
|
||||
|
||||
@Value("${spring.redis.uuid.host}")
|
||||
private String uuidHost;
|
||||
@Value("${spring.redis.uuid.password}")
|
||||
private String uuidPassword;
|
||||
@Value("${spring.redis.uuid.port}")
|
||||
private int uuidPort;
|
||||
@Value("${spring.redis.uuid.database}")
|
||||
private int uuidDatabase;
|
||||
@Value("${spring.redis.uuid.timeout}")
|
||||
private int uuidTimeout;
|
||||
|
||||
@Value("${spring.redis.cache.host}")
|
||||
private String cacheHost;
|
||||
@Value("${spring.redis.cache.password}")
|
||||
private String cachePassword;
|
||||
@Value("${spring.redis.cache.port}")
|
||||
private int cachePort;
|
||||
@Value("${spring.redis.cache.database}")
|
||||
private int cacheDatabase;
|
||||
@Value("${spring.redis.cache.timeout}")
|
||||
private int cacheTimeout;
|
||||
|
||||
private int maxWait;
|
||||
@Value("${spring.redis.jedis.pool.maxIdle}")
|
||||
private int maxIdle;
|
||||
@Value("${spring.redis.jedis.pool.minIdle}")
|
||||
private int minIdle;
|
||||
|
||||
// @Bean("jedisFactoryToken")
|
||||
// public JedisConnectionFactory jedisConnectionFactoryToken() {
|
||||
// return getJedisConnectionFactory(tokenHost,tokenPassword,tokenPort,tokenDatabase);
|
||||
// }
|
||||
//
|
||||
// @Bean("jedisFactoryUuid")
|
||||
// public JedisConnectionFactory jedisConnectionFactoryUuid() {
|
||||
// return getJedisConnectionFactory(uuidHost,uuidPassword,uuidPort,uuidDatabase);
|
||||
// }
|
||||
//
|
||||
// @Bean("jedisFactoryCache")
|
||||
// @Primary
|
||||
// public JedisConnectionFactory jedisConnectionFactoryCache() {
|
||||
// return getJedisConnectionFactory(cacheHost,cachePassword,cachePort,cacheDatabase);
|
||||
// }
|
||||
|
||||
//
|
||||
// public JedisConnectionFactory getJedisConnectionFactory(String host, String password, int port, int database) {
|
||||
// JedisConnectionFactory factory = new JedisConnectionFactory();
|
||||
// factory.setHostName(host);
|
||||
// factory.setPort(port);
|
||||
// factory.setPassword(password);
|
||||
// factory.setDatabase(database);
|
||||
// factory.setTimeout(tokenTimeout);
|
||||
//
|
||||
// JedisPoolConfig config = new JedisPoolConfig();
|
||||
// config.setJmxEnabled(true);
|
||||
// config.setMaxIdle(maxIdle);
|
||||
// config.setMinIdle(minIdle);
|
||||
//// config.setMaxTotal(maxActive);
|
||||
// config.setMaxWaitMillis(maxWait);
|
||||
// config.setTestOnBorrow(false);
|
||||
// config.setTestWhileIdle(true);
|
||||
// config.setMinEvictableIdleTimeMillis(1800000);
|
||||
// config.setSoftMinEvictableIdleTimeMillis(1800000);
|
||||
//
|
||||
// factory.setPoolConfig(config);
|
||||
// factory.afterPropertiesSet();
|
||||
//
|
||||
// return factory;
|
||||
// }
|
||||
// /**
|
||||
// * 默认配置 redis template
|
||||
// *
|
||||
// * @param redisConnectionFactory
|
||||
// * @return
|
||||
// */
|
||||
// @Bean(name = "redisTempletToken")
|
||||
// public RedisTemplate<String, Object> redisTemplateToken(@Qualifier("jedisFactoryToken") RedisConnectionFactory redisConnectionFactory) {
|
||||
// return createRedisTemplate(redisConnectionFactory);
|
||||
// }
|
||||
// @Bean(name = "redisTempletUuid")
|
||||
// public RedisTemplate<String, Object> redisTemplateUuid(@Qualifier("jedisFactoryUuid") RedisConnectionFactory redisConnectionFactory) {
|
||||
// return createRedisTemplate(redisConnectionFactory);
|
||||
// }
|
||||
// @Bean(name = "redisTempletCache")
|
||||
// @Primary()
|
||||
// public RedisTemplate<String, Object> redisTemplateCache(@Qualifier("jedisFactoryCache") RedisConnectionFactory redisConnectionFactory) {
|
||||
// return createRedisTemplate(redisConnectionFactory);
|
||||
// }
|
||||
// /**
|
||||
// * json 实现 redisTemplate
|
||||
// * <p>
|
||||
// * @return
|
||||
// */
|
||||
// public RedisTemplate<String, Object> createRedisTemplate(RedisConnectionFactory factory) {
|
||||
// RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||
// // 配置连接工厂
|
||||
// template.setConnectionFactory(factory);
|
||||
// //使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式)
|
||||
// Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class);
|
||||
// ObjectMapper om = new ObjectMapper();
|
||||
// // 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public
|
||||
// om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
// // 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常
|
||||
// om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
// jacksonSeial.setObjectMapper(om);
|
||||
// // 值采用json序列化
|
||||
// template.setValueSerializer(jacksonSeial);
|
||||
// //使用StringRedisSerializer来序列化和反序列化redis的key值
|
||||
// template.setKeySerializer(new StringRedisSerializer());
|
||||
// // 设置hash key 和value序列化模式
|
||||
// template.setHashKeySerializer(new StringRedisSerializer());
|
||||
// template.setHashValueSerializer(jacksonSeial);
|
||||
// template.afterPropertiesSet();
|
||||
// return template;
|
||||
// }
|
||||
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.ResourceHttpMessageConverter;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dino
|
||||
* @description:
|
||||
* @date 2020/10/27 10:43
|
||||
*/
|
||||
//@Configuration
|
||||
public class WebConfig extends WebMvcConfigurationSupport {
|
||||
|
||||
@Override
|
||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
converters.add(new ByteArrayHttpMessageConverter());
|
||||
converters.add(new StringHttpMessageConverter());
|
||||
converters.add(new ResourceHttpMessageConverter());
|
||||
converters.add(new AllEncompassingFormHttpMessageConverter());
|
||||
converters.add(new StringHttpMessageConverter());
|
||||
converters.add(longToStringConverter());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将返回给前端的Long和long,统一转化成字符串
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public MappingJackson2HttpMessageConverter longToStringConverter() {
|
||||
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
SimpleModule simpleModule = new SimpleModule();
|
||||
//Long
|
||||
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
||||
//long
|
||||
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
|
||||
mapper.registerModule(simpleModule);
|
||||
converter.setObjectMapper(mapper);
|
||||
return converter;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.constant;
|
||||
|
||||
/**
|
||||
* @author dino
|
||||
* @description: 公用常量
|
||||
* @date 2020/10/21 15:06
|
||||
*/
|
||||
public interface CommonConstants {
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
String STATUS_DEL = "deleted";
|
||||
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
String STATUS_NORMAL = "normal";
|
||||
|
||||
/**
|
||||
* 预审
|
||||
*/
|
||||
Integer ROOM_TYPE_1 = 1;
|
||||
|
||||
/**
|
||||
* 候审
|
||||
*/
|
||||
Integer ROOM_TYPE_2 = 2;
|
||||
|
||||
/**
|
||||
* seata transactionId
|
||||
*/
|
||||
String TRANSACTION_ID = "PtxId";
|
||||
|
||||
/**
|
||||
* seata spanId
|
||||
*/
|
||||
String P_SPAN_ID = "PspanId";
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.constant;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public enum EbtpRoleEnum {
|
||||
|
||||
|
||||
PURCHASE_MANAGER("ebtp-purchase", "采购经理"),
|
||||
|
||||
AGENCY_ADMIN("ebtp-agency-admin", "代理机构管理员"),
|
||||
|
||||
AGENCY_SUB_ADMIN("ebtp-agency-sub-admin", "代理机构子管理员"),
|
||||
|
||||
AGENCY_PROJECT_MANAGER("ebtp-agency-project-manager", "代理机构项目经理"),
|
||||
|
||||
EXPERT("ebtp-expert", "专家"),
|
||||
|
||||
SUPPLIER("ebtp-supplier", "供应商"),
|
||||
|
||||
UNICOM_MANAGER("ebtp-unicom-project-manager", "联通采购业务经理"),
|
||||
|
||||
AUCTION_MANAGER("ebtp-auction-manager", "内拍处置经理"),
|
||||
|
||||
AUCTION_PARTICIPANT("ebtp-auction-participant", "内拍参拍人"),
|
||||
|
||||
UNICOM_DEFAULT("ebtp-unicom-default", "联通普通用户"),
|
||||
|
||||
SYSTEM_ADMIN("ebtp-system-admin", "EBTP系统管理员"),
|
||||
|
||||
SYSTEM_SUPERVISION("ebtp-supervision", "监督人员"),
|
||||
|
||||
SYSTEM_EXAMINATION("ebtp-examination", "审查人员"),
|
||||
|
||||
DEFAULT("", ""),
|
||||
|
||||
;
|
||||
|
||||
|
||||
private String role;
|
||||
|
||||
private String desc;
|
||||
|
||||
private EbtpRoleEnum(String role, String desc) {
|
||||
|
||||
this.role = role;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public static EbtpRoleEnum matchDesc(String desc) {
|
||||
return Arrays.stream(values()).filter(o -> o.getDesc().equals(desc)).findAny().orElse(DEFAULT);
|
||||
}
|
||||
|
||||
public static EbtpRoleEnum matchRole(String role) {
|
||||
return Arrays.stream(values()).filter(o -> o.getRole().equals(role)).findAny().orElse(DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.constant;
|
||||
|
||||
/**
|
||||
* 服务名称
|
||||
*
|
||||
* @author dino
|
||||
* @date 2020/11/14 14:16
|
||||
*/
|
||||
public interface ServiceNameConstants {
|
||||
|
||||
|
||||
/**
|
||||
* 加解密服务
|
||||
*/
|
||||
String CRYPT_SERVICE = "core-service-ebtp-crypt";
|
||||
|
||||
/**
|
||||
* 即时通讯
|
||||
*/
|
||||
String IM_SERVICE = "core-service-ebtp-im";
|
||||
|
||||
/**
|
||||
* 支付服务
|
||||
*/
|
||||
String PAY_SERVICE = "core-service-ebtp-pay";
|
||||
|
||||
/**
|
||||
* 大文件上传下载
|
||||
*/
|
||||
String UPDOWNLOAD_SERVICE = "core-service-ebtp-updownload";
|
||||
|
||||
/**
|
||||
* 流程服务
|
||||
*/
|
||||
String PROCESS_SERVICE = "biz-service-ebtp-process";
|
||||
|
||||
/**
|
||||
* 费用设置
|
||||
*/
|
||||
String EXPENSES_SERVICE = "biz-service-ebtp-expenses";
|
||||
|
||||
/**
|
||||
* 竞拍
|
||||
*/
|
||||
String AUCTION_SERVICE = "biz-service-ebtp-auction";
|
||||
|
||||
/**
|
||||
* 应答格式
|
||||
*/
|
||||
String RESPS_SERVICE = "biz-service-ebtp-resps";
|
||||
|
||||
/**
|
||||
* 评审配置结构化服务
|
||||
*/
|
||||
String RSMS_SERVICE = "biz-service-ebtp-rsms";
|
||||
|
||||
|
||||
/**
|
||||
* 项目服务
|
||||
*/
|
||||
String PROJECT_SERVICE = "biz-service-ebtp-project";
|
||||
|
||||
/**
|
||||
* 招标公告、邀请函、应答文件服务
|
||||
*/
|
||||
String BID_SERVICE = "biz-service-ebtp-bid";
|
||||
|
||||
/**
|
||||
* 投标服务
|
||||
*/
|
||||
String TENDER_SERVICE = "biz-service-ebtp-tender";
|
||||
|
||||
/**
|
||||
* 开标大厅
|
||||
*/
|
||||
String OPEN_SERVICE = "biz-service-ebtp-opening";
|
||||
|
||||
/**
|
||||
* 评标
|
||||
*/
|
||||
String EVALUATION_SERVICE = "biz-service-ebtp-evaluation";
|
||||
|
||||
/**
|
||||
* 定标
|
||||
*/
|
||||
String CALIBRATION_SERVICE = "biz-service-ebtp-calibration";
|
||||
|
||||
/**
|
||||
* 归档
|
||||
*/
|
||||
String ARCHIVE_SERVICE = "biz-service-ebtp-archive";
|
||||
|
||||
/**
|
||||
* 交易工具前端
|
||||
*/
|
||||
String FRONTEND_SERVICE = "fe-service-ebtp-frontend";
|
||||
|
||||
/**
|
||||
* 投标客户端工具
|
||||
*/
|
||||
String BIDDING_TOOL_SERVICE = "client-ebtp-bidding-tool";
|
||||
|
||||
/**
|
||||
* 电子签章
|
||||
*/
|
||||
String ELEC_SIGN_SERVICE = "core-service-ebtp-elec-sign";
|
||||
|
||||
/**
|
||||
* 扩展服务
|
||||
*/
|
||||
String EXTEND_SERVICE = "biz-service-ebtp-extend";
|
||||
}
|
||||
|
@ -1,67 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.exception.common;
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.exception.service.BusinessExceptionAssert;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 公共错误提示信息
|
||||
*
|
||||
* @author daixc
|
||||
* @date 2020/10/10
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CommonExceptionEnum implements BusinessExceptionAssert {
|
||||
|
||||
/**
|
||||
* 数据为空
|
||||
*/
|
||||
FRAME_EXCEPTION_COMMON_NOT_FIND(100001, "数据为空!"),
|
||||
/**
|
||||
* 数据不存在
|
||||
*/
|
||||
FRAME_EXCEPTION_COMMON_NOT_EXIST(100002, "数据不存在!"),
|
||||
/**
|
||||
* 数据修改失败
|
||||
*/
|
||||
FRAME_EXCEPTION_COMMON_NOT_UPDATE(100003, "数据修改失败,请刷新后重试!"),
|
||||
/**
|
||||
* id为空
|
||||
*/
|
||||
FRAME_EXCEPTION_COMMON_ID_IS_NULL(100004, "id为空"),
|
||||
/**
|
||||
* 数据已存在
|
||||
*/
|
||||
FRAME_EXCEPTION_COMMON_REPEAT(100005, "数据已存在"),
|
||||
/**
|
||||
* 数据已存在
|
||||
*/
|
||||
FRAME_EXCEPTION_COMMON_ID_FORMAT(100006, "id格式错误"),
|
||||
/**
|
||||
* 数据错误
|
||||
*/
|
||||
FRAME_EXCEPTION_COMMON_DATA__ERROR(100007, "数据错误"),
|
||||
/**
|
||||
* 自定义输出内容
|
||||
*/
|
||||
FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR(100999, ""),
|
||||
/**
|
||||
* 登陆已超期
|
||||
*/
|
||||
LOGIN_EXPIRATION(90401, "登陆已超期"),
|
||||
/**
|
||||
* 无效请求
|
||||
*/
|
||||
LOGIN_CHECK_TOKEN_EXPIRATION(90501, "无效请求");
|
||||
|
||||
/**
|
||||
* 返回码
|
||||
*/
|
||||
private int code;
|
||||
/**
|
||||
* 返回消息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.exception.entity;
|
||||
|
||||
/**
|
||||
* 无效的token
|
||||
*
|
||||
* @author Ajaxfan
|
||||
*/
|
||||
public class AuthFailureException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 7870600175887301004L;
|
||||
|
||||
public AuthFailureException() {
|
||||
}
|
||||
|
||||
public AuthFailureException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public AuthFailureException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public AuthFailureException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.exception.entity;
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.exception.service.IResponseEnum;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
/**
|
||||
* 统一异常类实体
|
||||
*
|
||||
* @author 付庆吉
|
||||
* @date 2020-09-14
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class BusinessException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String message;
|
||||
|
||||
|
||||
public BusinessException(IResponseEnum iResponseEnum, String message) {
|
||||
super(message);
|
||||
this.code = iResponseEnum.getCode();
|
||||
this.message = message;
|
||||
|
||||
}
|
||||
|
||||
public BusinessException(IResponseEnum iResponseEnum, String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.code = iResponseEnum.getCode();
|
||||
this.message = message;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.exception;
|
@ -1,137 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.exception.service;
|
||||
|
||||
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.exception.entity.BusinessException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通用断言接口
|
||||
*
|
||||
* @author 付庆吉
|
||||
* @date 2020-09-14
|
||||
*/
|
||||
public interface Assert {
|
||||
|
||||
|
||||
/**
|
||||
* 创建异常
|
||||
*
|
||||
* @param args
|
||||
* @return
|
||||
*/
|
||||
BusinessException newException(Object... args);
|
||||
|
||||
/**
|
||||
* 创建异常
|
||||
*
|
||||
* @param t
|
||||
* @param args
|
||||
* @return
|
||||
*/
|
||||
BusinessException newException(Throwable t, Object... args);
|
||||
|
||||
/**
|
||||
* 费用管理专用异常
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
BusinessException newExpensesExceptionBykey(String key);
|
||||
|
||||
/**
|
||||
* <p>断言对象<code>obj</code>非空。如果对象<code>obj</code>为空,则抛出异常
|
||||
*
|
||||
* @param obj 待判断对象
|
||||
*/
|
||||
default void assertNotNull(Object obj) {
|
||||
if (obj == null) {
|
||||
throw newException(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>断言对象<code>args</code>非空。如果对象<code>args</code>为null或空字符串,则抛出异常
|
||||
*
|
||||
* @param args 待判断字符串
|
||||
*/
|
||||
default void assertStrNotNull(String... args) {
|
||||
this.assertNotNull(args);
|
||||
for (String arg : args) {
|
||||
if (arg == null || arg.isEmpty()) {
|
||||
throw newException(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据传参抛出异常,则抛出异常
|
||||
*
|
||||
* @param t 验证结果
|
||||
*/
|
||||
default void customValid(boolean t) {
|
||||
if (t) {
|
||||
throw newException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 抛出异常
|
||||
*/
|
||||
default void throwException() {
|
||||
throw newException();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>断言对象<code>obj</code>非空。如果对象<code>obj</code>为空,则抛出异常
|
||||
* 费用管理专用
|
||||
*
|
||||
* @param obj 待判断对象
|
||||
*/
|
||||
default void assertNotNullByKey(String key, Object obj) {
|
||||
if (obj == null) {
|
||||
throw newExpensesExceptionBykey(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断String非空使用
|
||||
* 费用管理专用
|
||||
*
|
||||
* @param obj 待判断对象
|
||||
*/
|
||||
default void assertStringNotNullByKey(String key, Object obj) {
|
||||
if (obj == null || "".equals(obj.toString())) {
|
||||
throw newExpensesExceptionBykey(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据传参抛出异常,则抛出异常
|
||||
*
|
||||
* @param t 验证结果
|
||||
*/
|
||||
default void customValidName(String name, boolean t) {
|
||||
if (t) {
|
||||
throw newExpensesExceptionBykey(name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>断言对象<code>list</code>非空。如果对象<code>list</code>为空,则抛出异常
|
||||
* name 抛出异常名称
|
||||
* 费用管理专用
|
||||
*
|
||||
* @param list 待判断对象
|
||||
*/
|
||||
default void assertListNotNullByName(String name, List list) {
|
||||
if (list != null && list.size() > 0) {
|
||||
|
||||
} else {
|
||||
throw newExpensesExceptionBykey(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.exception.service;
|
||||
|
||||
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.exception.entity.BusinessException;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
|
||||
/**
|
||||
* 初始化异常及断言接口,所有自定义异常Enum均需实现此接口
|
||||
* <p>
|
||||
* 自定义异常枚举中年必须有:code、message
|
||||
*
|
||||
* @author 付庆吉
|
||||
* @date 2020-09-14
|
||||
*/
|
||||
public interface BusinessExceptionAssert extends IResponseEnum, Assert {
|
||||
|
||||
|
||||
@Override
|
||||
default BusinessException newException(Object... args) {
|
||||
String msg = MessageFormat.format(this.getMessage(), args);
|
||||
|
||||
return new BusinessException(this, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
default BusinessException newException(Throwable t, Object... args) {
|
||||
String msg = MessageFormat.format(this.getMessage(), args);
|
||||
|
||||
return new BusinessException(this, msg, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* 费用管理专用
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
default BusinessException newExpensesExceptionBykey(String key) {
|
||||
|
||||
return new BusinessException(this, key + this.getMessage());
|
||||
}
|
||||
|
||||
}
|
@ -1,290 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.exception.service;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.base.entity.BaseResponse;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.exception.common.CommonExceptionEnum;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.exception.entity.AuthFailureException;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.exception.entity.BusinessException;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.util.JsonUtils;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 异常处理 拦截BindException异常,返回HttpStatus是400的绑定错误信息
|
||||
* 拦截FrameException异常,返回HttpStatus是406的业务处理错误信息(支持自定义状态码)
|
||||
* 拦截Exception异常,返回HttpStatus是500服务器内部异常
|
||||
*
|
||||
* @author fqj
|
||||
* @date 2020年9月3日 11:42:25
|
||||
*/
|
||||
@Slf4j
|
||||
@ControllerAdvice
|
||||
@Order()
|
||||
@ResponseBody
|
||||
@ConditionalOnProperty(name = "mconfig.io.seata.core.exception-handle-enabled", matchIfMissing = true)
|
||||
public class BusinessExceptionHandlerAdvice {
|
||||
|
||||
/**
|
||||
* 业务异常处理
|
||||
*
|
||||
* @param request 请求
|
||||
* @param exception ServiceErrorException异常对象
|
||||
* @return 响应
|
||||
*/
|
||||
@ExceptionHandler(value = BusinessException.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public BaseResponse<String> serviceErrorException(HttpServletRequest request, BusinessException exception) {
|
||||
log.info(ExceptionUtil.stacktraceToString(exception));
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
return BaseResponse.fail(exception.getCode(), exception.getMessage(), Convert.toStr(body));
|
||||
}
|
||||
|
||||
/**
|
||||
* hibernate valid 验证异常拦截
|
||||
*
|
||||
* @param request 请求
|
||||
* @param exception ServiceErrorException异常对象
|
||||
* @return 响应
|
||||
*/
|
||||
@ExceptionHandler(value = MethodArgumentNotValidException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public BaseResponse<String> handleInvalidMethodArgException(HttpServletRequest request,
|
||||
MethodArgumentNotValidException exception) {
|
||||
// 堆栈信息转为字符串
|
||||
log.info(ExceptionUtil.stacktraceToString(exception));
|
||||
// 按需重新封装需要返回的错误信息
|
||||
List<ArgumentInvalidResult> invalidArguments = new ArrayList<>();
|
||||
// 解析原错误信息,封装后返回,此处返回非法的字段名称,原始值,错误信息
|
||||
BindingResult bindingResult = exception.getBindingResult();
|
||||
for (FieldError error : bindingResult.getFieldErrors()) {
|
||||
ArgumentInvalidResult invalidArgument = new ArgumentInvalidResult();
|
||||
invalidArgument.setDefaultMessage(error.getDefaultMessage());
|
||||
invalidArgument.setField(error.getField());
|
||||
invalidArgument.setRejectedValue(error.getRejectedValue());
|
||||
invalidArguments.add(invalidArgument);
|
||||
}
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("errors", JsonUtils.objectToJson(invalidArguments));
|
||||
body.put("error", HttpStatus.BAD_REQUEST.getReasonPhrase());
|
||||
|
||||
return BaseResponse.fail(HttpStatus.BAD_REQUEST.value(), "参数验证错误", Convert.toStr(body));
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数绑定异常
|
||||
*
|
||||
* @param request 请求
|
||||
* @param exception BindException异常对象
|
||||
* @return 响应
|
||||
*/
|
||||
@ExceptionHandler(value = BindException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public BaseResponse<String> methodArgumentNotValidHandler(HttpServletRequest request, BindException exception) {
|
||||
// 按需重新封装需要返回的错误信息
|
||||
List<ArgumentInvalidResult> invalidArguments = new ArrayList<>();
|
||||
// 解析原错误信息,封装后返回,此处返回非法的字段名称,原始值,错误信息
|
||||
for (FieldError error : exception.getBindingResult().getFieldErrors()) {
|
||||
ArgumentInvalidResult invalidArgument = new ArgumentInvalidResult();
|
||||
invalidArgument.setDefaultMessage(error.getDefaultMessage());
|
||||
invalidArgument.setField(error.getField());
|
||||
invalidArgument.setRejectedValue(error.getRejectedValue());
|
||||
invalidArguments.add(invalidArgument);
|
||||
}
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("errors", JsonUtils.objectToJson(invalidArguments));
|
||||
body.put("error", HttpStatus.BAD_REQUEST.getReasonPhrase());
|
||||
|
||||
return BaseResponse.fail(HttpStatus.BAD_REQUEST.value(), "参数错误", Convert.toStr(body));
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求方式异常
|
||||
*
|
||||
* @param request 请求
|
||||
* @param exception HttpRequestMethodNotSupportedException异常对象
|
||||
* @return 响应
|
||||
*/
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
|
||||
public BaseResponse<String> handleMethodNotSupportedException(HttpServletRequest request,
|
||||
HttpRequestMethodNotSupportedException exception) {
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("errors", exception.getMessage());
|
||||
body.put("error", HttpStatus.METHOD_NOT_ALLOWED.getReasonPhrase());
|
||||
|
||||
return BaseResponse.fail(HttpStatus.METHOD_NOT_ALLOWED.value(), "错误的请求方式", Convert.toStr(body));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户验证失败,无效的token
|
||||
*
|
||||
* @param request 请求
|
||||
* @param exception InvalidTokenException异常对象
|
||||
* @return 响应
|
||||
*/
|
||||
@ExceptionHandler(AuthFailureException.class)
|
||||
@ResponseStatus(HttpStatus.UNAUTHORIZED)
|
||||
public BaseResponse<String> handleInvalidTokenException(HttpServletRequest request,
|
||||
AuthFailureException exception) {
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("errors", exception.getMessage());
|
||||
body.put("error", HttpStatus.UNAUTHORIZED.getReasonPhrase());
|
||||
|
||||
return BaseResponse.fail(CommonExceptionEnum.LOGIN_EXPIRATION.getCode(), "登陆已超期", Convert.toStr(body));
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数缺失
|
||||
*
|
||||
* @param request 请求
|
||||
* @param exception MissingServletRequestParameterException异常对象
|
||||
* @return 响应
|
||||
*/
|
||||
@ExceptionHandler(MissingServletRequestParameterException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public BaseResponse<String> handleMissingParameterException(HttpServletRequest request,
|
||||
MissingServletRequestParameterException exception) {
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("errors", exception.getMessage());
|
||||
body.put("error", HttpStatus.BAD_REQUEST.getReasonPhrase());
|
||||
|
||||
return BaseResponse.fail(HttpStatus.BAD_REQUEST.value(), "参数缺失", Convert.toStr(body));
|
||||
}
|
||||
|
||||
// ----------------------------data--------------------------------------
|
||||
|
||||
/**
|
||||
* 数据库异常
|
||||
*
|
||||
* @param request 请求
|
||||
* @param exception DataAccessException异常对象
|
||||
* @return 响应
|
||||
*/
|
||||
@ExceptionHandler(DataAccessException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public BaseResponse<String> handlerDataAccessException(HttpServletRequest request, DataAccessException exception) {
|
||||
log.error(ExceptionUtil.stacktraceToString(exception));
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("errors", exception.getMessage());
|
||||
body.put("error", HttpStatus.BAD_REQUEST.getReasonPhrase());
|
||||
|
||||
return BaseResponse.fail(HttpStatus.BAD_REQUEST.value(), "数据库异常", Convert.toStr(body));
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据不存在
|
||||
*
|
||||
* @param request 请求
|
||||
* @param exception EmptyResultDataAccessException异常对象
|
||||
* @return 响应
|
||||
*/
|
||||
@ExceptionHandler(EmptyResultDataAccessException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public BaseResponse<String> handleDataEmptyException(HttpServletRequest request,
|
||||
EmptyResultDataAccessException exception) {
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("errors", exception.getMessage());
|
||||
body.put("error", HttpStatus.BAD_REQUEST.getReasonPhrase());
|
||||
|
||||
return BaseResponse.fail(HttpStatus.BAD_REQUEST.value(), "数据不存在", Convert.toStr(body));
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求方式异常
|
||||
*
|
||||
* @param request 请求
|
||||
* @param exception DuplicateKeyException异常对象
|
||||
* @return 响应
|
||||
*/
|
||||
@ExceptionHandler(DuplicateKeyException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public BaseResponse<String> handleDataDualException(HttpServletRequest request, DuplicateKeyException exception) {
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("errors", exception.getMessage());
|
||||
body.put("error", HttpStatus.BAD_REQUEST.getReasonPhrase());
|
||||
|
||||
return BaseResponse.fail(HttpStatus.BAD_REQUEST.value(), "数据重复插入", Convert.toStr(body));
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法参数类型不匹配异常
|
||||
*
|
||||
* @param request 请求
|
||||
* @param exception MethodArgumentTypeMismatchException异常对象
|
||||
* @return 响应
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public BaseResponse<String> handleMethodArgumentTypeException(HttpServletRequest request,
|
||||
MethodArgumentTypeMismatchException exception) {
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("errors", exception.getMessage());
|
||||
body.put("error", HttpStatus.BAD_REQUEST.getReasonPhrase());
|
||||
|
||||
return BaseResponse.fail(HttpStatus.BAD_REQUEST.value(), "参数类型不匹配", Convert.toStr(body));
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局异常处理
|
||||
*
|
||||
* @param request 请求
|
||||
* @param exception Exception异常对象
|
||||
* @return 响应
|
||||
*/
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public BaseResponse<String> handleException(HttpServletRequest request, Exception exception) {
|
||||
// 堆栈信息转为字符串
|
||||
log.info(ExceptionUtil.stacktraceToString(exception));
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("errors", exception.getMessage());
|
||||
body.put("error", HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase());
|
||||
|
||||
return BaseResponse.fail(HttpStatus.INTERNAL_SERVER_ERROR.value(), "系统异常", Convert.toStr(body));
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数异常
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
class ArgumentInvalidResult {
|
||||
/**
|
||||
* 字段名
|
||||
*/
|
||||
private String field;
|
||||
/**
|
||||
* 输入的错误值
|
||||
*/
|
||||
private Object rejectedValue;
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
private String defaultMessage;
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.exception.service;
|
||||
|
||||
|
||||
public interface IResponseEnum {
|
||||
|
||||
|
||||
int getCode();
|
||||
|
||||
String getMessage();
|
||||
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.idempotent.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author ITyunqing
|
||||
*/
|
||||
@Inherited
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
public @interface Idempotent {
|
||||
|
||||
/**
|
||||
* 有效期 默认:1 有效期要大于程序执行时间,否则请求还是可能会进来
|
||||
*
|
||||
* @return expireTime
|
||||
*/
|
||||
int expireTime() default 1;
|
||||
|
||||
/**
|
||||
* 时间单位 默认:s
|
||||
*
|
||||
* @return TimeUnit
|
||||
*/
|
||||
TimeUnit timeUnit() default TimeUnit.SECONDS;
|
||||
|
||||
/**
|
||||
* 提示信息,可自定义
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String info() default "重复请求,请稍后重试";
|
||||
|
||||
/**
|
||||
* 是否在业务完成后删除key true:删除 false:不删除
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean delKey() default false;
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.poiExport.constant;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
||||
public class AbstractConstant {
|
||||
|
||||
|
||||
public static <T> List<T> deepCopy(List<T> src) throws IOException, ClassNotFoundException {
|
||||
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
||||
ObjectOutputStream out = new ObjectOutputStream(byteOut);
|
||||
out.writeObject(src);
|
||||
|
||||
ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
|
||||
ObjectInputStream in = new ObjectInputStream(byteIn);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<T> dest = (List<T>) in.readObject();
|
||||
return dest;
|
||||
}
|
||||
|
||||
public static String[] getExcelResultValue(String resultValue) {
|
||||
String[] value = null;
|
||||
if (resultValue.indexOf(")") > 0) {
|
||||
resultValue = resultValue.substring(1, resultValue.length());
|
||||
value = resultValue.split("\\)");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//初审选项
|
||||
public static String[] EXCEL_FIRST_RADIO_VALUE = new String[]{"合格", "不合格"};
|
||||
//详审选项
|
||||
public static String[] EXCEL_DETAILED_CHECKBOX_VALUE = new String[]{"满足", "不满足"};
|
||||
|
||||
|
||||
}
|
@ -1,324 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.poiExport.constant;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.poiExport.entity.ExcelTable;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.poiExport.entity.ExcelTd;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.common.poiExport.entity.ExcelTr;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ExportConstant {
|
||||
|
||||
|
||||
public static File generateExcelByTable(ExcelTable table) throws IOException {
|
||||
XSSFWorkbook wb = new XSSFWorkbook();//工作流
|
||||
|
||||
XSSFSheet sheet = wb.createSheet(table.getTableSheetName());
|
||||
|
||||
List<ExcelTr> trList = table.getExcelTrList();
|
||||
|
||||
Map<String, String> mergeColMap = new HashMap();//列相同屯行
|
||||
|
||||
for (int r = 0; r < trList.size(); r++) {
|
||||
XSSFRow row = sheet.createRow(r);//行
|
||||
ExcelTr tr = trList.get(r);
|
||||
if (tr.getHeight() != null) row.setHeight((short) tr.getHeight().intValue());
|
||||
//行隐藏
|
||||
if (tr.getIsHidde()) {
|
||||
row.getCTRow().setHidden(tr.getIsHidde());
|
||||
}
|
||||
|
||||
List<ExcelTd> tdList = tr.getExcelTdList();
|
||||
for (int col = 0; col < tdList.size(); col++) {
|
||||
XSSFCell ce = row.createCell(col);//列
|
||||
ExcelTd td = tdList.get(col);
|
||||
if (td.getIsAoutSizeColumn()) {
|
||||
sheet.autoSizeColumn(col, td.getIsAoutSizeColumn());
|
||||
}
|
||||
|
||||
if (td.getWidth() != null) sheet.setColumnWidth(col, td.getWidth());//列宽
|
||||
if (td.getIsRowMerge()) {
|
||||
CellRangeAddress cra = new CellRangeAddress(r, r, col, col + td.getRowMergeNum() - 1);//吞行
|
||||
sheet.addMergedRegion(cra);
|
||||
}
|
||||
|
||||
|
||||
if (td.getColEqMerge()) {
|
||||
String value = td.getTdValue();
|
||||
if (mergeColMap.get(value) != null) {
|
||||
String merge = mergeColMap.get(value);
|
||||
merge = merge.substring(0, merge.lastIndexOf("_")) + "_" + r;
|
||||
mergeColMap.put(value, merge);
|
||||
} else {
|
||||
String merge = col + "_" + col + "_" + r + "_" + r;
|
||||
mergeColMap.put(value, merge);
|
||||
}
|
||||
}
|
||||
|
||||
//列隐藏
|
||||
if (td.getIsHidde()) {
|
||||
sheet.setColumnHidden(col, td.getIsHidde());
|
||||
}
|
||||
|
||||
if (td.getIsSelect()) {
|
||||
ExportConstant.setExplicitList(td.getSelect(), sheet, r, r, col, col);
|
||||
}
|
||||
|
||||
ce.setCellValue(td.getTdValue());
|
||||
ce.setCellStyle(ExportConstant.getStyle(td.getCellStyleKey(), wb));
|
||||
}
|
||||
}
|
||||
|
||||
//吞列
|
||||
for (String key : mergeColMap.keySet()) {
|
||||
String merges = mergeColMap.get(key);
|
||||
String[] merge = merges.split("_");
|
||||
if (!merge[2].equals(merge[3])) {
|
||||
//第一行吞行
|
||||
CellRangeAddress mergCra = new CellRangeAddress(Integer.valueOf(merge[2]),
|
||||
Integer.valueOf(merge[3]),
|
||||
Integer.valueOf(merge[0]),
|
||||
Integer.valueOf(merge[1]));//吞行
|
||||
sheet.addMergedRegion(mergCra);
|
||||
}
|
||||
}
|
||||
|
||||
//FileOutputStream out = new FileOutputStream( new File("D:/恒熠/联通/需求/3.0/评审/测试.xlsx"));
|
||||
|
||||
File file = new File(table.getFileName() + ".xlsx");
|
||||
FileOutputStream out = new FileOutputStream(file);
|
||||
wb.write(out);
|
||||
out.close();
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成下拉选
|
||||
*
|
||||
* @param strs 下拉选内容
|
||||
* @param sheet 生成sheet
|
||||
* @param firstRow 起始列
|
||||
* @param lastRow 结束列
|
||||
* @param irstCol 起始行
|
||||
* @param lastCol 结束行
|
||||
*/
|
||||
public static void setExplicitList(String[] strs, XSSFSheet sheet, int firstRow, int lastRow, int irstCol, int lastCol) {
|
||||
//
|
||||
DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper();
|
||||
DataValidationConstraint createExplicitListConstraint = dataValidationHelper.createExplicitListConstraint(strs);
|
||||
CellRangeAddressList regions = new CellRangeAddressList(firstRow, lastRow, irstCol, lastCol);
|
||||
DataValidation createValidation = dataValidationHelper.createValidation(createExplicitListConstraint, regions);
|
||||
//处理Excel兼容性问题
|
||||
if (createValidation instanceof XSSFDataValidation) {
|
||||
createValidation.setSuppressDropDownArrow(true);
|
||||
createValidation.setShowErrorBox(true);
|
||||
} else {
|
||||
createValidation.setSuppressDropDownArrow(false);
|
||||
}
|
||||
sheet.addValidationData(createValidation);
|
||||
}
|
||||
|
||||
public static XSSFCellStyle getStyle(String key, XSSFWorkbook wb) {
|
||||
return ExportConstant.getStyle(key, wb, null);
|
||||
}
|
||||
|
||||
public static XSSFCellStyle getStyle(String key, XSSFWorkbook wb, java.awt.Color color) {
|
||||
if (color == null) color = new java.awt.Color(0x0A0A0A);//黑色
|
||||
if ("name".equals(key)) {
|
||||
return ExportConstant.getNameStyle(wb);
|
||||
} else if ("title1".equals(key)) {
|
||||
return ExportConstant.getTitleStyle(wb, "1");
|
||||
} else if ("title2".equals(key)) {
|
||||
return ExportConstant.getTitleStyle(wb, "2");
|
||||
} else if ("content_black".equals(key)) {
|
||||
|
||||
return ExportConstant.getContentStyle(wb, "宋体", 11, color);
|
||||
} else if ("noBorderCenter16".equals(key)) {
|
||||
return ExportConstant.noBorderCenter16(wb);
|
||||
} else if ("noBorderLeft12".equals(key)) {
|
||||
return ExportConstant.noBorderLeft12(wb);
|
||||
} else if ("noBorderRight12".equals(key)) {
|
||||
return ExportConstant.noBorderRight12(wb);
|
||||
}
|
||||
|
||||
return ExportConstant.getContentStyle(wb, "宋体", 11, color);
|
||||
}
|
||||
|
||||
public static XSSFCellStyle noBorderCenter16(XSSFWorkbook wb) {
|
||||
XSSFCellStyle cellStyle = wb.createCellStyle();
|
||||
cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中
|
||||
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
|
||||
|
||||
XSSFFont font = wb.createFont();
|
||||
font.setFontHeightInPoints((short) 16);
|
||||
cellStyle.setFont(font);
|
||||
return cellStyle;
|
||||
}
|
||||
|
||||
public static XSSFCellStyle noBorderLeft12(XSSFWorkbook wb) {
|
||||
XSSFCellStyle cellStyle = wb.createCellStyle();
|
||||
cellStyle.setAlignment(HorizontalAlignment.LEFT);//水平居左
|
||||
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
|
||||
|
||||
XSSFFont font = wb.createFont();
|
||||
font.setFontHeightInPoints((short) 12);
|
||||
cellStyle.setFont(font);
|
||||
return cellStyle;
|
||||
}
|
||||
|
||||
public static XSSFCellStyle noBorderRight12(XSSFWorkbook wb) {
|
||||
XSSFCellStyle cellStyle = wb.createCellStyle();
|
||||
cellStyle.setAlignment(HorizontalAlignment.RIGHT);//水平居右
|
||||
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
|
||||
|
||||
XSSFFont font = wb.createFont();
|
||||
font.setFontHeightInPoints((short) 12);
|
||||
cellStyle.setFont(font);
|
||||
return cellStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表头项目名称一列的样式
|
||||
*
|
||||
* @param wb 文本对象
|
||||
* @return
|
||||
*/
|
||||
public static XSSFCellStyle getNameStyle(XSSFWorkbook wb) {
|
||||
XSSFCellStyle style_name = wb.createCellStyle(); //项目名称样式
|
||||
style_name.setAlignment(HorizontalAlignment.CENTER);//水平居中
|
||||
style_name.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
|
||||
XSSFFont font_name = wb.createFont();//项目名称字体样式
|
||||
font_name.setBold(true);//加粗
|
||||
font_name.setFontName("宋体");
|
||||
font_name.setColor(new XSSFColor(new java.awt.Color(0xFF0000)));
|
||||
font_name.setFontHeightInPoints((short) 18);
|
||||
style_name.setFont(font_name);
|
||||
return style_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表头一列的样式 序号 评审类别 评审项 评审因素 评审标准 供应商1、2、3
|
||||
*
|
||||
* @param wb 文本对象
|
||||
* @param type 标题类型 1、标题 2、供应商
|
||||
* @return
|
||||
*/
|
||||
public static XSSFCellStyle getTitleStyle(XSSFWorkbook wb, String type) {
|
||||
|
||||
XSSFCellStyle style_title = wb.createCellStyle(); //标题样式1
|
||||
XSSFFont font_title = wb.createFont();//标题字体样式1
|
||||
if (type.equals("1")) {
|
||||
style_title.setFillForegroundColor(new XSSFColor(new java.awt.Color(0x8D8B8B)));//背景色
|
||||
style_title.setBorderBottom(BorderStyle.THIN);
|
||||
style_title.setBorderTop(BorderStyle.THIN);
|
||||
style_title.setBorderLeft(BorderStyle.THIN);
|
||||
style_title.setBorderRight(BorderStyle.THIN);
|
||||
style_title.setAlignment(HorizontalAlignment.CENTER);
|
||||
style_title.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
|
||||
|
||||
|
||||
font_title.setBold(true);//加粗
|
||||
font_title.setFontName("宋体");
|
||||
font_title.setColor(new XSSFColor(new java.awt.Color(0x070707)));//字体颜色
|
||||
font_title.setFontHeightInPoints((short) 12);
|
||||
style_title.setFont(font_title);
|
||||
} else if (type.equals("2")) {
|
||||
style_title.setFillForegroundColor(new XSSFColor(new java.awt.Color(0x898888)));//背景色
|
||||
style_title.setBorderBottom(BorderStyle.THIN);
|
||||
style_title.setBorderTop(BorderStyle.THIN);
|
||||
style_title.setBorderLeft(BorderStyle.THIN);
|
||||
style_title.setBorderRight(BorderStyle.THIN);
|
||||
style_title.setAlignment(HorizontalAlignment.CENTER);
|
||||
style_title.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
|
||||
font_title.setBold(true);//加粗
|
||||
font_title.setFontName("宋体");
|
||||
font_title.setColor(new XSSFColor(new java.awt.Color(0xF50303)));
|
||||
font_title.setFontHeightInPoints((short) 12);
|
||||
style_title.setFont(font_title);
|
||||
}
|
||||
return style_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表头一列的样式 序号 评审类别 评审项 评审因素 评审标准 供应商1、2、3
|
||||
*
|
||||
* @param wb 文本对象
|
||||
* @param fontName 字体
|
||||
* @param points 字号
|
||||
* @param color 颜色 1、黑 2、红
|
||||
* @return
|
||||
*/
|
||||
public static XSSFCellStyle getContentStyle(XSSFWorkbook wb, String fontName, int points, java.awt.Color color) {
|
||||
XSSFCellStyle style_content = wb.createCellStyle(); //内容样式1
|
||||
style_content.setBorderBottom(BorderStyle.THIN);
|
||||
style_content.setBorderTop(BorderStyle.THIN);
|
||||
style_content.setBorderLeft(BorderStyle.THIN);
|
||||
style_content.setBorderRight(BorderStyle.THIN);
|
||||
style_content.setAlignment(HorizontalAlignment.CENTER);
|
||||
style_content.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
|
||||
style_content.setWrapText(true);
|
||||
XSSFFont font_content = wb.createFont();//内容字体样式
|
||||
font_content.setFontName(fontName);//宋体
|
||||
font_content.setFontHeightInPoints((short) points);//11
|
||||
font_content.setColor(new XSSFColor(color));
|
||||
/* if(color.equals("1")) {
|
||||
font_content.setColor(new XSSFColor(new java.awt.Color(0x0A0A0A)));
|
||||
}else if(color.equals("2")){
|
||||
font_content.setColor(new XSSFColor(new java.awt.Color(0xF50303)));
|
||||
}*/
|
||||
|
||||
style_content.setFont(font_content);
|
||||
return style_content;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置列宽
|
||||
*
|
||||
* @param sheet
|
||||
* @param colList
|
||||
*/
|
||||
public static void setColumnWidth(XSSFSheet sheet, List<Integer> colList) {
|
||||
for (int i = 0; i < colList.size(); i++) {
|
||||
sheet.setColumnWidth(i, colList.get(i));//列宽
|
||||
}
|
||||
}
|
||||
|
||||
public static void exportFile(HttpServletResponse response, File file) {
|
||||
OutputStream out = null;
|
||||
InputStream is = null;
|
||||
try {
|
||||
response.addHeader("content-disposition", "attachment;filename="
|
||||
+ java.net.URLEncoder.encode(file.getName(), "utf-8"));
|
||||
out = response.getOutputStream();
|
||||
is = new FileInputStream(file);
|
||||
|
||||
byte[] b = new byte[4096];
|
||||
int size = is.read(b);
|
||||
while (size > 0) {
|
||||
out.write(b, 0, size);
|
||||
size = is.read(b);
|
||||
}
|
||||
out.close();
|
||||
is.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (is != null) is.close();
|
||||
if (out != null) out.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.poiExport.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fqj
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel
|
||||
public class ExcelTable implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ExcelTable(String tableSheetName) {
|
||||
this.setTableSheetName(tableSheetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
private String fileName;
|
||||
/**
|
||||
* sheet名称
|
||||
*/
|
||||
private String tableSheetName;
|
||||
/**
|
||||
* sheet序号
|
||||
*/
|
||||
private int tableSheetSort = 0;
|
||||
|
||||
private List<ExcelTr> excelTrList;
|
||||
|
||||
public void add(ExcelTr tr) {
|
||||
if (excelTrList != null) {
|
||||
|
||||
} else {
|
||||
excelTrList = new ArrayList<>();
|
||||
}
|
||||
excelTrList.add(tr);
|
||||
}
|
||||
|
||||
public void addll(List<ExcelTr> trList) {
|
||||
if (excelTrList != null) {
|
||||
|
||||
} else {
|
||||
excelTrList = new ArrayList<>();
|
||||
}
|
||||
excelTrList.addAll(trList);
|
||||
}
|
||||
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.poiExport.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author fqj
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel
|
||||
public class ExcelTd implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String tdName;
|
||||
/**
|
||||
* 内容 显示内容
|
||||
*/
|
||||
private String tdValue;
|
||||
/**
|
||||
* 行序号
|
||||
*/
|
||||
private int rowNum = 0;
|
||||
/**
|
||||
* 列序号
|
||||
*/
|
||||
private int colNum = 0;
|
||||
/**
|
||||
* 列是否隐藏
|
||||
*/
|
||||
private Boolean isHidde = false;
|
||||
/**
|
||||
* 样式
|
||||
*/
|
||||
private String cellStyleKey;
|
||||
|
||||
/**
|
||||
* 是否行合并
|
||||
*/
|
||||
private Boolean isRowMerge = false;
|
||||
/**
|
||||
* 行合并参数 当前位置向右吞行数量
|
||||
*/
|
||||
private Integer rowMergeNum;
|
||||
|
||||
/**
|
||||
* 是否列相同合并
|
||||
*/
|
||||
private Boolean colEqMerge = false;
|
||||
|
||||
/**
|
||||
* 宽
|
||||
*/
|
||||
private Integer width;
|
||||
|
||||
private Boolean isSelect = false;
|
||||
|
||||
private String[] select;
|
||||
|
||||
/**
|
||||
* 自适应行高
|
||||
*/
|
||||
private Boolean isAoutSizeColumn = false;
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.poiExport.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
||||
import org.apache.poi.xssf.usermodel.XSSFFont;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fqj
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel
|
||||
public class ExcelTr implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 样式
|
||||
*/
|
||||
private XSSFCellStyle cellStyle;
|
||||
/**
|
||||
* 字体
|
||||
*/
|
||||
private XSSFFont font;
|
||||
|
||||
/**
|
||||
* 行是否隐藏
|
||||
*/
|
||||
private Boolean isHidde = false;
|
||||
|
||||
private List<ExcelTd> excelTdList;
|
||||
|
||||
/**
|
||||
* 高
|
||||
*/
|
||||
private Integer height;
|
||||
|
||||
public void add(ExcelTd td) {
|
||||
if (excelTdList != null) {
|
||||
|
||||
} else {
|
||||
excelTdList = new ArrayList<>();
|
||||
}
|
||||
excelTdList.add(td);
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.util;
|
||||
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 获得request
|
||||
*
|
||||
* @author daixc
|
||||
* @version 1.0
|
||||
* @date 2020/10/16
|
||||
*/
|
||||
public final class HttpContextUtils {
|
||||
|
||||
/**
|
||||
* 静态类不可构造
|
||||
*/
|
||||
private HttpContextUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得HttpServletRequest
|
||||
*
|
||||
* @return HttpServletRequest
|
||||
*/
|
||||
public static HttpServletRequest getHttpServletRequest() {
|
||||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
if (requestAttributes != null) {
|
||||
return ((ServletRequestAttributes) requestAttributes).getRequest();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得HttpServletResponse
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static HttpServletResponse getHttpServletResponse() {
|
||||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
if (requestAttributes != null) {
|
||||
return ((ServletRequestAttributes) requestAttributes).getResponse();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* IP地址
|
||||
*/
|
||||
public class IPUtils {
|
||||
|
||||
private IPUtils() {
|
||||
}
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(IPUtils.class);
|
||||
@SuppressWarnings("PMD")
|
||||
public static final String LOCAL_V4 = "127.0.0.1";
|
||||
@SuppressWarnings("PMD")
|
||||
public static final String LOCAL_V6 = "0:0:0:0:0:0:0:1";
|
||||
|
||||
/**
|
||||
* 获取IP地址
|
||||
* <p>
|
||||
* 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
|
||||
* 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
|
||||
*/
|
||||
public static String getIpAddr(HttpServletRequest request) {
|
||||
try {
|
||||
final String un = "unknown";
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (StringUtils.isEmpty(ip) || un.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || ip.length() == 0 || un.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || un.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_CLIENT_IP");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || un.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || un.equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
return ip.equals(LOCAL_V6) ? LOCAL_V4 : ip;
|
||||
} catch (Exception e) {
|
||||
LOG.error("IPUtils ERROR ", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,124 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.util;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* json util
|
||||
*
|
||||
* @author 付庆吉
|
||||
* @date 2020-09-16
|
||||
*/
|
||||
@Slf4j
|
||||
public class JsonUtils {
|
||||
|
||||
// 定义jackson对象
|
||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||
|
||||
/**
|
||||
* 将对象转换成json字符串。
|
||||
* <p>Title: pojoToJson</p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static String objectToJson(Object data) {
|
||||
try {
|
||||
MAPPER.registerModule(new ParameterNamesModule())
|
||||
.registerModule(new Jdk8Module())
|
||||
.registerModule(new JavaTimeModule());
|
||||
return MAPPER.writeValueAsString(data);
|
||||
} catch (JsonProcessingException e) {
|
||||
log.info(ExceptionUtil.stacktraceToString(e));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将json结果集转化为对象
|
||||
*
|
||||
* @param jsonData json数据
|
||||
* @param beanType 对象中的object类型
|
||||
* @return
|
||||
*/
|
||||
public static <T> T jsonToPojo(String jsonData, Class<T> beanType) {
|
||||
try {
|
||||
return MAPPER.readValue(jsonData, beanType);
|
||||
} catch (Exception e) {
|
||||
log.info(ExceptionUtil.stacktraceToString(e));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将json数据转换成pojo对象list
|
||||
* <p>Title: jsonToList</p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @param jsonData
|
||||
* @param beanType
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<T> jsonToList(String jsonData, Class<T> beanType) {
|
||||
JavaType javaType = MAPPER.getTypeFactory().constructParametricType(List.class, beanType);
|
||||
try {
|
||||
List<T> list = MAPPER.readValue(jsonData, javaType);
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
log.info(ExceptionUtil.stacktraceToString(e));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将List<DTO>转为List<VO>
|
||||
* <p>Title: jsonToList</p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @param jsonData
|
||||
* @param beanType
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<T> jsonToList(List jsonData, Class<T> beanType) {
|
||||
List<T> list = new ArrayList<>();
|
||||
try {
|
||||
for (Object jd : jsonData) {
|
||||
T t = beanType.newInstance();
|
||||
BeanUtil.copyProperties(jd, t);
|
||||
list.add(t);
|
||||
}
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将可变参数转化为数组类型的字符串<VO>
|
||||
* <p>Title: jsonToList</p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @param args 参数列表
|
||||
* @return
|
||||
*/
|
||||
public static String argsToArray(Object... args) {
|
||||
return objectToJson(args);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.util;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* <P>配置文件参数注入</P>
|
||||
* 获取配置文件的参数配置
|
||||
*
|
||||
* @author daixc
|
||||
* @date 2020/10/10
|
||||
*/
|
||||
public class PropertyUtils {
|
||||
|
||||
private final static long WORKER_ID;
|
||||
private final static long DATACENTER_ID;
|
||||
|
||||
static {
|
||||
WORKER_ID = getWorkId();
|
||||
DATACENTER_ID = getDataCenterId();
|
||||
}
|
||||
|
||||
private static Long getWorkId() {
|
||||
try {
|
||||
String hostAddress = Inet4Address.getLocalHost().getHostAddress();
|
||||
int[] ints = StringUtils.toCodePoints(hostAddress);
|
||||
int sums = 0;
|
||||
for (int b : ints) {
|
||||
sums += b;
|
||||
}
|
||||
return (long) (sums % 32);
|
||||
} catch (UnknownHostException e) {
|
||||
// 如果获取失败,则使用随机数备用
|
||||
return RandomUtils.nextLong(0, 31);
|
||||
}
|
||||
}
|
||||
|
||||
private static Long getDataCenterId() {
|
||||
int[] ints = StringUtils.toCodePoints(SystemUtils.getHostName());
|
||||
int sums = 0;
|
||||
for (int i : ints) {
|
||||
sums += i;
|
||||
}
|
||||
return (long) (sums % 32);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成雪花id,
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getSnowflakeId() {
|
||||
return String.valueOf(getSnowflakeLongId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成雪花id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static long getSnowflakeLongId() {
|
||||
|
||||
return IdUtil.getSnowflake(WORKER_ID, DATACENTER_ID).nextId();
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.util;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* <p> Title: SpringContextUtil </p>
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2020-09-16
|
||||
*/
|
||||
@Component
|
||||
public class SpringContextBeansUtil implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
/**
|
||||
* 实现ApplicationContextAware接口的回调方法,设置上下文环境
|
||||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
setApplication(applicationContext);
|
||||
}
|
||||
|
||||
private static void setApplication(ApplicationContext context) {
|
||||
applicationContext = context;
|
||||
}
|
||||
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象
|
||||
*
|
||||
* @return Object 一个以所给名字注册的bean的实例 (service注解方式,自动生成以首字母小写的类名为bean name)
|
||||
*/
|
||||
public static Object getBean(String name) throws BeansException {
|
||||
return applicationContext.getBean(name);
|
||||
}
|
||||
|
||||
public static <T> T getBean(Class<T> clazz) {
|
||||
return getApplicationContext().getBean(clazz);
|
||||
}
|
||||
|
||||
public static boolean containsBean(String beanName) {
|
||||
return applicationContext.containsBean(beanName);
|
||||
}
|
||||
|
||||
}
|
@ -1 +0,0 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.common.util;
|
@ -2,34 +2,14 @@ server:
|
||||
port: 18096
|
||||
servlet:
|
||||
context-path: /
|
||||
|
||||
#seata:
|
||||
# service:
|
||||
# vgroup-mapping:
|
||||
# biz-supplier-manage-service-group: seata-server-jl
|
||||
# registry:
|
||||
# type: eureka
|
||||
# eureka:
|
||||
# serviceUrl: http://localhost:8080/eureka/
|
||||
|
||||
# 对应 apollo 配置中心的应用名
|
||||
app:
|
||||
id: biz-supplier-manage
|
||||
|
||||
# Apollo 配置信息
|
||||
apollo:
|
||||
meta: http://localhost:8070
|
||||
bootstrap:
|
||||
namespace: application
|
||||
enabled: true
|
||||
eagerLoad:
|
||||
enabled: true
|
||||
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:18848
|
||||
aop:
|
||||
auto: true #开启spring的aop配置
|
||||
proxy-target-class: true
|
||||
|
||||
application:
|
||||
name: biz-supplier-manage
|
||||
|
||||
@ -41,8 +21,8 @@ spring:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password: Unicom@2024
|
||||
jdbc-url: jdbc:mysql://59.110.10.99:53306/ebtp_mall_project?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||
url: jdbc:mysql://59.110.10.99:53306/ebtp_mall_project?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||
jdbc-url: jdbc:mysql://59.110.10.99:53306/cosco_supplier_manager?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||
url: jdbc:mysql://59.110.10.99:53306/cosco_supplier_manager?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||
filters: stat,wall,log4j
|
||||
maxActive: 20
|
||||
initialSize: 1
|
||||
@ -94,19 +74,12 @@ spring:
|
||||
redis:
|
||||
host: localhost # Redis 服务器地址,默认本地:ml-citation{ref="1,4" data="citationList"}
|
||||
port: 6379 # 监听端口,默认 6379:ml-citation{ref="1,4" data="citationList"}
|
||||
password: Yhblsqt%21 # 访问密码(若无密码可省略):ml-citation{ref="1,4" data="citationList"}
|
||||
database: 4 # 选择数据库编号,默认 0:ml-citation{ref="1,6" data="citationList"}
|
||||
# password: Yhblsqt%21 # 访问密码(若无密码可省略):ml-citation{ref="1,4" data="citationList"}
|
||||
# database: 4 # 选择数据库编号,默认 0:ml-citation{ref="1,6" data="citationList"}
|
||||
timeout: 3000 # 连接超时时间(单位:毫秒):ml-citation{ref="4,6" data="citationList"}
|
||||
|
||||
|
||||
# 天宫Eureka配置
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://localhost:8080/eureka/
|
||||
instance:
|
||||
prefer-ip-address: true
|
||||
instance-ip: ${spring.cloud.client.ip-address}:${server.port}
|
||||
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
@ -115,7 +88,7 @@ mybatis-plus:
|
||||
auto-mapping-behavior: full
|
||||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
|
||||
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
mapper-locations: classpath*:com/chinaunicom/mall/ebtp/**/mapper/*Mapper.xml
|
||||
mapper-locations: classpath*:com/chinaunicom/zyhy/ebtp/supplier/**/mapper/*Mapper.xml
|
||||
global-config:
|
||||
# 逻辑删除配置
|
||||
db-config:
|
||||
|
Reference in New Issue
Block a user