浏览代码

init from phab

xielq 4 年之前
父节点
当前提交
2e0ef838f2

+ 0 - 0
README.md


+ 103 - 0
pom.xml

@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<groupId>com.uas.ps</groupId>
+		<artifactId>ps-parent</artifactId>
+		<version>0.0.1-SNAPSHOT</version>
+	</parent>
+	<artifactId>ps-vote</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<packaging>jar</packaging>
+
+	<name>ps-vote</name>
+	<description>Spring Boot project for vote</description>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+		<java.version>1.8</java.version>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-web</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-configuration-processor</artifactId>
+			<optional>true</optional>
+		</dependency>
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+			<scope>runtime</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<!--jpa-->
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-data-jpa</artifactId>
+		</dependency>
+		<!--druid-->
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>druid</artifactId>
+		</dependency>
+		<!--fastjosn-->
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>fastjson</artifactId>
+		</dependency>
+		<!--ps-parent-->
+		<dependency>
+			<groupId>com.uas.ps</groupId>
+			<artifactId>ps-core</artifactId>
+		</dependency>
+	</dependencies>
+
+	<profiles>
+		<profile>
+			<!-- 开发环境 -->
+			<id>dev</id>
+			<activation>
+				<activeByDefault>true</activeByDefault>
+			</activation>
+			<properties>
+				<profile>dev</profile>
+			</properties>
+		</profile>
+		<profile>
+			<!-- 测试环境 -->
+			<id>test</id>
+			<properties>
+				<profile>test</profile>
+			</properties>
+		</profile>
+		<profile>
+			<!-- 生产环境 -->
+			<id>prod</id>
+			<properties>
+				<profile>prod</profile>
+			</properties>
+		</profile>
+	</profiles>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
+
+
+</project>

+ 14 - 0
src/main/java/com/uas/ps/vote/PsVoteApplication.java

@@ -0,0 +1,14 @@
+package com.uas.ps.vote;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@EnableAutoConfiguration
+public class PsVoteApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(PsVoteApplication.class, args);
+	}
+}

+ 70 - 0
src/main/java/com/uas/ps/vote/controller/VoteController.java

@@ -0,0 +1,70 @@
+package com.uas.ps.vote.controller;
+
+import com.uas.ps.core.page.PageParams;
+import com.uas.ps.vote.model.Vote;
+import com.uas.ps.vote.service.VoteService;
+import com.uas.ps.vote.support.ResultMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Author: huj
+ * @Date: Created in 14:14 2018/10/26.
+ */
+@RestController
+@RequestMapping("/vote")
+public class VoteController {
+
+    @Autowired
+    VoteService voteService;
+
+    /**
+     * 获取单个企业
+     * @param enUU
+     * @return
+     */
+    @RequestMapping("/one")
+    public ResultMap getEnterprise(Long enUU) {
+        return voteService.getEnterprise(enUU);
+    }
+
+    /**
+     * 获取企业列表
+     * @param params
+     * @param type
+     * @param keyword
+     * @return
+     */
+    @RequestMapping("/all")
+    public ResultMap getEnterprises(PageParams params, Vote.Type type, String keyword) {
+        return voteService.getEnterprises(params, type, keyword);
+    }
+
+    /**
+     * 企业报名
+     * @param enUU
+     * @param type
+     * @param userUU
+     * @param enDes
+     * @param enName
+     * @return
+     */
+    @RequestMapping(value = "/apply", method = RequestMethod.POST)
+    public ResultMap apply(Long enUU, Vote.Type type, Long userUU, String enDes, String enName, String userName) {
+        return voteService.apply(enUU, type, userUU, enDes, enName, userName);
+    }
+
+    /**
+     * 用户投票
+     * @param userUU
+     * @param type
+     * @param enUU
+     * @return
+     */
+    @RequestMapping(value = "/vote", method = RequestMethod.POST)
+    public ResultMap vote(Long userUU, Vote.Type type, Long enUU, String userName) {
+        return voteService.vote(userUU, type, enUU,userName);
+    }
+}

+ 21 - 0
src/main/java/com/uas/ps/vote/dao/EnterpriseDao.java

@@ -0,0 +1,21 @@
+package com.uas.ps.vote.dao;
+
+import com.uas.ps.vote.model.Enterprise;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @Author: huj
+ * @Date: Created in 14:39 2018/10/26.
+ */
+@Repository
+public interface EnterpriseDao extends JpaRepository<Enterprise, Long>, JpaSpecificationExecutor<Enterprise> {
+
+    /**
+     * 按enUU查找已报名企业
+     * @param enUU
+     * @return
+     */
+    Enterprise findByEnUU(Long enUU);
+}

+ 24 - 0
src/main/java/com/uas/ps/vote/dao/UserDao.java

@@ -0,0 +1,24 @@
+package com.uas.ps.vote.dao;
+
+import com.uas.ps.vote.model.User;
+import com.uas.ps.vote.model.Vote;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @Author: huj
+ * @Date: Created in 14:38 2018/10/26.
+ */
+@Repository
+public interface UserDao extends JpaSpecificationExecutor<User>, JpaRepository<User, Long> {
+
+    /**
+     * 查找投票记录
+     * @param userUU
+     * @param type
+     * @return
+     */
+    User findByUserUUAndType(Long userUU, Vote.Type type);
+
+}

+ 17 - 0
src/main/java/com/uas/ps/vote/dao/VoteDao.java

@@ -0,0 +1,17 @@
+package com.uas.ps.vote.dao;
+
+import com.uas.ps.vote.model.Vote;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @Author: huj
+ * @Date: Created in 14:34 2018/10/26.
+ */
+@Repository
+public interface VoteDao extends JpaSpecificationExecutor<Vote>, JpaRepository<Vote, Long> {
+
+    Vote findByName(String name);
+
+}

+ 205 - 0
src/main/java/com/uas/ps/vote/model/Enterprise.java

@@ -0,0 +1,205 @@
+package com.uas.ps.vote.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @Author: huj
+ * @Date: Created in 11:13 2018/10/26.
+ */
+@Entity
+@Table(name = "enterprise")
+public class Enterprise implements Serializable {
+
+    /**
+     * 序列号
+     */
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @Column(name = "id")
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+
+    /**
+     * 企业uu
+     */
+    @Column(name = "en_uu")
+    private Long enUU;
+
+    /**
+     * 企业name
+     */
+    @Column(name = "en_name")
+    private String enName;
+
+    /**
+     * 报名用户uu
+     */
+    @Column(name = "user_uu")
+    private Long userUU;
+
+    /**
+     * 企业简介or主营产品
+     */
+    @Column(name = "en_des", length = 2000)
+    private String enDes;
+
+    /**
+     * 投票次数
+     */
+    @Column(name = "votes")
+    private Long votes;
+
+    /**
+     * 企业logo
+     */
+    @Column(name = "pic")
+    private String pic;
+
+    /**
+     * 参选类型
+     */
+    @Column(name = "type")
+    @Enumerated(value = EnumType.STRING)
+    private Vote.Type type;
+
+    /**
+     * 申请时间
+     */
+    @Column(name = "apply_time")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    private String applyTime;
+
+    /**
+     * 报名人uu
+     */
+    @Column(name = "user_name")
+    private String userName;
+
+    /**
+     * 更新时间
+     */
+    @Column(name = "update_time")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    private String updateTime;
+
+    /**
+     * 创建时间
+     */
+    @Column(name = "creat_time")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    private String creatTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getEnUU() {
+        return enUU;
+    }
+
+    public void setEnUU(Long enUU) {
+        this.enUU = enUU;
+    }
+
+    public String getEnName() {
+        return enName;
+    }
+
+    public void setEnName(String enName) {
+        this.enName = enName;
+    }
+
+    public String getEnDes() {
+        return enDes;
+    }
+
+    public void setEnDes(String enDes) {
+        this.enDes = enDes;
+    }
+
+    public Long getVotes() {
+        return votes;
+    }
+
+    public void setVotes(Long votes) {
+        this.votes = votes;
+    }
+
+    public String getPic() {
+        return pic;
+    }
+
+    public void setPic(String pic) {
+        this.pic = pic;
+    }
+
+    public String getApplyTime() {
+        return applyTime;
+    }
+
+    public void setApplyTime(String applyTime) {
+        this.applyTime = applyTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Vote.Type getType() {
+        return type;
+    }
+
+    public void setType(Vote.Type type) {
+        this.type = type;
+    }
+
+    public Long getUserUU() {
+        return userUU;
+    }
+
+    public void setUserUU(Long userUU) {
+        this.userUU = userUU;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getCreatTime() {
+        return creatTime;
+    }
+
+    public void setCreatTime(String creatTime) {
+        this.creatTime = creatTime;
+    }
+
+    public Enterprise(Long enUU, Vote.Type type, Long userUU, String enDes, String enName, String userName) {
+        this.enUU = enUU;
+        this.enName = enName;
+        this.enDes = enDes;
+        this.type = type;
+        this.userName = userName;
+        this.userUU = userUU;
+        Date date = new Date();
+        this.applyTime = date.toString();
+    }
+
+    public Enterprise() {}
+}

+ 134 - 0
src/main/java/com/uas/ps/vote/model/User.java

@@ -0,0 +1,134 @@
+package com.uas.ps.vote.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @Author: huj
+ * @Date: Created in 14:08 2018/10/26.
+ */
+@Entity
+@Table(name = "user")
+public class User implements Serializable{
+
+    /**
+     * 序列号
+     */
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @Column(name = "id")
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+
+    /**
+     * userUU
+     */
+    @Column(name = "user_uu")
+    private Long userUU;
+
+    /**
+     * 投票企业uu
+     */
+    @Column(name = "en_uu")
+    private Long enUU;
+
+    /**
+     * 投票企业类型
+     */
+    @Column(name = "type")
+    @Enumerated(value = EnumType.STRING)
+    private Vote.Type type;
+
+    /**
+     * 投票时间
+     */
+    @Column(name = "vote_time")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    private String voteTime;
+
+    /**
+     * 创建时间
+     */
+    @Column(name = "createTime")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    private String createTime;
+
+    /**
+     * 投票人姓名
+     */
+    @Column(name = "user_name")
+    private String userName;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getUserUU() {
+        return userUU;
+    }
+
+    public void setUserUU(Long userUU) {
+        this.userUU = userUU;
+    }
+
+    public Long getEnUU() {
+        return enUU;
+    }
+
+    public void setEnUU(Long enUU) {
+        this.enUU = enUU;
+    }
+
+    public Vote.Type getType() {
+        return type;
+    }
+
+    public void setType(Vote.Type type) {
+        this.type = type;
+    }
+
+    public String getVoteTime() {
+        return voteTime;
+    }
+
+    public void setVoteTime(String voteTime) {
+        this.voteTime = voteTime;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public User(Long userUU, Vote.Type type, Long enUU, String userName) {
+        this.userUU = userUU;
+        this.type = type;
+        this.enUU = enUU;
+        Date date = new Date();
+        this.voteTime = date.toString();
+        this.userName = userName;
+    }
+
+    public User() {
+
+    }
+}

+ 140 - 0
src/main/java/com/uas/ps/vote/model/Vote.java

@@ -0,0 +1,140 @@
+package com.uas.ps.vote.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+/**
+ * @Author: huj
+ * @Date: Created in 14:24 2018/10/26.
+ */
+@Entity
+@Table(name = "vote")
+public class Vote implements Serializable {
+
+    /**
+     * 序列号
+     */
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @Column(name = "id")
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+
+    /**
+     * 创建时间
+     */
+    @Column(name = "createTime")
+    private String creatTime;
+
+    /**
+     * 报名起始时间
+     */
+    @Column(name = "apply_start_time")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    private String applyStartTime;
+
+    /**
+     * 报名截止时间
+     */
+    @Column(name = "apply_end_time")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    private String applyEndTime;
+
+    /**
+     * 投票开始时间
+     */
+    @Column(name = "vote_start_time")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    private String voteStartTime;
+
+    /**
+     * 投票截止时间
+     */
+    @Column(name = "vote_end_time")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    private String voteEndTime;
+
+    /**
+     * 类型
+     */
+    @Column(name = "type")
+    private String type;
+
+    @Column(name = "name")
+    private String name;
+
+
+    /**
+     * 类型:采购商:PURCHASERS 电商:ONLINE_RETAILERS  供应商:SUPPLIER
+     */
+    public enum Type {
+        PURCHASERS,ONLINE_RETAILERS,SUPPLIER
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getCreatTime() {
+        return creatTime;
+    }
+
+    public void setCreatTime(String creatTime) {
+        this.creatTime = creatTime;
+    }
+
+    public String getVoteStartTime() {
+        return voteStartTime;
+    }
+
+    public void setVoteStartTime(String voteStartTime) {
+        this.voteStartTime = voteStartTime;
+    }
+
+    public String getVoteEndTime() {
+        return voteEndTime;
+    }
+
+    public void setVoteEndTime(String voteEndTime) {
+        this.voteEndTime = voteEndTime;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getApplyStartTime() {
+        return applyStartTime;
+    }
+
+    public void setApplyStartTime(String applyStartTime) {
+        this.applyStartTime = applyStartTime;
+    }
+
+    public String getApplyEndTime() {
+        return applyEndTime;
+    }
+
+    public void setApplyEndTime(String applyEndTime) {
+        this.applyEndTime = applyEndTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

+ 37 - 0
src/main/java/com/uas/ps/vote/service/VoteService.java

@@ -0,0 +1,37 @@
+package com.uas.ps.vote.service;
+
+import com.uas.ps.core.page.PageParams;
+import com.uas.ps.vote.model.Vote;
+import com.uas.ps.vote.support.ResultMap;
+
+/**
+ * @Author: huj
+ * @Date: Created in 14:19 2018/10/26.
+ */
+public interface VoteService {
+
+    /**
+     * 获取单个企业
+     * @return
+     */
+    ResultMap getEnterprise(Long enUU);
+
+    /**
+     * 获取所有企业
+     * @return
+     */
+    ResultMap getEnterprises(PageParams params, Vote.Type type, String keyword);
+
+    /**
+     * 企业报名
+     * @return
+     */
+    ResultMap apply(Long enUU, Vote.Type type, Long userUU, String enDes, String enName, String userName);
+
+    /**
+     * 用户投票
+     * @return
+     */
+    ResultMap vote(Long userUU, Vote.Type type, Long enUU, String userName);
+
+}

+ 260 - 0
src/main/java/com/uas/ps/vote/service/impl/VoteServiceImpl.java

@@ -0,0 +1,260 @@
+package com.uas.ps.vote.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.uas.ps.core.page.PageInfo;
+import com.uas.ps.core.page.PageParams;
+import com.uas.ps.core.page.criteria.CriterionExpression;
+import com.uas.ps.core.page.criteria.SimpleExpression;
+import com.uas.ps.core.util.HttpUtil;
+import com.uas.ps.vote.dao.EnterpriseDao;
+import com.uas.ps.vote.dao.UserDao;
+import com.uas.ps.vote.dao.VoteDao;
+import com.uas.ps.vote.model.Enterprise;
+import com.uas.ps.vote.model.User;
+import com.uas.ps.vote.model.Vote;
+import com.uas.ps.vote.service.VoteService;
+import com.uas.ps.vote.support.ResultMap;
+import com.uas.ps.vote.support.UrlConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @Author: huj
+ * @Date: Created in 14:20 2018/10/26.
+ */
+@Service
+public class VoteServiceImpl implements VoteService{
+
+    private Logger LOGGER = LoggerFactory.getLogger(VoteServiceImpl.class);
+
+    @Autowired
+    EnterpriseDao enterpriseDao;
+
+    @Autowired
+    VoteDao voteDao;
+
+    @Autowired
+    UserDao userDao;
+
+    @Autowired
+    UrlConfig urlConfig;
+
+    private static List<String> TYPE = Arrays.asList("ONLINE_RETAILERS", "SUPPLIER", "PURCHASERS");
+
+    private static String storeUrl = "/api/vote/store";
+
+    private static String goodsUrl = "/api/vote/goods";
+
+    private static String inquiryUrl = "/inquiry/api/sum/enuu";
+
+    @Override
+    public ResultMap getEnterprise(Long enUU) {
+        Enterprise enterprise = enterpriseDao.findByEnUU(enUU);
+        if (StringUtils.isEmpty(enterprise)) {
+            return ResultMap.fail("该企业未报名");
+        } else {
+            return ResultMap.success(enterprise);
+        }
+    }
+
+    @Override
+    public ResultMap getEnterprises(PageParams params, Vote.Type type, String keyword) {
+        if (StringUtils.isEmpty(params) || StringUtils.isEmpty(params.getCount())
+                || StringUtils.isEmpty(params.getPage())) {
+            return ResultMap.fail("分页参数异常");
+        }
+        final PageInfo pageInfo = new PageInfo(params);
+        pageInfo.sorting(Sort.Direction.DESC, "votes", "applyTime");
+        if (!StringUtils.isEmpty(keyword)) {
+            SimpleExpression expression = new SimpleExpression("enName", keyword,
+                    CriterionExpression.Operator.LIKE, true);
+            pageInfo.expression(expression);
+        }
+        if (!StringUtils.isEmpty(type)) {
+            Page<Enterprise> page = enterpriseDao.findAll(new Specification<Enterprise>() {
+                @Override
+                public Predicate toPredicate(Root<Enterprise> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+                    query.where(pageInfo.getPredicates(root, query, builder));
+                    return null;
+                }
+            }, pageInfo);
+            return ResultMap.success(page);
+        } else {
+            pageInfo.expression(new SimpleExpression("type", TYPE.get(0), CriterionExpression.Operator.EQ, true));
+            Page<Enterprise> page = enterpriseDao.findAll(new Specification<Enterprise>() {
+                @Override
+                public Predicate toPredicate(Root<Enterprise> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+                    query.where(pageInfo.getPredicates(root, query, builder));
+                    return null;
+                }
+            }, pageInfo);
+            checkIsNull(pageInfo, page, TYPE.get(1));
+            checkIsNull(pageInfo, page, TYPE.get(2));
+            return ResultMap.success(page);
+        }
+    }
+
+    private void checkIsNull(final PageInfo pageInfo, Page<Enterprise> page, String type) {
+        if (CollectionUtils.isEmpty(page.getContent())) {
+            pageInfo.expression(new SimpleExpression("type", type, CriterionExpression.Operator.EQ, true));
+            page = enterpriseDao.findAll(new Specification<Enterprise>() {
+                @Override
+                public Predicate toPredicate(Root<Enterprise> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+                    query.where(pageInfo.getPredicates(root, query, builder));
+                    return null;
+                }
+            }, pageInfo);
+        }
+    }
+
+    @Override
+    public ResultMap apply(Long enUU, Vote.Type type, Long userUU, String enDes, String enName, String userName) {
+        if (StringUtils.isEmpty(enUU) || StringUtils.isEmpty(type) || StringUtils.isEmpty(userUU)) {
+            return ResultMap.fail("参数异常");
+        }
+        if (!TYPE.contains(type)) {
+            return ResultMap.fail("企业类型异常");
+        }
+        Enterprise enterprise = enterpriseDao.findByEnUU(enUU);
+        if (!StringUtils.isEmpty(enterprise)) {
+            return ResultMap.success("您的企业已报名,无需重复报名");
+        }
+        if (TYPE.get(0).equals(type)) {
+            if (existStore(enUU)) {
+                return ResultMap.fail("请先开店");
+            }
+            if (countGoods(enUU)) {
+                return ResultMap.fail("请先发布10条产品");
+            }
+            enterprise = new Enterprise(enUU, type, userUU, enDes, enName, userName);
+            enterpriseDao.save(enterprise);
+        }
+        if (TYPE.get(2).equals(type)) {
+            if (countInquiry(enUU)) {
+                return ResultMap.fail("请先发布100条询价");
+            }
+            enterprise = new Enterprise(enUU, type, userUU, enDes, enName, userName);
+            enterpriseDao.save(enterprise);
+        }
+        if (TYPE.get(0).equals(type)) {
+            enterprise = new Enterprise(enUU, type, userUU, enDes, enName, userName);
+            enterpriseDao.save(enterprise);
+        }
+        return ResultMap.fail("报名失败");
+    }
+
+    @Override
+    public ResultMap vote(Long userUU, Vote.Type type, Long enUU, String userName) {
+        if (StringUtils.isEmpty(userUU) || StringUtils.isEmpty(type) || StringUtils.isEmpty(enUU)) {
+            return ResultMap.fail("参数异常");
+        }
+        Vote vote = voteDao.findByName("2018年优软商城投票活动");
+        if (!vote.getType().contains(type.toString())) {
+            return ResultMap.fail("投票企业类型异常");
+        }
+        if (!checkTime(vote).isSuccess()) {
+            return ResultMap.fail("不在投票时间");
+        }
+        Enterprise enterprise = enterpriseDao.findByEnUU(enUU);
+        if (StringUtils.isEmpty(enterprise)) {
+            return ResultMap.fail("该企业未报名");
+        }
+        // 判断是否投过该类型企业
+        User existUser = userDao.findByUserUUAndType(userUU, type);
+        if (!StringUtils.isEmpty(enterprise)) {
+            return ResultMap.fail("投票失败,您已投过该类型企业");
+        }
+        User user = new User(userUU, type, enUU, userName);
+        // 保存投票数
+        Date date = new Date();
+        enterprise.setUpdateTime(date.toString());
+        enterprise.setVotes(enterprise.getVotes() + 1L);
+        enterpriseDao.save(enterprise);
+        userDao.save(user);
+        return ResultMap.success("投票成功");
+    }
+
+    private ResultMap checkTime(Vote vote) {
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date currentTime = new Date();
+        Date startTime = null;
+        Date endTime = null;
+        try {
+            startTime = formatter.parse(vote.getVoteStartTime());
+            endTime = formatter.parse(vote.getVoteEndTime());
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        if (startTime.after(currentTime) || endTime.before(currentTime)) {
+            return ResultMap.fail("不在报名或投票时间");
+        }
+        return ResultMap.success(vote);
+    }
+
+    // 是否开店
+    private Boolean existStore(Long enUU) {
+        Map<String, Long> map = new HashMap<>(1);
+        map.put("enUU", enUU);
+        boolean exist = false;
+        try {
+            HttpUtil.Response response = HttpUtil.sendGetRequest(urlConfig.getMall() + storeUrl, map);
+            ResultMap result = JSON.parseObject(response.getResponseText(), ResultMap.class);
+            if (result.isSuccess()) {
+                exist = true;
+            }
+        } catch (Exception e) {
+            LOGGER.error("获取开店信息失败:" + enUU + " 错误信息:" + e.getMessage());
+        }
+        return exist;
+    }
+
+    // 询价数
+    private Boolean countInquiry(Long enUU) {
+        Map<String, Long> map = new HashMap<>(1);
+        map.put("enuu", enUU);
+        boolean fill = false;
+        try {
+            HttpUtil.Response response = HttpUtil.sendGetRequest(urlConfig.getInquiry() + inquiryUrl, map);
+            Integer count = Integer.valueOf(JSON.parseObject(response.getResponseText()).get("count").toString());
+            if (count >= 10) {
+                fill = true;
+            }
+        } catch (Exception e) {
+            LOGGER.error("获取询价失败:" + enUU + " 错误信息:" + e.getMessage());
+        }
+        return fill;
+    }
+
+    // 发布产品数
+    private Boolean countGoods(Long enUU) {
+        Map<String, Long> map = new HashMap<>(1);
+        map.put("enUU", enUU);
+        boolean fill = false;
+        try {
+            HttpUtil.Response response = HttpUtil.sendGetRequest(urlConfig.getMall() + goodsUrl, map);
+            Integer count = Integer.valueOf(response.getResponseText().trim());
+            if (count >= 100) {
+                fill = true;
+            }
+        } catch (Exception e) {
+            LOGGER.error("获取询价失败:" + enUU + " 错误信息:" + e.getMessage());
+        }
+        return fill;
+    }
+
+}

+ 93 - 0
src/main/java/com/uas/ps/vote/support/CodeType.java

@@ -0,0 +1,93 @@
+package com.uas.ps.vote.support;
+
+/**
+ * 响应码
+ *
+ * history:
+ * Created by huxz on 2017-3-29 16:30:50
+ */
+public enum CodeType {
+
+	/**
+	 * 操作成功
+	 */
+	OK(200, "SUCCESS"),
+
+	/* 参数错误 100~199 */
+	/**
+	 * 参数信息缺失
+	 */
+	NO_INFO(100, "NO_INFO"),
+	/**
+	 * 参数异常,不在取值范围之内等原因
+	 */
+	PARAMETER_ERROR(101, "PARAMETER_ERROR"),
+
+	/* 权限问题 300~399 */
+	/**
+	 * 操作不允许
+	 */
+	NOT_PERMIT(300, "NOT_PERMIT"),
+
+	/* 操作实体错误 400~499 */
+	/**
+	 * 操作实体信息不全
+	 */
+	NOT_COMPLETE_INFO(401, "NOT_COMPLETE_INFO"),
+	/**
+	 * 操作实体已存在
+	 */
+	SAVED(402, "SAVED"),
+	/**
+	 * 操作实体不存在
+	 */
+	NOT_EXiST(403, "NOT_EXiST"),
+	/**
+	 * 非法状态
+	 */
+	ERROR_STATE(404, "ERROR_STATE"),
+
+	/* 系统错误,网络错误 500~599 */
+	/**
+	 * 系统异常
+	 */
+	SYSTEM_ERROR(500, "SYSTEM_ERROR"),
+	/**
+	 * 系统的基础参数不存在
+	 */
+	SYSTEM_NOT_EXIST(501, "SYSTEM_NOT_EXIST"),
+	/**
+	 * 超时请求
+	 */
+	TIME_OUT(502, "TIME_OUT");
+
+	private int code;
+
+	private String message;
+
+	CodeType(int code, String message) {
+		this.code = code;
+		this.message = message;
+	}
+
+	/**
+	 * code
+	 * @return code
+	 */
+	public int code() {
+		return this.code;
+	}
+
+	/**
+	 * message
+	 * @return message
+	 */
+	public String message() {
+		return this.message;
+	}
+
+	@Override
+	public String toString() {
+		return Integer.toString(code);
+	}
+}

+ 303 - 0
src/main/java/com/uas/ps/vote/support/DruidDBConfiguration.java

@@ -0,0 +1,303 @@
+package com.uas.ps.vote.support;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.druid.support.http.StatViewServlet;
+import com.alibaba.druid.support.http.WebStatFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Component;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+
+@Component
+@ConfigurationProperties(prefix = "datasource")
+public class DruidDBConfiguration {
+
+    private Logger logger = LoggerFactory.getLogger(DruidDBConfiguration.class);
+
+    private String url;
+
+    private String username;
+
+    private String password;
+
+    private String driverClassName;
+
+    private int initialSize;
+
+    private int minIdle;
+
+    private int maxActive;
+
+    private int maxWait;
+
+    private int timeBetweenEvictionRunsMillis;
+
+    private int minEvictableIdleTimeMillis;
+
+    private String validationQuery;
+
+    private boolean testWhileIdle;
+
+    private boolean testOnBorrow;
+
+    private boolean testOnReturn;
+
+    private int timeBetweenLogStatsMillis;
+
+    private boolean poolPreparedStatements;
+
+    private int maxPoolPreparedStatementPerConnectionSize;
+
+    private String filters;
+
+    private String connectionProperties;
+
+    private boolean removeAbandoned;
+
+    private int removeAbandonedTimeout;
+
+    private boolean logAbandoned;
+
+    @Bean
+    @Primary
+    public DataSource dataSource() {
+        DruidDataSource dataSource = new DruidDataSource();
+
+        dataSource.setUrl(url);
+        dataSource.setUsername(username);
+        dataSource.setPassword(password);
+        dataSource.setDriverClassName(driverClassName);
+
+        // configuration
+        dataSource.setInitialSize(initialSize);
+        dataSource.setMinIdle(minIdle);
+        dataSource.setMaxActive(maxActive);
+        dataSource.setMaxWait(maxWait);
+        dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
+        dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
+        dataSource.setValidationQuery(validationQuery);
+        dataSource.setTestWhileIdle(testWhileIdle);
+        dataSource.setTestOnBorrow(testOnBorrow);
+        dataSource.setTestOnReturn(testOnReturn);
+        // 设置闲置连接断开
+        dataSource.setRemoveAbandoned(removeAbandoned);
+        dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout);
+        dataSource.setLogAbandoned(logAbandoned);
+        dataSource.setTimeBetweenLogStatsMillis(timeBetweenLogStatsMillis);
+        dataSource.setPoolPreparedStatements(poolPreparedStatements);
+        dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
+        try {
+            dataSource.setFilters(filters);
+        } catch (SQLException e) {
+            logger.error("数据源初始化失败: setFilters", e);
+        }
+        dataSource.setConnectionProperties(connectionProperties);
+        return dataSource;
+    }
+
+    @Bean
+    public ServletRegistrationBean servletRegistrationBean() {
+        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
+        Map<String, String> initParams = new HashMap<>();
+        // 可配的属性都在 StatViewServlet 和其父类下
+        initParams.put("loginUsername", "admin");
+        initParams.put("loginPassword", "123");
+        servletRegistrationBean.setInitParameters(initParams);
+        return servletRegistrationBean;
+    }
+
+    @Bean
+    public FilterRegistrationBean filterRegistrationBean() {
+        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
+        filterRegistrationBean.setFilter(new WebStatFilter());
+        filterRegistrationBean.addUrlPatterns("/*");
+        filterRegistrationBean.addInitParameter("exclusions",
+            "*.js,*.gif,*.jpg,*.png,*.bmp,*.css,*.ico,*.html,/druid/*");
+        return filterRegistrationBean;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getDriverClassName() {
+        return driverClassName;
+    }
+
+    public void setDriverClassName(String driverClassName) {
+        this.driverClassName = driverClassName;
+    }
+
+    public int getInitialSize() {
+        return initialSize;
+    }
+
+    public void setInitialSize(int initialSize) {
+        this.initialSize = initialSize;
+    }
+
+    public int getMinIdle() {
+        return minIdle;
+    }
+
+    public void setMinIdle(int minIdle) {
+        this.minIdle = minIdle;
+    }
+
+    public int getMaxActive() {
+        return maxActive;
+    }
+
+    public void setMaxActive(int maxActive) {
+        this.maxActive = maxActive;
+    }
+
+    public int getMaxWait() {
+        return maxWait;
+    }
+
+    public void setMaxWait(int maxWait) {
+        this.maxWait = maxWait;
+    }
+
+    public int getTimeBetweenEvictionRunsMillis() {
+        return timeBetweenEvictionRunsMillis;
+    }
+
+    public void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) {
+        this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
+    }
+
+    public int getMinEvictableIdleTimeMillis() {
+        return minEvictableIdleTimeMillis;
+    }
+
+    public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) {
+        this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
+    }
+
+    public String getValidationQuery() {
+        return validationQuery;
+    }
+
+    public void setValidationQuery(String validationQuery) {
+        this.validationQuery = validationQuery;
+    }
+
+    public boolean isTestWhileIdle() {
+        return testWhileIdle;
+    }
+
+    public void setTestWhileIdle(boolean testWhileIdle) {
+        this.testWhileIdle = testWhileIdle;
+    }
+
+    public boolean isTestOnBorrow() {
+        return testOnBorrow;
+    }
+
+    public void setTestOnBorrow(boolean testOnBorrow) {
+        this.testOnBorrow = testOnBorrow;
+    }
+
+    public boolean isTestOnReturn() {
+        return testOnReturn;
+    }
+
+    public void setTestOnReturn(boolean testOnReturn) {
+        this.testOnReturn = testOnReturn;
+    }
+
+    public int getTimeBetweenLogStatsMillis() {
+        return timeBetweenLogStatsMillis;
+    }
+
+    public void setTimeBetweenLogStatsMillis(int timeBetweenLogStatsMillis) {
+        this.timeBetweenLogStatsMillis = timeBetweenLogStatsMillis;
+    }
+
+    public boolean isPoolPreparedStatements() {
+        return poolPreparedStatements;
+    }
+
+    public void setPoolPreparedStatements(boolean poolPreparedStatements) {
+        this.poolPreparedStatements = poolPreparedStatements;
+    }
+
+    public int getMaxPoolPreparedStatementPerConnectionSize() {
+        return maxPoolPreparedStatementPerConnectionSize;
+    }
+
+    public void setMaxPoolPreparedStatementPerConnectionSize(int maxPoolPreparedStatementPerConnectionSize) {
+        this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize;
+    }
+
+    public String getFilters() {
+        return filters;
+    }
+
+    public void setFilters(String filters) {
+        this.filters = filters;
+    }
+
+    public String getConnectionProperties() {
+        return connectionProperties;
+    }
+
+    public void setConnectionProperties(String connectionProperties) {
+        this.connectionProperties = connectionProperties;
+    }
+
+    public boolean isRemoveAbandoned() {
+        return removeAbandoned;
+    }
+
+    public void setRemoveAbandoned(boolean removeAbandoned) {
+        this.removeAbandoned = removeAbandoned;
+    }
+
+    public int getRemoveAbandonedTimeout() {
+        return removeAbandonedTimeout;
+    }
+
+    public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
+        this.removeAbandonedTimeout = removeAbandonedTimeout;
+    }
+
+    public boolean isLogAbandoned() {
+        return logAbandoned;
+    }
+
+    public void setLogAbandoned(boolean logAbandoned) {
+        this.logAbandoned = logAbandoned;
+    }
+}

+ 133 - 0
src/main/java/com/uas/ps/vote/support/ResultMap.java

@@ -0,0 +1,133 @@
+package com.uas.ps.vote.support;
+
+import com.alibaba.fastjson.JSON;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * 请求结果集
+ *
+ * history:
+ * Created by huxz on 2017-3-29 16:30:32
+ */
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+public class ResultMap {
+
+	private int code;
+
+	private boolean success;
+
+	private String message;
+
+	private Object data;
+
+	public ResultMap() {
+	}
+
+	public ResultMap(int status, String message) {
+		if (CodeType.OK.code() == status) {
+			this.success = true;
+		} else {
+			this.success = false;
+		}
+		this.code = status;
+		this.message = message;
+	}
+
+	public ResultMap(int status, Object data) {
+		if (CodeType.OK.code() == status) {
+			this.success = true;
+		} else {
+			this.success = false;
+		}
+		this.code = status;
+		this.data = data;
+	}
+
+	public ResultMap(CodeType status, String message) {
+		if (CodeType.OK.code() == status.code()) {
+			this.success = true;
+		} else {
+			this.success = false;
+		}
+		this.message = message;
+		this.code = status.code();
+	}
+
+	public ResultMap(int status, String message, Object data) {
+		if (CodeType.OK.code() == status) {
+			this.success = true;
+		} else {
+			this.success = false;
+		}
+		this.code = status;
+		this.message = message;
+		this.data = data;
+	}
+
+	public int getCode() {
+		return code;
+	}
+
+	public void setCode(int code) {
+		this.code = code;
+	}
+
+	public boolean isSuccess() {
+		return success;
+	}
+
+	public void setSuccess(boolean success) {
+		this.success = success;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+	public Object getData() {
+		return data;
+	}
+
+	public void setData(Object data) {
+		this.data = data;
+	}
+
+	@Override
+	public String toString() {
+		return JSON.toJSONString(this);
+	}
+
+	/**
+	 * 返回成功
+	 * @param data
+	 * @return
+	 */
+	public static ResultMap success(Object data) {
+		ResultMap result = new ResultMap(true, data);
+		return result;
+	}
+
+	/**
+	 * 返回失败信息
+	 * @param message message信息
+	 * @return
+	 */
+	public static ResultMap fail(String message) {
+		ResultMap result = new ResultMap(false, message);
+		return result;
+	}
+
+	public ResultMap(Boolean success, String message) {
+		this.success = success;
+		this.message = message;
+	}
+
+	public ResultMap(Boolean success, Object data) {
+		this.success = success;
+		this.data = data;
+	}
+}

+ 33 - 0
src/main/java/com/uas/ps/vote/support/UrlConfig.java

@@ -0,0 +1,33 @@
+package com.uas.ps.vote.support;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Author: huj
+ * @Date: Created in 17:45 2018/10/29.
+ */
+@Component
+@ConfigurationProperties(prefix = "url")
+public class UrlConfig {
+
+    private String inquiry;
+
+    private String mall;
+
+    public String getInquiry() {
+        return inquiry;
+    }
+
+    public void setInquiry(String inquiry) {
+        this.inquiry = inquiry;
+    }
+
+    public String getMall() {
+        return mall;
+    }
+
+    public void setMall(String mall) {
+        this.mall = mall;
+    }
+}

+ 23 - 0
src/main/resources/application.yml

@@ -0,0 +1,23 @@
+security:
+  basic:
+    enabled: false
+spring:
+  profiles:
+    active: dev
+  jpa:
+    database: mysql
+    show-sql: true
+    hibernate:
+      ddl-auto: none
+  http:
+    encoding:
+      enabled: true
+      charset: utf-8
+      force: true
+server:
+  port: 9999
+logging:
+  level: info
+  pattern:
+    file: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
+  path: log

+ 25 - 0
src/main/resources/config/application-dev.properties

@@ -0,0 +1,25 @@
+datasource.url=jdbc:mysql://192.168.253.12:3306/vote?characterEncoding=utf-8&useSSL=false
+datasource.username=root
+datasource.password=select111***
+datasource.driverClassName=com.mysql.jdbc.Driver
+datasource.initialSize=1
+datasource.minIdle=1
+datasource.maxActive=100
+datasource.maxWait=60000
+datasource.timeBetweenEvictionRunsMillis=60000
+datasource.minEvictableIdleTimeMillis=300000
+datasource.validationQuery=SELECT 1 FROM DUAL
+datasource.testWhileIdle=true
+datasource.testOnBorrow=true
+datasource.testOnReturn=false
+datasource.removeAbandoned=true
+datasource.removeAbandonedTimeout=1800
+datasource.logAbandoned=true
+datasource.poolPreparedStatements=true
+datasource.timeBetweenLogStatsMillis=60000
+datasource.maxPoolPreparedStatementPerConnectionSize=20
+datasource.filters=stat,slf4j
+datasource.connectionProperties=druid.stat.mergeSql=false;druid.stat.slowSqlMillis=5000
+
+url.mall=http://10.1.51.62:8188/
+url.inquiry=http://218.17.158.219:24000/

+ 25 - 0
src/main/resources/config/application-prod.properties

@@ -0,0 +1,25 @@
+datasource.url=jdbc:mysql://192.168.253.12:3306/vote?characterEncoding=utf-8&useSSL=false
+datasource.username=root
+datasource.password=select111***
+datasource.driverClassName=com.mysql.jdbc.Driver
+datasource.initialSize=1
+datasource.minIdle=1
+datasource.maxActive=100
+datasource.maxWait=60000
+datasource.timeBetweenEvictionRunsMillis=60000
+datasource.minEvictableIdleTimeMillis=300000
+datasource.validationQuery=SELECT 1 FROM DUAL
+datasource.testWhileIdle=true
+datasource.testOnBorrow=true
+datasource.testOnReturn=false
+datasource.removeAbandoned=true
+datasource.removeAbandonedTimeout=1800
+datasource.logAbandoned=true
+datasource.poolPreparedStatements=true
+datasource.timeBetweenLogStatsMillis=60000
+datasource.maxPoolPreparedStatementPerConnectionSize=20
+datasource.filters=stat,slf4j
+datasource.connectionProperties=druid.stat.mergeSql=false;druid.stat.slowSqlMillis=5000
+
+url.mall=http://10.1.51.62:8188/
+url.inquiry=http://218.17.158.219:24000/

+ 25 - 0
src/main/resources/config/application-test.properties

@@ -0,0 +1,25 @@
+datasource.url=jdbc:mysql://192.168.253.12:3306/vote?characterEncoding=utf-8&useSSL=false
+datasource.username=root
+datasource.password=select111***
+datasource.driverClassName=com.mysql.jdbc.Driver
+datasource.initialSize=1
+datasource.minIdle=1
+datasource.maxActive=100
+datasource.maxWait=60000
+datasource.timeBetweenEvictionRunsMillis=60000
+datasource.minEvictableIdleTimeMillis=300000
+datasource.validationQuery=SELECT 1 FROM DUAL
+datasource.testWhileIdle=true
+datasource.testOnBorrow=true
+datasource.testOnReturn=false
+datasource.removeAbandoned=true
+datasource.removeAbandonedTimeout=1800
+datasource.logAbandoned=true
+datasource.poolPreparedStatements=true
+datasource.timeBetweenLogStatsMillis=60000
+datasource.maxPoolPreparedStatementPerConnectionSize=20
+datasource.filters=stat,slf4j
+datasource.connectionProperties=druid.stat.mergeSql=false;druid.stat.slowSqlMillis=5000
+
+url.mall=http://10.1.51.62:8188/
+url.inquiry=http://218.17.158.219:24000/

+ 45 - 0
src/main/resources/sql/all.sql

@@ -0,0 +1,45 @@
+create table enterprise(
+  id int not null auto_increment comment 'id',
+  en_uu int not null comment '企业uu',
+	en_des varchar(2000) comment '主营产品',
+	en_name varchar(255) not null default '' comment '企业名称',
+	type varchar(50) not NULL default '' comment '类型',
+	votes int not null default 0 comment '票数',
+	pic varchar(2000) comment '企业logo',
+	user_uu int not null comment '用户uu',
+	user_name varchar(255) not null default '' comment '用户名',
+	apply_time timestamp not null default current_timestamp comment '申请时间',
+	update_time timestamp not null default current_timestamp on update current_timestamp comment '更新时间',
+	creat_time timestamp not null default current_timestamp comment '创建时间',
+	primary key(id) comment '主键,没有重复',
+	unique index(en_uu) comment '企业uu,唯一索引',
+  index(en_name) comment '企业名称索引',
+	index(type) comment '企业类型索引'
+)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '企业报名记录';
+
+create table user(
+  id int not null auto_increment comment 'id',
+	user_uu int not null comment '投票用户uu',
+	user_name varchar(255) not null default '' comment '投票用户名',
+	en_uu int not null comment '投票企业uu',
+	type varchar(50) not NULL default '' comment '类型',
+	vote_time timestamp not null default current_timestamp comment '投票时间',
+	creat_time timestamp not null default current_timestamp comment '创建时间',
+	primary key(id) comment '主键,没有重复',
+	unique index(user_uu,type) comment '用户uu、企业类型,唯一索引'
+)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '用户投票记录';
+
+create table vote(
+	id int not null auto_increment comment 'id',
+	creat_time timestamp not null default current_timestamp comment '创建时间',
+	apply_start_time timestamp not null default current_timestamp comment '报名起始时间',
+	apply_end_time timestamp not null default current_timestamp comment '报名结束时间',
+	vote_start_ime timestamp not null default current_timestamp comment '投票开始时间',
+	vote_end_time timestamp not null default current_timestamp comment '投票结束时间',
+	type varchar(50) not NULL default '' comment '类型',
+	primary key(id) comment '主键,没有重复',
+  index(apply_start_time) comment '报名起始时间索引',
+  index(apply_end_time) comment '报名结束时间索引',
+  index(vote_start_ime) comment '投票开始时间索引',
+  index(vote_end_time) comment '投票结束时间索引'
+)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '用户投票记录';

+ 30 - 0
src/test/java/com/uas/ps/vote/PsVoteApplicationTests.java

@@ -0,0 +1,30 @@
+package com.uas.ps.vote;
+
+import com.alibaba.fastjson.JSON;
+import com.uas.ps.core.util.HttpUtil;
+import com.uas.ps.vote.service.VoteService;
+import com.uas.ps.vote.service.impl.VoteServiceImpl;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class PsVoteApplicationTests {
+
+	@Autowired
+	VoteServiceImpl voteService;
+
+	@Test
+	public void contextLoads() {
+		//Boolean aBoolean = voteService.existStore(10030994L);
+		//System.out.println(aBoolean);
+	}
+
+}