Spring Boot
通过Restful API,在PostMan 中返回数据
- 资源组
新增
POST/resource_group/ad
请求体:
格式:from-data
参数:groupName=example
响应:
{
"code": 200,
"msg": "保存成功",
"data": null
}
- 删除
DELETE /resource_group/delete?id=1
参数:id—资源组主键
响应:
{
"code": 0,
"data": {},
"msg": "string"
}
GET/resource_group/list
无参数
响应
{
"code": 200,
"msg": "查询成功",
"data": [
{
"id": 19,
"name": "默认分组",
"createTime": "2021-07-28T18:08:12",
"updateTime": "2021-07-28T18:08:12"
}
]
}
过程:
在pojo包下封装了Resources_group结果类:
public class Resources_group {
private Integer id;
private String name;
private Date create_time;
private Date update_time;
public Resources_group(String name){
this.name = name;
}
public Resources_group(){
}
public Resources_group(String name, Date create_time, Date update_time) {
this.name = name;
this.create_time = create_time;
this.update_time = update_time;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getCreate_time() {
return create_time;
}
public void setCreate_time(Date create_time) {
this.create_time = create_time;
}
public Date getUpdate_time() {
return update_time;
}
public void setUpdate_time(Date update_time) {
this.update_time = update_time;
}
@Override
public String toString() {
return "Resources_group{" +
"id=" + id +
", name='" + name + '\'' +
", create_time=" + create_time +
", update_time=" + update_time +
'}';
}
}
在mappers包下有Resources_groupMapper 接口
public interface Resources_groupMapper {
public int add(Resources_group resources_group);
public int delete(int id);
//查询
List<Resources_group> select();
}
在resources/mappers/ResourcesGroupDao.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" >
<!--填写对应的dao文件所在的路径-->
<mapper namespace="com.suyuan.mappers.Resources_groupMapper">
<resultMap id="ResultResourceGroup" type="com.suyuan.pojo.Resources_group">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="create_time" column="create_time"/>
<result property="update_time" column="update_time"/>
</resultMap>
<!--删除用户信息-->
<delete id="delete" parameterType="int">
delete from t_resources_group
where id=#{id}
</delete>
<!--添加-->
<insert id="add" parameterType="com.suyuan.pojo.Resources_group">
INSERT INTO
t_resources_group(name,create_time,update_time)
values (#{name},#{create_time},#{update_time})
</insert>
<!--查询-->
<select id="select" resultType="com.suyuan.pojo.Resources_group">
select *
from t_resources_group
</select>
</mapper>
这个时候我们开始写service/ResourceService
@Service
public class ResourceGroupService {
@Resource
private Resources_groupMapper resources_groupMapper;
//添加
public ResultBean add(String groupName){
Resources_group rg = new Resources_group(groupName, new Date(), new Date());
int a = resources_groupMapper.add(rg);
ResultBean resultBean = new ResultBean();
resultBean.setData("null");
resultBean.setCode(200);
resultBean.setMsg("添加成功");
return resultBean;
}
//删除
public ResultBean delete(int id ){
int b = resources_groupMapper.delete(id);
ResultBean resultBean = new ResultBean();
resultBean.setCode(0);
resultBean.setMsg("string");
return resultBean;
}
//查询
public ResultBean select(){
List<Resources_group> list = resources_groupMapper.select();
ResultBean resultBean = new ResultBean();
resultBean.setData(list);
resultBean.setCode(200);
resultBean.setMsg("查询成功");
return resultBean;
}
}
最后完成controller/ResourceGroupController
@Controller
@RequestMapping("/resource_group")
public class ResourceGroupController {
@Autowired
private ResourceGroupService resourceGroupService;
//通过groupName 对数据进行添加
@RequestMapping(value = "/add",method = RequestMethod.POST)
@ResponseBody
public ResultBean add(String groupName ){
return resourceGroupService.add(groupName);
}
//删除通过主键id
@RequestMapping(value = "/delete",method = RequestMethod.DELETE)
@ResponseBody
public ResultBean delete(int id){
return resourceGroupService.delete(id);
}
//查询列表
@RequestMapping(value = "/select",method = RequestMethod.GET)
@ResponseBody
public ResultBean listResourceGroup(){
return resourceGroupService.select();
}
}
最后在PostMan中进行测试:
1.添加:
2.根据id进行删除
3.查询表中的内容
-
资源组件
-
新增/修改
POST/resource/addOrUpdate
请求参数:
格式application/json
示例:
{
"content": "string",
"description": "string",
"groupId": 0,
"id": 0,
"name": "string",
"type": "string"
}
响应:
{"code":200,"msg":"保存成功","data":null}
- 列表
POST/resource/list
请求参数:
格式:application/json
示例:
{
"code":"",
"groupId":"",
"name":""
}
响应:
{
"code": 200,
"msg": "查询成功",
"data": {
"records": [
{
"id": 47,
"code": "res_1627871127986",
"name": "random-amq-product.ktr",
"description": "本流程每运⾏⼀次随机⽣成⼀条字符串\n\n然后输出到ActiveMQ的dexfrom-random队列",
"groupId": 21,
"type": "转换",
"filePath": "ktr/21/random-amq-product.ktr",
"state": 1,
"createTime": "2021-07-30T16:57:12",
"updateTime": "2021-08-02T10:25:28",
"groupName": "调度测试"
},
{
"id": 46,
"code": "res_1627634761122",
"name": "dex-amq-kafka-2.ktr",
"description": "",
"groupId": 20,
"type": "转换",
"filePath": "ktr/20/dex-amq-kafka-2.ktr",
"state": 1,
"createTime": "2021-07-30T16:46:01",
"updateTime": "2021-07-30T16:46:01",
"groupName": "activemq"
}
]
}
}
过程
1.在mappers包下创建一个ResourcesMapper接口
ublic interface ResourcesMapper {
//添加或者更新,根据id,有则更新无则添加
int addOrUpdate (Resources resources);
//查询
List<Resources> select(ResourceController.ListParam param);
}
2.在pojo包下创建Resources实体类,并实现get,set,toString方法,以及实现全参构造器以及无参构造器
import java.util.Date;
public class Resources {
private Integer id;
private String code;
private String name;
private String description;
private int group_id;
private Integer type;
private String file_path;
private Date create_time;
private Date update_time;
private int state;
private String groupName;
public Resources() {
}
public Resources(Integer id, String code, String name, String description, int group_id, Integer type, String file_path, Date create_time, Date update_time, int state) {
this.id = id;
this.code = code;
this.name = name;
this.description = description;
this.group_id = group_id;
this.type = type;
this.file_path = file_path;
this.create_time = create_time;
this.update_time = update_time;
this.state = state;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getGroup_id() {
return group_id;
}
public void setGroup_id(int group_id) {
this.group_id = group_id;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getFile_path() {
return file_path;
}
public void setFile_path(String file_path) {
this.file_path = file_path;
}
public Date getCreate_time() {
return create_time;
}
public void setCreate_time(Date create_time) {
this.create_time = create_time;
}
public Date getUpdate_time() {
return update_time;
}
public void setUpdate_time(Date update_time) {
this.update_time = update_time;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
@Override
public String toString() {
return "Resources{" +
"id=" + id +
", code='" + code + '\'' +
", name='" + name + '\'' +
", description='" + description + '\'' +
", group_id=" + group_id +
", type=" + type +
", file_path='" + file_path + '\'' +
", create_time=" + create_time +
", update_time=" + update_time +
", state=" + state +
'}';
}
}
3.在resources/mappers包下创建 ResourcesDao.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.suyuan.mappers.ResourcesMapper">
<!--通过查询映射结果-->
<resultMap id="ResultResource" type="com.suyuan.pojo.Resources">
<id property="id" column="id"/>
<result property="code" column="code"/>
<result property="name" column="name"/>
<result property="description" column="description"/>
<result property="group_id" column="groupId"/>
<result property="type" column="type"/>
<result property="file_path" column="file_path"/>
<result property="create_time" column="create_time"/>
<result property="update_time" column="update_time"/>
<result property="state" column="state"/>
<result property="groupId" column="reg.id"/>
<result property="groupName" column="groupName"/>
</resultMap>
<!--新增/修改-->
<insert id="addOrUpdate" parameterType="com.suyuan.pojo.Resources" keyProperty="id" keyColumn="id"
useGeneratedKeys="true">
insert INTO t_resources(id,code,name,description,group_id,type,file_path,create_time,update_time,state)
values (#{id},#{code},#{name},#{description},#{group_id},#{type},#{file_path},#{create_time},#{update_time},#{state})
ON DUPLICATE KEY UPDATE
name =#{name},
description =#{description},
group_id =#{group_id},
type =#{type}
</insert>
<!--多表查询-->
<select id="select" resultMap="ResultResource">
select re.id id,re.code code,re.name name, re.description description,re.group_id groupId,re.*,reg.name
groupName,reg.id
from t_resources re inner join t_resources_group reg on re.group_id=reg.id
where 1=1
<if test='code !=null and code!=""'>
and code like %#{code}%
</if>
<if test="groupId != null and groupId!=0 ">
and group_id = #{groupId}
</if>
<if test='name !=null and name!=""'>
and re.name like #{name}
</if>
</select>
</mapper>
4.在service包下创建ResourceService
@Service
public class ResourceService {
@Resource
private ResourcesMapper resourcesMapper;
public static class Params_add {
private Integer id;
private String name;
private String description;
private Integer groupId;
private Integer type;
private String content;
public Params_add() {
}
public Params_add(Integer id, String name, String description, Integer groupId, Integer type, String content) {
this.id = id;
this.name = name;
this.description = description;
this.groupId = groupId;
this.type = type;
this.content = content;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getGroupId() {
return groupId;
}
public void setGroupId(Integer groupId) {
this.groupId = groupId;
}
public Integer getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
@Override
public String toString() {
return "Params_add{" +
"id=" + id +
", name='" + name + '\'' +
", description='" + description + '\'' +
", groupId=" + groupId +
", type='" + type + '\'' +
", content='" + content + '\'' +
'}';
}
}
public ResultBean addOrUpdate(Params_add params_add) {
Resources re = new Resources(params_add.getId(), "zzz", params_add.getName(), params_add.getDescription(),params_add.getGroupId(), params_add.getType(), "ccc", new Date(), new Date(), 22);
int b = resourcesMapper.addOrUpdate(re);
ResultBean resultBean = new ResultBean();
resultBean.setData("null");
resultBean.setCode(200);
resultBean.setMsg("新增|更新成功");
return resultBean;
}
//查询
public ResultBean select(ResourceController.ListParam param) {
List<Resources> list = resourcesMapper.select(param);
ResultBean resultBean = new ResultBean();
return resultBean.SUCCESS("查询成功", list);
}
}
5.在controller包创建ResourceController
@RestController
@RequestMapping("/resource")
public class ResourceController {
@Autowired
private ResourceService resourceService;
@RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)
@ResponseBody
public ResultBean addOrUpdate(@RequestBody ResourceService.Params_add params_add){
return resourceService.addOrUpdate(params_add);
}
public static class ListParam {
private String code;
private Integer groupId;
private String name;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getGroupId() {
return groupId;
}
public void setGroupId(Integer groupId) {
this.groupId = groupId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
//查询列表
@RequestMapping(value = "/select",method = RequestMethod.POST, headers = "Accept=application/json")
@ResponseBody
public ResultBean listResourceGroup(@RequestBody ListParam param){
return resourceService.select(param);
}
}
在PostMan中进行测试
一:添加或者更新
1.表中没有addOrUpdate的id,所以进行的添加
2.当表中有所要请求的id,所以对数据库中相同id的数据进行了更新,这里对44号id的name进行的更新.
二:查询
当code,groupId,name.为空时,将查询这个表中的所有的数据;当不为空时,将查询这些值所对应的数据.
1.这些字段为空时:
{
"code": 200,
"msg": "查询成功",
"data": [
{
"id": 44,
"code": "zzz",
"name": "abc",
"description": "string",
"group_id": 104,
"type": 9,
"file_path": "ccc",
"create_time": "2021-08-10T06:36:48.000+00:00",
"update_time": "2021-08-10T14:39:53.000+00:00",
"state": 22,
"groupName": "abc"
},
{
"id": 45,
"code": "zzz",
"name": "wys",
"description": "string",
"group_id": 104,
"type": 9,
"file_path": "ccc",
"create_time": "2021-08-04T03:02:36.000+00:00",
"update_time": "2021-08-09T17:29:57.000+00:00",
"state": 22,
"groupName": "abc"
},
{
"id": 46,
"code": "zzz",
"name": "abc",
"description": "string",
"group_id": 104,
"type": 9,
"file_path": "ccc",
"create_time": "2021-08-04T08:06:58.000+00:00",
"update_time": "2021-08-09T16:39:30.000+00:00",
"state": 22,
"groupName": "abc"
},
{
"id": 52,
"code": "zzz",
"name": "wys",
"description": "string",
"group_id": 104,
"type": 9,
"file_path": "ccc",
"create_time": "2021-08-09T01:58:20.000+00:00",
"update_time": "2021-08-09T17:52:19.000+00:00",
"state": 22,
"groupName": "abc"
},
{
"id": 53,
"code": "zzz",
"name": "wys",
"description": "string",
"group_id": 104,
"type": 9,
"file_path": "ccc",
"create_time": "2021-08-09T09:30:30.000+00:00",
"update_time": "2021-08-09T09:30:30.000+00:00",
"state": 22,
"groupName": "abc"
},
{
"id": 79,
"code": "zzz",
"name": "wys",
"description": "string",
"group_id": 104,
"type": 9,
"file_path": "ccc",
"create_time": "2021-08-09T09:51:47.000+00:00",
"update_time": "2021-08-09T09:51:47.000+00:00",
"state": 22,
"groupName": "abc"
},
{
"id": 80,
"code": "zzz",
"name": "wys",
"description": "string",
"group_id": 104,
"type": 9,
"file_path": "ccc",
"create_time": "2021-08-09T09:30:44.000+00:00",
"update_time": "2021-08-09T09:30:44.000+00:00",
"state": 22,
"groupName": "abc"
}
]
}
2.当name为abc时:
数据库的t_resources表和t_resources_group表为
- 流程组件
新增/修改
POST /flow/addOrUpdate
请求参数:
格式:application/json
式例:
{
"description": "",
"gid": 21,
"logLevel": "BASIC",
"name": "随机数到activemq",
"type": "定时调度",
"steps": "[47]"
}
响应:
{"code":200,"msg":"新增|更新成功","data":null}
列表
POST /flow/list
请求参数:
格式:application/json
示例:
{
"code": "",
"gid": "",
"name": "",
"type": null
}
响应:
{
"code": 200,
"msg": "SUCCESS",
"data": {
"records": [
{
"id": 53,
"code": "flow_1627871654597",
"name": "随机数到activemq",
"type": "定时调度",
"logLevel": "BASIC",
"description": "",
"steps": "[47]",
"status": "未开始",
"createTime": "2021-08-02T10:34:14",
"updateTime": "2021-08-02T10:34:14",
"groupName": "调度测试",
"resourcesList": [
{
"id": 47,
"code": "res_1627871127986",
"name": "random-amq-product.ktr",
"description": "本流程每运⾏⼀次随机⽣成⼀条字符串\n\n然后输出到ActiveMQ的dex-from-random队列",
"groupId": 21,
"type": "转换",
"filePath": "ktr/21/random-amq-product.ktr",
"state": 1,
"createTime": "2021-07-30T16:57:12",
"updateTime": "2021-08-02T10:25:28",
"groupName": null
}
],
"gid": 21
}
过程
1:在pojo包创建一个实体类Flow,实现get,set方法,toString方法,全参和无参构造器,
@Alias("t_flow")
public class Flow {
private int id;
private String code;
private String name;
private Integer type;
private Integer log_level;
private String description;
private int g_id;
private String steps;
private int status;
private Date create_time;
private Date update_time;
private String groupName;
private List<Resources> resourcesList;
public static Integer ids(Flow flows){
return flows.getId();
}
public Flow(){
}
public Flow(int id, String code, String name, Integer type, Integer log_level, String description, int g_id, String steps, int status, Date create_time, Date update_time) {
this.id = id;
this.code = code;
this.name = name;
this.type = type;
this.log_level = log_level;
this.description = description;
this.g_id = g_id;
this.steps = steps;
this.status = status;
this.create_time = create_time;
this.update_time = update_time;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getLog_level() {
return log_level;
}
public void setLog_level(Integer log_level) {
this.log_level = log_level;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getG_id() {
return g_id;
}
public void setG_id(int g_id) {
this.g_id = g_id;
}
public String getSteps() {
return steps;
}
public void setSteps(String steps) {
this.steps = steps;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public Date getCreate_time() {
return create_time;
}
public void setCreate_time(Date create_time) {
this.create_time = create_time;
}
public Date getUpdate_time() {
return update_time;
}
public void setUpdate_time(Date update_time) {
this.update_time = update_time;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public List<Resources> getResourcesList() {
return resourcesList;
}
public void setResourcesList(List<Resources> resourcesList) {
this.resourcesList = resourcesList;
}
@Override
public String toString() {
return "Flow{" +
", code=" + code +
", name='" + name + '\'' +
", type='" + type + '\'' +
", log_level='" + log_level + '\'' +
", description='" + description + '\'' +
", g_id=" + g_id +
", steps=" + steps +
", status=" + status +
", create_time=" + create_time +
", update_time=" + update_time +
'}';
}
}
2.在mappers包下创建FlowMapper接口,在接口中添加方法
@Mapper
@Repository
public interface FlowMapper {
public void insertFlow(Flow flow);
public int insert(Flow flow);
public int delete(int id);
public int update(Flow flow);
//查询所有的数据
List<Flow> query();
public Flow FlowInfo(int id);
int addOrUpdate(Flow flow);
//查询列表
List<Flow> select(FlowController.SelectFlow selectFlow);
List<Flow> list(FlowController.SelectFlow selectFlow);
}
3.在resources/mappers包下创建FlowDao.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" >
<!--填写对应的dao文件所在的路径-->
<mapper namespace="com.suyuan.mappers.FlowMapper">
<resultMap id="ResultFlow" type="com.suyuan.pojo.Flow">
<id property="id" column="id"></id>
<result property="code" column="code"></result>
<result property="name" column="name"></result>
<result property="type" column="type"></result>
<result property="log_level" column="log_level"></result>
<result property="description" column="description"></result>
<result property="g_id" column="g_id"></result>
<result property="steps" column="steps"></result>
<result property="status" column="status"></result>
<result property="create_time" column="create_time"></result>
<result property="update_time" column="update_time"></result>
</resultMap>
<!--新增/修改-->
<insert id="addOrUpdate" parameterType="com.suyuan.pojo.Flow" keyProperty="id" keyColumn="id" useGeneratedKeys="true">
INSERT INTO
t_flow(id,code,name,type,log_level,description,g_id,steps,status,create_time,update_time)
VALUES (#{id},#{code},#{name},#{type},#{log_level},#{description},#{g_id},#{steps},#{status},#{create_time},#{update_time})
ON DUPLICATE KEY UPDATE
description =#{description},
log_level=#{log_level},
g_id=#{g_id},
name=#{name},
type=#{type},
steps=#{steps}
</insert>
<!--多表查询-->
<select id="select" resultMap="ResultFlow">
select a.id id,a.code code,a.name name,a.type type,a.log_level log_level,a.description description,a.g_id g_id,a.steps steps,
a.status status,a.create_time create_time,a.update_time update_time,b.id gid
from t_flow a join t_resources_group b on a.g_id=b.id
where 1=1
<if test='code !=null and code!=""'>
and code like#{code}
</if>
<if test="gid !=null and gid!=0">
and gid = #{gid}
</if>
<if test='name !=null and name!=""'>
and a.name like #{name}
</if>
<if test="type !=null and type!=0">
and type = #{type}
</if>
</select>
</mapper>
4.在service包下创建FlowService
@Service
public class FlowService {
public static class Flow_add{
private int id;
private String description;
private int gid;
private Integer logLevel;
private String name;
private int type;
private String steps;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getGid() {
return gid;
}
public void setGid(int gid) {
this.gid = gid;
}
public Integer getLogLevel() {
return logLevel;
}
public void setLogLevel(Integer logLevel) {
this.logLevel = logLevel;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getSteps() {
return steps;
}
public void setSteps(String steps) {
this.steps = steps;
}
}
public ResultBean addOrUpdate(Flow_add flow_add) {
Flow fl = new Flow(flow_add.getId(), "qqq", flow_add.getName(), flow_add.getType(), flow_add.getLogLevel(), flow_add.getDescription(), flow_add.getGid(), flow_add.getSteps(), 10, new Date(), new Date());
int c = flowMapper.addOrUpdate(fl);
ResultBean resultBean = new ResultBean();
resultBean.setCode(200);
resultBean.setMsg("新增|更新成功");
resultBean.setData("null");
return resultBean;
}
//查询
public ResultBean select(FlowController.SelectFlow selectFlow) {
List<Flow> flows = flowMapper.select(selectFlow);
for (Flow flow : flows) {
List<Resources> resources = resourcesMapper.query(selectFlow);
flow.setResourcesList(resources);
}
ResultBean resultBean = new ResultBean();
return resultBean.SUCCESS("查询成功", flows);
}
}
5.在contraller包下创建FlowController
@RestController
@RequestMapping("/flow")
public class FlowController {
@Autowired
private FlowService flowService;
@RequestMapping(value = "/addOrUpdate", method = RequestMethod.POST)
@ResponseBody
public ResultBean addOrUpdate(@RequestBody FlowService.Flow_add flow_add) {
return flowService.addOrUpdate(flow_add);
}
//查询列表
public static class SelectFlow {
private String code;
private String gid;
private String name;
private Integer type;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getGid() {
return gid;
}
public void setGid(String gid) {
this.gid = gid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getType() {
return type;
}
public void setType(Integer typr) {
this.type = typr;
}
}
@RequestMapping(value = "/list", method = RequestMethod.POST)
@ResponseBody
public ResultBean ListFlow(@RequestBody SelectFlow selectFlow) {
return flowService.select(selectFlow);
}
}
进行测试
一:测试addOrUpdate
根据id进行测试,测试的id如果在数据库的t_flow中存在就会将数据库对应的数据进行更新;如果不存在就会在t_flow进行新增。
1.先测试id一样时的数据,这是没有操作的时候
这个时候将67号的name改为test
2.当id在数据库中找不到时:
这个时候我们发送一条id为:70的数据,这个时候,我们将会看到数据库中新增了一条id为70的一条数据