Spring boot 访问HTML页面 代码 不带解释的

7 篇文章 0 订阅
4 篇文章 0 订阅

application.properties 配置文件

#prot
server.port=8088
#server.port=7776
#view
spring.mvc.view.prefix=/templates/
spring.mvc.view.suffix=.html

#html
spring.thymeleaf.content-type=text/html
spring.thymeleaf.mode =LEGACYHTML5
spring.thymeleaf.cache=false

#TEST
#spring.datasource.url=jdbc:mysql://192.168.0.109:3333/xxxxx?useUnicode=true&characterEncoding=utf8&useSSL=false
#spring.datasource.username=xxxxx
#spring.datasource.password=xxxxx


#TEST
#spring.datasource.url=jdbc:mysql://xxxxxx:3306/xxxxx?useUnicode=true&characterEncoding=utf8&useSSL=false
#spring.datasource.username=xxxxx
#spring.datasource.password=xxxx

#SITE
spring.datasource.url=jdbc:mysql://xxxxxx:3333/xxxx?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.username=xxxx
spring.datasource.password=xxxxx


spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

spring.datasource.initialSize=5
spring.datasource.minIdle=5
spring.datasource.maxActive=20
spring.datasource.maxWait=60000
spring.datasource.timeBetweenEvictionRunsMillis=60000
spring.datasource.minEvictableIdleTimeMillis=300000
spring.datasource.validationQuery=SELECT 1 FROM DUAL
spring.datasource.testWhileIdle=true
spring.datasource.testOnBorrow=false
spring.datasource.testOnReturn=false
spring.datasource.continue-on-error=true
spring.datasource.poolPreparedStatements=true
spring.datasource.maxPoolPreparedStatementPerConnectionSize=20
spring.datasource.filters=stat,wall,log4j
spring.datasource.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000\u3001

spring.http.multipart.enabled=true
spring.http.multipart.maxFileSize = 10Mb
spring.http.multipart.maxRequestSize=100Mb

#mybatis-plus setting
mybatis-plus.mapper-locations=classpath:/mapper/*Mapper.xml
mybatis-plus.typeAliasesPackage=com.pos.pos_conn.entity
mybatis-plus.global-config.db-column-underline=true
mybatis-plus.global-config.refresh-mapper=true
mybatis-plus.configuration.map-underscore-to-camel-case=true
mybatis-plus.configuration.cache-enabled=false

文件路径

 

Controller 编写

package com.pos.pos_conn.controller.a_console;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.pos.pos_conn.base.BaseController;
import com.pos.pos_conn.entity.QrCode;
import com.pos.pos_conn.entity.WOrder;
import com.pos.pos_conn.entity.WShopLocation;
import com.pos.pos_conn.service.IQrCodeService;
import com.pos.pos_conn.service.IWOrderService;
import com.pos.pos_conn.service.IWShopLocationService;
import com.pos.pos_conn.util.JsonParseUtil;
import com.pos.pos_conn.util.qrcode.ZXingCode;
import com.pos.pos_conn.util.response.Response;

/**
 * 主页控制器
 * 
 * @author dizhang
 *
 */
@Controller
public class PageController extends BaseController {

	@Autowired
	IQrCodeService qrCodeService;
	@Autowired
	IWOrderService orderService;
	@Autowired
	IWShopLocationService shopLocationService ;

	/**
	 * 判断用户是否登陆 登陆则进入index页面 没有则跳转 login页面
	 * 
	 * @param session
	 * @return
	 */
	@RequestMapping("/pageIndex")
	public String pageIndex(HttpSession session) {
		if (isLogin(session)) {
			return "index";
		} else {
			return "login";
		}
	}

	@RequestMapping("/")
	public String login(HttpSession session) {
		return "login";
	}

	/**
	 * 跳转图片分類管理页面
	 */
	@RequestMapping("/pictureManage")
	public String pictureManage(HttpSession session) {
		if (isLogin(session)) {
			return "picture_manage/pic_type";
		}
		return "login";

	}

	/**
	 * 跳转图片管理页面
	 */
	@RequestMapping("/pictureManageType")
	public String pictureManageType(HttpSession session) {
		if (isLogin(session)) {
			return "picture_manage/pic_type";
		}
		return "login";

	}

	@ResponseBody
	@GetMapping("/qrCode/{num}")
	public Response qrCode(@PathVariable("num") String num) {
		System.out.println(num);
		QrCode qrCode = qrCodeService.selectByNum(num);
		if (qrCode == null) {
			return renderError("沒有找到用戶信息");
		}
		WOrder order = orderService.selectById(qrCode.getOrderId());
		if (order.getsStatus()==1) {
			return renderError("沒有找到用戶信息");
		}
		WShopLocation shopLocation = shopLocationService.selectById(order.getShopLocationId());
		Map<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("location", shopLocation.getShopName());
		resultMap.put("orderSn", order.getOrderSnIbs());
		resultMap.put("qrCodeData", ZXingCode.getLogoQRCode(order.getOrderSnIbs(), null, ""));
		resultMap.put("count", qrCode.getCount());
		return renderSuccess(resultMap);

	}
	
	
	@ResponseBody
	@RequestMapping("/qrCodePhone")
	public Response qrCodePhone(@RequestParam("MESSAGE") String MESSAGE) {
		JSONObject paramJson = JsonParseUtil.parseRequestParam(MESSAGE);
		
		// 用户ID
		String  ordersn = paramJson.getString("ordersn");
		WOrder order = orderService.getOrderByOrderSn(ordersn);
		if (order == null) {
			return renderError("沒有找到用戶信息");
		}
		if(order.getType()!=1)
		{
			return renderError("该訂單不是門市取貨訂單 無法生成二維碼");
		}
		WShopLocation shopLocation = shopLocationService.selectById(order.getShopLocationId());
		Map<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("order", order);
		resultMap.put("shop",shopLocation);
		resultMap.put("qrCodeData", ZXingCode.getLogoQRCode(order.getOrderSnIbs(), null, ""));
		return renderSuccess(resultMap);
	}

}

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sou_time

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值