基于weaverboot 实现后端架构(推荐使用
This commit is contained in:
parent
3587eddc75
commit
1c3c88efa4
|
|
@ -0,0 +1,15 @@
|
|||
package com.engine.organization.service;
|
||||
|
||||
import com.engine.organization.entity.po.Demo;
|
||||
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
* @Date 2022/4/28
|
||||
* @Version V1.0
|
||||
**/
|
||||
public interface TestService {
|
||||
|
||||
Demo list(String name);
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ import com.engine.organization.util.HrmI18nUtil;
|
|||
import com.engine.organization.util.LogAspect;
|
||||
import com.engine.organization.util.OrganizationAssert;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import com.weaverboot.frame.ioc.anno.classAnno.WeaIocService;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
|
@ -21,6 +22,7 @@ import java.util.List;
|
|||
* @Date 2022/4/27
|
||||
* @Version V1.0
|
||||
**/
|
||||
@WeaIocService
|
||||
public class DemoServiceImpl extends Service implements DemoService {
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.engine.organization.service.impl;
|
||||
|
||||
import com.engine.organization.entity.po.Demo;
|
||||
import com.engine.organization.service.TestService;
|
||||
import com.weaverboot.frame.ioc.anno.classAnno.WeaIocService;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
* @Date 2022/4/28
|
||||
* @Version V1.0
|
||||
**/
|
||||
@WeaIocService
|
||||
public class TestServiceImpl implements TestService {
|
||||
|
||||
@Override
|
||||
public Demo list(String name) {
|
||||
return Demo.builder().fid(1).build();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
package com.engine.organization.web;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.organization.entity.po.Demo;
|
||||
import com.engine.organization.service.TestService;
|
||||
import com.engine.organization.util.response.ReturnResult;
|
||||
import com.engine.organization.wrapper.DemoWrapper;
|
||||
import com.weaverboot.frame.ioc.anno.fieldAnno.WeaAutowired;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
|
|
@ -14,6 +17,7 @@ import javax.ws.rs.Produces;
|
|||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
|
|
@ -40,4 +44,25 @@ public class DemoController {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 方案2 基于weaverboot 实现后端架构(推荐使用)
|
||||
*/
|
||||
@WeaAutowired
|
||||
private TestService testService;
|
||||
|
||||
@GET
|
||||
@Path("/get")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult testGet(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
||||
@QueryParam("name") String name) {
|
||||
try {
|
||||
Demo list = testService.list(name);
|
||||
return ReturnResult.successed(list);
|
||||
}catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue