澳门美高梅手机网站手机验证码的系知识

之前一直为此到的种类是Spring
MVC+maven+mysql的,最近多少数据要运用mongoDB数据库,现在举行片总结。

1.欠信平台:
短信群发平台是基于中国移动、联通、电信直接提供的紧缺信端口和互联网连接实现和客户指定编号进行短信批量发送和从定义发送的,
它分成软件单机版(带客户端)CS 结构与网络共享版BS 结构。

 

提少信服务为其安全可靠、速度快、价格低廉、使用方便,按需付费等好,超值营销效益回报和上的服务得了大企业之信任,
日益成广中小企业进行短信营销、短信群发、短信促销等必要工具新宠。)有很多号供这么的服务,简单的做法即是,类似于激活码,发之上记录在数据库中,验证成功的下置空

第二步:配置

据悉发送量的大小选择当的短缺信接口:
一旦发送量比较异常,则需跟中国移动或者联通等报道运营商合作,他们见面让你从头一个端口,通过者端口可以和任何的主次相结合发送;
倘若发送量很有些,那么你可经过GSM/GPRS
Modem和处理器连,里边插入一摆SIM卡,相关支出包在Modem配的软件里可找到,通过开包吃的程序接口,也得同其它的诸如ASP,PHP,JSP,.Net等先后成。当然,这种措施是遵照您的SIM卡发送的紧缺信量收费的。

3、mongoDB存储过程:

2.云短信:
和传统短信平台还是短信群发软件比,云短信平台有在线自助、简单注册、按需付费、用则买进、价格低廉,免安装、免维护,免费应用
还是以月度租付费,支持单点或多接触登录,具有开放性等作用,能够无缝链接OA、ERP、网站等工作系统,实现对网络服务资源集合管理与调度,
向阳公司供按需采取、随需扩展的通信服务。

 

asp实现手机验证码:
预先输入手机号码,然后通过任意数生成验证码,通过短信接口,发送给已经输入的手机号码。
验证码的保留有点儿种艺术:
1.保设有session或者cookie中,随着session或者cookie的失效而失去效.
2.管验证码和验证码失效时同步囤到数据库中,在点击确认的时,再作证输入是否对(比较常用之办法).

Interview.java

老三步、MongoDB的增删改查

mongodb.database=cxstatistics
mongodb.replicaSet = 10.0.11.28:27017,10.0.11.29:27017,10.0.11.30:27017

1、Mongodb对象模型

<mongo:mongo id="mongo" host="${mongo.host}" port="${mongo.port}" >
        <mongo:options connections-per-host="${mongo.connectionsPerHost}" 
            threads-allowed-to-block-for-connection-multiplier="${mongo.threadsAllowedToBlockForConnectionMultiplier}" 
            connect-timeout="${mongo.connectTimeout}" max-wait-time="${mongo.maxWaitTime}" 
            auto-connect-retry="${mongo.autoConnectRetry}" socket-keep-alive="${mongo.socketKeepAlive}" 
            socket-timeout="${mongo.socketTimeout}" slave-ok="${mongo.slaveOk}" write-number="1" 
            write-timeout="0" write-fsync="true"/> 
    </mongo:mongo>

 

第一步:加载jar、maven配置

1、集群配置

applicationContext.xml

布局文件common-config.properties

@Document(collection="pagelog")
public class Interview implements Serializable {



    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Id
    private String id;

    private String time;
    private String desc;
    private long _createtime;
    private Integer _processed;
    private long fid;
    private String templateType;
    private long puid;

    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getTime() {
        return time;
    }
    public void setTime(String time) {
        this.time = time;
    }
    public String getDesc() {
        return desc;
    }
    public void setDesc(String desc) {
        this.desc = desc;
    }
    public long get_createtime() {
        return _createtime;
    }
    public void set_createtime(long _createtime) {
        this._createtime = _createtime;
    }
    public Integer get_processed() {
        return _processed;
    }
    public void set_processed(Integer _processed) {
        this._processed = _processed;
    }
    public long getFid() {
        return fid;
    }
    public void setFid(long fid) {
        this.fid = fid;
    }
    public String getTemplateType() {
        return templateType;
    }
    public void setTemplateType(String templateType) {
        this.templateType = templateType;
    }
    public long getPuid() {
        return puid;
    }
    public void setPuid(long puid) {
        this.puid = puid;
    }




}

applicationContext.xml

/**
     * 得到时间区间内的统计数据
     * @param beginDate
     * @param endDate
     * @return
     */
    public long getInterviewNum(String beginDate, String endDate);



/**
     * 得到时间区间内根据fid排序的统计数据list
     * @param beginDate
     * @return
     */
    public List<Pagecount> getPageGroup(String beginDate);
mongo.dbname = test_db #数据库名称
mongo.password = test_pwd #密码
mongo.username = test_user #用户名
mongo.host = 127.0.0.1 #主机
mongo.port= 27017 #端口号
mongo.connectionsPerHost= 8 #一个线程变为可用的最大阻塞数
mongo.threadsAllowedToBlockForConnectionMultiplier= 4 #线程队列数,它以上面connectionsPerHost值相乘的结果就是线程队列最大值
mongo.connectTimeout= 1500 #连接超时时间(毫秒)
mongo.maxWaitTime= 1500 #最大等待时间
mongo.autoConnectRetry= true #自动重连
mongo.socketKeepAlive= true #scoket保持活动
mongo.socketTimeout=1500 #scoket超时时间
mongo.slaveOk=true #读写分离
@Document(collection="countlog")
public class Pagecount implements Serializable{

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Id
    private String id;

    private String time;
    //private long  fid;
    List<Integer> fid = new ArrayList<Integer>();
    //private Integer pagenum;
    List<Integer> pagenum = new ArrayList<Integer>();

    public String getTime() {
        return time;
    }
    public void setTime(String time) {
        this.time = time;
    }
    public List<Integer> getFid() {
        return fid;
    }
    public void setFid(List<Integer> fid) {
        this.fid = fid;
    }
    public List<Integer> getPagenum() {
        return pagenum;
    }
    public void setPagenum(List<Integer> pagenum) {
        this.pagenum = pagenum;
    }


}

接口:

@Path("")
public class InterviewController {

    @Autowired
    StatisticsService statisticsService;


    @Post("/interview")
    @Get("/interview")
    @AdminLoginRequired
    public String index(Invocation inv) {
        Calendar c = Calendar.getInstance();   
        c.add(Calendar.MONTH, -1);
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");  
        String mDateTime=formatter.format(c.getTime());  
        inv.addModel("dateTime", new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
        inv.addModel("mDateTime", mDateTime);
        return "/views/statistics/interview.vm";
    }

    @Post("/getInterview")
    @Get("/getInterview")
    public String getInterview(Invocation inv,@Param("beginDate")String beginDate,@Param("endDate")String endDate){
        long Num = statisticsService.getInterviewNum(beginDate, endDate);
        inv.addModel("Num", Num);
        JSONObject json = new JSONObject();
        json.put("Num", Num);
        return "@"+json;
    }

    @Post("/interviewGroup")
    @Get("/interviewGroup")
    @AdminLoginRequired
    public String indexGroup(Invocation inv) {
        Calendar c = Calendar.getInstance();   
        c.add(Calendar.MONTH, -1);
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM");  
        String mDateTime=formatter.format(c.getTime()); 
        inv.addModel("mDateTime", mDateTime);
        return "/views/statistics/interviewGroup.vm";
    }

    @Post("/getPageGroup")
    @Get("/getPageGroup")
    public String getPageGroup(Invocation inv,@Param("beginDate")String beginDate){
         List<Pagecount> Pagecount = new ArrayList<Pagecount>();
         Pagecount = statisticsService.getPageGroup(beginDate);
         JSONObject json = new JSONObject();
         json.put("list", Pagecount);
         return "@"+json;
       }      
}

 

Pagecount.java

@Override
    @Path("getInterviewNum")
    @GET
    @Produces({"application/json; charset=UTF-8"})
    public long getInterviewNum(@QueryParam("beginDate")String beginDate, @QueryParam("endDate")String endDate) {
        long Num=mongo.count(new Query(Criteria.where("time").gt(beginDate).lte(endDate)), Interview.class);
        return Num;
    }

@Override
    @Path("getPageGroup")
    @GET
    @Produces({"application/json; charset=UTF-8"})
    public List<Pagecount> getPageGroup(@QueryParam("beginDate")String beginDate) {
        Criteria criatira= new Criteria();
        criatira.andOperator(Criteria.where("time").is(beginDate));
        List<Pagecount> pagecount = new ArrayList<Pagecount>();
        String year= beginDate.substring(0,4);
        String month=beginDate.substring(5);
        mongo.getDb().eval("pagelog("+year+","+month+")");
        //mongo.getDb().eval("pagelog("+beginDate+")", pagecount);
        pagecount= mongo.find(new Query(criatira).with(new Sort(new Order(Direction.DESC, "pagenum"))), Pagecount.class); 
        return pagecount;
    }  

布置文件common-config.properties

2、单机配置

2、查询示例代码

接口实现:

<!-- mongodb开始 -->
         <dependency>  
            <groupId>org.mongodb</groupId>  
            <artifactId>mongo-java-driver</artifactId>  
            <version>3.3.0</version>  
        </dependency> 
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-mongodb</artifactId>
            <version>1.7.1.RELEASE</version>
        </dependency>
        <!-- mongodb结束 -->

控制层:

<?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:jee="http://www.springframework.org/schema/jee"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mongo="http://www.springframework.org/schema/data/mongo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
        http://www.springframework.org/schema/jee
        http://www.springframework.org/schema/jee/spring-jee-4.1.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.1.xsd
        http://www.springframework.org/schema/schema/util
        http://www.springframework.org/schema/schema/util/spring-util-4.1.xsd
        http://www.springframework.org/schema/data/mongo
        http://www.springframework.org/schema/data/mongo/spring-mongo-1.5.xsd
        http://www.springframework.org/schema/data/repository
        http://www.springframework.org/schema/data/repository/spring-repository-1.5.xsd
        ">

   <mongo:mongo  id="mongo"  replica-set="${mongodb.replicaSet}" />
   <mongo:db-factory dbname="${mongodb.database}" mongo-ref="mongo"/> 

    <!-- mongo模板操作对象 -->
    <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
        <constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
    </bean>

</beans>
function(year,month){
var time=year+'-'+month;
if(month<10){
   time=year+'-0'+month;
 }
var num=[];
var fid=[];
db.getCollection('pagelog').aggregate([ { $match : {'time':{$regex: "^" + time + ".*$"}} },{$group : { _id : "$fid", num : {$sum : 1}}}]).forEach(function(obj){
            num.push(obj.num);
            fid.push(obj._id);
 })
document1=num;
document2=fid;
 db.countlog.update({'time':time},{$set:{'fid':document2,'pagenum':document1,'time':time}},true,true);
return time;
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注