旅游网站设计与实现
互联网发展到如今也近20年之久,济南旅游网站一直作为互联网发展中的一个重要角色在不断更新进化。济南旅游网站从最初的文本显示到现在集文字、视频、音频与一体,成为一种网络多媒体浏览网站。作为一种媒体传输媒介,济南旅游网站如今也分各个类别,各种形式。本文着重对济南旅游网站进行分析和研究,浅析济南旅游网站的现状和存在的一些问题并对此进行研究,通过对问题和现状的分析研究和对用户需求的一个简单整理建模,设计并且实现一个济南旅游网站。
济南旅游网站采用的开发框架为SSM框架,也就是Spring mvc、Spring、MyBatis这三个框架,页面设计用的是jsp技术作为动态页面文件设计,jsp文件里可以对实现html等界面布局的代码,采用SpringMVC替代传统的struts2框架,主要对jsp访问的拦截和控制,Spring作为整个控制的核心,通过控制反转技术和面向切面技术,让Spring自动对使用的类文件进行调用和导入,MyBatis主要作为底层操作数据库,不牵扯业务逻辑,开发工具采用Eclipse,服务器用的是tomcat。编码语言是Java,数据库采用Mysql。
Java SSM旅游网站,后端基于SSM框架进行开发设计,前端页面效果通过使用Vue进行编码实现,主要实现了用户跟管理员角色,将实现景区介绍管理、联系我们管理等功能。
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.format.annotation.DateTimeFormat;
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.JingqujieshaoEntity;
import com.entity.view.JingqujieshaoView;
import com.service.JingqujieshaoService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 景区介绍
* 后端接口
* @author
* @email
* @date 2021-05-11 14:38:57
*/
@RestController
@RequestMapping("/jingqujieshao")
public class JingqujieshaoController {
@Autowired
private JingqujieshaoService jingqujieshaoService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,JingqujieshaoEntity jingqujieshao,
HttpServletRequest request){
EntityWrapper<JingqujieshaoEntity> ew = new EntityWrapper<JingqujieshaoEntity>();
PageUtils page = jingqujieshaoService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, jingqujieshao), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,JingqujieshaoEntity jingqujieshao,
HttpServletRequest request){
EntityWrapper<JingqujieshaoEntity> ew = new EntityWrapper<JingqujieshaoEntity>();
PageUtils page = jingqujieshaoService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, jingqujieshao), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( JingqujieshaoEntity jingqujieshao){
EntityWrapper<JingqujieshaoEntity> ew = new EntityWrapper<JingqujieshaoEntity>();
ew.allEq(MPUtil.allEQMapPre( jingqujieshao, "jingqujieshao"));
return R.ok().put("data", jingqujieshaoService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(JingqujieshaoEntity jingqujieshao){
EntityWrapper< JingqujieshaoEntity> ew = new EntityWrapper< JingqujieshaoEntity>();
ew.allEq(MPUtil.allEQMapPre( jingqujieshao, "jingqujieshao"));
JingqujieshaoView jingqujieshaoView = jingqujieshaoService.selectView(ew);
return R.ok("查询景区介绍成功").put("data", jingqujieshaoView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
JingqujieshaoEntity jingqujieshao = jingqujieshaoService.selectById(id);
jingqujieshao.setClicknum(jingqujieshao.getClicknum()+1);
jingqujieshao.setClicktime(new Date());
jingqujieshaoService.updateById(jingqujieshao);
return R.ok().put("data", jingqujieshao);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
JingqujieshaoEntity jingqujieshao = jingqujieshaoService.selectById(id);
jingqujieshao.setClicknum(jingqujieshao.getClicknum()+1);
jingqujieshao.setClicktime(new Date());
jingqujieshaoService.updateById(jingqujieshao);
return R.ok().put("data", jingqujieshao);
}
/**
* 赞或踩
*/
@RequestMapping("/thumbsup/{id}")
public R thumbsup(@PathVariable("id") String id,String type){
JingqujieshaoEntity jingqujieshao = jingqujieshaoService.selectById(id);
if(type.equals("1")) {
jingqujieshao.setThumbsupnum(jingqujieshao.getThumbsupnum()+1);
} else {
jingqujieshao.setCrazilynum(jingqujieshao.getCrazilynum()+1);
}
jingqujieshaoService.updateById(jingqujieshao);
return R.ok();
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody JingqujieshaoEntity jingqujieshao, HttpServletRequest request){
jingqujieshao.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(jingqujieshao);
jingqujieshaoService.insert(jingqujieshao);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody JingqujieshaoEntity jingqujieshao, HttpServletRequest request){
jingqujieshao.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(jingqujieshao);
jingqujieshaoService.insert(jingqujieshao);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody JingqujieshaoEntity jingqujieshao, HttpServletRequest request){
//ValidatorUtils.validateEntity(jingqujieshao);
jingqujieshaoService.updateById(jingqujieshao);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
jingqujieshaoService.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<JingqujieshaoEntity> wrapper = new EntityWrapper<JingqujieshaoEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = jingqujieshaoService.selectCount(wrapper);
return R.ok().put("count", count);
}
/**
* 前端智能排序
*/
@IgnoreAuth
@RequestMapping("/autoSort")
public R autoSort(@RequestParam Map<String, Object> params,JingqujieshaoEntity jingqujieshao, HttpServletRequest request,String pre){
EntityWrapper<JingqujieshaoEntity> ew = new EntityWrapper<JingqujieshaoEntity>();
Map<String, Object> newMap = new HashMap<String, Object>();
Map<String, Object> param = new HashMap<String, Object>();
Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
String key = entry.getKey();
String newKey = entry.getKey();
if (pre.endsWith(".")) {
newMap.put(pre + newKey, entry.getValue());
} else if (StringUtils.isEmpty(pre)) {
newMap.put(newKey, entry.getValue());
} else {
newMap.put(pre + "." + newKey, entry.getValue());
}
}
params.put("sort", "clicknum");
params.put("order", "desc");
PageUtils page = jingqujieshaoService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, jingqujieshao), params), params));
return R.ok().put("data", page);
}
}
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.format.annotation.DateTimeFormat;
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.LianxiwomenEntity;
import com.entity.view.LianxiwomenView;
import com.service.LianxiwomenService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 联系我们
* 后端接口
* @author
* @email
* @date 2021-05-11 14:38:57
*/
@RestController
@RequestMapping("/lianxiwomen")
public class LianxiwomenController {
@Autowired
private LianxiwomenService lianxiwomenService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,LianxiwomenEntity lianxiwomen,
HttpServletRequest request){
EntityWrapper<LianxiwomenEntity> ew = new EntityWrapper<LianxiwomenEntity>();
PageUtils page = lianxiwomenService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, lianxiwomen), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,LianxiwomenEntity lianxiwomen,
HttpServletRequest request){
EntityWrapper<LianxiwomenEntity> ew = new EntityWrapper<LianxiwomenEntity>();
PageUtils page = lianxiwomenService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, lianxiwomen), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( LianxiwomenEntity lianxiwomen){
EntityWrapper<LianxiwomenEntity> ew = new EntityWrapper<LianxiwomenEntity>();
ew.allEq(MPUtil.allEQMapPre( lianxiwomen, "lianxiwomen"));
return R.ok().put("data", lianxiwomenService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(LianxiwomenEntity lianxiwomen){
EntityWrapper< LianxiwomenEntity> ew = new EntityWrapper< LianxiwomenEntity>();
ew.allEq(MPUtil.allEQMapPre( lianxiwomen, "lianxiwomen"));
LianxiwomenView lianxiwomenView = lianxiwomenService.selectView(ew);
return R.ok("查询联系我们成功").put("data", lianxiwomenView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
LianxiwomenEntity lianxiwomen = lianxiwomenService.selectById(id);
return R.ok().put("data", lianxiwomen);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
LianxiwomenEntity lianxiwomen = lianxiwomenService.selectById(id);
return R.ok().put("data", lianxiwomen);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody LianxiwomenEntity lianxiwomen, HttpServletRequest request){
lianxiwomen.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(lianxiwomen);
lianxiwomenService.insert(lianxiwomen);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody LianxiwomenEntity lianxiwomen, HttpServletRequest request){
lianxiwomen.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(lianxiwomen);
lianxiwomenService.insert(lianxiwomen);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody LianxiwomenEntity lianxiwomen, HttpServletRequest request){
//ValidatorUtils.validateEntity(lianxiwomen);
lianxiwomenService.updateById(lianxiwomen);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
lianxiwomenService.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<LianxiwomenEntity> wrapper = new EntityWrapper<LianxiwomenEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = lianxiwomenService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
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.format.annotation.DateTimeFormat;
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.YonghuEntity;
import com.entity.view.YonghuView;
import com.service.YonghuService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 用户
* 后端接口
* @author
* @email
* @date 2021-05-11 14:38:57
*/
@RestController
@RequestMapping("/yonghu")
public class YonghuController {
@Autowired
private YonghuService yonghuService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"yonghu", "用户" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody YonghuEntity yonghu){
//ValidatorUtils.validateEntity(yonghu);
YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao()));
if(user!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
yonghu.setId(uId);
yonghuService.insert(yonghu);
return R.ok();
}
/**
* 退出
*/
@RequestMapping("/logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
YonghuEntity user = yonghuService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
yonghuService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,YonghuEntity yonghu,
HttpServletRequest request){
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,YonghuEntity yonghu,
HttpServletRequest request){
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( YonghuEntity yonghu){
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
ew.allEq(MPUtil.allEQMapPre( yonghu, "yonghu"));
return R.ok().put("data", yonghuService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(YonghuEntity yonghu){
EntityWrapper< YonghuEntity> ew = new EntityWrapper< YonghuEntity>();
ew.allEq(MPUtil.allEQMapPre( yonghu, "yonghu"));
YonghuView yonghuView = yonghuService.selectView(ew);
return R.ok("查询用户成功").put("data", yonghuView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
YonghuEntity yonghu = yonghuService.selectById(id);
return R.ok().put("data", yonghu);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
YonghuEntity yonghu = yonghuService.selectById(id);
return R.ok().put("data", yonghu);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(yonghu);
YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao()));
if(user!=null) {
return R.error("用户已存在");
}
yonghu.setId(new Date().getTime());
yonghuService.insert(yonghu);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(yonghu);
YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao()));
if(user!=null) {
return R.error("用户已存在");
}
yonghu.setId(new Date().getTime());
yonghuService.insert(yonghu);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
//ValidatorUtils.validateEntity(yonghu);
yonghuService.updateById(yonghu);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
yonghuService.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<YonghuEntity> wrapper = new EntityWrapper<YonghuEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = yonghuService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
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.format.annotation.DateTimeFormat;
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.YouwangonglveEntity;
import com.entity.view.YouwangonglveView;
import com.service.YouwangonglveService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 游玩攻略
* 后端接口
* @author
* @email
* @date 2021-05-11 14:38:57
*/
@RestController
@RequestMapping("/youwangonglve")
public class YouwangonglveController {
@Autowired
private YouwangonglveService youwangonglveService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,YouwangonglveEntity youwangonglve,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("yonghu")) {
youwangonglve.setZhanghao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<YouwangonglveEntity> ew = new EntityWrapper<YouwangonglveEntity>();
PageUtils page = youwangonglveService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, youwangonglve), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,YouwangonglveEntity youwangonglve,
HttpServletRequest request){
EntityWrapper<YouwangonglveEntity> ew = new EntityWrapper<YouwangonglveEntity>();
PageUtils page = youwangonglveService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, youwangonglve), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( YouwangonglveEntity youwangonglve){
EntityWrapper<YouwangonglveEntity> ew = new EntityWrapper<YouwangonglveEntity>();
ew.allEq(MPUtil.allEQMapPre( youwangonglve, "youwangonglve"));
return R.ok().put("data", youwangonglveService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(YouwangonglveEntity youwangonglve){
EntityWrapper< YouwangonglveEntity> ew = new EntityWrapper< YouwangonglveEntity>();
ew.allEq(MPUtil.allEQMapPre( youwangonglve, "youwangonglve"));
YouwangonglveView youwangonglveView = youwangonglveService.selectView(ew);
return R.ok("查询游玩攻略成功").put("data", youwangonglveView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
YouwangonglveEntity youwangonglve = youwangonglveService.selectById(id);
return R.ok().put("data", youwangonglve);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
YouwangonglveEntity youwangonglve = youwangonglveService.selectById(id);
return R.ok().put("data", youwangonglve);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody YouwangonglveEntity youwangonglve, HttpServletRequest request){
youwangonglve.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(youwangonglve);
youwangonglveService.insert(youwangonglve);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody YouwangonglveEntity youwangonglve, HttpServletRequest request){
youwangonglve.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(youwangonglve);
youwangonglveService.insert(youwangonglve);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody YouwangonglveEntity youwangonglve, HttpServletRequest request){
//ValidatorUtils.validateEntity(youwangonglve);
youwangonglveService.updateById(youwangonglve);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
youwangonglveService.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<YouwangonglveEntity> wrapper = new EntityWrapper<YouwangonglveEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("yonghu")) {
wrapper.eq("zhanghao", (String)request.getSession().getAttribute("username"));
}
int count = youwangonglveService.selectCount(wrapper);
return R.ok().put("count", count);
}
}