小程序开发说明
开发语言:Java
框架:ssm
JDK版本:JDK1.8
服务器:tomcat7
数据库:mysql 5.7(一定要5.7版本)
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器
小程序框架:uniapp
小程序开发软件:HBuilder X
小程序运行软件:微信开发者
关键逻辑代码:
/**
* 购买信息
* 后端接口
* @author
* @email
* @date 2022-04-12 14:16:31
*/
@RestController
@RequestMapping("/goumaixinxi")
public class GoumaixinxiController {
@Autowired
private GoumaixinxiService goumaixinxiService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,GoumaixinxiEntity goumaixinxi,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("shangjia")) {
goumaixinxi.setShangjiazhanghao((String)request.getSession().getAttribute("username"));
}
if(tableName.equals("yonghu")) {
goumaixinxi.setYonghuzhanghao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<GoumaixinxiEntity> ew = new EntityWrapper<GoumaixinxiEntity>();
PageUtils page = goumaixinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, goumaixinxi), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,GoumaixinxiEntity goumaixinxi,
HttpServletRequest request){
EntityWrapper<GoumaixinxiEntity> ew = new EntityWrapper<GoumaixinxiEntity>();
PageUtils page = goumaixinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, goumaixinxi), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( GoumaixinxiEntity goumaixinxi){
EntityWrapper<GoumaixinxiEntity> ew = new EntityWrapper<GoumaixinxiEntity>();
ew.allEq(MPUtil.allEQMapPre( goumaixinxi, "goumaixinxi"));
return R.ok().put("data", goumaixinxiService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(GoumaixinxiEntity goumaixinxi){
EntityWrapper< GoumaixinxiEntity> ew = new EntityWrapper< GoumaixinxiEntity>();
ew.allEq(MPUtil.allEQMapPre( goumaixinxi, "goumaixinxi"));
GoumaixinxiView goumaixinxiView = goumaixinxiService.selectView(ew);
return R.ok("查询购买信息成功").put("data", goumaixinxiView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
GoumaixinxiEntity goumaixinxi = goumaixinxiService.selectById(id);
return R.ok().put("data", goumaixinxi);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
GoumaixinxiEntity goumaixinxi = goumaixinxiService.selectById(id);
return R.ok().put("data", goumaixinxi);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody GoumaixinxiEntity goumaixinxi, HttpServletRequest request){
goumaixinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(goumaixinxi);
goumaixinxiService.insert(goumaixinxi);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody GoumaixinxiEntity goumaixinxi, HttpServletRequest request){
goumaixinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(goumaixinxi);
goumaixinxiService.insert(goumaixinxi);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody GoumaixinxiEntity goumaixinxi, HttpServletRequest request){
//ValidatorUtils.validateEntity(goumaixinxi);
goumaixinxiService.updateById(goumaixinxi);//全部更新
return R.ok();
}