云悦智销项目11_技术点补充

一.Easycoder

它是idea的一个插件,主要是完成代码生成器
如果你要使用它,必需要会: velocity
velocity是java的模板引擎技术
它和我们学的freemarker是几乎一样的
https://gitee.com/hbyufan/EasyCode

1.1 velocity

它是一个模板技术
2019-11-12-wisdomsell-day4-查漏补缺/resources/velocity入门教程.pdf

1.2 原生velocity的基本用法

操作之前都得先导包

1.2.1 准备

/**
     * freemaker后缀默认是:ftl
     * Velocity后缀默认是:vm
     * @throws Exception
     */
    //模板技术  模板+数据=新的文本
    @Test
    public void testHello() throws Exception{
        //创建一个模板引擎
        VelocityEngine ve = new VelocityEngine();
        //根据引擎获取模板
        Template template = ve.getTemplate("template/hello.vm","UTF-8");
        //准备模板上下文
        VelocityContext velocityContext = new VelocityContext();
        velocityContext.put("txt", "hello, world!中国");
        //加上数据
        Employee employee = new Employee();
        employee.setUsername("小红帽");
        employee.setAge(34);
        velocityContext.put("employee",employee);

        FileWriter fw = new FileWriter("template/hello.html");
        template.merge(velocityContext, fw);
        fw.close();

    }
    

1.2.2 使用语法(模板代码)

$!{txt}waho

${employee.username} = ${employee.age}

加一个!的作用是没有值就不显示

$!txtwaho

set就是定义变量

#set($person = "Tom")
$person

#set($age = 89)

#if($age < 18)
    18不到,有前途
#elseif($age >=18 && $age<80)
    你已经燃烧得差不多了
#else
    <p></p>
#end

var list =[]

#set($list = [“a”, “b”, “c”])

  • #foreach($l in $list)
  • $l
  • #end

1.3 EasyCode

安装EasyCode

image

关系数据库

image

image

image

image

代码部分

domain搞定
##引入宏定义
$!define

##使用宏定义设置回调(保存位置与文件后缀)
#save("/domain", ".java")

##使用宏定义设置包后缀
#setPackageSuffix("domain")

##使用全局变量实现默认包导入
$!autoImport
import javax.persistence.Entity;
import javax.persistence.Table;

##使用宏定义实现类注释信息
#tableComment("实体类")
@Entity
@Table(name = "$!{tableInfo.obj.name}")
public class $!{tableInfo.name} extends BaseDomain  {

#foreach($column in $tableInfo.fullColumn)
    #if(${column.comment})/**
    * ${column.comment}
    */#end

    private $!{tool.getClsNameByFullName($column.type)} $!{column.name};
#end

#foreach($column in $tableInfo.fullColumn)
##使用宏定义实现get,set方法
    #getSetMethod($column)
#end

}
repository
##定义初始变量
#set($tableName = $tool.append($tableInfo.name, "Repository"))
##设置回调
$!callback.setFileName($tool.append($tableName, ".java"))

路径

$!callback.setSavePath($tool.append($tableInfo.savePath, "/repository"))

##拿到主键
#if(!$tableInfo.pkColumn.isEmpty())
    #set($pk = $tableInfo.pkColumn.get(0))
#end

#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}repository;

import $!{tableInfo.savePackageName}.domain.$!{tableInfo.name};


/**
 * $!{tableInfo.comment}($!{tableInfo.name})表数据库访问层
 *
 * @author $!author
 * @since $!time.currTime()
 */
public interface $!{tableName}  extends BaseRepository<$!{tableInfo.name},Long> {

}

二.报表

[forms for reporting to the higher organizations] 向上级报告情况的表格。简单的说:报表就是用表格、图表等格式来动态显示数据,可以用公式表示为:“报表 = 多样的格式 + 动态的数据”。
表格(详细),图表(直观)
image

2.1 图表怎么做?

技术角度:flash(ActionScript),h5
框架部分:各种chart(EChart,Highchart)
EChart:百度(开源免费,功能强大)
HighCharts(收费,功能强大,兼容IE)
2.2 Highcharts怎么用?

https://www.highcharts.com.cn/
下载highcharts
官网例子都有

<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/11/21
  Time: 14:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <link rel="icon" href="https://jscdn.com.cn/highcharts/images/favicon.ico">
    <%--视口,做响应式--%>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        /* css 代码  */
    </style>
    <script src="/js/highcharts/code/highcharts.js"></script>
    <script src="/js/highcharts/code/highcharts-3d.js"></script>
    <script src="/js/highcharts/code/modules/exporting.js"></script>
</head>
<body>
<%--放图表的地方--%>
<div id="container" style="height: 400px"></div>
<script>
    // JS 代码
    var chart = Highcharts.chart('container', {
        chart: {
            type: 'pie',
            options3d: {
                enabled: true,
                alpha: 45,
                beta: 0
            }
        },
        title: {
            text: '2014年某网站不同浏览器访问量占比'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                depth: 35,
                dataLabels: {
                    enabled: true,
                    format: '{point.name}'
                }
            }
        },
        series: [{
            type: 'pie',
            name: '浏览器占比',
            //从数据库中拿到数据然后放到这里来
            data: [
                ['Firefox',   45.0],
                ['IE',       26.8],
                {
                    name: 'Chrome',
                    y: 12.8,
                    sliced: true,
                    selected: true
                },
                ['Safari',    8.5],
                ['Opera',     6.2],
                ['Others',   0.7]
            ]
        }]
    });
</script>
</body>
</html>

三.任务调度

3.1 Java原生的定时器

//每过一秒钟执行一次
@Test
public void test02() throws Exception{
    //专用于做定时任务的类
    Timer timer = new Timer();
    /*
        参数一:任务(代码就在run中执行)
        参数二(delay):延时
        参数三(period):周期
     */
    timer.schedule(new TimerTask() {
        @Override
        public void run() {
            System.out.println(new Date().toLocaleString());
        }
    },0,1000);
    //防止主线程消失(以后tomcat运行不需要这个)
    Thread.sleep(10000); 
}

3.2 quartz框架

3.2.1 导包(已经引入)

<!-- 定时调度 -->
<dependency>
  <groupId>quartz</groupId>
  <artifactId>quartz</artifactId>
  <version>1.5.2</version>
</dependency>

3.2.2 xml配置

:需要先引用
cron表达式(网络与生成器) http://cron.qqe2.com/
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:task="http://www.springframework.org/schema/task"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
				http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
				http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
				http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <!-- cron表达式:在每天早上8点到晚上8点期间每1分钟触发一次 -->
    <!--value>0 0/1 8-20 * * ?</value-->
    <!-- cron表达式:5分钟触发一次 -->
    <!-- <value>0 0/5 * * * ?</value> -->
    <task:scheduled-tasks>
        <!-- 执行quartzJob里面的initDb方法,执行频率是cron表达式 -->
        <task:scheduled ref="createTable" method="create" cron="0/1 * * * * ?" />
    </task:scheduled-tasks>
</beans>

四.邮件发送

注:你得保证邮件是开启smtp协议的
image

4.1 导包

<!-- 邮件支持 -->
<dependency>
  <groupId>javax.mail</groupId>
  <artifactId>mail</artifactId>
  <version>1.4.1</version>
</dependency>

4.2 xml配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
				http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
				http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

	<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
		<!-- 163邮箱,smtp.163.com -->
		<!--smtp发邮件协议,简单邮件传输协议(Simple Message Transfer Protocol)-->
		<!--pop3收邮件协议,邮局通讯协定第三版(Post Office Protocol 3-->
		<!-- admin@163.com 用户名:admin 密码:xxx -->
		<!-- 4567899@qq.com 用户名: 4567899 密码:0000000qq邮箱独立密码,是否开启smtp -->
		<property name="host" value="smtp.qq.com" />
		<property name="username" value="43543534@qq.com" />
		<property name="password" value="xxxxxxx" /> 
		<property name="javaMailProperties">
			<props>
				<!-- 必须进行授权认证,它的目的就是阻止他人任意乱发邮件 -->
				<prop key="mail.smtp.auth">true</prop>
				<!-- SMTP加密方式:连接到一个TLS保护连接 -->
				<prop key="mail.smtp.starttls.enable">true</prop>
			</props>
		</property>
	</bean>

</beans>

4.2 bean实现

 @Autowired
MailSender mailSender;

public void testName() throws Exception {
//JavaMailSenderImpl xxx = (JavaMailSenderImpl)mailSender
    // 简单邮件对象
    SimpleMailMessage msg = new SimpleMailMessage();
    // 发送人:和配置一致
    msg.setFrom("43543534@qq.com");
    // 收件人
    msg.setTo("xiaohongmao@qq.com");
    // 主题
    msg.setSubject("牛皮大学录取通知书");
    // 内容
    msg.setText("你已经被录取了");
    // 设置固定回邮地址
    msg.setReplyTo("xxxx@xxx.com");
    // 发送
    mailSender.send(msg);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值