suochencheng 7 лет назад
Родитель
Сommit
be7dbee2fb
29 измененных файлов с 2092 добавлено и 291 удалено
  1. 33 0
      src/main/java/com/izouma/awesomeadmin/dao/BannerInfoMapper.java
  2. 350 0
      src/main/java/com/izouma/awesomeadmin/dao/BannerInfoMapper.xml
  3. 109 0
      src/main/java/com/izouma/awesomeadmin/model/BannerInfo.java
  4. 10 0
      src/main/java/com/izouma/awesomeadmin/model/GenCode.java
  5. 27 0
      src/main/java/com/izouma/awesomeadmin/service/BannerInfoService.java
  6. 137 0
      src/main/java/com/izouma/awesomeadmin/service/impl/BannerInfoServiceImpl.java
  7. 55 51
      src/main/java/com/izouma/awesomeadmin/util/ExportExcelUtil.java
  8. 160 0
      src/main/java/com/izouma/awesomeadmin/web/BannerInfoController.java
  9. 5 1
      src/main/java/com/izouma/codegenerator/ControllerGenerator.java
  10. 5 1
      src/main/java/com/izouma/codegenerator/EditViewGenerator.java
  11. 2 0
      src/main/java/com/izouma/codegenerator/GenList.java
  12. 2 0
      src/main/java/com/izouma/codegenerator/GeneratorTool.java
  13. 5 1
      src/main/java/com/izouma/codegenerator/ListViewGenerator.java
  14. 5 1
      src/main/java/com/izouma/codegenerator/MapperGenerator.java
  15. 5 1
      src/main/java/com/izouma/codegenerator/MapperXmlGenerator.java
  16. 5 1
      src/main/java/com/izouma/codegenerator/ModelGenerator.java
  17. 124 0
      src/main/java/com/izouma/codegenerator/ReadTableGenerator.java
  18. 5 1
      src/main/java/com/izouma/codegenerator/ServiceGenerator.java
  19. 5 1
      src/main/java/com/izouma/codegenerator/ServiceImplGenerator.java
  20. 7 0
      src/main/java/com/izouma/codegenerator/TableGenerator.java
  21. 44 1
      src/main/resources/templates/ControllerTemplate.vm
  22. 115 7
      src/main/resources/templates/ListTemplate.vm
  23. 167 67
      src/main/resources/templates/MapperXmlSqlServerTemplate.vm
  24. 96 1
      src/main/resources/templates/MapperXmlTemplate.vm
  25. 22 0
      src/main/resources/templates/ModelTemplate.vm
  26. 87 0
      src/main/vue/src/pages/BannerInfo.vue
  27. 323 0
      src/main/vue/src/pages/BannerInfos.vue
  28. 170 156
      src/main/vue/src/pages/GenCode.vue
  29. 12 0
      src/main/vue/src/router/index.js

+ 33 - 0
src/main/java/com/izouma/awesomeadmin/dao/BannerInfoMapper.java

@@ -0,0 +1,33 @@
+package com.izouma.awesomeadmin.dao;
+
+import java.util.*;
+import com.izouma.awesomeadmin.datasource.DataSource;
+import org.springframework.stereotype.Repository;
+import com.izouma.awesomeadmin.model.BannerInfo;
+
+
+/**
+*  Dao接口
+*/
+@Repository("com.zoumaframe.dao.BannerInfoMapper")
+public interface BannerInfoMapper{
+
+    int deleteByPrimaryKey(Integer id);
+
+    int insertSelective(BannerInfo record);
+
+    BannerInfo selectByPrimaryKey(Integer id);
+
+    int updateByPrimaryKeySelective(BannerInfo record);
+
+    List<BannerInfo> queryAllBannerInfo(BannerInfo record);
+
+    List<BannerInfo> queryBannerInfoByPage(Map<String, Object> parameter);
+
+    int delete(String id);
+
+    BannerInfo queryBannerInfo(BannerInfo record);
+
+    List<BannerInfo> query(BannerInfo record);
+}
+

+ 350 - 0
src/main/java/com/izouma/awesomeadmin/dao/BannerInfoMapper.xml

@@ -0,0 +1,350 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.izouma.awesomeadmin.dao.BannerInfoMapper" >
+    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.BannerInfo" >
+                <id column="id" property="id" jdbcType="INTEGER" />
+                                        <result column="del_flag" property="delFlag" jdbcType="CHAR" />
+                                <result column="title" property="title" jdbcType="VARCHAR" />
+                                <result column="subtitle" property="subtitle" jdbcType="VARCHAR" />
+                                <result column="image" property="image" jdbcType="VARCHAR" />
+                                <result column="news_url" property="newsUrl" jdbcType="VARCHAR" />
+                                <result column="rank" property="rank" jdbcType="INTEGER" />
+                                <result column="hot" property="hot" jdbcType="INTEGER" />
+                                <result column="remark" property="remark" jdbcType="VARCHAR" />
+            </resultMap>
+    <sql id="Base_Column_List" >
+        <trim  suffixOverrides="," >
+            id,
+
+            del_flag,
+
+            title,
+
+            subtitle,
+
+            image,
+
+            news_url,
+
+            rank,
+
+            hot,
+
+            remark,
+
+            </trim>
+    </sql>
+    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
+        select
+        <include refid="Base_Column_List" />
+        from banner_info
+        where id = #{id,jdbcType=INTEGER}
+    </select>
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
+        delete from banner_info
+        where id = #{id,jdbcType=INTEGER}
+    </delete>
+    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.BannerInfo" useGeneratedKeys="true" keyProperty="id">
+        insert into banner_info
+        <trim prefix="(" suffix=")" suffixOverrides="," >
+                <if test="id!= null" >
+                id,
+            </if>
+                <if test="delFlag!= null" >
+                del_flag,
+            </if>
+                <if test="title!= null" >
+                title,
+            </if>
+                <if test="subtitle!= null" >
+                subtitle,
+            </if>
+                <if test="image!= null" >
+                image,
+            </if>
+                <if test="newsUrl!= null" >
+                news_url,
+            </if>
+                <if test="rank!= null" >
+                rank,
+            </if>
+                <if test="hot!= null" >
+                hot,
+            </if>
+                <if test="remark!= null" >
+                remark,
+            </if>
+            </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides="," >
+                    <if test="id != null" >
+                #{id,jdbcType=INTEGER},
+            </if>
+                    <if test="delFlag != null" >
+                #{delFlag,jdbcType=CHAR},
+            </if>
+                    <if test="title != null" >
+                #{title,jdbcType=VARCHAR},
+            </if>
+                    <if test="subtitle != null" >
+                #{subtitle,jdbcType=VARCHAR},
+            </if>
+                    <if test="image != null" >
+                #{image,jdbcType=VARCHAR},
+            </if>
+                    <if test="newsUrl != null" >
+                #{newsUrl,jdbcType=VARCHAR},
+            </if>
+                    <if test="rank != null" >
+                #{rank,jdbcType=INTEGER},
+            </if>
+                    <if test="hot != null" >
+                #{hot,jdbcType=INTEGER},
+            </if>
+                    <if test="remark != null" >
+                #{remark,jdbcType=VARCHAR},
+            </if>
+                </trim>
+    </insert>
+    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.BannerInfo" >
+        update banner_info
+        <set >
+                    <if test="id != null" >
+               id= #{id,jdbcType=INTEGER},
+            </if>
+                     <if test="delFlag != null" >
+               del_flag= #{delFlag,jdbcType=CHAR},
+            </if>
+                     <if test="title != null" >
+               title= #{title,jdbcType=VARCHAR},
+            </if>
+                     <if test="subtitle != null" >
+               subtitle= #{subtitle,jdbcType=VARCHAR},
+            </if>
+                     <if test="image != null" >
+               image= #{image,jdbcType=VARCHAR},
+            </if>
+                     <if test="newsUrl != null" >
+               news_url= #{newsUrl,jdbcType=VARCHAR},
+            </if>
+                     <if test="rank != null" >
+               rank= #{rank,jdbcType=INTEGER},
+            </if>
+                     <if test="hot != null" >
+               hot= #{hot,jdbcType=INTEGER},
+            </if>
+                     <if test="remark != null" >
+               remark= #{remark,jdbcType=VARCHAR},
+            </if>
+                 </set>
+        where id = #{id,jdbcType=INTEGER}
+    </update>
+    <select id="queryBannerInfoByPage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.BannerInfo">
+        select <include refid="Base_Column_List"/> from banner_info
+        <where>
+            and del_flag = 'N'
+                    <if test="record.id != null and !&quot;&quot;.equals(record.id)">
+                and  id = #{record.id}
+            </if>
+                     <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
+                and  del_flag = #{record.delFlag}
+            </if>
+                     <if test="record.title != null and !&quot;&quot;.equals(record.title)">
+                and  title = #{record.title}
+            </if>
+                     <if test="record.subtitle != null and !&quot;&quot;.equals(record.subtitle)">
+                and  subtitle = #{record.subtitle}
+            </if>
+                     <if test="record.image != null and !&quot;&quot;.equals(record.image)">
+                and  image = #{record.image}
+            </if>
+                     <if test="record.newsUrl != null and !&quot;&quot;.equals(record.newsUrl)">
+                and  news_url = #{record.newsUrl}
+            </if>
+                     <if test="record.rank != null and !&quot;&quot;.equals(record.rank)">
+                and  rank = #{record.rank}
+            </if>
+                     <if test="record.hot != null and !&quot;&quot;.equals(record.hot)">
+                and  hot = #{record.hot}
+            </if>
+                     <if test="record.remark != null and !&quot;&quot;.equals(record.remark)">
+                and  remark = #{record.remark}
+            </if>
+                  <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
+             <trim prefix="and (" suffix=")" prefixOverrides="OR" >
+                                                                                                                                                                OR  title LIKE concat('%',#{record.searchKey},'%')
+                                                                                                    OR  subtitle LIKE concat('%',#{record.searchKey},'%')
+                                                                                                    OR  image LIKE concat('%',#{record.searchKey},'%')
+                                                                                                    OR  news_url LIKE concat('%',#{record.searchKey},'%')
+                                                                                                    OR  rank LIKE concat('%',#{record.searchKey},'%')
+                                                                                                    OR  hot LIKE concat('%',#{record.searchKey},'%')
+                                                                                                    OR  remark LIKE concat('%',#{record.searchKey},'%')
+                                                             </trim>
+         </if>
+
+            <if test="record.advancedQuery != null and !&quot;&quot;.equals(record.advancedQuery)">
+                <foreach item="item" index="index" collection="record.advancedQuery.split('_;')">
+                    <choose>
+                        <when test="item.indexOf('like') != -1">
+                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                                <if test="detailIndex == 3">
+                                    concat('%',#{itemDetail},'%')
+                                </if>
+
+                                <if test="detailIndex &lt; 3">
+                                    ${itemDetail}
+                                </if>
+
+                            </foreach>
+                        </when>
+                        <otherwise>
+                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                                <if test="detailIndex == 3">
+                                    #{itemDetail}
+                                </if>
+
+                                <if test="detailIndex &lt; 3">
+                                    ${itemDetail}
+                                </if>
+
+                            </foreach>
+                        </otherwise>
+                    </choose>
+
+
+                </foreach>
+
+
+            </if>
+
+        </where>
+        order by id desc
+    </select>
+    <select id="queryAllBannerInfo" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.BannerInfo">
+        select <include refid="Base_Column_List"/> from banner_info
+        <where>
+            and del_flag = 'N'
+                    <if test="id != null and !&quot;&quot;.equals(id)">
+                and  id = #{id}
+            </if>
+                    <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
+                and  del_flag = #{delFlag}
+            </if>
+                    <if test="title != null and !&quot;&quot;.equals(title)">
+                and  title = #{title}
+            </if>
+                    <if test="subtitle != null and !&quot;&quot;.equals(subtitle)">
+                and  subtitle = #{subtitle}
+            </if>
+                    <if test="image != null and !&quot;&quot;.equals(image)">
+                and  image = #{image}
+            </if>
+                    <if test="newsUrl != null and !&quot;&quot;.equals(newsUrl)">
+                and  news_url = #{newsUrl}
+            </if>
+                    <if test="rank != null and !&quot;&quot;.equals(rank)">
+                and  rank = #{rank}
+            </if>
+                    <if test="hot != null and !&quot;&quot;.equals(hot)">
+                and  hot = #{hot}
+            </if>
+                    <if test="remark != null and !&quot;&quot;.equals(remark)">
+                and  remark = #{remark}
+            </if>
+                    <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
+                <trim prefix="and (" suffix=")" prefixOverrides="OR" >
+                                                                                                                                                                                                                                                OR  title LIKE concat('%',#{searchKey},'%')
+                                                                                                                                                        OR  subtitle LIKE concat('%',#{searchKey},'%')
+                                                                                                                                                        OR  image LIKE concat('%',#{searchKey},'%')
+                                                                                                                                                        OR  news_url LIKE concat('%',#{searchKey},'%')
+                                                                                                                                                        OR  rank LIKE concat('%',#{searchKey},'%')
+                                                                                                                                                        OR  hot LIKE concat('%',#{searchKey},'%')
+                                                                                                                                                        OR  remark LIKE concat('%',#{searchKey},'%')
+                                                                                        </trim>
+            </if>
+<if test="advancedQuery != null and !&quot;&quot;.equals(advancedQuery)">
+    <foreach item="item" index="index" collection="advancedQuery.split('_;')">
+        <choose>
+            <when test="item.indexOf('like') != -1">
+                <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                    <if test="detailIndex == 3">
+                        concat('%',#{itemDetail},'%')
+                    </if>
+
+                    <if test="detailIndex &lt; 3">
+                        ${itemDetail}
+                    </if>
+
+                </foreach>
+            </when>
+            <otherwise>
+                <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                    <if test="detailIndex == 3">
+                        #{itemDetail}
+                    </if>
+
+                    <if test="detailIndex &lt; 3">
+                        ${itemDetail}
+                    </if>
+
+                </foreach>
+            </otherwise>
+        </choose>
+
+
+    </foreach>
+
+
+</if>
+        </where>
+        order by id desc
+    </select>
+    <select id="queryBannerInfo" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.BannerInfo">
+        select <include refid="Base_Column_List"/> from banner_info
+        <where>
+            and del_flag = 'N'
+                    <if test="id != null and !&quot;&quot;.equals(id)">
+                and id = #{id}
+            </if>
+                     <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
+                and del_flag = #{delFlag}
+            </if>
+                     <if test="title != null and !&quot;&quot;.equals(title)">
+                and title = #{title}
+            </if>
+                     <if test="subtitle != null and !&quot;&quot;.equals(subtitle)">
+                and subtitle = #{subtitle}
+            </if>
+                     <if test="image != null and !&quot;&quot;.equals(image)">
+                and image = #{image}
+            </if>
+                     <if test="newsUrl != null and !&quot;&quot;.equals(newsUrl)">
+                and news_url = #{newsUrl}
+            </if>
+                     <if test="rank != null and !&quot;&quot;.equals(rank)">
+                and rank = #{rank}
+            </if>
+                     <if test="hot != null and !&quot;&quot;.equals(hot)">
+                and hot = #{hot}
+            </if>
+                     <if test="remark != null and !&quot;&quot;.equals(remark)">
+                and remark = #{remark}
+            </if>
+         
+        </where>
+        LIMIT 1
+    </select>
+    <update id="delete">
+        UPDATE banner_info SET del_flag = 'Y'
+        <where>
+            AND id = #{id}
+        </where>
+    </update>
+    <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.BannerInfo">
+        select <include refid="Base_Column_List"/> from banner_info
+        <where>
+            and del_flag = 'N'
+                                                                                                                                                                                                                                                                                </where>
+        order by id desc
+    </select>
+</mapper>
+

+ 109 - 0
src/main/java/com/izouma/awesomeadmin/model/BannerInfo.java

@@ -0,0 +1,109 @@
+package com.izouma.awesomeadmin.model;
+
+import java.util.*;
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+
+@JsonAutoDetect
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class BannerInfo{
+    private Integer id;
+    private String delFlag;
+    private String title;
+    private String subtitle;
+    private String image;
+    private String newsUrl;
+    private Integer rank;
+    private Integer hot;
+    private String remark;
+
+private String searchKey;
+
+/**
+* and,test_name,like,value;or,remark,=,123
+*/
+private String advancedQuery;
+
+    public Integer getId(){
+        return this.id;
+    }
+
+    public void setId(Integer id){
+        this.id = id;
+    }
+    public String getDelFlag(){
+        return this.delFlag;
+    }
+
+    public void setDelFlag(String delFlag){
+        this.delFlag = delFlag;
+    }
+    public String getTitle(){
+        return this.title;
+    }
+
+    public void setTitle(String title){
+        this.title = title;
+    }
+    public String getSubtitle(){
+        return this.subtitle;
+    }
+
+    public void setSubtitle(String subtitle){
+        this.subtitle = subtitle;
+    }
+    public String getImage(){
+        return this.image;
+    }
+
+    public void setImage(String image){
+        this.image = image;
+    }
+    public String getNewsUrl(){
+        return this.newsUrl;
+    }
+
+    public void setNewsUrl(String newsUrl){
+        this.newsUrl = newsUrl;
+    }
+    public Integer getRank(){
+        return this.rank;
+    }
+
+    public void setRank(Integer rank){
+        this.rank = rank;
+    }
+    public Integer getHot(){
+        return this.hot;
+    }
+
+    public void setHot(Integer hot){
+        this.hot = hot;
+    }
+    public String getRemark(){
+        return this.remark;
+    }
+
+    public void setRemark(String remark){
+        this.remark = remark;
+    }
+
+public String getSearchKey() {
+    return searchKey;
+}
+
+public void setSearchKey(String searchKey) {
+    this.searchKey = searchKey;
+}
+
+public String getAdvancedQuery() {
+    return advancedQuery;
+}
+
+public void setAdvancedQuery(String advancedQuery) {
+    this.advancedQuery = advancedQuery;
+}
+
+}
+

+ 10 - 0
src/main/java/com/izouma/awesomeadmin/model/GenCode.java

@@ -77,6 +77,8 @@ public class GenCode {
     private List<TableField> fields;    // 表字段
     private TableField primaryField; //主键字段
 
+    private Boolean readTable;
+
     public List<TableField> getFields() {
         return fields;
     }
@@ -188,5 +190,13 @@ public class GenCode {
     public void setDataBaseType(String dataBaseType) {
         this.dataBaseType = dataBaseType;
     }
+
+    public Boolean getReadTable() {
+        return readTable;
+    }
+
+    public void setReadTable(Boolean readTable) {
+        this.readTable = readTable;
+    }
 }
 

+ 27 - 0
src/main/java/com/izouma/awesomeadmin/service/BannerInfoService.java

@@ -0,0 +1,27 @@
+package com.izouma.awesomeadmin.service;
+
+import java.util.*;
+import com.izouma.awesomeadmin.dto.Page;
+import com.izouma.awesomeadmin.model.BannerInfo;
+
+
+/**
+*  service接口类
+*/
+public interface BannerInfoService{
+
+    List<BannerInfo> getBannerInfoList(BannerInfo record);
+
+    List<BannerInfo> getBannerInfoByPage(Page page, BannerInfo record);
+
+    BannerInfo getBannerInfoById(String id);
+
+    BannerInfo getBannerInfo(BannerInfo record);
+
+    boolean createBannerInfo(BannerInfo record);
+
+    boolean deleteBannerInfo(String id);
+
+    boolean updateBannerInfo(BannerInfo record);
+}
+

+ 137 - 0
src/main/java/com/izouma/awesomeadmin/service/impl/BannerInfoServiceImpl.java

@@ -0,0 +1,137 @@
+package com.izouma.awesomeadmin.service.impl;
+
+import java.util.*;
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.izouma.awesomeadmin.constant.AppConstant;
+import com.izouma.awesomeadmin.dto.Page;
+import com.izouma.awesomeadmin.model.BannerInfo;
+import com.izouma.awesomeadmin.service.BannerInfoService;
+import com.izouma.awesomeadmin.dao.BannerInfoMapper;
+
+/**
+*  service接口实现类
+*/
+@Service
+public class BannerInfoServiceImpl implements BannerInfoService{
+
+    private static Logger logger = Logger.getLogger(BannerInfoServiceImpl.class);
+
+    @Autowired
+    private BannerInfoMapper bannerInfoMapper;
+
+    @Override
+    public List<BannerInfo> getBannerInfoList(BannerInfo record) {
+
+        logger.info("getBannerInfoList");
+        try {
+
+        return bannerInfoMapper.queryAllBannerInfo(record);
+        } catch (Exception e) {
+        logger.error("getBannerInfoList", e);
+        }
+
+        return null;
+    }
+    @Override
+    public List<BannerInfo> getBannerInfoByPage(Page page, BannerInfo record) {
+
+        logger.info("getBannerInfoByPage");
+        try {
+
+        Map<String, Object> parameter = new HashMap<String, Object>();
+        parameter.put("record", record);
+        parameter.put(AppConstant.PAGE, page);
+
+        return bannerInfoMapper.queryBannerInfoByPage(parameter);
+        } catch (Exception e) {
+        logger.error("getBannerInfoByPage", e);
+        }
+
+        return null;
+    }
+
+    @Override
+    public BannerInfo getBannerInfoById(String id) {
+
+        logger.info("getBannerInfoyId");
+        try {
+
+            return bannerInfoMapper.selectByPrimaryKey(Integer.valueOf(id));
+        } catch (Exception e) {
+        logger.error("getBannerInfoById", e);
+        }
+
+        return null;
+    }
+
+    @Override
+    public BannerInfo getBannerInfo(BannerInfo record) {
+
+        logger.info("getBannerInfo");
+        try {
+
+            return bannerInfoMapper.queryBannerInfo(record);
+        } catch (Exception e) {
+        logger.error("getBannerInfo", e);
+        }
+
+        return null;
+    }
+
+    @Override
+    public boolean createBannerInfo(BannerInfo record) {
+
+        logger.info("createBannerInfo");
+        try {
+
+            int updates = bannerInfoMapper.insertSelective(record);
+
+            if (updates > 0) {
+                 return true;
+            }
+        } catch (Exception e) {
+            logger.error("createBannerInfo", e);
+        }
+
+        return false;
+    }
+
+    @Override
+    public boolean deleteBannerInfo(String id) {
+
+        logger.info("deleteBannerInfo");
+        try {
+
+             int updates = bannerInfoMapper.delete(id);
+
+            if (updates > 0) {
+                 return true;
+            }
+        } catch (Exception e) {
+             logger.error("deleteBannerInfo", e);
+        }
+
+        return false;
+    }
+
+    @Override
+    public boolean updateBannerInfo(BannerInfo record) {
+
+        logger.info("updateBannerInfo");
+        try {
+
+            int updates = bannerInfoMapper.updateByPrimaryKeySelective(record);
+
+            if (updates > 0) {
+                 return true;
+            }
+        } catch (Exception e) {
+             logger.error("updateBannerInfo", e);
+        }
+
+        return false;
+    }
+}
+

+ 55 - 51
src/main/java/com/izouma/awesomeadmin/util/ExportExcelUtil.java

@@ -94,34 +94,36 @@ public class ExportExcelUtil {
                 cell.setCellStyle(style);
             }
 
+
+            // 为数据内容设置特点新单元格样式1 自动换行 上下居中
+            HSSFCellStyle zidonghuanhang = wb.createCellStyle();
+            zidonghuanhang.setWrapText(true);// 设置自动换行
+            zidonghuanhang.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 创建一个居中格式
+
+            // 设置边框
+            zidonghuanhang.setBottomBorderColor(HSSFColor.BLACK.index);
+            zidonghuanhang.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+            zidonghuanhang.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+            zidonghuanhang.setBorderRight(HSSFCellStyle.BORDER_THIN);
+            zidonghuanhang.setBorderTop(HSSFCellStyle.BORDER_THIN);
+
+            // 为数据内容设置特点新单元格样式2 自动换行 上下居中左右也居中
+            HSSFCellStyle zidonghuanhang2 = wb.createCellStyle();
+            zidonghuanhang2.setWrapText(true);// 设置自动换行
+            zidonghuanhang2
+                    .setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 创建一个上下居中格式
+            zidonghuanhang2.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
+
+            // 设置边框
+            zidonghuanhang2.setBottomBorderColor(HSSFColor.BLACK.index);
+            zidonghuanhang2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+            zidonghuanhang2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+            zidonghuanhang2.setBorderRight(HSSFCellStyle.BORDER_THIN);
+            zidonghuanhang2.setBorderTop(HSSFCellStyle.BORDER_THIN);
             // 第五步,创建单元格,并设置值
             for (int i = 0; i < dataList.length; i++) {
                 row = sheet.createRow((int) i + 2);
-                // 为数据内容设置特点新单元格样式1 自动换行 上下居中
-                HSSFCellStyle zidonghuanhang = wb.createCellStyle();
-                zidonghuanhang.setWrapText(true);// 设置自动换行
-                zidonghuanhang.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 创建一个居中格式
-
-                // 设置边框
-                zidonghuanhang.setBottomBorderColor(HSSFColor.BLACK.index);
-                zidonghuanhang.setBorderBottom(HSSFCellStyle.BORDER_THIN);
-                zidonghuanhang.setBorderLeft(HSSFCellStyle.BORDER_THIN);
-                zidonghuanhang.setBorderRight(HSSFCellStyle.BORDER_THIN);
-                zidonghuanhang.setBorderTop(HSSFCellStyle.BORDER_THIN);
-
-                // 为数据内容设置特点新单元格样式2 自动换行 上下居中左右也居中
-                HSSFCellStyle zidonghuanhang2 = wb.createCellStyle();
-                zidonghuanhang2.setWrapText(true);// 设置自动换行
-                zidonghuanhang2
-                        .setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 创建一个上下居中格式
-                zidonghuanhang2.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
-
-                // 设置边框
-                zidonghuanhang2.setBottomBorderColor(HSSFColor.BLACK.index);
-                zidonghuanhang2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
-                zidonghuanhang2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
-                zidonghuanhang2.setBorderRight(HSSFCellStyle.BORDER_THIN);
-                zidonghuanhang2.setBorderTop(HSSFCellStyle.BORDER_THIN);
+
                 HSSFCell datacell = null;
                 for (int j = 0; j < columnNumber; j++) {
                     datacell = row.createCell(j);
@@ -232,35 +234,37 @@ public class ExportExcelUtil {
                 cell.setCellStyle(style);
             }
 
+            // 为数据内容设置特点新单元格样式1 自动换行 上下居中
+            HSSFCellStyle zidonghuanhang = wb.createCellStyle();
+            zidonghuanhang.setWrapText(true);// 设置自动换行
+            zidonghuanhang
+                    .setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 创建一个居中格式
+
+            // 设置边框
+            zidonghuanhang.setBottomBorderColor(HSSFColor.BLACK.index);
+            zidonghuanhang.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+            zidonghuanhang.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+            zidonghuanhang.setBorderRight(HSSFCellStyle.BORDER_THIN);
+            zidonghuanhang.setBorderTop(HSSFCellStyle.BORDER_THIN);
+
+            // 为数据内容设置特点新单元格样式2 自动换行 上下居中左右也居中
+            HSSFCellStyle zidonghuanhang2 = wb.createCellStyle();
+            zidonghuanhang2.setWrapText(true);// 设置自动换行
+            zidonghuanhang2
+                    .setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 创建一个上下居中格式
+            zidonghuanhang2.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
+
+            // 设置边框
+            zidonghuanhang2.setBottomBorderColor(HSSFColor.BLACK.index);
+            zidonghuanhang2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+            zidonghuanhang2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+            zidonghuanhang2.setBorderRight(HSSFCellStyle.BORDER_THIN);
+            zidonghuanhang2.setBorderTop(HSSFCellStyle.BORDER_THIN);
+
             // 第五步,创建单元格,并设置值
             for (int i = 0; i < dataList.length; i++) {
                 row = sheet.createRow((int) i + 2);
-                // 为数据内容设置特点新单元格样式1 自动换行 上下居中
-                HSSFCellStyle zidonghuanhang = wb.createCellStyle();
-                zidonghuanhang.setWrapText(true);// 设置自动换行
-                zidonghuanhang
-                        .setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 创建一个居中格式
-
-                // 设置边框
-                zidonghuanhang.setBottomBorderColor(HSSFColor.BLACK.index);
-                zidonghuanhang.setBorderBottom(HSSFCellStyle.BORDER_THIN);
-                zidonghuanhang.setBorderLeft(HSSFCellStyle.BORDER_THIN);
-                zidonghuanhang.setBorderRight(HSSFCellStyle.BORDER_THIN);
-                zidonghuanhang.setBorderTop(HSSFCellStyle.BORDER_THIN);
-
-                // 为数据内容设置特点新单元格样式2 自动换行 上下居中左右也居中
-                HSSFCellStyle zidonghuanhang2 = wb.createCellStyle();
-                zidonghuanhang2.setWrapText(true);// 设置自动换行
-                zidonghuanhang2
-                        .setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 创建一个上下居中格式
-                zidonghuanhang2.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
-
-                // 设置边框
-                zidonghuanhang2.setBottomBorderColor(HSSFColor.BLACK.index);
-                zidonghuanhang2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
-                zidonghuanhang2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
-                zidonghuanhang2.setBorderRight(HSSFCellStyle.BORDER_THIN);
-                zidonghuanhang2.setBorderTop(HSSFCellStyle.BORDER_THIN);
+
                 HSSFCell datacell = null;
                 for (int j = 0; j < columnNumber; j++) {
                     datacell = row.createCell(j);

+ 160 - 0
src/main/java/com/izouma/awesomeadmin/web/BannerInfoController.java

@@ -0,0 +1,160 @@
+package com.izouma.awesomeadmin.web;
+
+import java.util.*;
+
+import com.izouma.awesomeadmin.util.ExportExcelUtil;
+import org.apache.commons.lang.StringUtils;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+import com.izouma.awesomeadmin.constant.AppConstant;
+import com.izouma.awesomeadmin.dto.Page;
+import com.izouma.awesomeadmin.dto.Result;
+import com.izouma.awesomeadmin.model.BannerInfo;
+import com.izouma.awesomeadmin.service.BannerInfoService;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+*  controller类
+*/
+@Controller
+@RequestMapping("/bannerInfo")
+public class BannerInfoController extends BaseController{
+
+    @Autowired
+    private BannerInfoService bannerInfoService;
+
+    /**
+    * <p>获取全部记录。</p>
+    */
+    @RequiresAuthentication
+    @RequestMapping(value = "/all", method = RequestMethod.GET)
+    @ResponseBody
+    public Result all(BannerInfo record) {
+        List<BannerInfo> pp = bannerInfoService.getBannerInfoList(record);
+        return new Result(true, pp);
+    }
+
+    /**
+    * <p>根据Id。</p>
+    */
+    @RequestMapping(value = "/getBannerInfo", method = RequestMethod.GET)
+    @ResponseBody
+    public Result getBannerInfo(@RequestParam(required = false, value = "id") String id) {
+        BannerInfo data = bannerInfoService.getBannerInfoById(id);
+        return new Result(true, data);
+    }
+
+    /**
+    * <p>根据条件获取。</p>
+    */
+    @RequestMapping(value = "/getOne", method = RequestMethod.GET)
+    @ResponseBody
+    public Result getOne(BannerInfo record) {
+        BannerInfo data = bannerInfoService.getBannerInfo(record);
+        return new Result(true, data);
+    }
+
+
+    /**
+    * <p>分页查询。</p>
+    */
+    @RequestMapping(value = "/page", method = RequestMethod.GET)
+    @ResponseBody
+    public Result page(Page page, BannerInfo record) {
+        Map<String, Object> result = new HashMap<>();
+
+        List<BannerInfo> pp =bannerInfoService.getBannerInfoByPage(page, record);
+
+        result.put(AppConstant.PAGE, page);
+        result.put("pp", pp);
+        return new Result(true, result);
+    }
+
+
+    /**
+    * <p>保存。</p>
+    */
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    @ResponseBody
+    public Result save(BannerInfo record) {
+        boolean num = bannerInfoService.createBannerInfo(record);
+        if (num) {
+        return new Result(true, record.getId());
+        }
+        return new Result(false, "保存异常");
+    }
+
+    /**
+    * <p>更新信息。</p>
+    */
+    @RequestMapping(value = "/update", method = RequestMethod.POST)
+    @ResponseBody
+    public Result updateBannerInfo(BannerInfo record) {
+        boolean num = bannerInfoService.updateBannerInfo(record);
+        if (num) {
+        return new Result(true, "保存成功");
+        }
+        return new Result(false, "保存异常");
+    }
+
+    /**
+    * <p>删除。</p>
+    */
+    @RequestMapping(value = "/del", method = RequestMethod.POST)
+    @ResponseBody
+    public Result deleteBannerInfo(@RequestParam(required = true, value = "id") String id) {
+
+        boolean num = bannerInfoService.deleteBannerInfo(id);
+        if (num) {
+        return new Result(true, "删除成功");
+        }
+        return new Result(false, "删除异常");
+    }
+
+    /**
+    * 导出Excel
+    * @param request
+    * @param response
+    * @param record
+    * @throws Exception
+    */
+    @RequestMapping(value = "/exportExcel", method = RequestMethod.GET)
+    @ResponseBody
+    public void exportExcel(HttpServletRequest request, HttpServletResponse response, BannerInfo record) throws Exception {
+
+    List<BannerInfo> bannerInfos = bannerInfoService.getBannerInfoList(record);
+
+
+        String sheetName = "banner_info";
+        String titleName = "首页banner数据表";
+        String fileName = "首页banner表";
+        int columnNumber = 9;
+        int[] columnWidth = { 20,  20,  20,  20,  20,  20,  20,  20,  20 };
+        String[] columnName = {  "" ,   "删除标识" ,   "标题" ,   "副标题" ,   "图片" ,   "链接" ,   "排序" ,   "热度" ,   "备注"  };
+        String[][] dataList = new String[bannerInfos.size()][9];
+
+        for (int i = 0; i < bannerInfos.size(); i++) {
+
+                        dataList[i][0] = String.valueOf(bannerInfos.get(i).getId());
+                        dataList[i][1] = String.valueOf(bannerInfos.get(i).getDelFlag());
+                        dataList[i][2] = String.valueOf(bannerInfos.get(i).getTitle());
+                        dataList[i][3] = String.valueOf(bannerInfos.get(i).getSubtitle());
+                        dataList[i][4] = String.valueOf(bannerInfos.get(i).getImage());
+                        dataList[i][5] = String.valueOf(bannerInfos.get(i).getNewsUrl());
+                        dataList[i][6] = String.valueOf(bannerInfos.get(i).getRank());
+                        dataList[i][7] = String.valueOf(bannerInfos.get(i).getHot());
+                        dataList[i][8] = String.valueOf(bannerInfos.get(i).getRemark());
+                    }
+
+
+        ExportExcelUtil.ExportWithResponse(sheetName, titleName, fileName,
+        columnNumber, columnWidth, columnName, dataList, response);
+
+
+        }
+    }
+

+ 5 - 1
src/main/java/com/izouma/codegenerator/ControllerGenerator.java

@@ -12,7 +12,9 @@ import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
 
 public class ControllerGenerator {
     public static void GenController(GenCode model) {
@@ -24,6 +26,8 @@ public class ControllerGenerator {
             Properties pro = new Properties();
             pro.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
             pro.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, templatePath);
+            pro.setProperty("directive.foreach.counter.name", "velocityCount");
+            pro.setProperty("directive.foreach.counter.initial.value", "1");
             Velocity.init(pro);
             ToolManager manager = new ToolManager(true, true);
             VelocityContext context = new VelocityContext(manager.createContext());

+ 5 - 1
src/main/java/com/izouma/codegenerator/EditViewGenerator.java

@@ -11,7 +11,9 @@ import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
 
 public class EditViewGenerator {
     public static void GenEditView(GenCode model) {
@@ -22,6 +24,8 @@ public class EditViewGenerator {
             Properties pro = new Properties();
             pro.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
             pro.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, templatePath);
+            pro.setProperty("directive.foreach.counter.name", "velocityCount");
+            pro.setProperty("directive.foreach.counter.initial.value", "1");
             Velocity.init(pro);
             ToolManager manager = new ToolManager(true, true);
             VelocityContext context = new VelocityContext(manager.createContext());

+ 2 - 0
src/main/java/com/izouma/codegenerator/GenList.java

@@ -49,6 +49,8 @@ public class GenList {
             Properties pro = new Properties();
             pro.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
             pro.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, "/Users/xiongzhu/Projects/Java/awesomeAdmin/src/main/java/com/izouma/ModelGenerator/templates");
+            pro.setProperty("directive.foreach.counter.name", "velocityCount");
+            pro.setProperty("directive.foreach.counter.initial.value", "1");
             Velocity.init(pro);
             ToolManager manager = new ToolManager(true, true);
             VelocityContext context = new VelocityContext(manager.createContext());

+ 2 - 0
src/main/java/com/izouma/codegenerator/GeneratorTool.java

@@ -65,6 +65,8 @@ public class GeneratorTool {
             return "INTEGER";
         } else if (jdbcType.equalsIgnoreCase("datetime")) {
             return "TIMESTAMP";
+        } else if (jdbcType.equalsIgnoreCase("nvarchar")) {
+            return "VARCHAR";
         }
         return jdbcType.toUpperCase();
     }

+ 5 - 1
src/main/java/com/izouma/codegenerator/ListViewGenerator.java

@@ -11,7 +11,9 @@ import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
 
 public class ListViewGenerator {
     public static void GenListView(GenCode model) {
@@ -22,6 +24,8 @@ public class ListViewGenerator {
             Properties pro = new Properties();
             pro.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
             pro.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, templatePath);
+            pro.setProperty("directive.foreach.counter.name", "velocityCount");
+            pro.setProperty("directive.foreach.counter.initial.value", "1");
             Velocity.init(pro);
             ToolManager manager = new ToolManager(true, true);
             VelocityContext context = new VelocityContext(manager.createContext());

+ 5 - 1
src/main/java/com/izouma/codegenerator/MapperGenerator.java

@@ -12,7 +12,9 @@ import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
 
 public class MapperGenerator {
     public static void GenMapper(GenCode model) {
@@ -24,6 +26,8 @@ public class MapperGenerator {
             Properties pro = new Properties();
             pro.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
             pro.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, templatePath);
+            pro.setProperty("directive.foreach.counter.name", "velocityCount");
+            pro.setProperty("directive.foreach.counter.initial.value", "1");
             Velocity.init(pro);
             ToolManager manager = new ToolManager(true, true);
             VelocityContext context = new VelocityContext(manager.createContext());

+ 5 - 1
src/main/java/com/izouma/codegenerator/MapperXmlGenerator.java

@@ -12,7 +12,9 @@ import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
 
 public class MapperXmlGenerator {
     public static void GenXml(GenCode model) {
@@ -23,6 +25,8 @@ public class MapperXmlGenerator {
             Properties pro = new Properties();
             pro.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
             pro.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, templatePath);
+            pro.setProperty("directive.foreach.counter.name", "velocityCount");
+            pro.setProperty("directive.foreach.counter.initial.value", "1");
             Velocity.init(pro);
             ToolManager manager = new ToolManager(true, true);
             VelocityContext context = new VelocityContext(manager.createContext());

+ 5 - 1
src/main/java/com/izouma/codegenerator/ModelGenerator.java

@@ -12,7 +12,9 @@ import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
 
 public class ModelGenerator {
     public static void GenModel(GenCode model) {
@@ -25,6 +27,8 @@ public class ModelGenerator {
             Properties pro = new Properties();
             pro.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
             pro.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, templatePath);
+            pro.setProperty("directive.foreach.counter.name", "velocityCount");
+            pro.setProperty("directive.foreach.counter.initial.value", "1");
             Velocity.init(pro);
             ToolManager manager = new ToolManager(true, true);
             VelocityContext context = new VelocityContext(manager.createContext());

+ 124 - 0
src/main/java/com/izouma/codegenerator/ReadTableGenerator.java

@@ -0,0 +1,124 @@
+package com.izouma.codegenerator;
+
+import com.izouma.awesomeadmin.model.GenCode;
+import com.izouma.awesomeadmin.model.TableField;
+import com.izouma.awesomeadmin.util.PropertiesFileLoader;
+import org.apache.commons.lang.StringUtils;
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class ReadTableGenerator {
+
+    public static void ReadTable(GenCode model) throws Exception {
+        Connection conn = null;
+        try {
+
+            String[] colnames; // 列名数组
+            String[] colTypes; //列名类型数组
+            String[] colComments;//列名注释数组mybatis-generator-core
+
+            int[] colSizes; //列名大小数组
+
+            String PK_NAME = "id";//主键名
+
+            //查要生成实体类的表
+            String sql = "select * from " + model.getTableName();
+            PreparedStatement pStemt = null;
+
+            if ("Mysql".equals(model.getDataBaseType())) {
+                Class.forName("com.mysql.jdbc.Driver");
+                System.out.println("成功加载MySQL驱动!");
+
+                PropertiesFileLoader propertiesFileLoader = PropertiesFileLoader.getInstance();
+                propertiesFileLoader.getProperties("properties/jdbc.properties", "jdbc.url");
+
+                String url = propertiesFileLoader.getProperties("properties/jdbc.properties", "jdbc.url");
+                String user = propertiesFileLoader.getProperties("properties/jdbc.properties", "jdbc.username");
+                String password = propertiesFileLoader.getProperties("properties/jdbc.properties", "jdbc.password");
+                conn = DriverManager.getConnection(url, user, password);
+
+                System.out.println("成功连接到数据库!");
+            } else if ("SqlServer".equals(model.getDataBaseType())) {
+                Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
+                System.out.println("成功加载SQLServer驱动!");
+
+                PropertiesFileLoader propertiesFileLoader = PropertiesFileLoader.getInstance();
+                propertiesFileLoader.getProperties("properties/jdbc.properties", "jdbc.url");
+
+                String url = propertiesFileLoader.getProperties("properties/jdbc.properties", "sqlserver.url");
+                String user = propertiesFileLoader.getProperties("properties/jdbc.properties", "sqlserver.user");
+                String password = propertiesFileLoader.getProperties("properties/jdbc.properties", "sqlserver.password");
+                conn = DriverManager.getConnection(url, user, password);
+            }
+
+
+            pStemt = conn.prepareStatement(sql);
+
+            ResultSetMetaData rsmd = pStemt.getMetaData();
+
+            ResultSet pkRSet = conn.getMetaData().getPrimaryKeys(conn.getCatalog().toUpperCase(),
+                    null, model.getTableName());
+
+            while (pkRSet.next()) {
+                System.out.println(pkRSet.getString("COLUMN_NAME"));
+                PK_NAME = pkRSet.getString("COLUMN_NAME");
+            }
+
+
+            int size = rsmd.getColumnCount();   //统计列
+            colComments = new String[size];
+            colnames = new String[size];
+            colTypes = new String[size];
+            colSizes = new int[size];
+            for (int i = 0; i < size; i++) {
+                colnames[i] = rsmd.getColumnName(i + 1);
+                colTypes[i] = rsmd.getColumnTypeName(i + 1);
+                colSizes[i] = rsmd.getColumnDisplaySize(i + 1);
+            }
+
+
+            if ("Mysql".equals(model.getDataBaseType())) {
+                //获取注释
+                ResultSet rs = pStemt.executeQuery("show full columns from " + model.getTableName());
+                int j = 0;
+                while (rs.next()) {
+                    colComments[j] = (rs.getString("Comment"));
+                    j++;
+                }
+            }
+            List<TableField> tableFields = new ArrayList<>();
+
+
+            for (int i = 0; i < colnames.length; i++) {
+                TableField tableField = new TableField();
+
+                tableField.setName(colnames[i]);
+                tableField.setJdbcType(colTypes[i]);
+                tableField.setNotNull(false);
+                tableField.setPrimaryKey(PK_NAME.equals(colnames[i]) ? true : false);
+                tableField.setAutoIncrease(PK_NAME.equals(colnames[i]) ? true : false);
+                tableField.setRemark((StringUtils.isNotEmpty(colComments[i]) ? colComments[i] : colnames[i]));
+                tableField.setShowInList(true);
+                tableField.setShowInForm("ID".equalsIgnoreCase(colnames[i]) ? false : true);
+                tableField.setFormType("singleLineText");
+
+                tableFields.add(tableField);
+            }
+
+            model.setFields(tableFields);
+
+            System.out.println("读取数据表成功");
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            conn.close();
+        }
+
+    }
+
+}
+

+ 5 - 1
src/main/java/com/izouma/codegenerator/ServiceGenerator.java

@@ -12,7 +12,9 @@ import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
 
 public class ServiceGenerator {
     public static void GenService(GenCode model) {
@@ -24,6 +26,8 @@ public class ServiceGenerator {
             Properties pro = new Properties();
             pro.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
             pro.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, templatePath);
+            pro.setProperty("directive.foreach.counter.name", "velocityCount");
+            pro.setProperty("directive.foreach.counter.initial.value", "1");
             Velocity.init(pro);
             ToolManager manager = new ToolManager(true, true);
             VelocityContext context = new VelocityContext(manager.createContext());

+ 5 - 1
src/main/java/com/izouma/codegenerator/ServiceImplGenerator.java

@@ -12,7 +12,9 @@ import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
 
 public class ServiceImplGenerator {
     public static void GemServicelImpl(GenCode model) {
@@ -24,6 +26,8 @@ public class ServiceImplGenerator {
             Properties pro = new Properties();
             pro.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
             pro.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, templatePath);
+            pro.setProperty("directive.foreach.counter.name", "velocityCount");
+            pro.setProperty("directive.foreach.counter.initial.value", "1");
             Velocity.init(pro);
             ToolManager manager = new ToolManager(true, true);
             VelocityContext context = new VelocityContext(manager.createContext());

+ 7 - 0
src/main/java/com/izouma/codegenerator/TableGenerator.java

@@ -159,6 +159,13 @@ public class TableGenerator {
             }
             String str = sql.substring(0, sql.lastIndexOf(","));
             String sql1 = str + " )";
+
+            if (StringUtils.isNotEmpty(model.getRemark())) {
+                if ("Mysql".equals(model.getDataBaseType())) {
+                    sql1 += " comment = " + "'" + model.getRemark() + "'";
+                }
+            }
+
             System.out.println(sql1);
             int result = stmt.executeUpdate(sql1);
             if (result != -1) {

+ 44 - 1
src/main/resources/templates/ControllerTemplate.vm

@@ -4,6 +4,9 @@ package com.izouma.awesomeadmin.web;
 $import
 #end
 import java.util.*;
+
+import com.izouma.awesomeadmin.util.ExportExcelUtil;
+import org.apache.commons.lang.StringUtils;
 import org.apache.shiro.authz.annotation.RequiresAuthentication;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -14,6 +17,9 @@ import com.izouma.awesomeadmin.dto.Result;
 import com.izouma.awesomeadmin.model.${model.className};
 import com.izouma.awesomeadmin.service.${model.className}Service;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 /**
 *  controller类
 */
@@ -111,5 +117,42 @@ public class ${model.className}Controller extends BaseController{
         }
         return new Result(false, "删除异常");
     }
-}
+
+    /**
+    * 导出Excel
+    * @param request
+    * @param response
+    * @param record
+    * @throws Exception
+    */
+    @RequestMapping(value = "/exportExcel", method = RequestMethod.GET)
+    @ResponseBody
+    public void exportExcel(HttpServletRequest request, HttpServletResponse response, ${model.className} record) throws Exception {
+
+    List<${model.className}> ${display.uncapitalize(${model.className})}s = ${display.uncapitalize(${model.className})}Service.get${model.className}List(record);
+
+
+        String sheetName = "${model.tableName}";
+        String titleName = "${model.remark}数据表";
+        String fileName = "${model.remark}表";
+        int columnNumber = ${model.fields.size()};
+        int[] columnWidth = {#foreach(${field} in ${model.fields}) 20#if(${velocityCount} != ${model.fields.size()}),#end #end};
+        String[] columnName = {#foreach(${field} in ${model.fields}) #if(${field.remark}) "${field.remark}" #else "${field.modelName}"#end#if(${velocityCount} != ${model.fields.size()}),#end #end};
+        String[][] dataList = new String[${display.uncapitalize(${model.className})}s.size()][${model.fields.size()}];
+
+        for (int i = 0; i < ${display.uncapitalize(${model.className})}s.size(); i++) {
+
+            #foreach(${field} in ${model.fields})
+                #set($fund=$velocityCount - 1)
+            dataList[i][$fund] = String.valueOf(${display.uncapitalize(${model.className})}s.get(i).get${display.capitalize($field.modelName)}());
+            #end
+        }
+
+
+        ExportExcelUtil.ExportWithResponse(sheetName, titleName, fileName,
+        columnNumber, columnWidth, columnName, dataList, response);
+
+
+        }
+    }
 

+ 115 - 7
src/main/resources/templates/ListTemplate.vm

@@ -6,8 +6,8 @@
              <el-input placeholder="${field.remark}" size="small" v-model="${field.name}" clearable class="filter-item"></el-input>
              #end
              #end*#
-            <el-input placeholder="用户名" size="small" v-model="filter1" clearable class="filter-item"></el-input>
-            <el-select placeholder="性别" size="small" v-model="filter2" clearable class="filter-item">
+            <el-input placeholder="关键字" size="small" v-model="filter1" clearable class="filter-item"></el-input>
+              <!--<el-select placeholder="性别" size="small" v-model="filter2" clearable class="filter-item">
                 <el-option
                         label="女"
                         value="item1">
@@ -16,13 +16,16 @@
                         label="男"
                         value="item2">
                 </el-option>
-            </el-select>
-
+            </el-select>-->
+            <el-button @click="showAdvancedQueryDialog = !showAdvancedQueryDialog" type="primary" size="small" icon="el-icon-search" class="filter-item">高级查询
+            </el-button>
             <el-button @click="getData" type="primary" size="small" icon="el-icon-search" class="filter-item">搜索
             </el-button>
             <el-button @click="${esc.d}router.push('/${display.uncapitalize($model.className)}')" type="primary" size="small" icon="el-icon-edit"
                        class="filter-item">添加
             </el-button>
+            <el-button @click="exportExcel" type="primary" size="small" icon="el-icon-share" class="filter-item">导出EXCEL
+            </el-button>
             <el-dropdown trigger="click" size="medium" class="table-column-filter">
                 <span>
                   筛选数据<i class="el-icon-arrow-down el-icon--right"></i>
@@ -88,6 +91,53 @@
                     :total="totalNumber">
             </el-pagination>
         </div>
+        <el-dialog title="高级查询" :visible.sync="showAdvancedQueryDialog">
+            <el-button @click="addField" type="text" icon="el-icon-plus">添加</el-button>
+            <el-table :data="advancedQueryFields">
+
+                <el-table-column prop="link" label="链接符" align="center">
+                    <template slot-scope="{row}">
+                        <el-select placeholder="链接" size="small" v-model="row.link" class="filter-item">
+                            <el-option label="AND" value="AND">
+                            </el-option>
+                            <el-option label="OR" value="OR">
+                            </el-option>
+                        </el-select>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="name" label="字段" align="center">
+                    <template slot-scope="{row}">
+                        <el-select v-model="row.name">
+
+                            <el-option v-for="item in advancedQueryColumns" :label="item.label" :value="item.value" :key="item.value"></el-option>
+                        </el-select>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="searchMethod" label="搜索方式" width="150" align="center">
+                    <template slot-scope="{row}">
+                        <el-select v-model="row.searchMethod">
+                            <el-option v-for="item in searchMethods" :label="item" :value="item" :key="item"></el-option>
+                        </el-select>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="value" label="参数" align="center">
+                    <template slot-scope="{row}">
+                        <el-input v-model="row.value"></el-input>
+                    </template>
+                </el-table-column>
+                <el-table-column width="60" align="center">
+                    <template slot-scope="{ row, column, $index }">
+                        <el-button @click="removeField($index)" size="small" type="text">删除</el-button>
+                    </template>
+                </el-table-column>
+            </el-table>
+
+            <span slot="footer" class="dialog-footer">
+
+                <el-button @click="advancedQuery" :loading="$store.state.fetchingData">确定</el-button>
+            </span>
+        </el-dialog>
+
     </div>
 </template>
 <script>
@@ -117,7 +167,21 @@
             #end
         #end
                 ],
-                multipleMode: false
+                multipleMode: false,
+                showAdvancedQueryDialog: false,
+                advancedQueryFields: [],
+                searchMethods: ['=', '!=', '>', '>=', '<', '<=', 'like'],
+                advancedQueryColumns: [
+                    #foreach($field in $model.fields)
+                        #if(${field.showInList})
+                            {
+                                label: '$display.alt(${field.remark},${field.modelName})',
+                                value: '${field.name}'
+                            },
+                        #end
+                    #end
+                ],
+                advancedQuerySearchKey: '',
             }
         },
         computed: {
@@ -128,6 +192,7 @@
         },
         methods: {
             pageSizeChange(size) {
+                this.currentPage = 1;
                 this.pageSize = size;
                 this.getData();
             },
@@ -140,7 +205,9 @@
                 url: '/${display.uncapitalize($model.className)}/page',
                 data: {
                     currentPage: this.currentPage,
-                    pageNumber: this.pageSize
+                    pageNumber: this.pageSize,
+                    searchKey: this.filter1,
+                    advancedQuery: this.advancedQuerySearchKey,
                 }
                 }).then(res => {
                     if (res.success) {
@@ -175,7 +242,48 @@
             },
             operation2() {
                 this.${esc.d}message('操作2');
-            }
+            },
+            addField() {
+                this.advancedQueryFields.push({
+                    link: 'AND',
+                    name: '',
+                    searchMethod: '=',
+                    value: '',
+                });
+            },
+            removeField(i) {
+                if (this.advancedQueryFields.length > 0) {
+                    this.advancedQueryFields.splice(i, 1);
+                }
+            },
+            advancedQuery() {
+
+                this.advancedQuerySearchKey = '';
+
+                if (this.advancedQueryFields.length > 0) {
+
+                    var templist = [];
+
+                    this.advancedQueryFields.forEach(item => {
+                        if (item.link && item.name && item.searchMethod && item.value) {
+                            var tempItem = item.link + '_,' + item.name + '_,' + item.searchMethod + '_,' + item.value;
+                            templist.push(tempItem);
+                        }
+                    })
+
+                    if (templist.length > 0) {
+
+                        this.advancedQuerySearchKey = templist.join('_;');
+                    }
+                }
+
+                this.getData();
+                this.showAdvancedQueryDialog = false;
+            },
+            exportExcel() {
+                window.location.href = this.$baseUrl + "/${display.uncapitalize($model.className)}/exportExcel?searchKey=" + this.filter1 + "&advancedQuery=" + this.advancedQuerySearchKey
+            },
+
         }
     }
 </script>

+ 167 - 67
src/main/resources/templates/MapperXmlSqlServerTemplate.vm

@@ -1,111 +1,211 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
-<mapper namespace="com.izouma.awesomeadmin.dao.${model.className}Mapper" >
-    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.${model.className}" >
-#foreach($field in $model.fields)
-        #if(${field.name}=='id')
-        <id column="id" property="id" jdbcType="INTEGER" />
-        #end
-        #if(${field.name}!='id')
-        <result column="${field.name}" property="$field.modelName" jdbcType="$field.sqlType" />
+<mapper namespace="com.izouma.awesomeadmin.dao.${model.className}Mapper">
+    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.${model.className}">
+        #foreach($field in $model.fields)
+            #if(${field.name}=='id'||${field.name}=='ID')
+                <id column="id" property="id" jdbcType="INTEGER"/>
+            #end
+            #if(${field.name}!='id'&&${field.name}!='ID')
+                <result column="${field.name}" property="$field.modelName" jdbcType="$field.sqlType"/>
+            #end
         #end
-#end
     </resultMap>
-    <sql id="Base_Column_List" >
-    #foreach($field in $model.fields)
-        ${field.name}#if($velocityCount!=$model.fields.size()),#end
-    #end
+    <sql id="Base_Column_List">
+        #foreach($field in $model.fields)
+            ${field.name}#if($velocityCount!=$model.fields.size()),#end
+        #end
     </sql>
-    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
+    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
         select
-        <include refid="Base_Column_List" />
+        <include refid="Base_Column_List"/>
         from $model.tableName
         where id = #{id,jdbcType=INTEGER}
     </select>
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
         delete from $model.tableName
         where id = #{id,jdbcType=INTEGER}
     </delete>
-    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.${model.className}" useGeneratedKeys="true" keyProperty="id">
+    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.${model.className}"
+            useGeneratedKeys="true" keyProperty="id">
         insert into $model.tableName
-        <trim prefix="(" suffix=")" suffixOverrides="," >
-    #foreach($field in $model.fields)
-        #if(${field.name}!='id')
-            <if test="$field.modelName!= null" >
-                ${field.name},
-            </if>
-        #end
-    #end
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            #foreach($field in $model.fields)
+                #if(${field.name}!='id'&&${field.name}!='ID')
+                    <if test="$field.modelName!= null">
+                        ${field.name},
+                    </if>
+                #end
+            #end
         </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides="," >
-        #foreach($field in $model.fields)
-            #if(${field.name}!='id')
-            <if test="$field.modelName != null" >
-                #{$field.modelName,jdbcType=${field.sqlType}},
-            </if>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            #foreach($field in $model.fields)
+                #if(${field.name}!='id'&&${field.name}!='ID')
+                    <if test="$field.modelName != null">
+                        #{$field.modelName,jdbcType=${field.sqlType}},
+                    </if>
+                #end
             #end
-        #end
         </trim>
     </insert>
-    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.${model.className}" >
+    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.${model.className}">
         update $model.tableName
-        <set >
-        #foreach($field in $model.fields)
-            #if(${field.name}!='id')
-            <if test="$field.modelName != null" >
-               ${field.name}= #{$field.modelName,jdbcType=${field.sqlType}},
-            </if>
+        <set>
+            #foreach($field in $model.fields)
+                #if(${field.name}!='id'&&${field.name}!='ID')
+                    <if test="$field.modelName != null">
+                        ${field.name}= #{$field.modelName,jdbcType=${field.sqlType}},
+                    </if>
+                #end
             #end
-         #end
         </set>
         where id = #{id,jdbcType=INTEGER}
     </update>
-    <select id="query${model.className}ByPage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.${model.className}">
-        select <include refid="Base_Column_List"/> from ${model.tableName}
+    <select id="query${model.className}ByPage" parameterType="java.util.Map"
+            resultType="com.izouma.awesomeadmin.model.${model.className}">
+        select
+        <include refid="Base_Column_List"/>
+        from ${model.tableName}
         <where>
-            and del_flag = 'N'
-        #foreach($field in $model.fields)
-            <if test="record.$field.modelName != null and !&quot;&quot;.equals(record.$field.modelName)">
-                and  ${field.name} = #{record.$field.modelName}
+            and FlagColumn = 0
+            #foreach($field in $model.fields)
+                <if test="record.$field.modelName != null and !&quot;&quot;.equals(record.$field.modelName)">
+                    and  ${field.name} = #{record.$field.modelName}
+                </if>
+            #end
+
+            <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
+                <trim prefix="and (" suffix=")" prefixOverrides="OR" >
+                    #foreach($field in $model.fields)
+                        #if(${field.name}!='id'&&${field.name}!='ID')
+                            OR  ${field.name} LIKE concat('%',#{record.searchKey},'%')
+                        #end
+                    #end
+                </trim>
+            </if>
+            <if test="record.advancedQuery != null and !&quot;&quot;.equals(record.advancedQuery)">
+                <foreach item="item" index="index" collection="record.advancedQuery.split('_;')">
+                    <choose>
+                        <when test="item.indexOf('like') != -1">
+                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                                <if test="detailIndex == 3">
+                                    concat('%',#{itemDetail},'%')
+                                </if>
+
+                                <if test="detailIndex &lt; 3">
+                                    ${esc.d}{itemDetail}
+                                </if>
+
+                            </foreach>
+                        </when>
+                        <otherwise>
+                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                                <if test="detailIndex == 3">
+                                    #{itemDetail}
+                                </if>
+
+                                <if test="detailIndex &lt; 3">
+                                    ${esc.d}{itemDetail}
+                                </if>
+
+                            </foreach>
+                        </otherwise>
+                    </choose>
+
+
+                </foreach>
+
+
             </if>
-         #end
         </where>
         order by id desc
     </select>
-    <select id="queryAll${model.className}" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.${model.className}">
-        select <include refid="Base_Column_List"/> from ${model.tableName}
+    <select id="queryAll${model.className}" parameterType="java.util.Map"
+            resultType="com.izouma.awesomeadmin.model.${model.className}">
+        select
+        <include refid="Base_Column_List"/>
+        from ${model.tableName}
         <where>
-            and del_flag = 'N'
-        #foreach($field in $model.fields)
-            <if test="$field.modelName != null and !&quot;&quot;.equals($field.modelName)">
-                and  ${field.name} = #{$field.modelName}
+            and FlagColumn = 0
+            #foreach($field in $model.fields)
+                <if test="$field.modelName != null and !&quot;&quot;.equals($field.modelName)">
+                    and  ${field.name} = #{$field.modelName}
+                </if>
+            #end
+
+            <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
+                <trim prefix="and (" suffix=")" prefixOverrides="OR" >
+                    #foreach($field in $model.fields)
+                        #if(${field.name}!='id'&&${field.name}!='ID')
+                            OR  ${field.name} LIKE concat('%',#{searchKey},'%')
+                        #end
+                    #end
+                </trim>
+            </if>
+            <if test="advancedQuery != null and !&quot;&quot;.equals(advancedQuery)">
+                <foreach item="item" index="index" collection="advancedQuery.split('_;')">
+                    <choose>
+                        <when test="item.indexOf('like') != -1">
+                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                                <if test="detailIndex == 3">
+                                    concat('%',#{itemDetail},'%')
+                                </if>
+
+                                <if test="detailIndex &lt; 3">
+                                    ${esc.d}{itemDetail}
+                                </if>
+
+                            </foreach>
+                        </when>
+                        <otherwise>
+                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                                <if test="detailIndex == 3">
+                                    #{itemDetail}
+                                </if>
+
+                                <if test="detailIndex &lt; 3">
+                                    ${esc.d}{itemDetail}
+                                </if>
+
+                            </foreach>
+                        </otherwise>
+                    </choose>
+
+
+                </foreach>
+
+
             </if>
-        #end
         </where>
         order by id desc
     </select>
-    <select id="query${model.className}" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.${model.className}">
-        select top 1 <include refid="Base_Column_List"/> from ${model.tableName}
+    <select id="query${model.className}" parameterType="java.util.Map"
+            resultType="com.izouma.awesomeadmin.model.${model.className}">
+        select top 1
+        <include refid="Base_Column_List"/>
+        from ${model.tableName}
         <where>
-            and del_flag = 'N'
-        #foreach($field in $model.fields)
-            <if test="$field.modelName != null and !&quot;&quot;.equals($field.modelName)">
-                and ${field.name} = #{$field.modelName}
-            </if>
-         #end
+            and FlagColumn = 0
+            #foreach($field in $model.fields)
+                <if test="$field.modelName != null and !&quot;&quot;.equals($field.modelName)">
+                    and ${field.name} = #{$field.modelName}
+                </if>
+            #end
 
         </where>
     </select>
     <update id="delete">
-        UPDATE ${model.tableName} SET del_flag = 'Y'
+        UPDATE ${model.tableName} SET FlagColumn = 1
         <where>
             AND id = #{id}
         </where>
     </update>
     <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.${model.className}">
-        select <include refid="Base_Column_List"/> from ${model.tableName}
+        select
+        <include refid="Base_Column_List"/>
+        from ${model.tableName}
         <where>
-            and del_flag = 'N'
+            and FlagColumn = 0
             #foreach($field in $model.fields)
                 #if(${field.searchable})
                     #if(${field.searchMethod}=="=")
@@ -127,10 +227,10 @@
                         and ${field.name} <= #{$field.modelName}
                     #end
                     #if(${field.searchMethod}=="like")
-                        and ${field.name} like  '%${$field.modelName}%'
+                        and ${field.name} like '%${$field.modelName}%'
                     #end
                     #if(${field.searchMethod}=="left like")
-                        and ${field.name} like  '%${$field.modelName}'
+                        and ${field.name} like '%${$field.modelName}'
                     #end
                     #if(${field.searchMethod}=="right like")
                         and ${field.name} like '${$field.modelName}%'

+ 96 - 1
src/main/resources/templates/MapperXmlTemplate.vm

@@ -12,9 +12,12 @@
 #end
     </resultMap>
     <sql id="Base_Column_List" >
+        <trim  suffixOverrides="," >
     #foreach($field in $model.fields)
-        ${field.name}#if($velocityCount!=$model.fields.size()),#end
+        ${field.name},
+
     #end
+        </trim>
     </sql>
     <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
         select
@@ -63,6 +66,53 @@
                 and  ${field.name} = #{record.$field.modelName}
             </if>
          #end
+         <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
+             <trim prefix="and (" suffix=")" prefixOverrides="OR" >
+             #foreach($field in $model.fields)
+                 #if(${field.name}!='id'&&${field.name}!='ID')
+                  #if(${field.showInForm})
+                 OR  ${field.name} LIKE concat('%',#{record.searchKey},'%')
+                  #end
+                 #end
+             #end
+             </trim>
+         </if>
+
+            <if test="record.advancedQuery != null and !&quot;&quot;.equals(record.advancedQuery)">
+                <foreach item="item" index="index" collection="record.advancedQuery.split('_;')">
+                    <choose>
+                        <when test="item.indexOf('like') != -1">
+                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                                <if test="detailIndex == 3">
+                                    concat('%',#{itemDetail},'%')
+                                </if>
+
+                                <if test="detailIndex &lt; 3">
+                                    ${esc.d}{itemDetail}
+                                </if>
+
+                            </foreach>
+                        </when>
+                        <otherwise>
+                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                                <if test="detailIndex == 3">
+                                    #{itemDetail}
+                                </if>
+
+                                <if test="detailIndex &lt; 3">
+                                    ${esc.d}{itemDetail}
+                                </if>
+
+                            </foreach>
+                        </otherwise>
+                    </choose>
+
+
+                </foreach>
+
+
+            </if>
+
         </where>
         order by id desc
     </select>
@@ -75,6 +125,51 @@
                 and  ${field.name} = #{$field.modelName}
             </if>
         #end
+            <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
+                <trim prefix="and (" suffix=")" prefixOverrides="OR" >
+                    #foreach($field in $model.fields)
+                        #if(${field.name}!='id'&&${field.name}!='ID')
+                            #if(${field.showInForm})
+                            OR  ${field.name} LIKE concat('%',#{searchKey},'%')
+                            #end
+                        #end
+                    #end
+                </trim>
+            </if>
+<if test="advancedQuery != null and !&quot;&quot;.equals(advancedQuery)">
+    <foreach item="item" index="index" collection="advancedQuery.split('_;')">
+        <choose>
+            <when test="item.indexOf('like') != -1">
+                <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                    <if test="detailIndex == 3">
+                        concat('%',#{itemDetail},'%')
+                    </if>
+
+                    <if test="detailIndex &lt; 3">
+                        ${esc.d}{itemDetail}
+                    </if>
+
+                </foreach>
+            </when>
+            <otherwise>
+                <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                    <if test="detailIndex == 3">
+                        #{itemDetail}
+                    </if>
+
+                    <if test="detailIndex &lt; 3">
+                        ${esc.d}{itemDetail}
+                    </if>
+
+                </foreach>
+            </otherwise>
+        </choose>
+
+
+    </foreach>
+
+
+</if>
         </where>
         order by id desc
     </select>

+ 22 - 0
src/main/resources/templates/ModelTemplate.vm

@@ -15,6 +15,13 @@ public class $model.className{
     private $field.javaType $field.modelName;
 #end
 
+private String searchKey;
+
+/**
+* and,test_name,like,value;or,remark,=,123
+*/
+private String advancedQuery;
+
 #foreach($field in $model.fields)
     public $field.javaType get${display.capitalize($field.modelName)}(){
         return this.$field.modelName;
@@ -25,6 +32,21 @@ public class $model.className{
     }
 #end
 
+public String getSearchKey() {
+    return searchKey;
+}
+
+public void setSearchKey(String searchKey) {
+    this.searchKey = searchKey;
+}
+
+public String getAdvancedQuery() {
+    return advancedQuery;
+}
+
+public void setAdvancedQuery(String advancedQuery) {
+    this.advancedQuery = advancedQuery;
+}
 
 }
 

+ 87 - 0
src/main/vue/src/pages/BannerInfo.vue

@@ -0,0 +1,87 @@
+<template>
+    <div>
+        <el-form :model="formData" :rules="rules" ref="form" label-width="80px" label-position="right" size="small"
+                 style="max-width: 500px;">
+                                                                                                                    <el-form-item prop="title" label="标题">
+                <el-input v-model="formData.title"></el-input>
+            </el-form-item>
+                                                                                                                                                                                                                                                                                                        <el-form-item prop="subtitle" label="副标题">
+                <el-input v-model="formData.subtitle"></el-input>
+            </el-form-item>
+                                                                                                                                                                                                                                                                                                                                                                                                                                 <el-form-item prop="image" label="图片">
+                 <single-upload v-model="formData.image"></single-upload>
+             </el-form-item>
+                                                                                                                                                                                <el-form-item prop="newsUrl" label="链接">
+                <el-input v-model="formData.newsUrl"></el-input>
+            </el-form-item>
+                                                                                                                                                                                                                                                                                                        <el-form-item prop="rank" label="排序">
+                <el-input v-model="formData.rank"></el-input>
+            </el-form-item>
+                                                                                                                                                                                                                                                                                                                                                <el-form-item prop="hot" label="热度">
+                <el-input type="number" v-model="formData.hot"></el-input>
+            </el-form-item>
+                                                                                                                                                                                                                                                                                                        <el-form-item prop="remark" label="备注">
+                <el-input type="number" v-model="formData.remark"></el-input>
+            </el-form-item>
+                                                                                                                                                                                                                            <el-form-item>
+                <el-button @click="onSave" :loading="$store.state.fetchingData" type="primary">保存</el-button>
+                <el-button @click="$router.go(-1)">取消</el-button>
+            </el-form-item>
+        </el-form>
+    </div>
+</template>
+<script>
+    import formValidator from '../formValidator'
+
+    export default {
+        created() {
+            if (this.$route.query.id) {
+                this.$http.get({
+                    url: '/bannerInfo/getOne',
+                    data: {
+                        id: this.$route.query.id
+                    }
+                }).then(res => {
+                    if (res.success) {
+                        this.formData = res.data;
+                    }
+                })
+            }
+        },
+        data() {
+            return {
+                saving: false,
+                formData: {},
+                rules: {
+                                                                                                                                                                                                                                                                                },
+        }
+        },
+        methods: {
+            onSave() {
+                this.$refs.form.validate((valid) => {
+                    if (valid) {
+                        this.submit();
+                    } else {
+                        return false;
+                    }
+                });
+            },
+            submit() {
+                var data = JSON.parse(JSON.stringify(this.formData));
+                this.$http.post({
+                    url: this.formData.id ? '/bannerInfo/update' : '/bannerInfo/save',
+                    data: data
+                }).then(res => {
+                    if (res.success) {
+                        this.$message.success('成功');
+                        this.$router.go(-1);
+                    } else {
+                        this.$message.warning('失败')
+                    }
+                });
+            }
+        }
+    }
+</script>
+<style lang="less" scoped>
+</style>

+ 323 - 0
src/main/vue/src/pages/BannerInfos.vue

@@ -0,0 +1,323 @@
+<template>
+    <div>
+        <div class="filters-container">
+
+            <el-input placeholder="关键字" size="small" v-model="filter1" clearable class="filter-item"></el-input>
+            <!--<el-select placeholder="性别" size="small" v-model="filter2" clearable class="filter-item">
+                <el-option
+                        label="女"
+                        value="item1">
+                </el-option>
+                <el-option
+                        label="男"
+                        value="item2">
+                </el-option>
+            </el-select>-->
+            <!-- <el-button @click="showAdvancedQueryDialog = !showAdvancedQueryDialog" type="primary" size="small" icon="el-icon-search" class="filter-item">高级查询
+            </el-button> -->
+            <el-button @click="getData" type="primary" size="small" icon="el-icon-search" class="filter-item">搜索
+            </el-button>
+            <el-button @click="$router.push('/bannerInfo')" type="primary" size="small" icon="el-icon-edit" class="filter-item">添加
+            </el-button>
+            <el-dropdown trigger="click" size="medium" class="table-column-filter">
+                <span>
+                    筛选数据
+                    <i class="el-icon-arrow-down el-icon--right"></i>
+                </span>
+                <el-dropdown-menu slot="dropdown" class="table-column-filter-wrapper">
+                    <el-checkbox v-for="item in tableColumns" :key="item.value" v-model="item.show">{{item.label}}
+                    </el-checkbox>
+                </el-dropdown-menu>
+            </el-dropdown>
+        </div>
+        <el-table :data="tableData" :height="tableHeight" row-key="id" ref="table">
+            <el-table-column v-if="multipleMode" align="center" type="selection" width="50">
+            </el-table-column>
+            <el-table-column type="index" min-width="50" align="center">
+            </el-table-column>
+            <el-table-column v-if="isColumnShow('title')" prop="title" label="标题" min-width="100">
+            </el-table-column>
+            <el-table-column v-if="isColumnShow('subtitle')" prop="subtitle" label="副标题" min-width="100">
+            </el-table-column>
+            <el-table-column v-if="isColumnShow('image')" prop="image" label="图片" min-width="100">
+                <template slot-scope="scope">
+                    <img :src="scope.row.image" @click="showImg(scope.row.image)" style="width: 100px;height: 100px;vertical-align: middle;" />
+                </template>
+            </el-table-column>
+            <el-table-column v-if="isColumnShow('newsUrl')" prop="newsUrl" label="链接" min-width="100">
+            </el-table-column>
+            <el-table-column v-if="isColumnShow('rank')" prop="rank" label="排序" min-width="100">
+            </el-table-column>
+            <el-table-column v-if="isColumnShow('hot')" prop="hot" label="热度" min-width="100">
+            </el-table-column>
+            <el-table-column v-if="isColumnShow('remark')" prop="remark" label="备注" min-width="100">
+            </el-table-column>
+            <el-table-column label="操作" align="center" fixed="right">
+                <template slot-scope="scope">
+                    <el-button @click="editRow(scope.row)" type="primary" size="mini" plain>编辑</el-button>
+                </template>
+            </el-table-column>
+        </el-table>
+        <div class="pagination-wrapper">
+            <div class="multiple-mode-wrapper">
+                <el-button size="small" v-if="!multipleMode" @click="toggleMultipleMode(true)">批量编辑</el-button>
+                <el-button-group v-else>
+                    <el-button size="small" @click="operation1">批量操作1</el-button>
+                    <el-button size="small" @click="operation2">批量操作2</el-button>
+                    <el-button size="small" @click="toggleMultipleMode(false)">取消</el-button>
+                </el-button-group>
+            </div>
+            <el-pagination background @size-change="pageSizeChange" @current-change="currentPageChange" :current-page="currentPage" :page-sizes="[10, 20, 30, 40, 50]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="totalNumber">
+            </el-pagination>
+        </div>
+        <el-dialog title="高级查询" :visible.sync="showAdvancedQueryDialog">
+            <el-button @click="addField" type="text" icon="el-icon-plus">添加</el-button>
+            <el-table :data="advancedQueryFields">
+
+                <el-table-column prop="link" label="链接符" align="center">
+                    <template slot-scope="{row}">
+                        <el-select placeholder="链接" size="small" v-model="row.link" class="filter-item">
+                            <el-option label="AND" value="AND">
+                            </el-option>
+                            <el-option label="OR" value="OR">
+                            </el-option>
+                        </el-select>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="name" label="字段" align="center">
+                    <template slot-scope="{row}">
+                        <el-select v-model="row.name">
+
+                            <el-option v-for="item in advancedQueryColumns" :label="item.label" :value="item.value" :key="item.value"></el-option>
+                        </el-select>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="searchMethod" label="搜索方式" width="150" align="center">
+                    <template slot-scope="{row}">
+                        <el-select v-model="row.searchMethod">
+                            <el-option v-for="item in searchMethods" :label="item" :value="item" :key="item"></el-option>
+                        </el-select>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="value" label="参数" align="center">
+                    <template slot-scope="{row}">
+                        <el-input v-model="row.value"></el-input>
+                    </template>
+                </el-table-column>
+                <el-table-column width="60" align="center">
+                    <template slot-scope="{ row, column, $index }">
+                        <el-button @click="removeField($index)" size="small" type="text">删除</el-button>
+                    </template>
+                </el-table-column>
+            </el-table>
+
+            <span slot="footer" class="dialog-footer">
+
+                <el-button @click="advancedQuery" :loading="$store.state.fetchingData">确定</el-button>
+            </span>
+        </el-dialog>
+
+        <el-dialog title="查看图片" :visible.sync="imageDialogVisible" size="small">
+            <img width="100%" :src="imgSrc" alt="">
+        </el-dialog>
+
+    </div>
+</template>
+<script>
+import { mapState } from 'vuex'
+
+export default {
+    created() {
+        this.getData();
+    },
+    data() {
+        return {
+            totalNumber: 0,
+            totalPage: 10,
+            currentPage: 1,
+            pageSize: 20,
+            tableData: [],
+            filter1: '',
+            filter2: '',
+            tableColumns: [
+                {
+                    label: '标题',
+                    value: 'title',
+                    show: true
+                },
+                {
+                    label: '副标题',
+                    value: 'subtitle',
+                    show: true
+                },
+                {
+                    label: '图片',
+                    value: 'image',
+                    show: true
+                },
+                {
+                    label: '链接',
+                    value: 'newsUrl',
+                    show: true
+                },
+                {
+                    label: '排序',
+                    value: 'rank',
+                    show: true
+                },
+                {
+                    label: '热度',
+                    value: 'hot',
+                    show: true
+                },
+                {
+                    label: '备注',
+                    value: 'remark',
+                    show: true
+                },
+            ],
+            multipleMode: false,
+            showAdvancedQueryDialog: false,
+            advancedQueryFields: [],
+            searchMethods: ['=', '!=', '>', '>=', '<', '<=', 'like'],
+            advancedQueryColumns: [
+                {
+                    label: '标题',
+                    value: 'title'
+                },
+                {
+                    label: '副标题',
+                    value: 'subtitle'
+                },
+                {
+                    label: '图片',
+                    value: 'image'
+                },
+                {
+                    label: '链接',
+                    value: 'news_url'
+                },
+                {
+                    label: '排序',
+                    value: 'rank'
+                },
+                {
+                    label: '热度',
+                    value: 'hot'
+                },
+                {
+                    label: '备注',
+                    value: 'remark'
+                },
+            ],
+            advancedQuerySearchKey: '',
+            imgSrc: '',
+            imageDialogVisible: false,
+        }
+    },
+    computed: {
+        ...mapState(['tableHeight']),
+        selection() {
+            return this.$refs.table.selection.map(i => i.id);
+        }
+    },
+    methods: {
+        pageSizeChange(size) {
+            this.currentPage = 1;
+            this.pageSize = size;
+            this.getData();
+        },
+        currentPageChange(page) {
+            this.currentPage = page;
+            this.getData();
+        },
+        getData() {
+            this.$http.get({
+                url: '/bannerInfo/page',
+                data: {
+                    currentPage: this.currentPage,
+                    pageNumber: this.pageSize,
+                    searchKey: this.filter1,
+                    //advancedQuery: this.advancedQuerySearchKey,
+                }
+            }).then(res => {
+                if (res.success) {
+                    this.totalNumber = res.data.page.totalNumber;
+                    this.tableData = res.data.pp;
+                }
+            })
+        },
+        isColumnShow(column) {
+            var row = this.tableColumns.find(i => i.value === column);
+            return row ? row.show : false;
+        },
+        toggleMultipleMode(multipleMode) {
+            this.multipleMode = multipleMode;
+            if (!multipleMode) {
+                this.$refs.table.clearSelection();
+            }
+        },
+        editRow(row) {
+            this.$router.push({
+                path: '/bannerInfo',
+                query: {
+                    id: row.id
+                }
+            })
+        },
+        operation1() {
+            this.$notify({
+                title: '提示',
+                message: this.selection
+            });
+        },
+        operation2() {
+            this.$message('操作2');
+        },
+        addField() {
+            this.advancedQueryFields.push({
+                link: 'AND',
+                name: '',
+                searchMethod: '=',
+                value: '',
+            });
+        },
+        removeField(i) {
+            if (this.advancedQueryFields.length > 0) {
+                this.advancedQueryFields.splice(i, 1);
+            }
+        },
+        advancedQuery() {
+
+            this.advancedQuerySearchKey = '';
+
+            if (this.advancedQueryFields.length > 0) {
+
+                var templist = [];
+
+                this.advancedQueryFields.forEach(item => {
+                    if (item.link && item.name && item.searchMethod && item.value) {
+                        var tempItem = item.link + '_,' + item.name + '_,' + item.searchMethod + '_,' + item.value;
+                        templist.push(tempItem);
+                    }
+                })
+
+                if (templist.length > 0) {
+
+                    this.advancedQuerySearchKey = templist.join('_;');
+                }
+            }
+
+            this.getData();
+            this.showAdvancedQueryDialog = false;
+        },
+        showImg(img) {
+            this.imgSrc = img;
+            this.imageDialogVisible = true;
+        },
+
+    }
+}
+</script>
+<style lang="less" scoped>
+</style>

+ 170 - 156
src/main/vue/src/pages/GenCode.vue

@@ -7,15 +7,17 @@
             <el-form-item prop="remark" label="描述">
                 <el-input v-model="formData.remark" style="width: 400px;"></el-input>
             </el-form-item>
+            <el-form-item prop="readTable" label="读表">
+
+                <el-switch :value="formData.readTable" on-text="读表" off-text="不读" @change="updateReadTable()">
+                </el-switch>
+
+            </el-form-item>
             <el-form-item prop="dataBaseType" label="数据库">
-                <el-select placeholder="数据库类型" size="small" v-model="formData.dataBaseType"  class="filter-item">
-                    <el-option
-                        label="Mysql"
-                        value="Mysql">
+                <el-select placeholder="数据库类型" size="small" v-model="formData.dataBaseType" class="filter-item">
+                    <el-option label="Mysql" value="Mysql">
                     </el-option>
-                    <el-option
-                        label="SqlServer"
-                        value="SqlServer">
+                    <el-option label="SqlServer" value="SqlServer">
                     </el-option>
                 </el-select>
             </el-form-item>
@@ -28,7 +30,7 @@
             <el-form-item prop="javaPath" label="根目录">
                 <el-input v-model="formData.rootPath"></el-input>
             </el-form-item>
-            <el-form-item prop="fields" label="数据">
+            <el-form-item prop="fields" label="数据" v-if="!formData.readTable">
                 <el-tabs value="1" type="border-card" @tab-click="tabClick">
                     <el-tab-pane label="字段" name="1">
                         <el-table :data="fields">
@@ -40,8 +42,7 @@
                             <el-table-column prop="type" label="类型" width="150" align="center">
                                 <template slot-scope="{row}">
                                     <el-select v-model="row.jdbcType" filterable>
-                                        <el-option v-for="item in fieldTypes" :value="item" :label="item"
-                                                   :key="item"></el-option>
+                                        <el-option v-for="item in fieldTypes" :value="item" :label="item" :key="item"></el-option>
                                     </el-select>
                                 </template>
                             </el-table-column>
@@ -110,17 +111,14 @@
                             <el-table-column prop="formType" label="表单类型" width="150" align="center">
                                 <template slot-scope="{row}">
                                     <el-select v-model="row.formType">
-                                        <el-option v-for="item in formTypes" :label="item.label" :value="item.value"
-                                                   :key="item.value"></el-option>
+                                        <el-option v-for="item in formTypes" :label="item.label" :value="item.value" :key="item.value"></el-option>
                                     </el-select>
                                 </template>
                             </el-table-column>
                             <el-table-column prop="searchMethod" label="搜索方式" width="150" align="center">
                                 <template slot-scope="{row}">
                                     <el-select v-model="row.searchMethod">
-                                        <el-option v-for="item in searchMethods" :label="item"
-                                                   :value="item"
-                                                   :key="item"></el-option>
+                                        <el-option v-for="item in searchMethods" :label="item" :value="item" :key="item"></el-option>
                                     </el-select>
                                 </template>
                             </el-table-column>
@@ -163,8 +161,7 @@
                             <el-table-column prop="validatorType" label="校验类型" width="150" align="center">
                                 <template slot-scope="{row}">
                                     <el-select v-model="row.validatorType">
-                                        <el-option v-for="item in validatorTypes" :label="item.label"
-                                                   :value="item.label" :key="item.label"></el-option>
+                                        <el-option v-for="item in validatorTypes" :label="item.label" :value="item.label" :key="item.label"></el-option>
                                     </el-select>
                                 </template>
                             </el-table-column>
@@ -182,155 +179,172 @@
 </template>
 
 <script>
-    import axios from 'axios'
+import axios from 'axios'
 
-    export default {
-        created() {
-            this.$http.get({
-                url: '/genCode/getSrcPath'
-            }).then(res => {
-                if (res.success) {
-                    this.formData.rootPath = res.data.root;
-                    this.formData.javaPathRelative = res.data.javaPath;
-                    this.formData.viewPathRelative = res.data.viewPath;
-                }
-            })
-        },
-        data() {
-            return {
-                fieldTypes: ['char', 'varchar', 'int', 'text', 'timestamp', 'datetime', 'decimal', 'float'],
-                searchMethods: ['=', '!=', '>', '>=', '<', '<=', 'between', 'like', 'left like', 'right like'],
-                formTypes: [
-                    {label: '单行文本', value: 'singleLineText'},
-                    {label: '多行文本', value: 'textarea'},
-                    {label: '富文本', value: 'richText'},
-                    {label: '数字', value: 'number'},
-                    {label: '日期选择', value: 'date'},
-                    {label: '单选下拉框', value: 'select'},
-                    {label: '多选下拉框', value: 'multiSelect'},
-                    {label: '单图上传', value: 'singleImage'},
-                    {label: '多图上传', value: 'multiImage'},
-                    {label: '文件上传', value: 'fileUpload'},
-                    {label: '树形选择', value: 'tree'},
-                    {label: '开关', value: 'switch'}
-                ],
-                validatorTypes: [
-                    {label: '英文', value: 'english'},
-                    {label: '数字', value: 'number'},
-                    {label: '手机', value: 'phone'},
-                    {label: '网址', value: 'url'},
-                    {label: '电子邮件', value: 'email'},
-                    {label: '身份证', value: 'id'}
-                ],
-                rules: {
-                    tableName: [
-                        {required: true, message: '请填写表名', trigger: 'blur'},
-                        {
-                            validator: (rule, value, callback) => {
-                                if (value) {
-                                    if (/^[a-zA-Z0-9_]*$/.test(value)) {
-                                        callback();
-                                    } else {
-                                        callback(new Error('表名不正确'));
-                                    }
-                                }
-                            }, trigger: 'blur'
-                        }
-                    ],
-                    remark: [{required: true, message: '请填写描述', trigger: 'blur'}],
-                    rootPath: [{required: true, message: '请填写生成目录', trigger: 'blur'}]
-                },
-                formData: {
-                    tableName: '',
-                    remark: '',
-                    genTable: true,
-                    genClass: true,
-                    genList: true,
-                    genForm: true,
-                    rootPath: '',
-                    javaPathRelative: '',
-                    viewPathRelative: '',
-                    dataBaseType:'Mysql'
-                },
-                fields: [{
-                    name: 'id',
-                    jdbcType: 'int',
-                    notNull: true,
-                    primaryKey: true,
-                    autoIncrease: true,
-                    remark: '',
-                    showInList: false,
-                    showInForm: false,
-                    searchable: false
-                },
-                    {
-                        name: 'del_flag',
-                        jdbcType: 'char',
-                        notNull: true,
-                        primaryKey: false,
-                        autoIncrease: false,
-                        remark: '删除标识',
-                        showInList: false,
-                        showInForm: false,
-                        searchable: false,
-                        defaultValue:'N',
-                        length:1
-                    },
-                ]
-            }
-        },
-        computed: {
-            editableFields() {
-                return this.fields.filter(i => {
-                    return i.name
-                });
+export default {
+    created() {
+        this.$http.get({
+            url: '/genCode/getSrcPath'
+        }).then(res => {
+            if (res.success) {
+                this.formData.rootPath = res.data.root;
+                this.formData.javaPathRelative = res.data.javaPath;
+                this.formData.viewPathRelative = res.data.viewPath;
             }
-        },
-        methods: {
-            onSave() {
-                this.$refs.form.validate((valid) => {
-                    if (valid) {
-                        this.submit();
-                    } else {
-                        return false;
+        })
+    },
+    data() {
+        return {
+            fieldTypes: ['char', 'varchar', 'int', 'text', 'timestamp', 'datetime', 'decimal', 'float'],
+            searchMethods: ['=', '!=', '>', '>=', '<', '<=', 'between', 'like', 'left like', 'right like'],
+            formTypes: [
+                { label: '单行文本', value: 'singleLineText' },
+                { label: '多行文本', value: 'textarea' },
+                { label: '富文本', value: 'richText' },
+                { label: '数字', value: 'number' },
+                { label: '日期选择', value: 'date' },
+                { label: '单选下拉框', value: 'select' },
+                { label: '多选下拉框', value: 'multiSelect' },
+                { label: '单图上传', value: 'singleImage' },
+                { label: '多图上传', value: 'multiImage' },
+                { label: '文件上传', value: 'fileUpload' },
+                { label: '树形选择', value: 'tree' },
+                { label: '开关', value: 'switch' }
+            ],
+            validatorTypes: [
+                { label: '英文', value: 'english' },
+                { label: '数字', value: 'number' },
+                { label: '手机', value: 'phone' },
+                { label: '网址', value: 'url' },
+                { label: '电子邮件', value: 'email' },
+                { label: '身份证', value: 'id' }
+            ],
+            rules: {
+                tableName: [
+                    { required: true, message: '请填写表名', trigger: 'blur' },
+                    {
+                        validator: (rule, value, callback) => {
+                            if (value) {
+                                if (/^[\u4e00-\u9fa5a-zA-Z0-9_]*$/.test(value)) {
+                                    callback();
+                                } else {
+                                    callback(new Error('表名不正确'));
+                                }
+                            }
+                        }, trigger: 'blur'
                     }
-                });
+                ],
+                remark: [{ required: true, message: '请填写描述', trigger: 'blur' }],
+                rootPath: [{ required: true, message: '请填写生成目录', trigger: 'blur' }]
             },
-            submit() {
-                this.formData.fields = this.fields;
-                this.formData.javaPath = this.formData.rootPath + this.formData.javaPathRelative;
-                this.formData.viewPath = this.formData.rootPath + this.formData.viewPathRelative;
-                axios.post('/genCode/save', this.formData).then(res => {
-                    this.$msgbox({title: '提示', type: 'success', message: '代码生成成功'});
-                })
+            formData: {
+                tableName: '',
+                remark: '',
+                genTable: true,
+                genClass: true,
+                genList: true,
+                genForm: true,
+                rootPath: '',
+                javaPathRelative: '',
+                viewPathRelative: '',
+                dataBaseType: 'Mysql',
+                readTable: false,
             },
-            addField() {
-                this.fields.push({
-                    name: '',
-                    jdbcType: 'varchar',
-                    notNull: false,
-                    primaryKey: false,
-                    autoIncrease: false,
-                    remark: '',
-                    showInList: true,
-                    showInForm: true,
-                    searchable: false,
-                    formType:'singleLineText'
-                });
+            fields: [{
+                name: 'id',
+                jdbcType: 'int',
+                notNull: true,
+                primaryKey: true,
+                autoIncrease: true,
+                remark: '',
+                showInList: false,
+                showInForm: false,
+                searchable: false
             },
-            removeField(i) {
-                if (this.fields.length > 1) {
-                    this.fields.splice(i, 1);
-                }
+            {
+                name: 'del_flag',
+                jdbcType: 'char',
+                notNull: true,
+                primaryKey: false,
+                autoIncrease: false,
+                remark: '删除标识',
+                showInList: false,
+                showInForm: false,
+                searchable: false,
+                defaultValue: 'N',
+                length: 1
             },
-            tabClick(tab) {
-                window.xxx = tab;
-                setTimeout(() => tab.$nextTick(), 1000);
-            }
+            ]
+        }
+    },
+    computed: {
+        editableFields() {
+            return this.fields.filter(i => {
+                return i.name
+            });
         }
+    },
+    methods: {
+        onSave() {
+            this.$refs.form.validate((valid) => {
+                if (valid) {
+                    this.submit();
+                } else {
+                    return false;
+                }
+            });
+        },
+        submit() {
+
+            this.formData.fields = this.fields;
+            this.formData.javaPath = this.formData.rootPath + this.formData.javaPathRelative;
+            this.formData.viewPath = this.formData.rootPath + this.formData.viewPathRelative;
+            var alertMsg = "生成代码可能会删除已有同名表、数据或文件,确认要生成么?";
+
+            this.$alert(alertMsg, '警告', { type: 'error' }).then(() => {
+                return axios.post('/genCode/save', this.formData)
+            }).then(() => {
+                this.$msgbox({ title: '提示', type: 'success', message: '代码生成成功' });
+            }).catch(() => {
+                if (res === 'cancel') {
+                    this.$msgbox({ title: '提示', type: 'error', message: '生成取消' });
+                } else {
+                    this.$msgbox({ title: '提示', type: 'error', message: '生成失败' });
+                }
+            })
+
+
+        },
+        addField() {
+            this.fields.push({
+                name: '',
+                jdbcType: 'varchar',
+                notNull: false,
+                primaryKey: false,
+                autoIncrease: false,
+                remark: '',
+                showInList: true,
+                showInForm: true,
+                searchable: false,
+                formType: 'singleLineText'
+            });
+        },
+        removeField(i) {
+            if (this.fields.length > 1) {
+                this.fields.splice(i, 1);
+            }
+        },
+        tabClick(tab) {
+            window.xxx = tab;
+            setTimeout(() => tab.$nextTick(), 1000);
+        },
+        updateReadTable() {
+            this.formData.readTable = !this.formData.readTable;
+            this.formData.genTable = !this.formData.readTable;
+        },
     }
+}
 </script>
 
 <style lang="less" scoped>
-
 </style>

+ 12 - 0
src/main/vue/src/router/index.js

@@ -317,6 +317,18 @@ const router = new Router({
                     name: 'hotSearch',
                     component: () => import('../pages/HotSearch')
                 },
+
+                //首页Banner
+                {
+                    path: '/bannerInfos',
+                    name: 'bannerInfos',
+                    component: () => import('../pages/BannerInfos')
+                },
+                {
+                    path: '/bannerInfo',
+                    name: 'bannerInfo',
+                    component: () => import('../pages/BannerInfo')
+                },
             ]
         },
         {