二次开发Service开发步骤
二次开发是由于平台现有的接口不满足业务需求,会自己写业务来实现,二次开发代码一般放在je-web目录下
在je-web下新建代码文件夹
一般都是一个业务模块统一建一个文件夹来管理
然后修改spring-mvc.xml配置文件,让能扫描到这个包
编写Controller
新建的Controller,需要继承AbstractPlatformController类,安全改造之后都需要继承这个类
案例代码
package com.project.demo.controller;
import com.je.core.base.AbstractPlatformController;
import com.project.demo.service.DemoPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping(value = "/je/demoPlatform")
public class DemoPlatformController extends AbstractPlatformController {
@Autowired
private DemoPlatformService demoPlatformService;
@ResponseBody
@RequestMapping(value = "/getTeacherInfo",method = RequestMethod.POST)
public List<Map> getTeacherInfo(){
List<Map> list = demoPlatformService.getTeacherInfo();
return list;
}
}
编写Servcie
Service中的接口是在不满足条件的情况下,扩展出来一些自定义接口来实现业务,让Controller来调运Servcie
案例代码
package com.project.demo.service;
import java.util.List;
import java.util.Map;
/**
*接口
*/
public interface DemoPlatformService {
List<Map> getTeacherInfo();
}
package com.project.demo.service;
import com.project.demo.mapper.DemoPlatformDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
*接口实现
*/
@Service("DemoPlatformService")
public class DemoPlatformServiceImpl implements DemoPlatformService{
@Autowired
private MetaService metaService;
@Override
public List<Map>getTeacherInfo() {
return metaService.selectSql();
}
}
最后编辑: 呼丽华 文档更新时间: 2024-08-21 10:58 作者:刘利军