基于微信小程序+SSM+Vue+Node实现智慧旅游商城系统(二)https://developer.aliyun.com/article/1423219
package com.controller; import java.util.Arrays; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.annotation.IgnoreAuth; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.entity.ConfigEntity; import com.service.ConfigService; import com.utils.PageUtils; import com.utils.R; import com.utils.ValidatorUtils; /** * 登录相关 */ @RequestMapping("config") @RestController public class ConfigController{ @Autowired private ConfigService configService; /** * 列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,ConfigEntity config){ EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); PageUtils page = configService.queryPage(params); return R.ok().put("data", page); } /** * 列表 */ @IgnoreAuth @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,ConfigEntity config){ EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); PageUtils page = configService.queryPage(params); return R.ok().put("data", page); } /** * 信息 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") String id){ ConfigEntity config = configService.selectById(id); return R.ok().put("data", config); } /** * 详情 */ @IgnoreAuth @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") String id){ ConfigEntity config = configService.selectById(id); return R.ok().put("data", config); } /** * 根据name获取信息 */ @RequestMapping("/info") public R infoByName(@RequestParam String name){ ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); return R.ok().put("data", config); } /** * 保存 */ @PostMapping("/save") public R save(@RequestBody ConfigEntity config){ // ValidatorUtils.validateEntity(config); configService.insert(config); return R.ok(); } /** * 修改 */ @RequestMapping("/update") public R update(@RequestBody ConfigEntity config){ // ValidatorUtils.validateEntity(config); configService.updateById(config);//全部更新 return R.ok(); } /** * 删除 */ @RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ configService.deleteBatchIds(Arrays.asList(ids)); return R.ok(); } }
package com.controller; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Map; import java.util.HashMap; import java.util.Iterator; import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletRequest; import com.utils.ValidatorUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.Wrapper; import com.annotation.IgnoreAuth; import com.entity.DiscussjingdianxinxiEntity; import com.entity.view.DiscussjingdianxinxiView; import com.service.DiscussjingdianxinxiService; import com.service.TokenService; import com.utils.PageUtils; import com.utils.R; import com.utils.MPUtil; import com.utils.CommonUtil; /** * 景点信息评论表 * 后端接口 * @author * @email * @date 2022-09-29 11:11:16 */ @RestController @RequestMapping("/discussjingdianxinxi") public class DiscussjingdianxinxiController { @Autowired private DiscussjingdianxinxiService discussjingdianxinxiService; /** * 后端列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,DiscussjingdianxinxiEntity discussjingdianxinxi, HttpServletRequest request){ EntityWrapper<DiscussjingdianxinxiEntity> ew = new EntityWrapper<DiscussjingdianxinxiEntity>(); PageUtils page = discussjingdianxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discussjingdianxinxi), params), params)); return R.ok().put("data", page); } /** * 前端列表 */ @IgnoreAuth @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,DiscussjingdianxinxiEntity discussjingdianxinxi, HttpServletRequest request){ EntityWrapper<DiscussjingdianxinxiEntity> ew = new EntityWrapper<DiscussjingdianxinxiEntity>(); PageUtils page = discussjingdianxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discussjingdianxinxi), params), params)); return R.ok().put("data", page); } /** * 列表 */ @RequestMapping("/lists") public R list( DiscussjingdianxinxiEntity discussjingdianxinxi){ EntityWrapper<DiscussjingdianxinxiEntity> ew = new EntityWrapper<DiscussjingdianxinxiEntity>(); ew.allEq(MPUtil.allEQMapPre( discussjingdianxinxi, "discussjingdianxinxi")); return R.ok().put("data", discussjingdianxinxiService.selectListView(ew)); } /** * 查询 */ @RequestMapping("/query") public R query(DiscussjingdianxinxiEntity discussjingdianxinxi){ EntityWrapper< DiscussjingdianxinxiEntity> ew = new EntityWrapper< DiscussjingdianxinxiEntity>(); ew.allEq(MPUtil.allEQMapPre( discussjingdianxinxi, "discussjingdianxinxi")); DiscussjingdianxinxiView discussjingdianxinxiView = discussjingdianxinxiService.selectView(ew); return R.ok("查询景点信息评论表成功").put("data", discussjingdianxinxiView); } /** * 后端详情 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") Long id){ DiscussjingdianxinxiEntity discussjingdianxinxi = discussjingdianxinxiService.selectById(id); return R.ok().put("data", discussjingdianxinxi); } /** * 前端详情 */ @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ DiscussjingdianxinxiEntity discussjingdianxinxi = discussjingdianxinxiService.selectById(id); return R.ok().put("data", discussjingdianxinxi); } /** * 后端保存 */ @RequestMapping("/save") public R save(@RequestBody DiscussjingdianxinxiEntity discussjingdianxinxi, HttpServletRequest request){ discussjingdianxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(discussjingdianxinxi); discussjingdianxinxiService.insert(discussjingdianxinxi); return R.ok(); } /** * 前端保存 */ @RequestMapping("/add") public R add(@RequestBody DiscussjingdianxinxiEntity discussjingdianxinxi, HttpServletRequest request){ discussjingdianxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(discussjingdianxinxi); discussjingdianxinxiService.insert(discussjingdianxinxi); return R.ok(); } /** * 修改 */ @RequestMapping("/update") public R update(@RequestBody DiscussjingdianxinxiEntity discussjingdianxinxi, HttpServletRequest request){ //ValidatorUtils.validateEntity(discussjingdianxinxi); discussjingdianxinxiService.updateById(discussjingdianxinxi);//全部更新 return R.ok(); } /** * 删除 */ @RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ discussjingdianxinxiService.deleteBatchIds(Arrays.asList(ids)); return R.ok(); } /** * 提醒接口 */ @RequestMapping("/remind/{columnName}/{type}") public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, @PathVariable("type") String type,@RequestParam Map<String, Object> map) { map.put("column", columnName); map.put("type", type); if(type.equals("2")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); Date remindStartDate = null; Date remindEndDate = null; if(map.get("remindstart")!=null) { Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindStart); remindStartDate = c.getTime(); map.put("remindstart", sdf.format(remindStartDate)); } if(map.get("remindend")!=null) { Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindEnd); remindEndDate = c.getTime(); map.put("remindend", sdf.format(remindEndDate)); } } Wrapper<DiscussjingdianxinxiEntity> wrapper = new EntityWrapper<DiscussjingdianxinxiEntity>(); if(map.get("remindstart")!=null) { wrapper.ge(columnName, map.get("remindstart")); } if(map.get("remindend")!=null) { wrapper.le(columnName, map.get("remindend")); } int count = discussjingdianxinxiService.selectCount(wrapper); return R.ok().put("count", count); } }
五,项目总结
通过需求分析和设计出了旅游服务软件,实现首页、个人中心、旅游攻略管理、旅游资讯管理、景点信息管理、门票预定管理、用户管理、酒店信息管理、酒店预定管理、推荐路线管理、论坛管理、系统管理等功能,给用户提供一个完整的旅游服务软件资源平台。对旅游服务软件进行系统测试。