springboot vue健美操评分系统源码和论文

健美操评分系统采用B/S架构,数据库是MySQL。系统的搭建与开发采用了先进的JAVA进行编写,使用了springboot框架。该系统从三个对象:由管理员、裁判员和用户来对系统进行设计构建。主要功能包括首页,个人中心,裁判员管理,用户管理,视频分类管理,健美操管理,评分管理,系统管理等功能进行管理。本系统在一般健美操评分系统的基础上增加了健美操资讯的功能,方便用户快速浏览,是一个高效的、动态的、交互友好的健美操评分系统。

本系统采用的数据库是MySQL,使用java技术开发。在设计过程中,很好地发挥了该开发方式的优势,让实现代码有了良好的可读性,而且使代码的更新和维护更加的方便,操作方便,对以后的维护减少了很多麻烦。系统的顺利开发和实现,对于健美操评分这一方面提供巨大的便利服务,对管理员、裁判员和用户带来了极大的便利,方便大众,为社会的进步与发展提供了一些动力。

关键词:健美操评分;java;MySQL 

springboot vue健美操评分系统源码和论文PPT705

Abstract

Aerobics scoring system uses B/S architecture, the database is MySQL. The system is constructed and developed with advanced JAVA and springboot framework. The system is designed and constructed from three objects: administrators, referees and users. The main functions include home page, personal center, referee management, user management, video classification management, aerobics management, scoring management, system management and other functions. This system increases the function of aerobics information on the basis of the general aerobics scoring system, which is convenient for users to browse quickly. It is an efficient, dynamic, interactive and friendly aerobics scoring system.

This system uses MySQL database, using java technology development. In the design process, the advantages of the development way are well played, so that the implementation code has a good readability, and make the code update and maintenance more convenient, easy to operate, to reduce a lot of trouble in the future maintenance. The smooth development and implementation of the system, for the aerobics scoring this aspect to provide great convenience services, administrators, referees and users have brought great convenience, convenient for the public, for the progress and development of society to provide some power.

Key words: aerobics score; java; MySQL

1 绪  论

1.1背景与意义

随着社会的快速发展,计算机技术的影响是全面且深入的。目前,社会的各种类型的系统越来越多,但是有些类型的系统附加了太多的商业元素和虚假信息,而且,用户在搜索相关信息时需访问多个系统和大量垃圾广告,这已经在很大程度上影响了对信息搜索效率,并且降低了用户的体验感,使用户很难快速地浏览或查询到自己所需要的相关信息。电子计算机在现代管理中的应用使电子,计算机变成了人类运用现代信息技术的主要工具。可以更高效的处理人类获取信息中精细化、全面化的问题,从而提高了效率[2]。本系统使用具有独特且和资源相对优势的管理方式,来提供一个优秀的系统,在这个管理过程受到了鼓励与帮助。而随着互联网的应用,互联网也以一种巨大变革力的新形象出现于商务关系领域。

1.2 国内外研究概况

在当前这个飞速发展的时代,无论是国内还是国外,发展都是突飞猛进的,经济形势也是一片明朗。在这种背景下,互联网的这一块的市场成为了各个国家想要争夺的香饽饽。于是无论是国内还是国外一些公司把目光投向了互联网这块市场,越来越多的人对互联网有所了解,具备了一些网络意识。在这种互联网大浪潮的不断冲刷下,各种各样的系统被开发出来。计算机技术无论是在国内还是国外中应用普遍,使计算机这一新型工具成为人们耳熟能详、妇孺皆知的新技术。计算机和互联网的广泛应用,让国内外的距离变“近”了,这个庞大的地球家园一下变成了地球村。国内国外的互联网发展也存在一些差距,我国近些年的互联网发展迅速,跻身于世界前列。

本系统使用java技术,B/S架构和MySQL数据库进行开发。该系统的开发方式无论在国内还是国外都比较常见,而且开发完成后使用普遍,可以给用户提供大量的便利[3]。该系统在国内外前景较为良好。

1.3 研究的内容

目前很多人仍把传统的纸质工具,如记录本、文档、文件夹等视为信息处理的主要工具,对大多数人而言,选择记录和获取信息的第一选择永远是纸质工具,而互联网上的信息和数据对人们而言相对抽象遥远。这些纸质工具存在一些优点,但在当下这个互联网飞速发展的社会,纸质工具的缺点也被逐渐放大,如记录数据内容有限、操作不方便、数据重读性低、容易丢失以及浪费资源等。虽然也有很多人在互联网上冲浪来获取信息,但网络这一块的理解也是很有局限的。当下流行的WPS、Word等办公软件成为了人们耳熟能详的系统,但一些更加专业性、性能更加强大的网络信息工具被人们“埋没”在互联网的大海中。因此本文主要论述了系统开发的过程和实现的功能,结合Web技术来实现的健美操评分系统。本系统以软件工程理论为开发基础,以专业的计算机编程语言来开发并实现系统的功能。

该选题原则上力求采用标签模块分类等方法,来完成注册、健美操评分信息管理和用户的交流连接、管理员对页面的设置和对后台数据库中数据的增删查改等一系列的操作和运行等。在这一系列模块分类的功能下,完成对健美操评分信息的高效执行和规范管理。


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("/hanfuOrder")
public class HanfuOrderController {
    private static final Logger logger = LoggerFactory.getLogger(HanfuOrderController.class);

    private static final String TABLE_NAME = "hanfuOrder";

    @Autowired
    private HanfuOrderService hanfuOrderService;


    @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 YonghuService yonghuService;//用户
    @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 = hanfuOrderService.queryPage(params);

        //字典表数据转换
        List<HanfuOrderView> list =(List<HanfuOrderView>)page.getList();
        for(HanfuOrderView 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);
        HanfuOrderEntity hanfuOrder = hanfuOrderService.selectById(id);
        if(hanfuOrder !=null){
            //entity转view
            HanfuOrderView view = new HanfuOrderView();
            BeanUtils.copyProperties( hanfuOrder , view );//把实体数据重构到view中
            //级联表 汉服信息
            //级联表
            HanfuEntity hanfu = hanfuService.selectById(hanfuOrder.getHanfuId());
            if(hanfu != null){
            BeanUtils.copyProperties( hanfu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
            view.setHanfuId(hanfu.getId());
            }
            //级联表 用户
            //级联表
            YonghuEntity yonghu = yonghuService.selectById(hanfuOrder.getYonghuId());
            if(yonghu != null){
            BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
            view.setYonghuId(yonghu.getId());
            }
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody HanfuOrderEntity hanfuOrder, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,hanfuOrder:{}",this.getClass().getName(),hanfuOrder.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永远不会进入");
        else if("用户".equals(role))
            hanfuOrder.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));

        hanfuOrder.setCreateTime(new Date());
        hanfuOrder.setInsertTime(new Date());
        hanfuOrderService.insert(hanfuOrder);

        return R.ok();
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody HanfuOrderEntity hanfuOrder, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        logger.debug("update方法:,,Controller:{},,hanfuOrder:{}",this.getClass().getName(),hanfuOrder.toString());
        HanfuOrderEntity oldHanfuOrderEntity = hanfuOrderService.selectById(hanfuOrder.getId());//查询原先数据

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");
//        else if("用户".equals(role))
//            hanfuOrder.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));

            hanfuOrderService.updateById(hanfuOrder);//根据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<HanfuOrderEntity> oldHanfuOrderList =hanfuOrderService.selectBatchIds(Arrays.asList(ids));//要删除的数据
        hanfuOrderService.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<HanfuOrderEntity> hanfuOrderList = 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){
                            //循环
                            HanfuOrderEntity hanfuOrderEntity = new HanfuOrderEntity();
//                            hanfuOrderEntity.setHanfuOrderUuidNumber(data.get(0));                    //订单编号 要改的
//                            hanfuOrderEntity.setHanfuId(Integer.valueOf(data.get(0)));   //汉服 要改的
//                            hanfuOrderEntity.setYonghuId(Integer.valueOf(data.get(0)));   //用户 要改的
//                            hanfuOrderEntity.setHanfuOrderTruePrice(data.get(0));                    //实付价格 要改的
//                            hanfuOrderEntity.setHanfuOrderTypes(Integer.valueOf(data.get(0)));   //订单类型 要改的
//                            hanfuOrderEntity.setInsertTime(date);//时间
//                            hanfuOrderEntity.setCreateTime(date);//时间
                            hanfuOrderList.add(hanfuOrderEntity);


                            //把要查询是否重复的字段放入map中
                                //订单编号
                                if(seachFields.containsKey("hanfuOrderUuidNumber")){
                                    List<String> hanfuOrderUuidNumber = seachFields.get("hanfuOrderUuidNumber");
                                    hanfuOrderUuidNumber.add(data.get(0));//要改的
                                }else{
                                    List<String> hanfuOrderUuidNumber = new ArrayList<>();
                                    hanfuOrderUuidNumber.add(data.get(0));//要改的
                                    seachFields.put("hanfuOrderUuidNumber",hanfuOrderUuidNumber);
                                }
                        }

                        //查询是否重复
                         //订单编号
                        List<HanfuOrderEntity> hanfuOrderEntities_hanfuOrderUuidNumber = hanfuOrderService.selectList(new EntityWrapper<HanfuOrderEntity>().in("hanfu_order_uuid_number", seachFields.get("hanfuOrderUuidNumber")));
                        if(hanfuOrderEntities_hanfuOrderUuidNumber.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(HanfuOrderEntity s:hanfuOrderEntities_hanfuOrderUuidNumber){
                                repeatFields.add(s.getHanfuOrderUuidNumber());
                            }
                            return R.error(511,"数据库的该表中的 [订单编号] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                        hanfuOrderService.insertBatch(hanfuOrderList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            return R.error(511,"批量插入数据异常,请联系管理员");
        }
    }




    /**
    * 前端列表
    */
    @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 = hanfuOrderService.queryPage(params);

        //字典表数据转换
        List<HanfuOrderView> list =(List<HanfuOrderView>)page.getList();
        for(HanfuOrderView 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);
        HanfuOrderEntity hanfuOrder = hanfuOrderService.selectById(id);
            if(hanfuOrder !=null){


                //entity转view
                HanfuOrderView view = new HanfuOrderView();
                BeanUtils.copyProperties( hanfuOrder , view );//把实体数据重构到view中

                //级联表
                    HanfuEntity hanfu = hanfuService.selectById(hanfuOrder.getHanfuId());
                if(hanfu != null){
                    BeanUtils.copyProperties( hanfu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setHanfuId(hanfu.getId());
                }
                //级联表
                    YonghuEntity yonghu = yonghuService.selectById(hanfuOrder.getYonghuId());
                if(yonghu != null){
                    BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setYonghuId(yonghu.getId());
                }
                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view, request);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody HanfuOrderEntity hanfuOrder, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,hanfuOrder:{}",this.getClass().getName(),hanfuOrder.toString());
            HanfuEntity hanfuEntity = hanfuService.selectById(hanfuOrder.getHanfuId());
            if(hanfuEntity == null){
                return R.error(511,"查不到该汉服信息");
            }
            // Double hanfuNewMoney = hanfuEntity.getHanfuNewMoney();

            if(false){
            }
            else if(hanfuEntity.getHanfuNewMoney() == null){
                return R.error(511,"费用不能为空");
            }

            //计算所获得积分
            Double buyJifen =0.0;
            Integer userId = (Integer) request.getSession().getAttribute("userId");
            YonghuEntity yonghuEntity = yonghuService.selectById(userId);
            if(yonghuEntity == null)
                return R.error(511,"用户不能为空");
            if(yonghuEntity.getNewMoney() == null)
                return R.error(511,"用户金额不能为空");
            double balance = yonghuEntity.getNewMoney() - hanfuEntity.getHanfuNewMoney()*1-hanfuEntity.getHanfuOldMoney();//余额
            if(balance<0)
                return R.error(511,"余额不够支付");
            hanfuOrder.setHanfuOrderTypes(101); //设置订单状态为已支付
            hanfuOrder.setHanfuOrderTruePrice(hanfuEntity.getHanfuNewMoney()*1+hanfuEntity.getHanfuOldMoney()); //设置实付价格
            hanfuOrder.setYonghuId(userId); //设置订单支付人id
            hanfuOrder.setHanfuOrderUuidNumber(String.valueOf(new Date().getTime()));
            hanfuOrder.setInsertTime(new Date());
            hanfuOrder.setCreateTime(new Date());
                hanfuOrderService.insert(hanfuOrder);//新增订单
            //更新第一注册表
            yonghuEntity.setNewMoney(balance);//设置金额
            yonghuService.updateById(yonghuEntity);


            return R.ok();
    }


    /**
    * 拒绝
    */
    @RequestMapping("/refund")
    public R refund(Integer id, HttpServletRequest request){
        logger.debug("refund方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        String role = String.valueOf(request.getSession().getAttribute("role"));

            HanfuOrderEntity hanfuOrder = hanfuOrderService.selectById(id);//当前表service
            Integer hanfuId = hanfuOrder.getHanfuId();
            if(hanfuId == null)
                return R.error(511,"查不到该汉服信息");
            HanfuEntity hanfuEntity = hanfuService.selectById(hanfuId);
            if(hanfuEntity == null)
                return R.error(511,"查不到该汉服信息");
            Double hanfuNewMoney = hanfuEntity.getHanfuNewMoney();
            if(hanfuNewMoney == null)
                return R.error(511,"汉服信息价格不能为空");

            Integer userId = (Integer) request.getSession().getAttribute("userId");
            YonghuEntity yonghuEntity = yonghuService.selectById(userId);
            if(yonghuEntity == null)
                return R.error(511,"用户不能为空");
            if(yonghuEntity.getNewMoney() == null)
            return R.error(511,"用户金额不能为空");
            Double zhekou = 1.0;

                //计算金额
                Double money = hanfuEntity.getHanfuNewMoney() +  hanfuEntity.getHanfuOldMoney();
                //计算所获得积分
                Double buyJifen = 0.0;
                yonghuEntity.setNewMoney(yonghuEntity.getNewMoney() + money); //设置金额




            hanfuOrder.setHanfuOrderTypes(102);//设置订单状态为已拒绝
            hanfuOrderService.updateAllColumnById(hanfuOrder);//根据id更新
            yonghuService.updateById(yonghuEntity);//更新用户信息
            hanfuService.updateById(hanfuEntity);//更新订单中汉服信息的信息

            return R.ok();
    }

    /**
    * 评价
    */
    @RequestMapping("/commentback")
    public R commentback(Integer id, String commentbackText, Integer hanfuCommentbackPingfenNumber, HttpServletRequest request){
        logger.debug("commentback方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
            HanfuOrderEntity hanfuOrder = hanfuOrderService.selectById(id);
        if(hanfuOrder == null)
            return R.error(511,"查不到该订单");
        Integer hanfuId = hanfuOrder.getHanfuId();
        if(hanfuId == null)
            return R.error(511,"查不到该汉服信息");

        HanfuCommentbackEntity hanfuCommentbackEntity = new HanfuCommentbackEntity();
            hanfuCommentbackEntity.setId(id);
            hanfuCommentbackEntity.setHanfuId(hanfuId);
            hanfuCommentbackEntity.setYonghuId((Integer) request.getSession().getAttribute("userId"));
            hanfuCommentbackEntity.setHanfuCommentbackText(commentbackText);
            hanfuCommentbackEntity.setInsertTime(new Date());
            hanfuCommentbackEntity.setReplyText(null);
            hanfuCommentbackEntity.setUpdateTime(null);
            hanfuCommentbackEntity.setCreateTime(new Date());
            hanfuCommentbackService.insert(hanfuCommentbackEntity);

            hanfuOrder.setHanfuOrderTypes(105);//设置订单状态为已评价
            hanfuOrderService.updateById(hanfuOrder);//根据id更新
            return R.ok();
    }

    /**
     * 同意
     */
    @RequestMapping("/deliver")
    public R deliver(Integer id  , HttpServletRequest request){
        logger.debug("refund:,,Controller:{},,ids:{}",this.getClass().getName(),id.toString());
        HanfuOrderEntity  hanfuOrderEntity = hanfuOrderService.selectById(id);
        hanfuOrderEntity.setHanfuOrderTypes(103);//设置订单状态为已同意
        hanfuOrderService.updateById( hanfuOrderEntity);

        return R.ok();
    }


    /**
     * 归还
     */
    @RequestMapping("/receiving")
    public R receiving(Integer id , HttpServletRequest request){
        logger.debug("refund:,,Controller:{},,ids:{}",this.getClass().getName(),id.toString());
        HanfuOrderEntity  hanfuOrderEntity = hanfuOrderService.selectById(id);
        hanfuOrderEntity.setHanfuOrderTypes(104);//设置订单状态为归还
        hanfuOrderService.updateById( hanfuOrderEntity);
        return R.ok();
    }


    /**
     * 退还押金
     */
    @RequestMapping("/tuihuan")
    public R tuihuan(Integer id  , HttpServletRequest request){
        logger.debug("refund:,,Controller:{},,ids:{}",this.getClass().getName(),id.toString());
        HanfuOrderEntity  hanfuOrderEntity = hanfuOrderService.selectById(id);
        HanfuEntity hanfuEntity = hanfuService.selectById(hanfuOrderEntity.getHanfuId());
        YonghuEntity yonghuEntity = yonghuService.selectById(hanfuOrderEntity.getYonghuId());
        Double hanfuOldMoney = hanfuEntity.getHanfuOldMoney();
        yonghuEntity.setNewMoney(yonghuEntity.getNewMoney()+hanfuOldMoney);
        hanfuOrderEntity.setHanfuOrderTypes(106);//设置订单状态为已同意
        yonghuService.updateById(yonghuEntity);
        hanfuOrderService.updateById( hanfuOrderEntity);

        return R.ok();
    }

}

 


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,"账户或者用户手机号或者用户身份证号已经被使用");
        }
    }

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值