• 大小: 35.44MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-06-30
  • 语言: Java
  • 标签: IDEA  JAVA  Spring  MVC  Hibernate  

资源简介

简单的一个购物商城demo哦。只适合学习使用; 使用IDEA编译器,Maven+mysql数据库Hibernate 注意:需要配置resources里面的database.properties数据库root和密码;

资源截图

代码片段和文件信息

package com.shopping.controller;

import com.alibaba.fastjson.JSONArray;
import com.shopping.entity.Evaluation;
import com.shopping.service.EvaluationService;
import com.shopping.service.ShoppingRecordService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by 14437 on 2017/3/7.
 */
@Controller
public class EvaluationController {
    @Resource
    private EvaluationService evaluationService;

    @Resource
    private ShoppingRecordService shoppingRecordService;

    @RequestMapping(value = “/addShoppingEvaluation“method = RequestMethod.POST)
    @ResponseBody
    public Mapject> addShoppingEvaluation(int userId int productId String content){
        System.out.println(“我添加了“+userId+“ “+productId);
        String result = null;
        if(shoppingRecordService.getUserProductRecord(userIdproductId)){
            Evaluation evaluation = new Evaluation();
            evaluation.setUserId(userId);
            evaluation.setProductId(productId);
            Date date = new Date();
            SimpleDateFormat sf = new SimpleDateFormat(“yyyy-MM-dd HH-mm-ss“);
            evaluation.setTime(sf.format(date));
            evaluation.setContent(content);
            evaluationService.addEvaluation(evaluation);
            result = “success“;
        }
        else{
            result=“noneRecord“;
        }

        Mapject> resultMap = new HashMapject>();
        resultMap.put(“result“result);
        return resultMap;
    }

    @RequestMapping(value = “/getShoppingEvaluations“method = RequestMethod.POST)
    @ResponseBody
    public Mapject> getShoppingEvaluations(int productId){
        List evaluationList = evaluationService.getProductEvaluation(productId);
        String evaluations = JSONArray.toJSONString(evaluationList);
        Mapject> resultMap = new HashMapject>();
        resultMap.put(“result“evaluations);
        return resultMap;
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1308  2018-12-09 10:39  Shopping-MVC\.classpath

     文件        249  2018-10-23 16:52  Shopping-MVC\.gitignore

     文件          8  2019-06-25 09:09  Shopping-MVC\.idea\.name

     文件        290  2019-06-25 09:10  Shopping-MVC\.idea\artifacts\shopping_war.xml

     文件       4707  2019-06-25 09:10  Shopping-MVC\.idea\artifacts\shopping_war_exploded.xml

     文件       1192  2019-06-25 09:10  Shopping-MVC\.idea\compiler.xml

     文件         76  2019-06-25 09:09  Shopping-MVC\.idea\copyright\profiles_settings.xml

     文件        256  2019-06-25 09:12  Shopping-MVC\.idea\encodings.xml

     文件        462  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__antlr_antlr_2_7_7.xml

     文件        605  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__commons_fileupload_commons_fileupload_1_3_2.xml

     文件        503  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__commons_io_commons_io_2_2.xml

     文件        558  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__commons_logging_commons_logging_1_2.xml

     文件        514  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__com_alibaba_fastjson_1_2_24.xml

     文件        644  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml

     文件        595  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_core_2_9_7.xml

     文件        623  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_databind_2_9_6.xml

     文件        525  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__com_sun_mail_javax_mail_1_5_0.xml

     文件        462  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__dom4j_dom4j_1_6_1.xml

     文件        527  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__javax_activation_activation_1_1.xml

     文件        483  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__javax_javaee_api_7_0.xml

     文件        510  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__javax_servlet_jsp_jsp_api_2_1.xml

     文件        537  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__javax_servlet_jsp_jstl_jstl_api_1_2.xml

     文件        522  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__javax_servlet_servlet_api_2_5.xml

     文件        462  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__junit_junit_3_8_1.xml

     文件        574  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__mysql_mysql_connector_java_5_1_38.xml

     文件        570  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__org_apache_commons_commons_dbcp2_2_1_1.xml

     文件        570  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__org_apache_commons_commons_pool2_2_4_2.xml

     文件        542  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__org_aspectj_aspectjweaver_1_8_9.xml

     文件        629  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__org_glassfish_web_javax_servlet_jsp_jstl_1_2_2.xml

     文件        732  2019-06-25 09:10  Shopping-MVC\.idea\libraries\Maven__org_hibernate_common_hibernate_commons_annotations_4_0_5_Final.xml

............此处省略369个文件信息

评论

共有 条评论