1、首先是js发送一个post 或者get请求到controller
2、controller处理请求返回一个界面(这里并没有检查权限,当处理增删改操作时才检查是否有这个权限),即完成跳转界面操作
/**
* 跳转到部门管理首页
*/
@RequestMapping("")
public String index() {
return PREFIX + "dept.html";
}
3、界面加载时根据权限进行加载按钮
4、点击相应按钮后由js发送post,get请求到controller
eptInfoDlg.addSubmit = function () {
var ajax = new $ax(Feng.ctxPath + "/dept/add", function (data) {
parent.Feng.success("添加成功!");
window.parent.Dept.table.refresh();
DeptInfoDlg.close();
}, function (data) {
parent.Feng.error("添加失败!" + data.responseJSON.message + "!");
});
ajax.set(DeptInfoDlg.data);
ajax.start();
};
5、controller通过service对象 : service->serviceImpl->mapper 然后通过orm框架
(mybatis-plus)进行映射mapper的函数以及实体类。然后controller返回的数据
通过spring mvc的 @ResponseBody 注解将数据变成JSON对象数据格式返回。
controller
@Autowired
private sendandreService sen;
/**
* 获取所有收派标准列表
*/
@RequestMapping(value = "/listt")
@ResponseBody
public List<Map<String, Object>> list(@RequestParam(value = "sendName", required = false) String condition)
{
List<Map<String, Object>> list = this.sen.list(condition);
return list;
}
service
//得加个component,具体是为什么忘了,可以去掉试下(会出错)
@Component
public class sendandreService extends ServiceImpl<SendandreMapper, Sendandre> {
/**
* 获取收派列表
*/
public List<Map<String, Object>> list(String condition) {
return this.baseMapper.list(condition);
}
public List<Map<String, Object>> selectbyid(Long sendid) {
return this.baseMapper.selectbyid(sendid);
}
}
mapper
public interface SendandreMapper extends BaseMapper<Sendandre> {
/**
* 获取收派列表
*/
List<Map<String, Object>> list(@Param("condition") String condition);
mapper.xml
<?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.bos.modular.system.mapper.SendandreMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.bos.modular.system.entity.Sendandre">
<id column="id" property="sendid" />
<result column="sendname" property="sendname" />
<result column="minwe" property="minwe" />
<result column="maxwe" property="maxwe" />
<result column="operator" property="operatorid" />
<result column="dotime" property="dotime" />
<result column="dodept" property="dodeptid" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id AS sendid, sendname AS sendname, minwe, maxwe, operator AS operatorid, dotime, dodept AS dodeptid
</sql>
<select id="list" resultType="map">
select
<include refid="Base_Column_List"></include>
from basic_sendandre
<if test="condition != null and condition != ''">
where sendname like CONCAT('%',#{condition},'%')
</if>
order by sendname
</select>
<mapper>