赞
踩
1.本课题的目的及研究意义 |
旅游行业的飞速发展,非常有效地促进了经济社会的进步。但是在一个产业的快速发展中,产业始终会出现许多的问题,旅游行业也不排除在外,如果不及时应对变化,解决这一系列问题的话,这些问题最终会影响整个行业的不断发展。就比如在旅游网站的开发技术方面,如何解决人们日益增长的需求,水平的提高同样伴随的人民要求的提高,人们不仅仅需要系统的安全可靠,能够很好的保护客户的信息,而且需要在页面美观的前提下系统能够给用户提供更多更好的选择,系统如何能够根据用户的点击,关注等等,通过一系列的算法分析出一个用户的爱好所在,以提供适合个人用户的旅游,富含情怀和内容的场所,也是必须解决的问题。 随着互联网的渐渐普及和信息化的发展的同时,客户也希望通过更快的联系方式,更简单方便的网络来满足自己的需求。网络的发展以渗透到人们的日常生活中。本系统是一个基于B/S模式的旅游网站,即可以为旅游公司人员提供更方便、快捷的工作环境,又可以通过网络使客户更方便、快捷的报名参加旅游项目,来减少公司的人员还有旅游者双方的时间,提高人们的工作效率。 |
2.本课题的国内外的研究现状 |
在最初的旅游管理方面,大都是通过人力来完成的,比如现场确认要游玩的景点、有哪些套餐推荐、价格的优惠程度,确认完之后进行现场买票,最后凭纸质票进入。随着互联网的不断发展,发达国家在计算机方面已达到相当高的水平,现在国内外的旅游景点这种导游平台,基本都会选择旅游管理系统来协助管理。 近年来,随着国家的不断发展,经济不断提高,旅游业也成为热门行业之一。 而随着旅游业变得热门,线下的店面正在面临着人挤人的现象,为买一票需要排很长的队,甚至有时还买不到,浪费了大量的时间,且有很大的安全隐患。旅游人数的增多,也意味着售票的工作人员的任务量也大幅度提升,这就难免会出一些小差错而导致许多麻烦。因此,开发一个旅游管理系统,有利于工作人员的管理,更有利于消费者直观的选择自己的旅游方式,带来更好的旅游体验。 |
毕业设计(论 文)开题报告
3.本课题的研究内容 |
开发一个旅游管理平台,需要实现: 三个角色: 1、游客:可浏览景点信息以及论坛。 2、普通用户;新用户注册、老用户登陆、浏览旅游景点、旅游线路预订、论坛留言。 3、管理员:用户管理、新闻资讯管理、景点管理、线路管理、预订管理、论坛管理 以下功能: 1、景点信息功能:景点信息的展示,可通过关键字查找。用户可查看相关景点。管理员对景点信息进行管理 2、线路推荐功能:用户可查看相关线路进行自驾游或者线路预订。管理员可对线路进行管理。 3、线路预订功能:用户可选择一条线路进行预订,购买成功会显示该线路已购买的总数量。游客只能查看不能预订。管理员可对线路进行管理。 4、新闻资讯功能:该功能主要为用户展示各景点内最新新闻的报道,用户游客可查看,管理员可进行管理。 5、论坛管理功能:游客只能浏览不能评论。用户可以浏览以及发表留言。管理员管理留言 |
4.本课题的实行方案、进度及预期效果 |
实行方案: 在系统设计与实现过程中,前段采用Vue框架,后端采用Springboot作为开发框架,将MySQL数据库作为本系统的数据存储。 |
毕业设计(论 文)开题报告
5、已查阅参考文献:(10篇以上中文,至少1篇英文,总共至少11篇) |
[1]邹盛荣.UML面向对象需求分析与建模教程[M].北京:科学出版社,2017. [2]西尔伯沙茨(Silberschatz.A.).计算机科学丛书:数据库系统概念(原书第6版)[M]. 机械工业出版社,2018,03.。 [3]陈雄华 企业应用开发详解 电子大学出版社,2017。 [4]孙秀娟,田晓玲.基于CSS+DIV的页面分栏布局的应用[J].北京工业职业技术学院学报,2016,15(04):10-14+18. [5]刘春茂.网页设计与网站建设案例课堂(第2版)[M].北京:清华大学出版社,2018. [6]王虎. 基于B/S模式的信息管理平台[D].天津大学,2018. [7]史胜辉,王春明,沈学华 JavaEE基础教程 清华大学出版社 2016 。 [8]徐鹏涛.基于Vue的前端开发框架的设计与实现[D]. 济南:山东大学,2020. [9]王丹,孙晓宇,杨路斌,高胜严. 基于Springboot的软件统计分析系统设计与实现[J].软件工程. 2019,(03):40-42. [10]疯狂软件.Spring Boot 2 企业应用实战[M].北京:电子工业出版社,2018. [11] Durgesh Raghuvanshi. Introduction to Software Testing[J] Journal of Trend in Scientific Research and Development,2020.:797-800. |
基于springboot旅游景点导游平台源码和论文453
演示视频:
基于springboot旅游景点导游平台源码和论文
-
- package com.controller;
-
- import java.io.File;
- import java.math.BigDecimal;
- import java.net.URL;
- import java.text.SimpleDateFormat;
- import com.alibaba.fastjson.JSONObject;
- import java.util.*;
- import org.springframework.beans.BeanUtils;
- import javax.servlet.http.HttpServletRequest;
- import org.springframework.web.context.ContextLoader;
- import javax.servlet.ServletContext;
- import com.service.TokenService;
- import com.utils.*;
- import java.lang.reflect.InvocationTargetException;
-
- import com.service.DictionaryService;
- import org.apache.commons.lang3.StringUtils;
- import com.annotation.IgnoreAuth;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.*;
- import com.baomidou.mybatisplus.mapper.EntityWrapper;
- import com.baomidou.mybatisplus.mapper.Wrapper;
- import com.entity.*;
- import com.entity.view.*;
- import com.service.*;
- import com.utils.PageUtils;
- import com.utils.R;
- import com.alibaba.fastjson.*;
-
- /**
- * 用户
- * 后端接口
- * @author
- * @email
- */
- @RestController
- @Controller
- @RequestMapping("/yonghu")
- public class YonghuController {
- private static final Logger logger = LoggerFactory.getLogger(YonghuController.class);
-
- private static final String TABLE_NAME = "yonghu";
-
- @Autowired
- private YonghuService yonghuService;
-
-
- @Autowired
- private TokenService tokenService;
-
- @Autowired
- private DictionaryService dictionaryService;//字典
- @Autowired
- private ForumService forumService;//交流论坛
- @Autowired
- private GonggaoService gonggaoService;//公告资讯
- @Autowired
- private HanfuService hanfuService;//汉服信息
- @Autowired
- private HanfuCollectionService hanfuCollectionService;//汉服收藏
- @Autowired
- private HanfuCommentbackService hanfuCommentbackService;//汉服评价
- @Autowired
- private HanfuOrderService hanfuOrderService;//汉服租赁
- @Autowired
- private UsersService usersService;//管理员
-
-
- /**
- * 后端列表
- */
- @RequestMapping("/page")
- public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
- logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
- String role = String.valueOf(request.getSession().getAttribute("role"));
- if(false)
- return R.error(511,"永不会进入");
- else if("用户".equals(role))
- params.put("yonghuId",request.getSession().getAttribute("userId"));
- CommonUtil.checkMap(params);
- PageUtils page = yonghuService.queryPage(params);
-
- //字典表数据转换
- List<YonghuView> list =(List<YonghuView>)page.getList();
- for(YonghuView c:list){
- //修改对应字典表字段
- dictionaryService.dictionaryConvert(c, request);
- }
- return R.ok().put("data", page);
- }
-
- /**
- * 后端详情
- */
- @RequestMapping("/info/{id}")
- public R info(@PathVariable("id") Long id, HttpServletRequest request){
- logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
- YonghuEntity yonghu = yonghuService.selectById(id);
- if(yonghu !=null){
- //entity转view
- YonghuView view = new YonghuView();
- BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中
- //修改对应字典表字段
- dictionaryService.dictionaryConvert(view, request);
- return R.ok().put("data", view);
- }else {
- return R.error(511,"查不到数据");
- }
-
- }
-
- /**
- * 后端保存
- */
- @RequestMapping("/save")
- public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
- logger.debug("save方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
-
- String role = String.valueOf(request.getSession().getAttribute("role"));
- if(false)
- return R.error(511,"永远不会进入");
-
- Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
- .eq("username", yonghu.getUsername())
- .or()
- .eq("yonghu_phone", yonghu.getYonghuPhone())
- .or()
- .eq("yonghu_id_number", yonghu.getYonghuIdNumber())
- ;
-
- logger.info("sql语句:"+queryWrapper.getSqlSegment());
- YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
- if(yonghuEntity==null){
- yonghu.setCreateTime(new Date());
- yonghu.setPassword("123456");
- yonghuService.insert(yonghu);
- return R.ok();
- }else {
- return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");
- }
- }
-
- /**
- * 后端修改
- */
- @RequestMapping("/update")
- public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
- logger.debug("update方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
- YonghuEntity oldYonghuEntity = yonghuService.selectById(yonghu.getId());//查询原先数据
-
- String role = String.valueOf(request.getSession().getAttribute("role"));
- // if(false)
- // return R.error(511,"永远不会进入");
- if("".equals(yonghu.getYonghuPhoto()) || "null".equals(yonghu.getYonghuPhoto())){
- yonghu.setYonghuPhoto(null);
- }
-
- yonghuService.updateById(yonghu);//根据id更新
- return R.ok();
- }
-
-
-
- /**
- * 删除
- */
- @RequestMapping("/delete")
- public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
- logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
- List<YonghuEntity> oldYonghuList =yonghuService.selectBatchIds(Arrays.asList(ids));//要删除的数据
- yonghuService.deleteBatchIds(Arrays.asList(ids));
-
- return R.ok();
- }
-
-
- /**
- * 批量上传
- */
- @RequestMapping("/batchInsert")
- public R save( String fileName, HttpServletRequest request){
- logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
- Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- //.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
- try {
- List<YonghuEntity> yonghuList = new ArrayList<>();//上传的东西
- Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
- Date date = new Date();
- int lastIndexOf = fileName.lastIndexOf(".");
- if(lastIndexOf == -1){
- return R.error(511,"该文件没有后缀");
- }else{
- String suffix = fileName.substring(lastIndexOf);
- if(!".xls".equals(suffix)){
- return R.error(511,"只支持后缀为xls的excel文件");
- }else{
- URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
- File file = new File(resource.getFile());
- if(!file.exists()){
- return R.error(511,"找不到上传文件,请联系管理员");
- }else{
- List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
- dataList.remove(0);//删除第一行,因为第一行是提示
- for(List<String> data:dataList){
- //循环
- YonghuEntity yonghuEntity = new YonghuEntity();
- // yonghuEntity.setUsername(data.get(0)); //账户 要改的
- // yonghuEntity.setPassword("123456");//密码
- // yonghuEntity.setYonghuUuidNumber(data.get(0)); //用户编号 要改的
- // yonghuEntity.setYonghuName(data.get(0)); //用户姓名 要改的
- // yonghuEntity.setYonghuPhone(data.get(0)); //用户手机号 要改的
- // yonghuEntity.setYonghuIdNumber(data.get(0)); //用户身份证号 要改的
- // yonghuEntity.setYonghuPhoto("");//详情和图片
- // yonghuEntity.setSexTypes(Integer.valueOf(data.get(0))); //性别 要改的
- // yonghuEntity.setNewMoney(data.get(0)); //余额 要改的
- // yonghuEntity.setYonghuEmail(data.get(0)); //用户邮箱 要改的
- // yonghuEntity.setCreateTime(date);//时间
- yonghuList.add(yonghuEntity);
-
-
- //把要查询是否重复的字段放入map中
- //账户
- if(seachFields.containsKey("username")){
- List<String> username = seachFields.get("username");
- username.add(data.get(0));//要改的
- }else{
- List<String> username = new ArrayList<>();
- username.add(data.get(0));//要改的
- seachFields.put("username",username);
- }
- //用户编号
- if(seachFields.containsKey("yonghuUuidNumber")){
- List<String> yonghuUuidNumber = seachFields.get("yonghuUuidNumber");
- yonghuUuidNumber.add(data.get(0));//要改的
- }else{
- List<String> yonghuUuidNumber = new ArrayList<>();
- yonghuUuidNumber.add(data.get(0));//要改的
- seachFields.put("yonghuUuidNumber",yonghuUuidNumber);
- }
- //用户手机号
- if(seachFields.containsKey("yonghuPhone")){
- List<String> yonghuPhone = seachFields.get("yonghuPhone");
- yonghuPhone.add(data.get(0));//要改的
- }else{
- List<String> yonghuPhone = new ArrayList<>();
- yonghuPhone.add(data.get(0));//要改的
- seachFields.put("yonghuPhone",yonghuPhone);
- }
- //用户身份证号
- if(seachFields.containsKey("yonghuIdNumber")){
- List<String> yonghuIdNumber = seachFields.get("yonghuIdNumber");
- yonghuIdNumber.add(data.get(0));//要改的
- }else{
- List<String> yonghuIdNumber = new ArrayList<>();
- yonghuIdNumber.add(data.get(0));//要改的
- seachFields.put("yonghuIdNumber",yonghuIdNumber);
- }
- }
-
- //查询是否重复
- //账户
- List<YonghuEntity> yonghuEntities_username = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("username", seachFields.get("username")));
- if(yonghuEntities_username.size() >0 ){
- ArrayList<String> repeatFields = new ArrayList<>();
- for(YonghuEntity s:yonghuEntities_username){
- repeatFields.add(s.getUsername());
- }
- return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
- }
- //用户编号
- List<YonghuEntity> yonghuEntities_yonghuUuidNumber = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_uuid_number", seachFields.get("yonghuUuidNumber")));
- if(yonghuEntities_yonghuUuidNumber.size() >0 ){
- ArrayList<String> repeatFields = new ArrayList<>();
- for(YonghuEntity s:yonghuEntities_yonghuUuidNumber){
- repeatFields.add(s.getYonghuUuidNumber());
- }
- return R.error(511,"数据库的该表中的 [用户编号] 字段已经存在 存在数据为:"+repeatFields.toString());
- }
- //用户手机号
- List<YonghuEntity> yonghuEntities_yonghuPhone = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_phone", seachFields.get("yonghuPhone")));
- if(yonghuEntities_yonghuPhone.size() >0 ){
- ArrayList<String> repeatFields = new ArrayList<>();
- for(YonghuEntity s:yonghuEntities_yonghuPhone){
- repeatFields.add(s.getYonghuPhone());
- }
- return R.error(511,"数据库的该表中的 [用户手机号] 字段已经存在 存在数据为:"+repeatFields.toString());
- }
- //用户身份证号
- List<YonghuEntity> yonghuEntities_yonghuIdNumber = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_id_number", seachFields.get("yonghuIdNumber")));
- if(yonghuEntities_yonghuIdNumber.size() >0 ){
- ArrayList<String> repeatFields = new ArrayList<>();
- for(YonghuEntity s:yonghuEntities_yonghuIdNumber){
- repeatFields.add(s.getYonghuIdNumber());
- }
- return R.error(511,"数据库的该表中的 [用户身份证号] 字段已经存在 存在数据为:"+repeatFields.toString());
- }
- yonghuService.insertBatch(yonghuList);
- return R.ok();
- }
- }
- }
- }catch (Exception e){
- e.printStackTrace();
- return R.error(511,"批量插入数据异常,请联系管理员");
- }
- }
-
- /**
- * 登录
- */
- @IgnoreAuth
- @RequestMapping(value = "/login")
- public R login(String username, String password, String captcha, HttpServletRequest request) {
- YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
- if(yonghu==null || !yonghu.getPassword().equals(password))
- return R.error("账号或密码不正确");
- String token = tokenService.generateToken(yonghu.getId(),username, "yonghu", "用户");
- R r = R.ok();
- r.put("token", token);
- r.put("role","用户");
- r.put("username",yonghu.getYonghuName());
- r.put("tableName","yonghu");
- r.put("userId",yonghu.getId());
- return r;
- }
-
- /**
- * 注册
- */
- @IgnoreAuth
- @PostMapping(value = "/register")
- public R register(@RequestBody YonghuEntity yonghu, HttpServletRequest request) {
- // ValidatorUtils.validateEntity(user);
- Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
- .eq("username", yonghu.getUsername())
- .or()
- .eq("yonghu_phone", yonghu.getYonghuPhone())
- .or()
- .eq("yonghu_id_number", yonghu.getYonghuIdNumber())
- ;
- YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
- if(yonghuEntity != null)
- return R.error("账户或者用户手机号或者用户身份证号已经被使用");
- yonghu.setYonghuUuidNumber(String.valueOf(new Date().getTime()));
- yonghu.setNewMoney(0.0);
- yonghu.setCreateTime(new Date());
- yonghuService.insert(yonghu);
-
- return R.ok();
- }
-
- /**
- * 重置密码
- */
- @GetMapping(value = "/resetPassword")
- public R resetPassword(Integer id, HttpServletRequest request) {
- YonghuEntity yonghu = yonghuService.selectById(id);
- yonghu.setPassword("123456");
- yonghuService.updateById(yonghu);
- return R.ok();
- }
-
- /**
- * 修改密码
- */
- @GetMapping(value = "/updatePassword")
- public R updatePassword(String oldPassword, String newPassword, HttpServletRequest request) {
- YonghuEntity yonghu = yonghuService.selectById((Integer)request.getSession().getAttribute("userId"));
- if(newPassword == null){
- return R.error("新密码不能为空") ;
- }
- if(!oldPassword.equals(yonghu.getPassword())){
- return R.error("原密码输入错误");
- }
- if(newPassword.equals(yonghu.getPassword())){
- return R.error("新密码不能和原密码一致") ;
- }
- yonghu.setPassword(newPassword);
- yonghuService.updateById(yonghu);
- return R.ok();
- }
-
-
-
- /**
- * 忘记密码
- */
- @IgnoreAuth
- @RequestMapping(value = "/resetPass")
- public R resetPass(String username, HttpServletRequest request) {
- YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
- if(yonghu!=null){
- yonghu.setPassword("123456");
- yonghuService.updateById(yonghu);
- return R.ok();
- }else{
- return R.error("账号不存在");
- }
- }
-
-
- /**
- * 获取用户的session用户信息
- */
- @RequestMapping("/session")
- public R getCurrYonghu(HttpServletRequest request){
- Integer id = (Integer)request.getSession().getAttribute("userId");
- YonghuEntity yonghu = yonghuService.selectById(id);
- if(yonghu !=null){
- //entity转view
- YonghuView view = new YonghuView();
- BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中
-
- //修改对应字典表字段
- dictionaryService.dictionaryConvert(view, request);
- return R.ok().put("data", view);
- }else {
- return R.error(511,"查不到数据");
- }
- }
-
-
- /**
- * 退出
- */
- @GetMapping(value = "logout")
- public R logout(HttpServletRequest request) {
- request.getSession().invalidate();
- return R.ok("退出成功");
- }
-
-
-
- /**
- * 前端列表
- */
- @IgnoreAuth
- @RequestMapping("/list")
- public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
- logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
-
- CommonUtil.checkMap(params);
- PageUtils page = yonghuService.queryPage(params);
-
- //字典表数据转换
- List<YonghuView> list =(List<YonghuView>)page.getList();
- for(YonghuView c:list)
- dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
-
- return R.ok().put("data", page);
- }
-
- /**
- * 前端详情
- */
- @RequestMapping("/detail/{id}")
- public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
- logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
- YonghuEntity yonghu = yonghuService.selectById(id);
- if(yonghu !=null){
-
-
- //entity转view
- YonghuView view = new YonghuView();
- BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中
-
- //修改对应字典表字段
- dictionaryService.dictionaryConvert(view, request);
- return R.ok().put("data", view);
- }else {
- return R.error(511,"查不到数据");
- }
- }
-
-
- /**
- * 前端保存
- */
- @RequestMapping("/add")
- public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
- logger.debug("add方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
- Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
- .eq("username", yonghu.getUsername())
- .or()
- .eq("yonghu_phone", yonghu.getYonghuPhone())
- .or()
- .eq("yonghu_id_number", yonghu.getYonghuIdNumber())
- // .notIn("yonghu_types", new Integer[]{102})
- ;
- logger.info("sql语句:"+queryWrapper.getSqlSegment());
- YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
- if(yonghuEntity==null){
- yonghu.setCreateTime(new Date());
- yonghu.setPassword("123456");
- yonghuService.insert(yonghu);
-
- return R.ok();
- }else {
- return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");
- }
- }
-
- }
-
- 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-04-19 16:07:48
- */
- @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("yonghuming", 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("yonghuming", yonghu.getYonghuming()));
- 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("yonghuming", 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("yonghuming", yonghu.getYonghuming()));
- 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("yonghuming", yonghu.getYonghuming()));
- 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);
- }
-
-
-
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。