Commit 8dd6121e authored by 赵啸非's avatar 赵啸非

添加feign接口自动生成

parent aa098ae5
...@@ -162,43 +162,56 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge ...@@ -162,43 +162,56 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
continue; continue;
} }
//如果开启feign生成模式,加载feign生成模板 //如果开启feign生成模式,加载feign生成模板
if (gentableEntity.getGenFeign()!=null&&gentableEntity.getGenFeign() == 0) { if (gentableEntity.getGenFeign() != null && gentableEntity.getGenFeign() == 0) {
if (temp.contains("feign.java.ftl") || temp.contains("pdu.java.ftl")) { if (temp.contains("feign.java.ftl") || temp.contains("pdu.java.ftl")) {
continue; continue;
} }
} }
if (gentableEntity.getIsShowControl()!=null&&gentableEntity.getIsShowControl() == 2) { if (gentableEntity.getIsShowControl() != null) {
if (temp.contains("webForm.java.ftl")) { if (gentableEntity.getIsShowControl() == 2) {
continue; if (temp.contains("webForm.java.ftl")) {
} continue;
}
// if (temp.contains("entity.java.ftl")||temp.contains("entityQuery.java.ftl")) { // if (temp.contains("entity.java.ftl")||temp.contains("entityQuery.java.ftl")) {
// continue; // continue;
// } // }
} } else if (gentableEntity.getIsShowControl() == 0) {
if (gentableEntity.getIsShowControl() == 0) { if (temp.contains("webBody.java.ftl")) {
if (temp.contains("webBody.java.ftl")) { continue;
}
}
} else {
if (temp.contains("webForm.java.ftl")) {
continue; continue;
} }
} }
if (gentableEntity.getDetailShow()!=null&&gentableEntity.getDetailShow() == 0) {
if (temp.contains("VueDialogShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) { if (gentableEntity.getDetailShow() != null) {
continue; if (gentableEntity.getDetailShow() == 0) {
} if (temp.contains("VueDialogShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) {
} else if (gentableEntity.getDetailShow() == 1) { continue;
if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) { }
continue; } else if (gentableEntity.getDetailShow() == 1) {
} if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) {
} else if (gentableEntity.getDetailShow() == 2) { continue;
if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDialogShow.vue.ftl")) { }
continue; } else if (gentableEntity.getDetailShow() == 2) {
if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDialogShow.vue.ftl")) {
continue;
}
} else {
if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) {
continue;
}
} }
}else{ } else {
if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) { if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) {
continue; continue;
} }
} }
if (temp.equals("menu.sql.ftl") || temp.equals("db.sql.ftl") || temp.equals("api.md.ftl")) { if (temp.equals("menu.sql.ftl") || temp.equals("db.sql.ftl") || temp.equals("api.md.ftl")) {
try { try {
List<GentableEntity> tableList = new ArrayList<>(); List<GentableEntity> tableList = new ArrayList<>();
...@@ -502,41 +515,45 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge ...@@ -502,41 +515,45 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
continue; continue;
} }
//restBody模式 不加载web,webForm模式 if (gentableEntity.getIsShowControl() != null) {
if (gentableEntity.getIsShowControl() == 2) { if (gentableEntity.getIsShowControl() == 2) {
if (temp.contains("web.java.ftl") || temp.contains("webForm.java.ftl")) { if (temp.contains("webForm.java.ftl")) {
continue; continue;
}
// if (temp.contains("entity.java.ftl")||temp.contains("entityQuery.java.ftl")) {
// continue;
// }
} else if (gentableEntity.getIsShowControl() == 0) {
if (temp.contains("webBody.java.ftl")) {
continue;
}
} }
// if (temp.contains("entity.java.ftl")||temp.contains("entityQuery.java.ftl")) {
// continue;
// }
} else { } else {
if (temp.contains("webBody.java.ftl")) { if (temp.contains("webForm.java.ftl")) {
continue;
}
}
//如果开启feign生成模式,加载feign生成模板
if (gentableEntity.getGenFeign() == 0) {
if (temp.contains("feign.java.ftl") || temp.contains("pdu.java.ftl")) {
continue; continue;
} }
} }
if (gentableEntity.getDetailShow()!=null&&gentableEntity.getDetailShow() == 0) {
if (temp.contains("VueDialogShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) { if (gentableEntity.getDetailShow() != null) {
continue; if (gentableEntity.getDetailShow() == 0) {
} if (temp.contains("VueDialogShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) {
} else if (gentableEntity.getDetailShow() == 1) { continue;
if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) { }
continue; } else if (gentableEntity.getDetailShow() == 1) {
} if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) {
} else if (gentableEntity.getDetailShow() == 2) { continue;
if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDialogShow.vue.ftl")) { }
continue; } else if (gentableEntity.getDetailShow() == 2) {
if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDialogShow.vue.ftl")) {
continue;
}
} else {
if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) {
continue;
}
} }
}else{ } else {
if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) { if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) {
continue; continue;
} }
......
package ${packageFeignName}; package ${packageFeignName};
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.${businessName}.${ClassName}Pdu; import com.mortals.xhx.common.pdu.${businessName}.${ClassName}Pdu;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
...@@ -9,13 +9,13 @@ import lombok.extern.slf4j.Slf4j; ...@@ -9,13 +9,13 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* ${functionName} Feign接口 * ${functionName} Feign接口
* @author ${author} * @author ${author}
* @date ${datetime} * @date ${datetime}
*/ */
@FeignClient(name = "${code}", path = "${path}", fallback = ${ClassName}FeignFallbackFactory.class) @FeignClient(name = "${code}", path = "${path}", fallbackFactory = ${ClassName}FeignFallbackFactory.class)
public interface I${ClassName}Feign extends IFeign { public interface I${ClassName}Feign extends IFeign {
...@@ -26,7 +26,7 @@ public interface I${ClassName}Feign extends IFeign { ...@@ -26,7 +26,7 @@ public interface I${ClassName}Feign extends IFeign {
* @return * @return
*/ */
@PostMapping(value = "/${RequestMapping}/list") @PostMapping(value = "/${RequestMapping}/list")
String list(@RequestBody ${ClassName}Pdu ${className}Pdu); Rest<RespData<List<${ClassName}Pdu>>> list(@RequestBody ${ClassName}Pdu ${className}Pdu);
/** /**
...@@ -36,7 +36,7 @@ public interface I${ClassName}Feign extends IFeign { ...@@ -36,7 +36,7 @@ public interface I${ClassName}Feign extends IFeign {
* @return * @return
*/ */
@GetMapping(value = "/${RequestMapping}/info") @GetMapping(value = "/${RequestMapping}/info")
String info(@RequestParam(value = "id") Long id); Rest<${ClassName}Pdu> info(@RequestParam(value = "id") Long id);
/** /**
* 删除${functionName} * 删除${functionName}
...@@ -45,7 +45,7 @@ public interface I${ClassName}Feign extends IFeign { ...@@ -45,7 +45,7 @@ public interface I${ClassName}Feign extends IFeign {
* @return * @return
*/ */
@GetMapping(value = "/${RequestMapping}/delete") @GetMapping(value = "/${RequestMapping}/delete")
String delete(Long[] ids,@RequestHeader("Authorization") String authorization); Rest<Void> delete(Long[] ids,@RequestHeader("Authorization") String authorization);
/** /**
...@@ -55,7 +55,7 @@ public interface I${ClassName}Feign extends IFeign { ...@@ -55,7 +55,7 @@ public interface I${ClassName}Feign extends IFeign {
* @return * @return
*/ */
@PostMapping(value = "/${RequestMapping}/save") @PostMapping(value = "/${RequestMapping}/save")
String save(@RequestBody ${ClassName}Pdu ${className}Pdu,@RequestHeader("Authorization") String authorization); Rest<RespData<${ClassName}Pdu>> save(@RequestBody ${ClassName}Pdu ${className}Pdu,@RequestHeader("Authorization") String authorization);
} }
...@@ -68,23 +68,23 @@ class ${ClassName}FeignFallbackFactory implements FallbackFactory<I${ClassName}F ...@@ -68,23 +68,23 @@ class ${ClassName}FeignFallbackFactory implements FallbackFactory<I${ClassName}F
public I${ClassName}Feign create(Throwable t) { public I${ClassName}Feign create(Throwable t) {
return new I${ClassName}Feign() { return new I${ClassName}Feign() {
@Override @Override
public String list(${ClassName}Pdu ${className}Pdu) { public Rest<RespData<List<${ClassName}Pdu>>> list(${ClassName}Pdu ${className}Pdu) {
return JSON.toJSONString(Rest.fail("暂时无法获取${functionName}列表,请稍后再试!")); return Rest.fail("暂时无法获取${functionName}列表,请稍后再试!");
} }
@Override @Override
public String info(Long id) { public Rest<${ClassName}Pdu> info(Long id) {
return JSON.toJSONString(Rest.fail("暂时无法获取${functionName}详细,请稍后再试!")); return Rest.fail("暂时无法获取${functionName}详细,请稍后再试!");
} }
@Override @Override
public String delete(Long[] ids, String authorization) { public Rest<Void> delete(Long[] ids, String authorization) {
return JSON.toJSONString(Rest.fail("暂时无法删除${functionName},请稍后再试!")); return Rest.fail("暂时无法删除${functionName},请稍后再试!");
} }
@Override @Override
public String save(${ClassName}Pdu ${className}Pdu, String authorization) { public Rest<RespData<${ClassName}Pdu>> save(${ClassName}Pdu ${className}Pdu, String authorization) {
return JSON.toJSONString(Rest.fail("暂时无法保存${functionName},请稍后再试!")); return Rest.fail("暂时无法保存${functionName},请稍后再试!");
} }
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment