丽江文化旅游学院易腾创想Java实训第8组总结

本次实训,小组成员分工明确,主要进行Java环境配置及HelloWorld项目。项目包括配置Java环境、安装IDEA、设置Maven和MySQL。在学习过程中,成员们体会到团队合作的重要性,以及在面临就业压力时应如何提升自我。通过实训,对Java编程有了更深入的理解,认识到良好的指导和团队合作对于学习效率的提升至关重要。
摘要由CSDN通过智能技术生成

小组成员分工

zhanghanmu:主要完成源码编写
zhaoxue :主要完成软件的环境配置,可以运行helloworld等,认真听课
wangchenyue:主要完成软件的环境配置,可以运行helloworld等,认真听课
fengqilu:主要完成软件的环境配置,可以运行helloworld等,认真听课
zhaozhehan: 主要完成软件的环境配置,可以运行helloworld等,认真听课
jinjiajun:主要完成软件的环境配置,可以运行helloworld等,认真听课

项目介绍

请在此处描述项目的主要功能、核代码、代码截图、运行效果截图在这里插入代码片在这里插入代码片`
1.首先配置好java环境
java -version
2.安装好IDEA
在这里插入图片描述3.创建helloworld包
看是否能正常运行
4.安装maven,并解决maven导包问题
在这里插入图片描述5.安装完成MySQL
在这里插入图片描述等一些环境的配置。

package com.cn.panda.config;

public class Constants {
   
    public static  String ok = "ok";
    public static  String ERROR = "ERROR";
}

package com.cn.panda.controller;

import com.cn.panda.entity.Attraction;
import com.cn.panda.entity.Order;
import com.cn.panda.entity.User;
import com.cn.panda.service.AttractionService;
import com.cn.panda.service.CollectService;
import com.cn.panda.service.OrderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/attraction")
public class AttractionController {
   
    @Autowired
    private AttractionService attractionService;
    @Autowired
    private CollectService collectService;
    @Autowired
    private OrderService orderService;

    @RequestMapping("/list")
    public String getAttractions(HttpServletRequest request, @RequestParam(required = true, name = "page", defaultValue = "1") Integer page) {
   
        PageHelper.startPage(page, 8);
        List<Attraction> attractions = attractionService.getAttractions();
        PageInfo<Attraction> pageInfo = new PageInfo<>(attractions, 5);
        request.setAttribute("pageInfo", pageInfo);
        System.out.println("当前页:" + pageInfo.getPageNum());
        System.out.println("总页码:" + pageInfo.getPages());
        System.out.println("总条数:" + pageInfo.getPageSize());
        System.out.println("每页显示的条数:" + pageInfo.getPageSize());
        List<Attraction> list = pageInfo.getList();
        for (int i = 0; i < list.size(); i++) {
   
            Attraction attraction = list.get(i);
            System.out.println(attraction);
        }
        return "front/attraction";
        @RequestMapping("/{id}")
        public String getAttractionById(@PathVariable(name = "id") int id, HttpServletRequest request){
   
            Attraction attraction = attractionsService.getAttractionById(id);
            request.setAttribute("attraction", attraction);
            User user = (User) request.getSession().getAttribute("user");
            if (user != null) {
   
                int userID = user.getId();
                boolean isCollect = collectService.isCollect(userID, Type.attraction, id);
                request.setAttribute("isCollect", isCollect);
                Order order = orderService.getOrderByTypeAndIDs(UserId, Type.attraction, id);
                if (order != null) {
   
                    String pattern = "yyyy-MM-dd";
                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
                    Date createTimeDate = order.getOrderTime();
                    String createTimeString = simpleDateFormat(createTimeDate);
                    Date todayTimeDate = new Date();
                    String todayTimeString = simpleDateFormat.format(todayTimeDate);
                    if (createTimeString.equals(todayTimeString)) {
   
                        request.setAttribute("isOrder", true);
                    } else {
   
                        request.setAttribute("isOrder", false);
                    }
                } else {
   
                    request.setAttribute("idOrder", false);
                }
            } else {
   
                request.setAttribute("isOrder", false);
            }
            return "front/attraction_datail";
        }
    }

}

package com.cn.panda.controller;

import com.cn.panda.entity.Collect;
import com.cn.panda.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/collect")
public class CollectController {
   
    @Autowired
    private CollectService collectService;
    @PostMapping("/on")
    public String on(Collect collect, @RequestParam(name="from",required = true)String from, HttpSession session){
   
        boolean on = collectService.saveCollect(collect);
        if (on){
   
            session.setAttribute("message","收藏成功");
        }else {
   
            session.setAttribute("message","收藏失败");
        }
        return "redirect:" + from;
    }
    @PostMapping("off")
    public String off(Collect collect, @RequestParam(name="from",required = true)String from, HttpSession session){
   
        boolean off = collectService.saveCollect(collect);
        if (off){
   
         
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值