固定车管理系统API接口 - 添加、查询、修改、删除固定车
固定车管理系统API接口
该接口提供以下功能:
- 添加固定车
- 查询固定车列表
- 修改固定车信息
- 删除固定车
- 固定车统计
API 接口列表
/gudingche/page/add:返回添加固定车的页面,并查询出所有可用的车位。/gudingche/query:查询所有固定车,并查询出所有可用的车位,返回固定车列表页面。/gudingche/add:添加或编辑固定车,并更新相应的车位状态。/gudingche/del/{id}:删除固定车,并更新相应的车位状态。/gudingche/edit:编辑固定车,并更新相应的车位状态。/gudingche/page/edit/{id}:返回编辑固定车的页面,并查询出所有可用的车位。/gudingche/page/gutongji:返回固定车统计页面。/gudingche/tj/month:根据指定月份查询固定车的统计信息。
代码示例
package com.dian.controller;
import com.dian.domain.Chewei;
import com.dian.domain.Gudingche;
import com.dian.service.GudingcheService;
import com.dian.type.ResponseType;
import com.dian.util.FastjsonUtils;
import com.dian.vo.ResponseVo;
import com.dian.vo.Tongji;
import com.github.pagehelper.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @Author www.lifedian.com
*/
@Controller
@RequestMapping(value = '/gudingche', produces = {'application/json;charset=UTF-8'})
public class GudingcheController extends BaseController {
@Resource
private GudingcheService gudingcheService;
@RequestMapping(value = '/page/add')
public String addPage(ModelMap modelMap) {
List<Chewei> cheweis = cheweiService.query();
modelMap.put('cheweiList',cheweis);
return'/gudingche/gudingche_add';
}
@RequestMapping(value = '/query')
public String query(HttpServletRequest request, @RequestParam(required = false, defaultValue = '1') int startId,
@RequestParam(required = false, defaultValue = '1') int pageIndex,
@RequestParam(required = false, defaultValue = '10') int pageSize, ModelMap modelMap) {
Page<Gudingche> result = gudingcheService.selectByPage(startId, pageIndex, pageSize);
modelMap.put('gudingcheList', result.getResult());
List<Chewei> cheweis = cheweiService.query();
modelMap.put('cheweiList',cheweis);
modelMap.put('page', getPageInfo(result).getHtml());
return '/gudingche/gudingche_list';
}
@RequestMapping(value = '/add', method = RequestMethod.POST)
@ResponseBody
public String editTiku(HttpServletRequest request, Gudingche gudingche, ModelMap modelMap) {
if (gudingche.getId() == null) {
modelMap.put('result', new ResponseVo(gudingcheService.insertSelective(gudingche) ? ResponseType.ADD_SUCCESS : ResponseType.ADD_FAIL));
Chewei chewei = new Chewei();
chewei.setId(gudingche.getCheweiid());
chewei.setState(0);
cheweiService.updateByPrimaryKeySelective(chewei);
}
return FastjsonUtils.serialize(modelMap);
}
@RequestMapping(value = '/del/{id}')
@ResponseBody
public String del(@PathVariable Integer id, ModelMap modelMap) {
Gudingche gudingche = new Gudingche();
gudingche.setId(id);
//直接删除
boolean result = gudingcheService.deleteByPrimaryKey(id);
//更新删除
modelMap.put('result', new ResponseVo(result ? ResponseType.DEL_SUCCESS : ResponseType.DEL_FAIL));
return FastjsonUtils.serialize(modelMap);
}
@RequestMapping(value = '/edit', method = RequestMethod.POST)
@ResponseBody
public String edit(HttpServletRequest request,Integer yuancheweiid, Gudingche gudingche, ModelMap modelMap) {
Chewei chewei = new Chewei();
chewei.setId(yuancheweiid);
chewei.setState(1);
cheweiService.updateByPrimaryKeySelective(chewei);
Chewei chewei1 = new Chewei();
chewei1.setId(gudingche.getCheweiid());
chewei1.setState(0);
cheweiService.updateByPrimaryKeySelective(chewei1);
modelMap.put('result', new ResponseVo(gudingcheService.updateByPrimaryKeySelective(gudingche) ? ResponseType.EDIT_SUCCESS : ResponseType.EDIT_FAIL));
return FastjsonUtils.serialize(modelMap);
}
@RequestMapping(value = '/page/edit/{id}')
public String editTiku(@PathVariable Integer id, ModelMap modelMap) {
List<Chewei> cheweis = cheweiService.query();
modelMap.put('cheweiList',cheweis);
Gudingche result = gudingcheService.selectByPrimaryKey(id);
modelMap.put('result', result);
return '/gudingche/gudingche_edit';
}
@RequestMapping(value = '/page/gutongji')
public String lintongji() {
return '/tongji/gutongji_list';
}
@RequestMapping(value = '/tj/month')
@ResponseBody
public String getTongjiByMonth(Integer months, ModelMap modelMap){
Tongji tongji = gudingcheService.getTongjiByMonth(months);
modelMap.put('tongji', tongji);
return FastjsonUtils.serialize(modelMap);
}
}
注意事项
- 该接口使用JSON格式进行数据传输。
- 所有接口请求均需使用 UTF-8 编码。
- 具体接口参数请参考代码示例。
- 该接口需要在 Spring MVC 环境下运行。
联系方式
如有任何问题,请与 www.lifedian.com 联系。
原文地址: https://www.cveoy.top/t/topic/nEAC 著作权归作者所有。请勿转载和采集!