Browse Source
Conflicts: epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.javamaster
77 changed files with 821 additions and 180 deletions
@ -0,0 +1,37 @@ |
|||
package com.epmet.commons.tools.utils; |
|||
|
|||
import java.io.File; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.nio.file.Files; |
|||
|
|||
public class FileUtils { |
|||
|
|||
/** |
|||
* 创建临时文件. |
|||
* |
|||
* @param inputStream 输入文件流 |
|||
* @param name 文件名 |
|||
* @param ext 扩展名 |
|||
* @param tmpDirFile 临时文件夹目录 |
|||
*/ |
|||
public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException { |
|||
File resultFile = File.createTempFile(name, '.' + ext, tmpDirFile); |
|||
|
|||
resultFile.deleteOnExit(); |
|||
org.apache.commons.io.FileUtils.copyToFile(inputStream, resultFile); |
|||
return resultFile; |
|||
} |
|||
|
|||
/** |
|||
* 创建临时文件. |
|||
* |
|||
* @param inputStream 输入文件流 |
|||
* @param name 文件名 |
|||
* @param ext 扩展名 |
|||
*/ |
|||
public static File createTmpFile(InputStream inputStream, String name, String ext) throws IOException { |
|||
return createTmpFile(inputStream, name, ext, Files.createTempDirectory("weixin-java-tools-temp").toFile()); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.epmet.commons.tools.utils; |
|||
|
|||
import org.apache.http.HttpEntity; |
|||
import org.apache.http.HttpResponse; |
|||
import org.apache.http.StatusLine; |
|||
import org.apache.http.client.HttpResponseException; |
|||
import org.apache.http.client.ResponseHandler; |
|||
import org.apache.http.util.EntityUtils; |
|||
|
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
|
|||
/** |
|||
* 输入流响应处理器. |
|||
* |
|||
* @author Daniel Qian |
|||
*/ |
|||
public class InputStreamResponseHandler implements ResponseHandler<InputStream> { |
|||
public static final ResponseHandler<InputStream> INSTANCE = new InputStreamResponseHandler(); |
|||
private static final int STATUS_CODE_300 = 300; |
|||
|
|||
@Override |
|||
public InputStream handleResponse(final HttpResponse response) throws IOException { |
|||
final StatusLine statusLine = response.getStatusLine(); |
|||
final HttpEntity entity = response.getEntity(); |
|||
if (statusLine.getStatusCode() >= STATUS_CODE_300) { |
|||
EntityUtils.consume(entity); |
|||
throw new HttpResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase()); |
|||
} |
|||
return entity == null ? null : entity.getContent(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.epmet.commons.tools.utils; |
|||
|
|||
import org.apache.http.Consts; |
|||
import org.apache.http.HttpEntity; |
|||
import org.apache.http.HttpResponse; |
|||
import org.apache.http.StatusLine; |
|||
import org.apache.http.client.HttpResponseException; |
|||
import org.apache.http.client.ResponseHandler; |
|||
import org.apache.http.util.EntityUtils; |
|||
|
|||
import java.io.IOException; |
|||
|
|||
/** |
|||
* copy from {@link org.apache.http.impl.client.BasicResponseHandler} |
|||
* |
|||
* @author Daniel Qian |
|||
*/ |
|||
public class Utf8ResponseHandler implements ResponseHandler<String> { |
|||
|
|||
public static final ResponseHandler<String> INSTANCE = new Utf8ResponseHandler(); |
|||
|
|||
@Override |
|||
public String handleResponse(final HttpResponse response) throws IOException { |
|||
final StatusLine statusLine = response.getStatusLine(); |
|||
final HttpEntity entity = response.getEntity(); |
|||
if (statusLine.getStatusCode() >= 300) { |
|||
EntityUtils.consume(entity); |
|||
throw new HttpResponseException(statusLine.getStatusCode(), statusLine.toString()); |
|||
} |
|||
return entity == null ? null : EntityUtils.toString(entity, Consts.UTF_8); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,18 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import lombok.Data; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author zhaoqifeng |
|||
* @dscription |
|||
* @date 2020/7/24 10:10 |
|||
*/ |
|||
@Data |
|||
public class QrCodeDTO implements Serializable { |
|||
private static final long serialVersionUID = -1787470699926486609L; |
|||
private byte[] qrCode; |
|||
private MultipartFile media; |
|||
} |
@ -0,0 +1,25 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/7/24 16:31 |
|||
*/ |
|||
@Data |
|||
public class OpenAppIdFormDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 4181403694668558506L; |
|||
|
|||
/** |
|||
* 客户端类型 |
|||
*/ |
|||
private String clientType; |
|||
|
|||
/** |
|||
* 客户ID |
|||
*/ |
|||
private String customerId; |
|||
} |
@ -0,0 +1,26 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/7/23 9:09 |
|||
*/ |
|||
@Data |
|||
public class RemoveBindFormDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1920195626466407047L; |
|||
|
|||
public interface RemoveBind extends CustomerClientShowGroup {} |
|||
|
|||
/** |
|||
* 客户端类型 resi:居民端 , work:工作端 |
|||
*/ |
|||
@NotBlank(message = "客户端类型不能为空",groups = {RemoveBindFormDTO.RemoveBind.class}) |
|||
private String clientType; |
|||
|
|||
} |
@ -0,0 +1,11 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
|
|||
@Data |
|||
public class GovFootBarFormDTO { |
|||
//@NotBlank(message = "客户ID不能为空")
|
|||
private String customerId; |
|||
} |
@ -1,21 +0,0 @@ |
|||
package com.epmet.feign; |
|||
|
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.CustomerFootBarDTO; |
|||
import com.epmet.dto.form.CustomerFootBarFormDTO; |
|||
import com.epmet.feign.fallback.OperCustomizeFeignClientFallBack; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
|
|||
import java.util.List; |
|||
|
|||
@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeFeignClientFallBack.class) |
|||
public interface OperCustomizeFeignClient { |
|||
|
|||
@PostMapping(value = "/oper/customize/customerfootbar/customerfootbars", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) |
|||
Result<List<CustomerFootBarDTO>> getCustomerfootbars(@RequestBody CustomerFootBarFormDTO formDTO); |
|||
|
|||
} |
@ -1,22 +0,0 @@ |
|||
package com.epmet.feign.fallback; |
|||
|
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.utils.ModuleUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.CustomerFootBarDTO; |
|||
import com.epmet.dto.form.CustomerFootBarFormDTO; |
|||
import com.epmet.dto.form.CustomerHomeFormDTO; |
|||
import com.epmet.dto.result.HomeDesignByCustomerResultDTO; |
|||
import com.epmet.feign.OperCustomizeFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Component |
|||
public class OperCustomizeFeignClientFallBack implements OperCustomizeFeignClient { |
|||
|
|||
@Override |
|||
public Result<List<CustomerFootBarDTO>> getCustomerfootbars(CustomerFootBarFormDTO formDTO) { |
|||
return ModuleUtils.feignConError(ServiceConstant.OPER_CUSTOMIZE_SERVER, "getCustomerfootbars",formDTO); |
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
alter table customer_foot_bar add column `app_type` varchar(20) not null after `CUSTOMER_ID`; |
|||
alter table customer_foot_bar add column `order` int(2) not null after `SELECTED_ICON_PATH`; |
|||
|
|||
update customer_foot_bar set `app_type`='gov' , `order`=1 where CUSTOMER_ID='default' and BAR_KEY='work'; |
|||
update customer_foot_bar set `app_type`='gov' , `order`=2 where CUSTOMER_ID='default' and BAR_KEY='org'; |
|||
update customer_foot_bar set `app_type`='gov' , `order`=3 where CUSTOMER_ID='default' and BAR_KEY='data'; |
|||
update customer_foot_bar set `app_type`='gov' , `order`=4 where CUSTOMER_ID='default' and BAR_KEY='find'; |
|||
|
|||
INSERT INTO epmet_oper_customize.customer_foot_bar (ID, CUSTOMER_ID, app_type, BAR_KEY, BAR_NAME, PAGE_TITLE, ICON_PATH, SELECTED_ICON_PATH, `order`, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME) VALUES (uuid(), 'default', 'resi', 'garden', '党建园地', '党建园地', null, null, 1, 0, 0, 'APP_USER', now(), 'APP_USER', now()); |
|||
INSERT INTO epmet_oper_customize.customer_foot_bar (ID, CUSTOMER_ID, app_type, BAR_KEY, BAR_NAME, PAGE_TITLE, ICON_PATH, SELECTED_ICON_PATH, `order`, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME) VALUES (uuid(), 'default', 'resi', 'issue', '党群议事', '党群议事', null, null, 2, 0, 0, 'APP_USER', now(), 'APP_USER', now()); |
|||
INSERT INTO epmet_oper_customize.customer_foot_bar (ID, CUSTOMER_ID, app_type, BAR_KEY, BAR_NAME, PAGE_TITLE, ICON_PATH, SELECTED_ICON_PATH, `order`, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME) VALUES (uuid(), 'default', 'resi', 'group', '楼院小组', '楼院小组', null, null, 3, 0, 0, 'APP_USER', now(), 'APP_USER', now()); |
@ -0,0 +1,10 @@ |
|||
package com.epmet.resi.mine.dto.from; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class ResiFootBarFormDTO { |
|||
|
|||
private String customerId; |
|||
|
|||
} |
@ -0,0 +1,39 @@ |
|||
package com.epmet.modules.app.controller; |
|||
|
|||
import com.epmet.commons.tools.constant.AppClientConstant; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.CustomerFootBarDTO; |
|||
import com.epmet.dto.form.CustomerFootBarFormDTO; |
|||
import com.epmet.feign.OperCustomizeOpenFeignClient; |
|||
import com.epmet.resi.mine.dto.from.ResiFootBarFormDTO; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.util.CollectionUtils; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
|
|||
@RestController |
|||
@RequestMapping("app") |
|||
public class AppController { |
|||
|
|||
@Autowired |
|||
private OperCustomizeOpenFeignClient operCustomizeFeign; |
|||
|
|||
@PostMapping("footbar") |
|||
public Result getResiFootBars(@RequestBody ResiFootBarFormDTO input) { |
|||
CustomerFootBarFormDTO form = new CustomerFootBarFormDTO(); |
|||
form.setCustomerId(input.getCustomerId()); |
|||
form.setAppType(AppClientConstant.APP_RESI); |
|||
Result<List<CustomerFootBarDTO>> result = operCustomizeFeign.getCustomerfootbars(form); |
|||
if (CollectionUtils.isEmpty(result.getData())) { |
|||
form.setCustomerId("default"); |
|||
result = operCustomizeFeign.getCustomerfootbars(form); |
|||
} |
|||
return result; |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1 @@ |
|||
INSERT INTO epmet_user.gov_staff_role_template (ID, ROLE_KEY, ROLE_NAME, ORG_TYPE, FULL_TIME_ONLY, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME) VALUES (uuid(), 'root_manager', '根管理员', 'agency', 1, 0, 0, 'APP_USER', now(), 'APP_USER', now()); |
Loading…
Reference in new issue