init
This commit is contained in:
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
.idea
|
||||
*.iml
|
||||
/*/target/
|
||||
.svn
|
||||
.settings/
|
||||
.project
|
||||
.classpath
|
||||
/*/test-output/
|
||||
.DS_Store
|
||||
target
|
||||
BIN
bin/com/openpark/db/CodeGenerator.class
Normal file
BIN
bin/com/openpark/db/CodeGenerator.class
Normal file
Binary file not shown.
BIN
bin/com/openpark/main/Generator.class
Normal file
BIN
bin/com/openpark/main/Generator.class
Normal file
Binary file not shown.
BIN
bin/com/openpark/model/Base.class
Normal file
BIN
bin/com/openpark/model/Base.class
Normal file
Binary file not shown.
BIN
bin/com/openpark/model/Configure.class
Normal file
BIN
bin/com/openpark/model/Configure.class
Normal file
Binary file not shown.
BIN
bin/com/openpark/model/Constants.class
Normal file
BIN
bin/com/openpark/model/Constants.class
Normal file
Binary file not shown.
26
op-mapper/pom.xml
Normal file
26
op-mapper/pom.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>OpenPark</artifactId>
|
||||
<groupId>cn.feast.coding</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>op-mapper</artifactId>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.feast.coding</groupId>
|
||||
<artifactId>op-model</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
18
op-mapper/src/main/java/cn/feast/coding/mapper/IMapper.java
Normal file
18
op-mapper/src/main/java/cn/feast/coding/mapper/IMapper.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package cn.feast.coding.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IMapper<T> {
|
||||
int insert(T t);
|
||||
|
||||
int update(T t);
|
||||
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
List<T> selectAll(T t);
|
||||
|
||||
T selectByPrimaryKey(Integer id);
|
||||
|
||||
List<T> queryAll();
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.feast.coding.mapper.generator;
|
||||
|
||||
import cn.feast.coding.model.generator.Colunm;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface ColunmMapper{
|
||||
Integer save(Colunm model);
|
||||
|
||||
void update(Colunm model);
|
||||
|
||||
void deleteById(Integer id);
|
||||
|
||||
int queryByCount(Colunm model);
|
||||
|
||||
List<Colunm> queryByList(Map paramsMap);
|
||||
|
||||
List<Colunm> queryByColunm(Colunm model);
|
||||
|
||||
Colunm queryById(Integer id);
|
||||
|
||||
List<Colunm> queryByTable(Integer tableId);
|
||||
|
||||
Colunm queryPrimaryKey(Integer tableId);
|
||||
|
||||
void deleteProjectRelatedData(Integer projectId);
|
||||
|
||||
Integer saveByBatch(List<Colunm> list);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.feast.coding.mapper.generator;
|
||||
|
||||
import cn.feast.coding.model.generator.DataSource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface DataSourceMapper{
|
||||
Integer save(DataSource model);
|
||||
|
||||
void update(DataSource model);
|
||||
|
||||
void deleteById(Integer id);
|
||||
|
||||
int queryByCount(DataSource model);
|
||||
|
||||
List<DataSource> queryByList(Map paramsMap);
|
||||
|
||||
List<DataSource> queryByDataSource(DataSource model);
|
||||
|
||||
DataSource queryById(Integer id);
|
||||
|
||||
List<DataSource> queryAll();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.feast.coding.mapper.generator;
|
||||
|
||||
import cn.feast.coding.model.generator.Module;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface ModuleMapper{
|
||||
Integer save(Module model);
|
||||
|
||||
void update(Module model);
|
||||
|
||||
void deleteById(Integer id);
|
||||
|
||||
int queryByCount(Module model);
|
||||
|
||||
List<Module> queryByList(Map paramsMap);
|
||||
|
||||
List<Module> queryByModule(Module model);
|
||||
|
||||
Module queryById(Integer id);
|
||||
|
||||
List<Module> queryAll();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.feast.coding.mapper.generator;
|
||||
|
||||
|
||||
import cn.feast.coding.model.generator.ModuleProject;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface ModuleProjectMapper {
|
||||
Integer save(ModuleProject model);
|
||||
|
||||
void update(ModuleProject model);
|
||||
|
||||
void deleteById(Integer id);
|
||||
|
||||
int queryByCount(ModuleProject model);
|
||||
|
||||
List<ModuleProject> queryByList(Map paramsMap);
|
||||
|
||||
List<ModuleProject> queryByModuleProject(ModuleProject model);
|
||||
|
||||
ModuleProject queryById(Integer id);
|
||||
|
||||
List<ModuleProject> queryByProject(Integer projectId);
|
||||
|
||||
List<ModuleProject> queryByModule(Integer moduleId);
|
||||
|
||||
void deleteProjectRelatedData(Integer projectId);
|
||||
|
||||
List<ModuleProject> queryByProjectAndModule(@Param("projectId") Integer projectId, @Param("moduleName") String moduleName);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.feast.coding.mapper.generator;
|
||||
|
||||
|
||||
import cn.feast.coding.model.generator.PageTemplate;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface PageTemplateMapper {
|
||||
Integer save(PageTemplate model);
|
||||
|
||||
void update(PageTemplate model);
|
||||
|
||||
void deleteById(Integer id);
|
||||
|
||||
int queryByCount(PageTemplate model);
|
||||
|
||||
List<PageTemplate> queryByList(Map paramsMap);
|
||||
|
||||
List<PageTemplate> queryByPageTemplate(PageTemplate model);
|
||||
|
||||
PageTemplate queryById(Integer id);
|
||||
|
||||
List<PageTemplate> queryAll();
|
||||
|
||||
List<PageTemplate> getPage(@Param("templateType") String templateType);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.feast.coding.mapper.generator;
|
||||
|
||||
|
||||
import cn.feast.coding.model.generator.Project;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface ProjectMapper {
|
||||
Integer save(Project model);
|
||||
|
||||
void update(Project model);
|
||||
|
||||
void deleteById(Integer id);
|
||||
|
||||
int queryByCount(Project model);
|
||||
|
||||
List<Project> queryByList(Map paramsMap);
|
||||
|
||||
List<Project> queryByProject(Project model);
|
||||
|
||||
Project queryById(Integer id);
|
||||
|
||||
List<Project> queryByDataSource(Integer dataSourceId);
|
||||
|
||||
List<Project> queryByPageTemplate(Integer pageTemplateId);
|
||||
|
||||
List<Project> queryAll();
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.feast.coding.mapper.generator;
|
||||
|
||||
|
||||
import cn.feast.coding.model.generator.Table;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface TableMapper {
|
||||
Integer save(Table model);
|
||||
|
||||
void update(Table model);
|
||||
|
||||
void deleteById(Integer id);
|
||||
|
||||
int queryByCount(Table model);
|
||||
|
||||
List<Table> queryByList(Map paramsMap);
|
||||
|
||||
List<Table> queryByTable(Table model);
|
||||
|
||||
Table queryById(Integer id);
|
||||
|
||||
List<Table> queryByProject(Integer projectId);
|
||||
|
||||
void deleteProjectRelatedData(Integer projectId);
|
||||
|
||||
int saveByBatch(List<Table> list);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.feast.coding.mapper.links;
|
||||
|
||||
import cn.feast.coding.mapper.IMapper;
|
||||
import cn.feast.coding.model.links.Link;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface LinkMapper extends IMapper<Link> {
|
||||
List queryByTypeTimes(Integer urlType);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.feast.coding.mapper.order;
|
||||
|
||||
import cn.feast.coding.mapper.IMapper;
|
||||
import cn.feast.coding.model.order.MonthStatis;
|
||||
import cn.feast.coding.model.order.Order;
|
||||
import cn.feast.coding.model.order.OrderStatis;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface OrderMapper extends IMapper<Order> {
|
||||
|
||||
List<OrderStatis> statisOrderMoney(@Param("year") String year);
|
||||
|
||||
List<OrderStatis> statisOrderCount(@Param("year") String year);
|
||||
|
||||
List<MonthStatis> statisOrderMonthCount(@Param("year") String year, @Param("shop") String shop);
|
||||
|
||||
List<MonthStatis> statisOrderMonthMoney(@Param("year") String year, @Param("shop") String shop);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.feast.coding.mapper.stock;
|
||||
|
||||
|
||||
import cn.feast.coding.mapper.IMapper;
|
||||
import cn.feast.coding.model.stock.StockAnalyse;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface StockAnalyseMapper extends IMapper<StockAnalyse> {
|
||||
List<Map<String, Object>> queryAnalyse(String date);
|
||||
|
||||
List<Map<String, Object>> queryAnalyse1();
|
||||
|
||||
List<Map<String, Object>> queryAnalyse2(String date);
|
||||
|
||||
List<Map<String, Object>> sortByTurn();
|
||||
|
||||
List<Map<String, Object>> sortByPrice();
|
||||
|
||||
List<Map<String, Object>> querySentiment();
|
||||
|
||||
List<Map<String, Object>> queryConcept();
|
||||
|
||||
List<Map<String, Object>> queryStockConcept(String stockCode);
|
||||
|
||||
List<Map<String, Object>> queryConceptStocks(String conceptName);
|
||||
|
||||
List<Map<String, Object>> getKLineData(String stockCode);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.feast.coding.mapper.stock;
|
||||
|
||||
import cn.feast.coding.mapper.IMapper;
|
||||
import cn.feast.coding.model.stock.Stock;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface StockMapper extends IMapper<Stock> {
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.feast.coding.mapper.system;
|
||||
|
||||
|
||||
import cn.feast.coding.model.system.Permission;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface PermissionMapper {
|
||||
Integer save(Permission model);
|
||||
|
||||
void update(Permission model);
|
||||
|
||||
void deleteById(Integer id);
|
||||
|
||||
int queryByCount(Permission model);
|
||||
|
||||
List<Permission> queryByList(Map paramsMap);
|
||||
|
||||
List<Permission> queryByPermission(Permission model);
|
||||
|
||||
Permission queryById(Integer id);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.feast.coding.mapper.system;
|
||||
|
||||
|
||||
import cn.feast.coding.model.system.Role;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface RoleMapper {
|
||||
|
||||
Integer save(Role model);
|
||||
|
||||
void update(Role model);
|
||||
|
||||
void deleteById(Integer id);
|
||||
|
||||
int queryByCount(Role model);
|
||||
|
||||
List<Role> queryByList(Map paramsMap);
|
||||
|
||||
List<Role> queryByRole(Role model);
|
||||
|
||||
Role queryById(Integer id);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.feast.coding.mapper.system;
|
||||
|
||||
|
||||
import cn.feast.coding.model.system.RolePermission;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface RolePermissionMapper {
|
||||
Integer save(RolePermission model);
|
||||
|
||||
void update(RolePermission model);
|
||||
|
||||
void deleteById(Integer id);
|
||||
|
||||
int queryByCount(RolePermission model);
|
||||
|
||||
List<RolePermission> queryByList(Map paramsMap);
|
||||
|
||||
List<RolePermission> queryByRolePermission(RolePermission model);
|
||||
|
||||
RolePermission queryById(Integer id);
|
||||
|
||||
void deleteByRole(Integer roleid);
|
||||
|
||||
List<RolePermission> queryByRole(Integer roleid);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.feast.coding.mapper.system;
|
||||
|
||||
|
||||
import cn.feast.coding.model.system.Permission;
|
||||
import cn.feast.coding.model.system.Role;
|
||||
import cn.feast.coding.model.system.User;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface UserMapper {
|
||||
Integer save(User model);
|
||||
|
||||
void update(User model);
|
||||
|
||||
void deleteById(Integer id);
|
||||
|
||||
int queryByCount(User model);
|
||||
|
||||
List<User> queryByList(Map paramsMap);
|
||||
|
||||
List<User> queryByUser(User model);
|
||||
|
||||
User queryById(Integer id);
|
||||
|
||||
User findByUsername(@Param("username") String username);
|
||||
|
||||
List<Role> findRoles(String username);
|
||||
|
||||
List<Permission> findPermissions(String username);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.feast.coding.mapper.system;
|
||||
|
||||
|
||||
import cn.feast.coding.model.system.UserRole;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public interface UserRoleMapper {
|
||||
Integer save(UserRole model);
|
||||
|
||||
void update(UserRole model);
|
||||
|
||||
void deleteById(Integer id);
|
||||
|
||||
int queryByCount(UserRole model);
|
||||
|
||||
List<UserRole> queryByList(Map paramsMap);
|
||||
|
||||
List<UserRole> queryByUserRole(UserRole model);
|
||||
|
||||
UserRole queryById(Integer id);
|
||||
|
||||
void deleteByUser(Integer userid);
|
||||
|
||||
List<UserRole> queryByUser(Integer userid);
|
||||
}
|
||||
270
op-mapper/src/main/resources/mapper/generator/ColunmMapper.xml
Normal file
270
op-mapper/src/main/resources/mapper/generator/ColunmMapper.xml
Normal file
@@ -0,0 +1,270 @@
|
||||
<?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="cn.feast.coding.mapper.generator.ColunmMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.generator.Colunm">
|
||||
<result column="id" property="id"/>
|
||||
<result column="colunm_name" property="colunmName"/>
|
||||
<result column="filed_name" property="filedName"/>
|
||||
<result column="colunm_type" property="colunmType"/>
|
||||
<result column="show_name" property="showName"/>
|
||||
<result column="edit_style" property="editStyle"/>
|
||||
<result column="is_primary" property="isPrimary"/>
|
||||
<result column="is_showed" property="isShowed"/>
|
||||
<result column="table_id" property="tableId"/>
|
||||
<association property="table" column="table_id" select="cn.feast.coding.mapper.generator.TableMapper.queryById" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="queryResultMap" type="cn.feast.coding.model.generator.Colunm">
|
||||
<result column="id" property="id"/>
|
||||
<result column="colunm_name" property="colunmName"/>
|
||||
<result column="filed_name" property="filedName"/>
|
||||
<result column="colunm_type" property="colunmType"/>
|
||||
<result column="show_name" property="showName"/>
|
||||
<result column="edit_style" property="editStyle"/>
|
||||
<result column="is_primary" property="isPrimary"/>
|
||||
<result column="is_showed" property="isShowed"/>
|
||||
<result column="table_id" property="tableId"/>
|
||||
<association property="table" javaType="cn.feast.coding.model.generator.Table">
|
||||
<id property="id" column="id"/>
|
||||
<result property="tableName" column="table_name"/>
|
||||
<result column="class_name" property="className"/>
|
||||
<result column="show_name" property="showName"/>
|
||||
<result column="show_style" property="showStyle"/>
|
||||
<result column="project_id" property="projectId"/>
|
||||
</association>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_colunm
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
id,
|
||||
colunm_name,
|
||||
filed_name,
|
||||
colunm_type,
|
||||
show_name,
|
||||
edit_style,
|
||||
is_primary,
|
||||
is_showed,
|
||||
table_id
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="colunmName != null and colunmName !=''">
|
||||
colunm_name=#{colunmName},
|
||||
</if>
|
||||
<if test="filedName != null and filedName !=''">
|
||||
filed_name=#{filedName},
|
||||
</if>
|
||||
<if test="colunmType != null and colunmType !=''">
|
||||
colunm_type=#{colunmType},
|
||||
</if>
|
||||
<if test="showName != null and showName !=''">
|
||||
show_name=#{showName},
|
||||
</if>
|
||||
<if test="editStyle != null">
|
||||
edit_style=#{editStyle},
|
||||
</if>
|
||||
<if test="isPrimary != null">
|
||||
is_primary=#{isPrimary},
|
||||
</if>
|
||||
<if test="isShowed != null">
|
||||
is_showed=#{isShowed},
|
||||
</if>
|
||||
<if test="tableId != null">
|
||||
table_id=#{tableId},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
and id=#{id}
|
||||
</if>
|
||||
<if test="colunmName != null and colunmName !=''">
|
||||
and colunm_name=#{colunmName}
|
||||
</if>
|
||||
<if test="filedName != null and filedName !=''">
|
||||
and filed_name=#{filedName}
|
||||
</if>
|
||||
<if test="colunmType != null and colunmType !=''">
|
||||
and colunm_type=#{colunmType}
|
||||
</if>
|
||||
<if test="showName != null and showName !=''">
|
||||
and show_name=#{showName}
|
||||
</if>
|
||||
<if test="editStyle != null">
|
||||
and edit_style=#{editStyle}
|
||||
</if>
|
||||
<if test="isPrimary != null">
|
||||
and is_primary=#{isPrimary}
|
||||
</if>
|
||||
<if test="isShowed != null">
|
||||
and is_showed=#{isShowed}
|
||||
</if>
|
||||
<if test="tableId != null">
|
||||
and table_id=#{tableId}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="save" parameterType="Object">
|
||||
insert into
|
||||
<include refid="table_name"/>
|
||||
(
|
||||
colunm_name,
|
||||
filed_name,
|
||||
colunm_type,
|
||||
show_name,
|
||||
edit_style,
|
||||
is_primary,
|
||||
is_showed,
|
||||
table_id
|
||||
)
|
||||
values
|
||||
(
|
||||
#{colunmName},
|
||||
#{filedName},
|
||||
#{colunmType},
|
||||
#{showName},
|
||||
#{editStyle},
|
||||
#{isPrimary},
|
||||
#{isShowed},
|
||||
#{tableId}
|
||||
)
|
||||
</insert>
|
||||
<insert id="saveByBatch" parameterType="Object">
|
||||
insert into
|
||||
<include refid="table_name"/>
|
||||
(
|
||||
colunm_name,
|
||||
filed_name,
|
||||
colunm_type,
|
||||
show_name,
|
||||
edit_style,
|
||||
is_primary,
|
||||
is_showed,
|
||||
table_id
|
||||
)
|
||||
values
|
||||
<foreach collection="list" item="c" separator=",">
|
||||
(
|
||||
#{c.colunmName},
|
||||
#{c.filedName},
|
||||
#{c.colunmType},
|
||||
#{c.showName},
|
||||
#{c.editStyle},
|
||||
#{c.isPrimary},
|
||||
#{c.isShowed},
|
||||
#{c.tableId}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
<select id="queryById" resultMap="queryResultMap" parameterType="Object">
|
||||
select
|
||||
*
|
||||
from
|
||||
t_colunm c, t_table t
|
||||
where
|
||||
c.table_id = t.id
|
||||
and c.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryPrimaryKey" resultMap="queryResultMap" parameterType="Object">
|
||||
select
|
||||
*
|
||||
from
|
||||
t_colunm c, t_table t
|
||||
where
|
||||
c.table_id = t.id
|
||||
and c.table_id = #{tableId}
|
||||
and c.is_primary = 1
|
||||
</select>
|
||||
|
||||
<select id="queryByTable" resultMap="queryResultMap" parameterType="Object">
|
||||
select
|
||||
*
|
||||
from
|
||||
t_colunm c, t_table t
|
||||
where
|
||||
c.table_id = t.id
|
||||
and c.table_id = #{tableId}
|
||||
order by c.id asc
|
||||
</select>
|
||||
|
||||
<select id="queryByCount" resultType="java.lang.Integer" parameterType="Object">
|
||||
select count(1) from
|
||||
<include refid="table_name"/>
|
||||
<include refid="query_where_clause"/>
|
||||
</select>
|
||||
|
||||
<select id="queryByList" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name"/>
|
||||
<include refid="query_where_clause"/>
|
||||
order by id asc
|
||||
${pageQueryCondition}
|
||||
</select>
|
||||
|
||||
<select id="queryByColunm" resultMap="queryResultMap" parameterType="Object">
|
||||
select
|
||||
*
|
||||
from
|
||||
t_colunm c, t_table t
|
||||
where
|
||||
c.table_id = t.id
|
||||
<if test="tableId != null">
|
||||
and c.table_id=#{tableId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--<select id="queryByColunm" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name"/>
|
||||
<include refid="query_where_clause"/>
|
||||
</select>-->
|
||||
|
||||
<update id="update" parameterType="Object">
|
||||
update
|
||||
<include refid="table_name"/>
|
||||
set
|
||||
<include refid="update_clause"/>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateResult" parameterType="Object">
|
||||
update
|
||||
<include refid="table_name"/>
|
||||
set
|
||||
<include refid="update_clause"/>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById" parameterType="Object">
|
||||
delete from
|
||||
<include refid="table_name"/>
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteProjectRelatedData" parameterType="Object">
|
||||
delete
|
||||
tc
|
||||
from
|
||||
t_colunm as tc, t_table as tt, t_project as tp
|
||||
where
|
||||
tc.table_id = tt.id
|
||||
and tt.project_id = tp.id
|
||||
and tp.id = #{projectId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,154 @@
|
||||
<?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="cn.feast.coding.mapper.generator.DataSourceMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.generator.DataSource">
|
||||
<result column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="jdbc_url" property="jdbcUrl"/>
|
||||
<result column="jdbc_user" property="jdbcUser"/>
|
||||
<result column="jdbc_pass" property="jdbcPass"/>
|
||||
<result column="is_default" property="isDefault"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_data_source
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
id,
|
||||
name,
|
||||
jdbc_url,
|
||||
jdbc_user,
|
||||
jdbc_pass,
|
||||
is_default
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="name != null and name !=''">
|
||||
name=#{name},
|
||||
</if>
|
||||
<if test="jdbcUrl != null and jdbcUrl !=''">
|
||||
jdbc_url=#{jdbcUrl},
|
||||
</if>
|
||||
<if test="jdbcUser != null and jdbcUser !=''">
|
||||
jdbc_user=#{jdbcUser},
|
||||
</if>
|
||||
<if test="jdbcPass != null and jdbcPass !=''">
|
||||
jdbc_pass=#{jdbcPass},
|
||||
</if>
|
||||
<if test="isDefault != null">
|
||||
is_default=#{isDefault},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
and id=#{id}
|
||||
</if>
|
||||
<if test="name != null and name !=''">
|
||||
and name=#{name}
|
||||
</if>
|
||||
<if test="jdbcUrl != null and jdbcUrl !=''">
|
||||
and jdbc_url=#{jdbcUrl}
|
||||
</if>
|
||||
<if test="jdbcUser != null and jdbcUser !=''">
|
||||
and jdbc_user=#{jdbcUser}
|
||||
</if>
|
||||
<if test="jdbcPass != null and jdbcPass !=''">
|
||||
and jdbc_pass=#{jdbcPass}
|
||||
</if>
|
||||
<if test="isDefault != null">
|
||||
and is_default=#{isDefault}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="save" parameterType="Object">
|
||||
insert into
|
||||
<include refid="table_name"/>
|
||||
(
|
||||
name,
|
||||
jdbc_url,
|
||||
jdbc_user,
|
||||
jdbc_pass,
|
||||
is_default
|
||||
)
|
||||
values
|
||||
(
|
||||
#{name},
|
||||
#{jdbcUrl},
|
||||
#{jdbcUser},
|
||||
#{jdbcPass},
|
||||
#{isDefault}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="queryById" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryAll" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name"/>
|
||||
</select>
|
||||
|
||||
<select id="queryByCount" resultType="java.lang.Integer" parameterType="Object">
|
||||
select count(1) from
|
||||
<include refid="table_name"/>
|
||||
<include refid="query_where_clause"/>
|
||||
</select>
|
||||
|
||||
<select id="queryByList" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name"/>
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
${pageQueryCondition}
|
||||
</select>
|
||||
|
||||
<select id="queryByDataSource" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name"/>
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object">
|
||||
update
|
||||
<include refid="table_name"/>
|
||||
set
|
||||
<include refid="update_clause"/>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateResult" parameterType="Object">
|
||||
update
|
||||
<include refid="table_name"/>
|
||||
set
|
||||
<include refid="update_clause"/>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById" parameterType="Object">
|
||||
delete from
|
||||
<include refid="table_name"/>
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
131
op-mapper/src/main/resources/mapper/generator/ModuleMapper.xml
Normal file
131
op-mapper/src/main/resources/mapper/generator/ModuleMapper.xml
Normal file
@@ -0,0 +1,131 @@
|
||||
<?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="cn.feast.coding.mapper.generator.ModuleMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.generator.Module">
|
||||
<result column="id" property="id"/>
|
||||
<result column="module_name" property="moduleName"/>
|
||||
<result column="module_desc" property="moduleDesc"/>
|
||||
<result column="module_method" property="moduleMethod"/>
|
||||
<result column="module_default" property="moduleDefault"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_module
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
id,
|
||||
module_name,
|
||||
module_desc,
|
||||
module_method,
|
||||
module_default
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="moduleName != null and moduleName !=''">
|
||||
module_name=#{moduleName},
|
||||
</if>
|
||||
<if test="moduleDesc != null and moduleDesc !=''">
|
||||
module_desc=#{moduleDesc},
|
||||
</if>
|
||||
<if test="moduleMethod != null and moduleMethod !=''">
|
||||
module_method=#{moduleMethod},
|
||||
</if>
|
||||
<if test="moduleDefault != null">
|
||||
module_default=#{moduleDefault},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
and id=#{id}
|
||||
</if>
|
||||
<if test="moduleName != null and moduleName !=''">
|
||||
and module_name=#{moduleName}
|
||||
</if>
|
||||
<if test="moduleDesc != null and moduleDesc !=''">
|
||||
and module_desc=#{moduleDesc}
|
||||
</if>
|
||||
<if test="moduleMethod != null and moduleMethod !=''">
|
||||
and module_method=#{moduleMethod}
|
||||
</if>
|
||||
<if test="moduleDefault != null">
|
||||
and module_default=#{moduleDefault}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="save" parameterType="Object" >
|
||||
insert into
|
||||
<include refid="table_name" />
|
||||
(
|
||||
module_name,
|
||||
module_desc,
|
||||
module_method,
|
||||
module_default
|
||||
)
|
||||
values
|
||||
(
|
||||
#{moduleName},
|
||||
#{moduleDesc},
|
||||
#{moduleMethod},
|
||||
#{moduleDefault}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="queryById" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryAll" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" />
|
||||
</select>
|
||||
|
||||
<select id="queryByCount" resultType="java.lang.Integer" parameterType="Object">
|
||||
select count(1) from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause" />
|
||||
</select>
|
||||
|
||||
<select id="queryByList" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
${pageQueryCondition}
|
||||
</select>
|
||||
|
||||
<select id="queryByModule" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateResult" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,271 @@
|
||||
<?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="cn.feast.coding.mapper.generator.ModuleProjectMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.generator.ModuleProject">
|
||||
<result column="id" property="id"/>
|
||||
<result column="module_id" property="moduleId"/>
|
||||
<result column="project_id" property="projectId"/>
|
||||
<result column="table_id" property="tableId"/>
|
||||
<result column="module_param1" property="moduleParam1"/>
|
||||
<result column="module_param1_type" property="moduleParam1Type"/>
|
||||
<result column="module_param1_field" property="moduleParam1Field"/>
|
||||
<result column="module_param2" property="moduleParam2"/>
|
||||
<result column="module_param2_type" property="moduleParam2Type"/>
|
||||
<result column="module_param2_field" property="moduleParam2Field"/>
|
||||
<result column="module_param3" property="moduleParam3"/>
|
||||
<result column="module_param3_type" property="moduleParam3Type"/>
|
||||
<result column="module_param3_field" property="moduleParam3Field"/>
|
||||
<association property="table" column="table_id" select="cn.feast.coding.mapper.generator.TableMapper.queryById" />
|
||||
<association property="module" column="module_id" select="cn.feast.coding.mapper.generator.ModuleMapper.queryById" />
|
||||
<association property="project" column="project_id" select="cn.feast.coding.mapper.generator.ProjectMapper.queryById" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="queryResultMap" type="cn.feast.coding.model.generator.ModuleProject">
|
||||
<result column="id" property="id"/>
|
||||
<result column="module_id" property="moduleId"/>
|
||||
<result column="project_id" property="projectId"/>
|
||||
<result column="table_id" property="tableId"/>
|
||||
<result column="module_param1" property="moduleParam1"/>
|
||||
<result column="module_param1_type" property="moduleParam1Type"/>
|
||||
<result column="module_param1_field" property="moduleParam1Field"/>
|
||||
<result column="module_param2" property="moduleParam2"/>
|
||||
<result column="module_param2_type" property="moduleParam2Type"/>
|
||||
<result column="module_param2_field" property="moduleParam2Field"/>
|
||||
<result column="module_param3" property="moduleParam3"/>
|
||||
<result column="module_param3_type" property="moduleParam3Type"/>
|
||||
<result column="module_param3_field" property="moduleParam3Field"/>
|
||||
<association property="project" javaType="cn.feast.coding.model.generator.Project">
|
||||
<id property="id" column="id"/>
|
||||
<result property="projectName" column="project_name"/>
|
||||
</association>
|
||||
<association property="module" javaType="cn.feast.coding.model.generator.Module">
|
||||
<id property="id" column="id"/>
|
||||
<result property="moduleName" column="module_name"/>
|
||||
</association>
|
||||
<association property="table" javaType="cn.feast.coding.model.generator.Table">
|
||||
<id property="id" column="id"/>
|
||||
<result property="tableName" column="table_name"/>
|
||||
<result property="className" column="class_name"/>
|
||||
</association>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_module_project
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
id,
|
||||
module_id,
|
||||
project_id,
|
||||
table_id,
|
||||
module_param1,
|
||||
module_param1_type,
|
||||
module_param1_field,
|
||||
module_param2,
|
||||
module_param2_type,
|
||||
module_param2_field,
|
||||
module_param3,
|
||||
module_param3_type,
|
||||
module_param3_field
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="moduleId != null">
|
||||
module_id=#{moduleId},
|
||||
</if>
|
||||
<if test="projectId != null">
|
||||
project_id=#{projectId},
|
||||
</if>
|
||||
<if test="tableId != null">
|
||||
table_id=#{tableId},
|
||||
</if>
|
||||
<if test="moduleParam1 != null">
|
||||
module_param1=#{moduleParam1},
|
||||
</if>
|
||||
<if test="moduleParam1Type != null">
|
||||
module_param1_type=#{moduleParam1Type},
|
||||
</if>
|
||||
<if test="moduleParam1Field != null">
|
||||
module_param1_field=#{moduleParam1Field},
|
||||
</if>
|
||||
<if test="moduleParam2 != null">
|
||||
module_param2=#{moduleParam2},
|
||||
</if>
|
||||
<if test="moduleParam2Type != null">
|
||||
module_param2_type=#{moduleParam2Type},
|
||||
</if>
|
||||
<if test="moduleParam2Field != null">
|
||||
module_param2_field=#{moduleParam2Field},
|
||||
</if>
|
||||
<if test="moduleParam3 != null">
|
||||
module_param3=#{moduleParam3},
|
||||
</if>
|
||||
<if test="moduleParam3Type != null">
|
||||
module_param3_type=#{moduleParam3Type},
|
||||
</if>
|
||||
<if test="moduleParam3Field != null">
|
||||
module_param3_field=#{moduleParam3Field},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
and id=#{id}
|
||||
</if>
|
||||
<if test="moduleId != null">
|
||||
and module_id=#{moduleId}
|
||||
</if>
|
||||
<if test="projectId != null">
|
||||
and project_id=#{projectId}
|
||||
</if>
|
||||
<if test="tableId != null">
|
||||
and table_id=#{tableId}
|
||||
</if>
|
||||
<if test="moduleParam1 != null">
|
||||
and module_param1=#{moduleParam1}
|
||||
</if>
|
||||
<if test="moduleParam1Type != null">
|
||||
and module_param1_type=#{moduleParam1Type}
|
||||
</if>
|
||||
<if test="moduleParam1Field != null">
|
||||
and module_param1_field=#{moduleParam1Field}
|
||||
</if>
|
||||
<if test="moduleParam2 != null">
|
||||
and module_param2=#{moduleParam2}
|
||||
</if>
|
||||
<if test="moduleParam2Type != null">
|
||||
and module_param2_type=#{moduleParam2Type}
|
||||
</if>
|
||||
<if test="moduleParam2Field != null">
|
||||
and module_param2_field=#{moduleParam2Field}
|
||||
</if>
|
||||
<if test="moduleParam3 != null">
|
||||
and module_param3=#{moduleParam3}
|
||||
</if>
|
||||
<if test="moduleParam3Type != null">
|
||||
and module_param3_type=#{moduleParam3Type}
|
||||
</if>
|
||||
<if test="moduleParam3Field != null">
|
||||
and module_param3_field=#{moduleParam3Field}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="save" parameterType="Object" >
|
||||
insert into
|
||||
<include refid="table_name" />
|
||||
(
|
||||
module_id,
|
||||
project_id,
|
||||
table_id,
|
||||
module_param1,
|
||||
module_param1_type,
|
||||
module_param1_field,
|
||||
module_param2,
|
||||
module_param2_type,
|
||||
module_param2_field,
|
||||
module_param3,
|
||||
module_param3_type,
|
||||
module_param3_field
|
||||
)
|
||||
values
|
||||
(
|
||||
#{moduleId},
|
||||
#{projectId},
|
||||
#{tableId},
|
||||
#{moduleParam1},
|
||||
#{moduleParam1Type},
|
||||
#{moduleParam1Field},
|
||||
#{moduleParam2},
|
||||
#{moduleParam2Type},
|
||||
#{moduleParam2Field},
|
||||
#{moduleParam3},
|
||||
#{moduleParam3Type},
|
||||
#{moduleParam3Field}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="queryById" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryByModule" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where module_id = #{moduleId}
|
||||
</select>
|
||||
|
||||
<select id="queryByProject" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where project_id = #{projectId}
|
||||
</select>
|
||||
|
||||
<select id="queryByProjectAndModule" resultMap="queryResultMap" parameterType="Object">
|
||||
select
|
||||
*
|
||||
from
|
||||
t_module_project mp, t_module m, t_table t
|
||||
where
|
||||
mp.module_id = m.id
|
||||
and mp.table_id = t.id
|
||||
and mp.project_id = #{projectId}
|
||||
and m.module_method = #{moduleName}
|
||||
</select>
|
||||
|
||||
<select id="queryByCount" resultType="java.lang.Integer" parameterType="Object">
|
||||
select count(1) from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause" />
|
||||
</select>
|
||||
|
||||
<select id="queryByList" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
${pageQueryCondition}
|
||||
</select>
|
||||
|
||||
<select id="queryByModuleProject" resultMap="queryResultMap" parameterType="Object">
|
||||
select
|
||||
*
|
||||
from
|
||||
t_module_project mp, t_project p, t_table t, t_module m
|
||||
where 1=1
|
||||
<if test="projectId != null">
|
||||
and mp.project_id=#{projectId}
|
||||
</if>
|
||||
and mp.module_id = m.id
|
||||
and mp.project_id = p.id
|
||||
and mp.table_id = t.id
|
||||
order by mp.id desc
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateResult" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteProjectRelatedData" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where project_id = #{projectId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,172 @@
|
||||
<?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="cn.feast.coding.mapper.generator.PageTemplateMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.generator.PageTemplate">
|
||||
<result column="id" property="id"/>
|
||||
<result column="page_name" property="pageName"/>
|
||||
<result column="page_path" property="pagePath"/>
|
||||
<result column="page_imag" property="pageImag"/>
|
||||
<result column="page_frame" property="pageFrame"/>
|
||||
<result column="page_desc" property="pageDesc"/>
|
||||
<result column="page_default" property="pageDefault"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_page_template
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
id,
|
||||
page_name,
|
||||
page_path,
|
||||
page_imag,
|
||||
page_frame,
|
||||
page_desc,
|
||||
page_default
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="pageName != null and pageName !=''">
|
||||
page_name=#{pageName},
|
||||
</if>
|
||||
<if test="pagePath != null and pagePath !=''">
|
||||
page_path=#{pagePath},
|
||||
</if>
|
||||
<if test="pageImag != null and pageImag !=''">
|
||||
page_imag=#{pageImag},
|
||||
</if>
|
||||
<if test="pageFrame != null and pageFrame !=''">
|
||||
page_frame=#{pageFrame},
|
||||
</if>
|
||||
<if test="pageDesc != null and pageDesc !=''">
|
||||
page_desc=#{pageDesc},
|
||||
</if>
|
||||
<if test="pageDefault != null and pageDefault !=''">
|
||||
page_default=#{pageDefault},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
and id=#{id}
|
||||
</if>
|
||||
<if test="pageName != null and pageName !=''">
|
||||
and page_name=#{pageName}
|
||||
</if>
|
||||
<if test="pagePath != null and pagePath !=''">
|
||||
and page_path=#{pagePath}
|
||||
</if>
|
||||
<if test="pageImag != null and pageImag !=''">
|
||||
and page_imag=#{pageImag}
|
||||
</if>
|
||||
<if test="pageFrame != null and pageFrame !=''">
|
||||
and page_frame=#{pageFrame}
|
||||
</if>
|
||||
<if test="pageDesc != null and pageDesc !=''">
|
||||
and page_desc=#{pageDesc}
|
||||
</if>
|
||||
<if test="pageDefault != null">
|
||||
and page_default=#{pageDefault}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="save" parameterType="Object">
|
||||
insert into
|
||||
<include refid="table_name"/>
|
||||
(
|
||||
page_name,
|
||||
page_path,
|
||||
page_imag,
|
||||
page_frame,
|
||||
page_desc,
|
||||
page_default
|
||||
)
|
||||
values
|
||||
(
|
||||
#{pageName},
|
||||
#{pagePath},
|
||||
#{pageImag},
|
||||
#{pageFrame},
|
||||
#{pageDesc},
|
||||
#{pageDefault}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="queryById" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryAll" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name"/>
|
||||
</select>
|
||||
|
||||
<select id="getPage" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name"/>
|
||||
where
|
||||
FIND_IN_SET(#{templateType}, page_frame)
|
||||
</select>
|
||||
<select id="queryByCount" resultType="java.lang.Integer" parameterType="Object">
|
||||
select count(1) from
|
||||
<include refid="table_name"/>
|
||||
<include refid="query_where_clause"/>
|
||||
</select>
|
||||
|
||||
<select id="queryByList" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name"/>
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
${pageQueryCondition}
|
||||
</select>
|
||||
|
||||
<select id="queryByPageTemplate" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name"/>
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object">
|
||||
update
|
||||
<include refid="table_name"/>
|
||||
set
|
||||
<include refid="update_clause"/>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateResult" parameterType="Object">
|
||||
update
|
||||
<include refid="table_name"/>
|
||||
set
|
||||
<include refid="update_clause"/>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById" parameterType="Object">
|
||||
delete from
|
||||
<include refid="table_name"/>
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
204
op-mapper/src/main/resources/mapper/generator/ProjectMapper.xml
Normal file
204
op-mapper/src/main/resources/mapper/generator/ProjectMapper.xml
Normal file
@@ -0,0 +1,204 @@
|
||||
<?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="cn.feast.coding.mapper.generator.ProjectMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.generator.Project">
|
||||
<result column="id" property="id"/>
|
||||
<result column="project_name" property="projectName"/>
|
||||
<result column="project_file_name" property="projectFileName"/>
|
||||
<result column="project_desc" property="projectDesc"/>
|
||||
<result column="data_sourse" property="dataSourse"/>
|
||||
<result column="pack_name" property="packName"/>
|
||||
<result column="page_path" property="pagePath"/>
|
||||
<result column="page_style" property="pageStyle"/>
|
||||
<result column="template_type" property="templateType"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="queryResultMap" type="cn.feast.coding.model.generator.Project">
|
||||
<result column="id" property="id"/>
|
||||
<result column="project_name" property="projectName"/>
|
||||
<result column="project_file_name" property="projectFileName"/>
|
||||
<result column="project_desc" property="projectDesc"/>
|
||||
<result column="data_sourse" property="dataSourse"/>
|
||||
<result column="pack_name" property="packName"/>
|
||||
<result column="page_path" property="pagePath"/>
|
||||
<result column="page_style" property="pageStyle"/>
|
||||
<result column="template_type" property="templateType"/>
|
||||
<association property="dataSource" javaType="cn.feast.coding.model.generator.DataSource">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</association>
|
||||
<association property="pageTemplate" javaType="cn.feast.coding.model.generator.PageTemplate">
|
||||
<id property="id" column="id"/>
|
||||
<result property="pageName" column="page_name"/>
|
||||
</association>
|
||||
</resultMap>
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_project
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
id,
|
||||
project_name,
|
||||
project_file_name,
|
||||
project_desc,
|
||||
data_sourse,
|
||||
pack_name,
|
||||
page_path,
|
||||
page_style,
|
||||
template_type
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="projectName != null and projectName !=''">
|
||||
project_name=#{projectName},
|
||||
</if>
|
||||
<if test="projectFileName != null and projectFileName !=''">
|
||||
project_file_name=#{projectFileName},
|
||||
</if>
|
||||
<if test="projectDesc != null and projectDesc !=''">
|
||||
project_desc=#{projectDesc},
|
||||
</if>
|
||||
<if test="dataSourse != null">
|
||||
data_sourse=#{dataSourse},
|
||||
</if>
|
||||
<if test="packName != null and packName !=''">
|
||||
pack_name=#{packName},
|
||||
</if>
|
||||
<if test="pagePath != null and pagePath !=''">
|
||||
page_path=#{pagePath},
|
||||
</if>
|
||||
<if test="pageStyle != null">
|
||||
page_style=#{pageStyle},
|
||||
</if>
|
||||
<if test="templateType != null">
|
||||
template_type=#{templateType},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
and id=#{id}
|
||||
</if>
|
||||
<if test="projectName != null and projectName !=''">
|
||||
and project_name LIKE CONCAT(CONCAT('%', #{projectName}), '%')
|
||||
</if>
|
||||
<if test="projectFileName != null and projectFileName !=''">
|
||||
and project_file_name=#{projectFileName}
|
||||
</if>
|
||||
<if test="projectDesc != null and projectDesc !=''">
|
||||
and project_desc=#{projectDesc}
|
||||
</if>
|
||||
<if test="dataSourse != null">
|
||||
and data_sourse=#{dataSourse}
|
||||
</if>
|
||||
<if test="packName != null and packName !=''">
|
||||
and pack_name=#{packName}
|
||||
</if>
|
||||
<if test="pagePath != null and pagePath !=''">
|
||||
and page_path=#{pagePath}
|
||||
</if>
|
||||
<if test="pageStyle != null">
|
||||
and page_style=#{pageStyle}
|
||||
</if>
|
||||
<if test="templateType != null">
|
||||
and template_type=#{templateType}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="save" parameterType="Object" >
|
||||
insert into
|
||||
<include refid="table_name" />
|
||||
(
|
||||
project_name,
|
||||
project_file_name,
|
||||
project_desc,
|
||||
data_sourse,
|
||||
pack_name,
|
||||
page_path,
|
||||
page_style,
|
||||
template_type
|
||||
)
|
||||
values
|
||||
(
|
||||
#{projectName},
|
||||
#{projectFileName},
|
||||
#{projectDesc},
|
||||
#{dataSourse},
|
||||
#{packName},
|
||||
#{pagePath},
|
||||
#{pageStyle},
|
||||
#{templateType}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="queryById" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryByDataSource" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where data_sourse = #{dataSourceId}
|
||||
</select>
|
||||
|
||||
<select id="queryByPageTemplate" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where page_style = #{pageTemplateId}
|
||||
</select>
|
||||
|
||||
<select id="queryAll" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" />
|
||||
</select>
|
||||
|
||||
<select id="queryByCount" resultType="java.lang.Integer" parameterType="Object">
|
||||
select count(1) from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause" />
|
||||
</select>
|
||||
|
||||
<select id="queryByList" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
${pageQueryCondition}
|
||||
</select>
|
||||
|
||||
<select id="queryByProject" resultMap="queryResultMap" parameterType="Object">
|
||||
select
|
||||
*
|
||||
from
|
||||
t_project p, t_data_source ds, t_page_template pt
|
||||
<include refid="query_where_clause"/>
|
||||
and p.data_sourse = ds.id
|
||||
and p.page_style = pt.id
|
||||
order by p.id desc
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateResult" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
197
op-mapper/src/main/resources/mapper/generator/TableMapper.xml
Normal file
197
op-mapper/src/main/resources/mapper/generator/TableMapper.xml
Normal file
@@ -0,0 +1,197 @@
|
||||
<?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="cn.feast.coding.mapper.generator.TableMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.generator.Table">
|
||||
<result column="id" property="id"/>
|
||||
<result column="table_name" property="tableName"/>
|
||||
<result column="class_name" property="className"/>
|
||||
<result column="show_name" property="showName"/>
|
||||
<result column="show_style" property="showStyle"/>
|
||||
<result column="project_id" property="projectId"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="queryResultMap" type="cn.feast.coding.model.generator.Table">
|
||||
<result column="id" property="id"/>
|
||||
<result column="table_name" property="tableName"/>
|
||||
<result column="class_name" property="className"/>
|
||||
<result column="show_name" property="showName"/>
|
||||
<result column="show_style" property="showStyle"/>
|
||||
<result column="project_id" property="projectId"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_table
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
id,
|
||||
table_name,
|
||||
class_name,
|
||||
show_name,
|
||||
show_style,
|
||||
project_id
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="tableName != null and tableName !=''">
|
||||
table_name=#{tableName},
|
||||
</if>
|
||||
<if test="className != null and className !=''">
|
||||
class_name=#{className},
|
||||
</if>
|
||||
<if test="showName != null and showName !=''">
|
||||
show_name=#{showName},
|
||||
</if>
|
||||
<if test="showStyle != null">
|
||||
show_style=#{showStyle},
|
||||
</if>
|
||||
<if test="projectId != null">
|
||||
project_id=#{projectId},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
and id=#{id}
|
||||
</if>
|
||||
<if test="tableName != null and tableName !=''">
|
||||
and table_name=#{tableName}
|
||||
</if>
|
||||
<if test="className != null and className !=''">
|
||||
and class_name=#{className}
|
||||
</if>
|
||||
<if test="showName != null and showName !=''">
|
||||
and show_name=#{showName}
|
||||
</if>
|
||||
<if test="showStyle != null">
|
||||
and show_style=#{showStyle}
|
||||
</if>
|
||||
<if test="projectId != null">
|
||||
and project_id=#{projectId}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="save" parameterType="Object">
|
||||
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID() AS id
|
||||
</selectKey>
|
||||
insert into
|
||||
<include refid="table_name"/>
|
||||
(
|
||||
table_name,
|
||||
class_name,
|
||||
show_name,
|
||||
show_style,
|
||||
project_id
|
||||
)
|
||||
values
|
||||
(
|
||||
#{tableName},
|
||||
#{className},
|
||||
#{showName},
|
||||
#{showStyle},
|
||||
#{projectId}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="saveByBatch" parameterType="Object">
|
||||
insert into
|
||||
<include refid="table_name"/>
|
||||
(
|
||||
table_name,
|
||||
class_name,
|
||||
show_name,
|
||||
show_style,
|
||||
project_id
|
||||
)
|
||||
values
|
||||
<foreach collection="list" item="t" separator=",">
|
||||
(
|
||||
#{t.tableName},
|
||||
#{t.className},
|
||||
#{t.showName},
|
||||
#{t.showStyle},
|
||||
#{t.projectId}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="queryById" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryByProject" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name"/>
|
||||
where project_id = #{projectId}
|
||||
</select>
|
||||
|
||||
<select id="queryByCount" resultType="java.lang.Integer" parameterType="Object">
|
||||
select count(1) from
|
||||
<include refid="table_name"/>
|
||||
<include refid="query_where_clause"/>
|
||||
</select>
|
||||
|
||||
<select id="queryByList" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name"/>
|
||||
<include refid="query_where_clause"/>
|
||||
${pageQueryCondition}
|
||||
</select>
|
||||
|
||||
<select id="queryByTable" resultMap="queryResultMap" parameterType="Object">
|
||||
select
|
||||
*
|
||||
from
|
||||
t_table t, t_project p
|
||||
<include refid="query_where_clause"/>
|
||||
and t.project_id = p.id
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object">
|
||||
update
|
||||
<include refid="table_name"/>
|
||||
set
|
||||
<include refid="update_clause"/>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateResult" parameterType="Object">
|
||||
update
|
||||
<include refid="table_name"/>
|
||||
set
|
||||
<include refid="update_clause"/>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById" parameterType="Object">
|
||||
delete from
|
||||
<include refid="table_name"/>
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteProjectRelatedData" parameterType="Object">
|
||||
delete
|
||||
tt
|
||||
from
|
||||
t_table as tt, t_project as tp
|
||||
where
|
||||
tt.project_id = tp.id
|
||||
and tp.id = #{projectId}
|
||||
</delete>
|
||||
</mapper>
|
||||
128
op-mapper/src/main/resources/mapper/links/LinkMapper.xml
Normal file
128
op-mapper/src/main/resources/mapper/links/LinkMapper.xml
Normal file
@@ -0,0 +1,128 @@
|
||||
<?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="cn.feast.coding.mapper.links.LinkMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.links.Link">
|
||||
<result column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="url" property="url"/>
|
||||
<result column="description" property="description"/>
|
||||
<result column="times" property="times"/>
|
||||
<result column="typeid" property="typeid"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_link
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
id,
|
||||
name,
|
||||
url,
|
||||
description,
|
||||
times,
|
||||
typeid
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="name != null and name !=''">
|
||||
name=#{name},
|
||||
</if>
|
||||
<if test="url != null and url !=''">
|
||||
url=#{url},
|
||||
</if>
|
||||
<if test="description != null and description !=''">
|
||||
description=#{description},
|
||||
</if>
|
||||
<if test="times != null">
|
||||
times=#{times},
|
||||
</if>
|
||||
<if test="typeid != null">
|
||||
typeid=#{typeid},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
and id=#{id}
|
||||
</if>
|
||||
<if test="name != null and name !=''">
|
||||
and name LIKE CONCAT(CONCAT('%',#{name},'%'))
|
||||
</if>
|
||||
<if test="url != null and url !=''">
|
||||
and url=#{url}
|
||||
</if>
|
||||
<if test="description != null and description !=''">
|
||||
and description=#{description}
|
||||
</if>
|
||||
<if test="times != null">
|
||||
and times=#{times}
|
||||
</if>
|
||||
<if test="typeid != null">
|
||||
and typeid=#{typeid}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="insert" parameterType="Object" >
|
||||
insert into
|
||||
<include refid="table_name" />
|
||||
(
|
||||
name,
|
||||
url,
|
||||
description,
|
||||
times,
|
||||
typeid
|
||||
)
|
||||
values
|
||||
(
|
||||
#{name},
|
||||
#{url},
|
||||
#{description},
|
||||
#{times},
|
||||
#{typeid}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="selectByPrimaryKey" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryAll" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" />
|
||||
</select>
|
||||
|
||||
<select id="queryByTypeTimes" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" />
|
||||
where typeid = #{urlType}
|
||||
order by times desc
|
||||
</select>
|
||||
|
||||
<select id="selectAll" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
236
op-mapper/src/main/resources/mapper/order/OrderMapper.xml
Normal file
236
op-mapper/src/main/resources/mapper/order/OrderMapper.xml
Normal file
@@ -0,0 +1,236 @@
|
||||
<?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="cn.feast.coding.mapper.order.OrderMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.order.Order">
|
||||
<result column="id" property="id"/>
|
||||
<result column="order_date" property="orderDate"/>
|
||||
<result column="order_name" property="orderName"/>
|
||||
<result column="order_type" property="orderType"/>
|
||||
<result column="order_detail" property="orderDetail"/>
|
||||
<result column="order_money" property="orderMoney"/>
|
||||
<result column="order_deposit" property="orderDeposit"/>
|
||||
<result column="order_wangwang" property="orderWangwang"/>
|
||||
<result column="order_contact" property="orderContact"/>
|
||||
<result column="order_principal" property="orderPrincipal"/>
|
||||
<result column="order_shop" property="orderShop"/>
|
||||
<result column="order_status" property="orderStatus"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="orderStatisMap" type="cn.feast.coding.model.order.OrderStatis">
|
||||
<result column="order_type" property="orderType"/>
|
||||
<result column="order_total" property="orderTotal"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="orderStatisMonthMap" type="cn.feast.coding.model.order.MonthStatis">
|
||||
<result column="month" property="month"/>
|
||||
<result column="total" property="orderTotal"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_tb_order
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
id,
|
||||
order_date,
|
||||
order_name,
|
||||
order_type,
|
||||
order_detail,
|
||||
order_money,
|
||||
order_deposit,
|
||||
order_wangwang,
|
||||
order_contact,
|
||||
order_principal,
|
||||
order_shop,
|
||||
order_status
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="orderDate != null and orderDate !=''">
|
||||
order_date=#{orderDate},
|
||||
</if>
|
||||
<if test="orderName != null and orderName !=''">
|
||||
order_name=#{orderName},
|
||||
</if>
|
||||
<if test="orderType != null and orderType !=''">
|
||||
order_type=#{orderType},
|
||||
</if>
|
||||
<if test="orderDetail != null and orderDetail !=''">
|
||||
order_detail=#{orderDetail},
|
||||
</if>
|
||||
<if test="orderMoney != null">
|
||||
order_money=#{orderMoney},
|
||||
</if>
|
||||
<if test="orderDeposit != null">
|
||||
order_deposit=#{orderDeposit},
|
||||
</if>
|
||||
<if test="orderWangwang != null and orderWangwang !=''">
|
||||
order_wangwang=#{orderWangwang},
|
||||
</if>
|
||||
<if test="orderContact != null and orderContact !=''">
|
||||
order_contact=#{orderContact},
|
||||
</if>
|
||||
<if test="orderPrincipal != null and orderPrincipal !=''">
|
||||
order_principal=#{orderPrincipal},
|
||||
</if>
|
||||
<if test="orderShop != null and orderShop !=''">
|
||||
order_shop=#{orderShop},
|
||||
</if>
|
||||
<if test="orderStatus != null">
|
||||
order_status=#{orderStatus},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
and id=#{id}
|
||||
</if>
|
||||
<if test="orderDate != null and orderDate !=''">
|
||||
and order_date=#{orderDate}
|
||||
</if>
|
||||
<if test="orderName != null and orderName !=''">
|
||||
and order_name=#{orderName}
|
||||
</if>
|
||||
<if test="orderType != null and orderType !=''">
|
||||
and order_type=#{orderType}
|
||||
</if>
|
||||
<if test="orderDetail != null and orderDetail !=''">
|
||||
and order_detail=#{orderDetail}
|
||||
</if>
|
||||
<if test="orderMoney != null">
|
||||
and order_money=#{orderMoney}
|
||||
</if>
|
||||
<if test="orderDeposit != null">
|
||||
and order_deposit=#{orderDeposit}
|
||||
</if>
|
||||
<if test="orderWangwang != null and orderWangwang !=''">
|
||||
and order_wangwang=#{orderWangwang}
|
||||
</if>
|
||||
<if test="orderContact != null and orderContact !=''">
|
||||
and order_contact=#{orderContact}
|
||||
</if>
|
||||
<if test="orderPrincipal != null and orderPrincipal !=''">
|
||||
and order_principal=#{orderPrincipal}
|
||||
</if>
|
||||
<if test="orderShop != null and orderShop !=''">
|
||||
and order_shop=#{orderShop}
|
||||
</if>
|
||||
<if test="orderStatus != null">
|
||||
and order_status=#{orderStatus}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="insert" parameterType="Object" >
|
||||
insert into
|
||||
<include refid="table_name" />
|
||||
(
|
||||
order_date,
|
||||
order_name,
|
||||
order_type,
|
||||
order_detail,
|
||||
order_money,
|
||||
order_deposit,
|
||||
order_wangwang,
|
||||
order_contact,
|
||||
order_principal,
|
||||
order_shop,
|
||||
order_status
|
||||
)
|
||||
values
|
||||
(
|
||||
#{orderDate},
|
||||
#{orderName},
|
||||
#{orderType},
|
||||
#{orderDetail},
|
||||
#{orderMoney},
|
||||
#{orderDeposit},
|
||||
#{orderWangwang},
|
||||
#{orderContact},
|
||||
#{orderPrincipal},
|
||||
#{orderShop},
|
||||
#{orderStatus}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="selectByPrimaryKey" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryAll" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" />
|
||||
</select>
|
||||
|
||||
<select id="statisOrderMoney" resultMap="orderStatisMap" parameterType="Object">
|
||||
select sum(order_money) as order_total, order_type
|
||||
from t_tb_order
|
||||
<if test="year != null and year !=''">
|
||||
where YEAR(STR_TO_DATE(order_date,'%Y-%m-%d')) = #{year}
|
||||
</if>
|
||||
GROUP BY order_type;
|
||||
</select>
|
||||
|
||||
<select id="statisOrderCount" resultMap="orderStatisMap" parameterType="Object">
|
||||
select count(id) as order_total, order_type
|
||||
from t_tb_order
|
||||
<if test="year != null and year !=''">
|
||||
where YEAR(STR_TO_DATE(order_date,'%Y-%m-%d')) = #{year}
|
||||
</if>
|
||||
GROUP BY order_type;
|
||||
</select>
|
||||
|
||||
<select id="statisOrderMonthMoney" resultMap="orderStatisMonthMap" parameterType="Object">
|
||||
select
|
||||
MONTH(STR_TO_DATE(order_date,'%Y-%m-%d')) as month,
|
||||
SUM(order_money) as total
|
||||
from
|
||||
t_tb_order
|
||||
where
|
||||
YEAR(STR_TO_DATE(order_date,'%Y-%m-%d')) = #{year}
|
||||
<if test="shop != null and shop !=''">
|
||||
and order_shop=#{shop}
|
||||
</if>
|
||||
GROUP BY month
|
||||
</select>
|
||||
|
||||
<select id="statisOrderMonthCount" resultMap="orderStatisMonthMap" parameterType="Object">
|
||||
select
|
||||
MONTH(STR_TO_DATE(order_date,'%Y-%m-%d')) as month,
|
||||
count(id) as total
|
||||
from
|
||||
t_tb_order
|
||||
where
|
||||
YEAR(STR_TO_DATE(order_date,'%Y-%m-%d')) = #{year}
|
||||
<if test="shop != null and shop !=''">
|
||||
and order_shop=#{shop}
|
||||
</if>
|
||||
GROUP BY month
|
||||
</select>
|
||||
|
||||
<select id="selectAll" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by order_date desc
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
359
op-mapper/src/main/resources/mapper/stock/StockAnalyseMapper.xml
Normal file
359
op-mapper/src/main/resources/mapper/stock/StockAnalyseMapper.xml
Normal file
@@ -0,0 +1,359 @@
|
||||
<?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="cn.feast.coding.mapper.stock.StockAnalyseMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.stock.StockAnalyse">
|
||||
<result column="id" property="id"/>
|
||||
<result column="date" property="date"/>
|
||||
<result column="code" property="code"/>
|
||||
<result column="price" property="price"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
stock_analyse
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
id,
|
||||
date,
|
||||
code,
|
||||
price
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="date != null and date !=''">
|
||||
date=#{date},
|
||||
</if>
|
||||
<if test="code != null and code !=''">
|
||||
code=#{code},
|
||||
</if>
|
||||
<if test="price != null">
|
||||
price=#{price},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
and id=#{id}
|
||||
</if>
|
||||
<if test="date != null and date !=''">
|
||||
and date=#{date}
|
||||
</if>
|
||||
<if test="code != null and code !=''">
|
||||
and code=#{code}
|
||||
</if>
|
||||
<if test="price != null">
|
||||
and price=#{price}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="insert" parameterType="Object" >
|
||||
insert into
|
||||
<include refid="table_name" />
|
||||
(
|
||||
date,
|
||||
code,
|
||||
price
|
||||
)
|
||||
values
|
||||
(
|
||||
#{date},
|
||||
#{code},
|
||||
#{price}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="selectByPrimaryKey" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryAll" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" />
|
||||
</select>
|
||||
|
||||
<select id="selectAll" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<select id="queryAnalyse" resultType="java.util.HashMap" parameterType="Object">
|
||||
SELECT
|
||||
sb.code AS code,
|
||||
sn.name AS name,
|
||||
si.industry AS industry,
|
||||
sb.date AS date,
|
||||
sb.price AS price,
|
||||
ROUND(sc.param3,2) AS nowPrice,
|
||||
sb1.sentiment AS sentiment,
|
||||
s2.sentiment AS sentiment1,
|
||||
CONCAT(ROUND(sc.param32 ,2),'%') AS zdf,
|
||||
CONCAT(ROUND((sc.param3 - sb.price) / sb.price * 100 ,2),'%') AS zdf1,
|
||||
ROUND(s5.maxLow,2) AS dd,
|
||||
CONCAT(ROUND((sc.param3 - s5.maxLow) / s5.maxLow * 100 ,2),'%') AS zdf2,
|
||||
IFNULL(s3.count, 0) AS buyCount,
|
||||
s3.price AS buyPrice,
|
||||
s4.id AS zjpm,
|
||||
s4.flow AS flow
|
||||
FROM
|
||||
stock_analyse sb
|
||||
LEFT JOIN stock_name sn ON sb.code = sn.code
|
||||
LEFT JOIN stock_buy sb1 ON sb.code = sb1.code AND date_format(sb.date, '%Y-%m-%d') = date_format(sb1.date, '%Y-%m-%d')
|
||||
LEFT JOIN stock_current sc ON sc.code = sn.alias
|
||||
LEFT JOIN stock_industry si ON si.code = sb.code
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
tt.code,
|
||||
ROUND( MIN( tt.high ), 2 ) as maxLow
|
||||
FROM
|
||||
(SELECT * FROM stock_temp) tt
|
||||
GROUP BY code
|
||||
) s5 ON sb.code = s5.code
|
||||
LEFT JOIN (
|
||||
SELECT ss.code AS code, ss.sentiment as sentiment from stock_sentiment ss
|
||||
) s2 ON sn.alias = s2.code
|
||||
LEFT JOIN (
|
||||
SELECT code, COUNT( * ) count, GROUP_CONCAT(price SEPARATOR '--') price FROM stock_buy GROUP BY code
|
||||
) s3 ON sb.code = s3.code
|
||||
LEFT JOIN (
|
||||
SELECT sf.code AS code, sf.id as id, sf.param2 as flow from stock_flow sf
|
||||
) s4 ON sn.alias = s4.code
|
||||
WHERE sb.date like CONCAT('%', #{date}, '%')
|
||||
-- AND s4.flow > 0
|
||||
-- AND sb1.sentiment < 500
|
||||
-- AND ((sc.param3 - s5.maxLow) / s5.maxLow * 100) < 30
|
||||
GROUP BY sb.code
|
||||
ORDER BY sb.date
|
||||
</select>
|
||||
|
||||
<select id="queryAnalyse1" resultType="java.util.HashMap" parameterType="Object">
|
||||
SELECT s.code, sn.name,
|
||||
si.industry as industry,
|
||||
CONCAT(ROUND(s1.turn,2),'%') as turn,
|
||||
ROUND(s.maxHigh,2) AS maxHigh,
|
||||
ROUND(s1.high,2) AS high,
|
||||
ROUND(s1.close,2) AS close,
|
||||
CONCAT(ROUND(s1.applies,2),'%') AS applies,
|
||||
CONCAT(ROUND(s1.market_value,2),'亿') AS marketValue,
|
||||
CONCAT(ROUND(s1.amount / 10000,2),'亿') AS amount,
|
||||
CONCAT(ROUND((s1.high - s.maxHigh) / s.maxHigh * 100,2), '%') AS high1,
|
||||
CONCAT(ROUND((s1.high - s1.close) / s1.close * 100,2), '%') AS high2,
|
||||
s2.sentiment AS sentiment,
|
||||
DATE_FORMAT(SYSDATE(),'%Y-%m-%d') AS date
|
||||
FROM (
|
||||
SELECT
|
||||
tt.code,
|
||||
ROUND( MAX( tt.high ), 2 ) as maxHigh
|
||||
FROM
|
||||
(SELECT * FROM stock_temp WHERE date IN (SELECT ttt.date FROM (SELECT DISTINCT date from stock_temp ORDER BY date desc limit 20) ttt)) tt
|
||||
GROUP BY code
|
||||
) s
|
||||
LEFT JOIN (
|
||||
SELECT sn.code AS code,param33 AS high,param3 AS close, param32 AS applies, param38 AS turn,param36 AS volume,param37 AS amount, param45 AS market_value
|
||||
FROM stock_current sc
|
||||
LEFT JOIN stock_name sn on sc.alias = sn.alias
|
||||
) s1 ON s.code = s1.code
|
||||
LEFT JOIN stock_name sn ON sn.code = s.code
|
||||
LEFT JOIN stock_industry si ON si.code = s.code
|
||||
LEFT JOIN (
|
||||
SELECT sn.code AS code, ss.sentiment as sentiment from stock_sentiment ss
|
||||
LEFT JOIN stock_name sn on ss.code = sn.alias
|
||||
) s2 ON s.code = s2.code
|
||||
WHERE sn.name NOT LIKE '%ST%'
|
||||
AND sn.code NOT LIKE '%30%'
|
||||
AND sn.code NOT LIKE '%688%'
|
||||
AND (s1.turn < 20 AND s1.turn > 5)
|
||||
-- AND ROUND((s1.high - s.maxHigh) / s.maxHigh * 100,2) > 1 ## 突破比例大于1%
|
||||
-- AND ROUND((s1.high - s1.close) / s1.close * 100,2) < 3 ## 回撤比例小于3%
|
||||
-- AND (s1.market_value > 50 AND s1.market_value < 200 ) ## 市值大于50亿小于200亿
|
||||
AND (s1.applies > 7 AND s1.applies < 9.5)
|
||||
ORDER BY s1.applies desc
|
||||
</select>
|
||||
|
||||
<select id="queryAnalyse2" resultType="java.util.HashMap" parameterType="Object">
|
||||
SELECT
|
||||
sb.code AS code,
|
||||
sn.name AS name,
|
||||
si.industry AS industry,
|
||||
sb.date AS date,
|
||||
sb.price AS price,
|
||||
ROUND(sc.param3,2) AS nowPrice,
|
||||
sb1.sentiment AS sentiment,
|
||||
s2.sentiment AS sentiment1,
|
||||
CONCAT(ROUND(sc.param32 ,2),'%') AS zdf,
|
||||
CONCAT(ROUND((sc.param3 - sb.price) / sb.price * 100 ,2),'%') AS zdf1,
|
||||
ROUND(s5.maxLow,2) AS dd,
|
||||
CONCAT(ROUND((sc.param3 - s5.maxLow) / s5.maxLow * 100 ,2),'%') AS zdf2,
|
||||
IFNULL(s3.count, 0) AS buyCount,
|
||||
s3.price AS buyPrice,
|
||||
s4.id AS zjpm,
|
||||
s4.flow AS flow
|
||||
FROM
|
||||
stock_analyse sb
|
||||
LEFT JOIN stock_name sn ON sb.code = sn.code
|
||||
LEFT JOIN stock_buy sb1 ON sb.code = sb1.code AND date_format(sb.date, '%Y-%m-%d') = date_format(sb1.date, '%Y-%m-%d')
|
||||
LEFT JOIN stock_current sc ON sc.code = sn.alias
|
||||
LEFT JOIN stock_industry si ON si.code = sb.code
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
tt.code,
|
||||
ROUND( MIN( tt.high ), 2 ) as maxLow
|
||||
FROM
|
||||
(SELECT * FROM stock_temp) tt
|
||||
GROUP BY code
|
||||
) s5 ON sb.code = s5.code
|
||||
LEFT JOIN (
|
||||
SELECT ss.code AS code, ss.sentiment as sentiment from stock_sentiment ss
|
||||
) s2 ON sn.alias = s2.code
|
||||
LEFT JOIN (
|
||||
SELECT code, COUNT( * ) count, GROUP_CONCAT(price SEPARATOR '--') price FROM stock_buy GROUP BY code
|
||||
) s3 ON sb.code = s3.code
|
||||
LEFT JOIN (
|
||||
SELECT sf.code AS code, sf.id as id, sf.param2 as flow from stock_flow sf
|
||||
) s4 ON sn.alias = s4.code
|
||||
WHERE sb.date like CONCAT('%', #{date}, '%')
|
||||
AND s4.flow > 0
|
||||
AND sb1.sentiment < 300
|
||||
-- AND ((sc.param3 - s5.maxLow) / s5.maxLow * 100) < 30
|
||||
GROUP BY sb.code
|
||||
ORDER BY sb.date
|
||||
</select>
|
||||
|
||||
<select id="sortByTurn" resultType="java.util.HashMap" parameterType="Object">
|
||||
SELECT
|
||||
sc.name,
|
||||
sc.code,
|
||||
si.industry,
|
||||
ROUND(sc.param3,2) AS param3,
|
||||
CONCAT( ROUND( sc.param32, 2 ), '%' ) AS param32,
|
||||
CONCAT( ROUND( sc.param37 / 10000, 2 ), '亿' ) AS param37,
|
||||
CONCAT( ROUND( sc.param38, 2 ), '%' ) AS param38,
|
||||
CONCAT( ROUND(sc.param45, 2), '亿') AS param45
|
||||
FROM
|
||||
stock_current sc
|
||||
LEFT JOIN stock_name sn ON sc.CODE = sn.alias
|
||||
LEFT JOIN stock_industry si ON sn.CODE = si.CODE
|
||||
ORDER BY
|
||||
sc.param37 DESC
|
||||
</select>
|
||||
|
||||
<select id="sortByPrice" resultType="java.util.HashMap" parameterType="Object">
|
||||
SELECT
|
||||
sc.name,
|
||||
sc.code,
|
||||
si.industry,
|
||||
ROUND(sc.param3,2) AS param3,
|
||||
CONCAT( ROUND( sc.param32, 2 ), '%' ) AS param32,
|
||||
CONCAT( ROUND( sc.param37 / 10000, 2 ), '亿' ) AS param37,
|
||||
CONCAT( ROUND( sc.param38, 2 ), '%' ) AS param38
|
||||
FROM
|
||||
stock_current sc
|
||||
LEFT JOIN stock_name sn ON sc.CODE = sn.alias
|
||||
LEFT JOIN stock_industry si ON sn.CODE = si.CODE
|
||||
WHERE sc.code not like '%30%'
|
||||
AND sc.code not like '%688%'
|
||||
AND sc.name not like '%N%'
|
||||
ORDER BY
|
||||
sc.param32 DESC
|
||||
</select>
|
||||
|
||||
<select id="querySentiment" resultType="java.util.HashMap" parameterType="Object">
|
||||
SELECT
|
||||
ss.name,
|
||||
ss.code,
|
||||
ss.sentiment
|
||||
FROM
|
||||
stock_sentiment ss
|
||||
</select>
|
||||
|
||||
<select id="queryConcept" resultType="java.util.HashMap" parameterType="Object">
|
||||
SELECT
|
||||
sc.concept_name,
|
||||
sc.ranking,
|
||||
sc.count1,
|
||||
sc.count2,
|
||||
sc.stock,
|
||||
sc.stock_zdf
|
||||
FROM
|
||||
stock_concept sc
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="queryStockConcept" resultType="java.util.HashMap" parameterType="String">
|
||||
SELECT DISTINCT
|
||||
sc.ranking,
|
||||
sc.concept_name,
|
||||
sc.concept_code,
|
||||
sc.price,
|
||||
sc.amount,
|
||||
sc.plimit,
|
||||
sc.allamount,
|
||||
sc.turnrate,
|
||||
sc.count1,
|
||||
sc.count2,
|
||||
sc.stock,
|
||||
sc.stock_zdf
|
||||
FROM
|
||||
stock_concept sc
|
||||
INNER JOIN
|
||||
stock_concept_detail scd
|
||||
ON
|
||||
sc.concept_name = scd.concept
|
||||
WHERE
|
||||
scd.code = #{stockCode}
|
||||
ORDER BY
|
||||
sc.ranking ASC
|
||||
</select>
|
||||
|
||||
<select id="queryConceptStocks" resultType="java.util.HashMap" parameterType="String">
|
||||
SELECT DISTINCT
|
||||
scd.code,
|
||||
scd.name
|
||||
FROM
|
||||
stock_concept_detail scd
|
||||
WHERE
|
||||
scd.concept = #{conceptName}
|
||||
ORDER BY
|
||||
scd.code ASC
|
||||
</select>
|
||||
|
||||
<select id="getKLineData" resultType="java.util.HashMap" parameterType="String">
|
||||
SELECT
|
||||
date,
|
||||
CAST(open AS DECIMAL(11,2)) as open,
|
||||
CAST(high AS DECIMAL(11,2)) as high,
|
||||
CAST(low AS DECIMAL(11,2)) as low,
|
||||
CAST(close AS DECIMAL(11,2)) as close,
|
||||
volume,
|
||||
amount,
|
||||
turn,
|
||||
pctChg
|
||||
FROM
|
||||
stock
|
||||
WHERE
|
||||
code = #{stockCode}
|
||||
ORDER BY
|
||||
date ASC
|
||||
LIMIT 100
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
100
op-mapper/src/main/resources/mapper/stock/StockMapper.xml
Normal file
100
op-mapper/src/main/resources/mapper/stock/StockMapper.xml
Normal file
@@ -0,0 +1,100 @@
|
||||
<?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="cn.feast.coding.mapper.stock.StockMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.stock.Stock">
|
||||
<result column="id" property="id"/>
|
||||
<result column="stock_code" property="stockCode"/>
|
||||
<result column="stock_name" property="stockName"/>
|
||||
<result column="stock_state" property="stockState"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_stock
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
id,
|
||||
stock_code,
|
||||
stock_name,
|
||||
stock_state
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="stockCode != null and stockCode !=''">
|
||||
stock_code=#{stockCode},
|
||||
</if>
|
||||
<if test="stockName != null and stockName !=''">
|
||||
stock_name=#{stockName},
|
||||
</if>
|
||||
<if test="stockState != null">
|
||||
stock_state=#{stockState},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
and id=#{id}
|
||||
</if>
|
||||
<if test="stockCode != null and stockCode !=''">
|
||||
and stock_code=#{stockCode}
|
||||
</if>
|
||||
<if test="stockName != null and stockName !=''">
|
||||
and stock_name=#{stockName}
|
||||
</if>
|
||||
<if test="stockState != null">
|
||||
and stock_state=#{stockState}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="insert" parameterType="Object" >
|
||||
insert into
|
||||
<include refid="table_name" />
|
||||
(
|
||||
stock_code,
|
||||
stock_name,
|
||||
stock_state
|
||||
)
|
||||
values
|
||||
(
|
||||
#{stockCode},
|
||||
#{stockName},
|
||||
#{stockState}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="selectByPrimaryKey" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryAll" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" />
|
||||
</select>
|
||||
|
||||
<select id="selectAll" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
135
op-mapper/src/main/resources/mapper/system/PermissionMapper.xml
Normal file
135
op-mapper/src/main/resources/mapper/system/PermissionMapper.xml
Normal file
@@ -0,0 +1,135 @@
|
||||
<?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="cn.feast.coding.mapper.system.PermissionMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.system.Permission">
|
||||
<result column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="url" property="url"/>
|
||||
<result column="permission" property="permission"/>
|
||||
<result column="parentid" property="parentid"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_permission
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
id,
|
||||
name,
|
||||
type,
|
||||
url,
|
||||
permission,
|
||||
parentid
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="name != null and name !=''">
|
||||
name=#{name},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
type=#{type},
|
||||
</if>
|
||||
<if test="url != null and url !=''">
|
||||
url=#{url},
|
||||
</if>
|
||||
<if test="permission != null and permission !=''">
|
||||
permission=#{permission},
|
||||
</if>
|
||||
<if test="parentid != null">
|
||||
parentid=#{parentid},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
and id=#{id}
|
||||
</if>
|
||||
<if test="name != null and name !=''">
|
||||
and name=#{name}
|
||||
</if>
|
||||
<if test="type != null">
|
||||
and type=#{type}
|
||||
</if>
|
||||
<if test="url != null and url !=''">
|
||||
and url=#{url}
|
||||
</if>
|
||||
<if test="permission != null and permission !=''">
|
||||
and permission=#{permission}
|
||||
</if>
|
||||
<if test="parentid != null">
|
||||
and parentid=#{parentid}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="save" parameterType="Object" >
|
||||
insert into
|
||||
<include refid="table_name" />
|
||||
(
|
||||
name,
|
||||
type,
|
||||
url,
|
||||
permission,
|
||||
parentid
|
||||
)
|
||||
values
|
||||
(
|
||||
#{name},
|
||||
#{type},
|
||||
#{url},
|
||||
#{permission},
|
||||
#{parentid}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="queryById" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryByCount" resultType="java.lang.Integer" parameterType="Object">
|
||||
select count(1) from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause" />
|
||||
</select>
|
||||
|
||||
<select id="queryByList" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by id
|
||||
${pageQueryCondition}
|
||||
</select>
|
||||
|
||||
<select id="queryByPermission" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by id
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateResult" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
108
op-mapper/src/main/resources/mapper/system/RoleMapper.xml
Normal file
108
op-mapper/src/main/resources/mapper/system/RoleMapper.xml
Normal file
@@ -0,0 +1,108 @@
|
||||
<?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="cn.feast.coding.mapper.system.RoleMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.system.Role">
|
||||
<result column="id" property="id"/>
|
||||
<result column="role" property="role"/>
|
||||
<result column="description" property="description"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_role
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
id,
|
||||
role,
|
||||
description
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="role != null and role !=''">
|
||||
role=#{role},
|
||||
</if>
|
||||
<if test="description != null and description !=''">
|
||||
description=#{description},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
and id=#{id}
|
||||
</if>
|
||||
<if test="role != null and role !=''">
|
||||
and role=#{role}
|
||||
</if>
|
||||
<if test="description != null and description !=''">
|
||||
and description=#{description}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="save" parameterType="Object" >
|
||||
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID() AS id
|
||||
</selectKey>
|
||||
insert into
|
||||
<include refid="table_name" />
|
||||
(
|
||||
role,
|
||||
description
|
||||
)
|
||||
values
|
||||
(
|
||||
#{role},
|
||||
#{description}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="queryById" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryByCount" resultType="java.lang.Integer" parameterType="Object">
|
||||
select count(1) from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause" />
|
||||
</select>
|
||||
|
||||
<select id="queryByList" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
${pageQueryCondition}
|
||||
</select>
|
||||
|
||||
<select id="queryByRole" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateResult" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,107 @@
|
||||
<?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="cn.feast.coding.mapper.system.RolePermissionMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.system.RolePermission">
|
||||
<result column="roleid" property="roleid"/>
|
||||
<result column="permissionid" property="permissionid"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_role_permission
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
roleid,
|
||||
permissionid
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="roleid != null">
|
||||
roleid=#{roleid},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="roleid != null">
|
||||
and roleid=#{roleid}
|
||||
</if>
|
||||
<if test="permissionid != null">
|
||||
and permissionid=#{permissionid}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="save" parameterType="Object" >
|
||||
insert into
|
||||
<include refid="table_name" />
|
||||
(
|
||||
roleid,
|
||||
permissionid
|
||||
)
|
||||
values
|
||||
(
|
||||
#{roleid},
|
||||
#{permissionid}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="queryById" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where permissionid = #{permissionid}
|
||||
</select>
|
||||
|
||||
<select id="queryByRole" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where roleid = #{roleid}
|
||||
</select>
|
||||
|
||||
<select id="queryByCount" resultType="java.lang.Integer" parameterType="Object">
|
||||
select count(1) from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause" />
|
||||
</select>
|
||||
|
||||
<select id="queryByList" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by permissionid desc
|
||||
${pageQueryCondition}
|
||||
</select>
|
||||
|
||||
<select id="queryByRolePermission" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by permissionid desc
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where permissionid = #{permissionid}
|
||||
</update>
|
||||
|
||||
<update id="updateResult" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where permissionid = #{permissionid}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where permissionid = #{permissionid}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByRole" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where roleid = #{roleid}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
203
op-mapper/src/main/resources/mapper/system/UserMapper.xml
Normal file
203
op-mapper/src/main/resources/mapper/system/UserMapper.xml
Normal file
@@ -0,0 +1,203 @@
|
||||
<?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="cn.feast.coding.mapper.system.UserMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.system.User">
|
||||
<result column="id" property="id"/>
|
||||
<result column="user_name" property="userName"/>
|
||||
<result column="user_pass" property="userPass"/>
|
||||
<result column="user_salt" property="userSalt"/>
|
||||
<result column="user_real" property="userReal"/>
|
||||
<result column="user_gender" property="userGender"/>
|
||||
<result column="user_phone" property="userPhone"/>
|
||||
<result column="user_email" property="userEmail"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- Role Result Map -->
|
||||
<resultMap id="roleResultMap" type="cn.feast.coding.model.system.Role">
|
||||
<result column="id" property="id"/>
|
||||
<result column="role" property="role"/>
|
||||
<result column="description" property="description"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- Permission Result Map -->
|
||||
<resultMap id="permissionResultMap" type="cn.feast.coding.model.system.Permission">
|
||||
<result column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="url" property="url"/>
|
||||
<result column="permission" property="permission"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_user
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
id,
|
||||
user_name,
|
||||
user_pass,
|
||||
user_salt,
|
||||
user_real,
|
||||
user_gender,
|
||||
user_phone,
|
||||
user_email
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="userName != null and userName !=''">
|
||||
user_name=#{userName},
|
||||
</if>
|
||||
<if test="userPass != null and userPass !=''">
|
||||
user_pass=#{userPass},
|
||||
</if>
|
||||
<if test="userSalt != null and userSalt !=''">
|
||||
user_salt=#{userSalt},
|
||||
</if>
|
||||
<if test="userReal != null and userReal !=''">
|
||||
user_real=#{userReal},
|
||||
</if>
|
||||
<if test="userGender != null">
|
||||
user_gender=#{userGender},
|
||||
</if>
|
||||
<if test="userPhone != null and userPhone !=''">
|
||||
user_phone=#{userPhone},
|
||||
</if>
|
||||
<if test="userEmail != null and userEmail !=''">
|
||||
user_email=#{userEmail},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
and id=#{id}
|
||||
</if>
|
||||
<if test="userName != null and userName !=''">
|
||||
and user_name=#{userName}
|
||||
</if>
|
||||
<if test="userPass != null and userPass !=''">
|
||||
and user_pass=#{userPass}
|
||||
</if>
|
||||
<if test="userSalt != null and userSalt !=''">
|
||||
and user_salt=#{userSalt}
|
||||
</if>
|
||||
<if test="userReal != null and userReal !=''">
|
||||
and user_real like concat(concat("%",#{userReal}),"%")
|
||||
</if>
|
||||
<if test="userGender != null">
|
||||
and user_gender=#{userGender}
|
||||
</if>
|
||||
<if test="userPhone != null and userPhone !=''">
|
||||
and user_phone=#{userPhone}
|
||||
</if>
|
||||
<if test="userEmail != null and userEmail !=''">
|
||||
and user_email=#{userEmail}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="save" parameterType="Object" >
|
||||
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID() AS id
|
||||
</selectKey>
|
||||
insert into
|
||||
<include refid="table_name" />
|
||||
(
|
||||
user_name,
|
||||
user_pass,
|
||||
user_salt,
|
||||
user_real,
|
||||
user_gender,
|
||||
user_phone,
|
||||
user_email
|
||||
)
|
||||
values
|
||||
(
|
||||
#{userName},
|
||||
#{userPass},
|
||||
#{userSalt},
|
||||
#{userReal},
|
||||
#{userGender},
|
||||
#{userPhone},
|
||||
#{userEmail}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="queryById" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findByUsername" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where user_name = #{username}
|
||||
</select>
|
||||
|
||||
<select id="findRoles" resultMap="roleResultMap" parameterType="Object">
|
||||
select
|
||||
r.id as id, r.role as role, r.description as description
|
||||
from
|
||||
t_user u, t_role r, t_user_role ur
|
||||
where ur.userid = u.id
|
||||
AND ur.roleid = r.id
|
||||
AND u.user_name = #{username}
|
||||
</select>
|
||||
|
||||
<select id="findPermissions" resultMap="permissionResultMap" parameterType="Object">
|
||||
select
|
||||
p.id as id, p.name as name, p.type as type, p.url as url, p.permission as permission
|
||||
from
|
||||
t_user u, t_role r, t_user_role ur, t_permission p, t_role_permission rp
|
||||
where
|
||||
u.id = ur.userid
|
||||
and r.id = ur.roleid
|
||||
and rp.roleid = r.id
|
||||
and rp.permissionid = p.id
|
||||
and u.user_name = #{username}
|
||||
</select>
|
||||
|
||||
<select id="queryByCount" resultType="java.lang.Integer" parameterType="Object">
|
||||
select count(1) from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause" />
|
||||
</select>
|
||||
|
||||
<select id="queryByList" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
${pageQueryCondition}
|
||||
</select>
|
||||
|
||||
<select id="queryByUser" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateResult" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
107
op-mapper/src/main/resources/mapper/system/UserRoleMapper.xml
Normal file
107
op-mapper/src/main/resources/mapper/system/UserRoleMapper.xml
Normal file
@@ -0,0 +1,107 @@
|
||||
<?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="cn.feast.coding.mapper.system.UserRoleMapper">
|
||||
<!-- Result Map -->
|
||||
<resultMap id="baseResultMap" type="cn.feast.coding.model.system.UserRole">
|
||||
<result column="userid" property="userid"/>
|
||||
<result column="roleid" property="roleid"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<!-- table name -->
|
||||
<sql id="table_name">
|
||||
t_user_role
|
||||
</sql>
|
||||
<!-- property table all fields -->
|
||||
<sql id="base_column_list">
|
||||
userid,
|
||||
roleid
|
||||
</sql>
|
||||
<sql id="update_clause">
|
||||
<trim suffixOverrides=",">
|
||||
<if test="userid != null">
|
||||
userid=#{userid},
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<sql id="query_where_clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides=",">
|
||||
<if test="userid != null">
|
||||
and userid=#{userid}
|
||||
</if>
|
||||
<if test="roleid != null">
|
||||
and roleid=#{roleid}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
<insert id="save" parameterType="Object" >
|
||||
insert into
|
||||
<include refid="table_name" />
|
||||
(
|
||||
userid,
|
||||
roleid
|
||||
)
|
||||
values
|
||||
(
|
||||
#{userid},
|
||||
#{roleid}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="queryById" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where roleid = #{roleid}
|
||||
</select>
|
||||
|
||||
<select id="queryByUser" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list" />
|
||||
from <include refid="table_name" /> where userid = #{userid}
|
||||
</select>
|
||||
|
||||
<select id="queryByCount" resultType="java.lang.Integer" parameterType="Object">
|
||||
select count(1) from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause" />
|
||||
</select>
|
||||
|
||||
<select id="queryByList" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by roleid desc
|
||||
${pageQueryCondition}
|
||||
</select>
|
||||
|
||||
<select id="queryByUserRole" resultMap="baseResultMap" parameterType="Object">
|
||||
select
|
||||
<include refid="base_column_list"/>
|
||||
from
|
||||
<include refid="table_name" />
|
||||
<include refid="query_where_clause"/>
|
||||
order by roleid desc
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where roleid = #{roleid}
|
||||
</update>
|
||||
|
||||
<update id="updateResult" parameterType="Object" >
|
||||
update <include refid="table_name" /> set <include refid="update_clause" /> where roleid = #{roleid}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where roleid = #{roleid}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByUser" parameterType="Object">
|
||||
delete from <include refid="table_name" /> where userid = #{userid}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
53
op-mapper/src/main/resources/mybatis-config.xml
Normal file
53
op-mapper/src/main/resources/mybatis-config.xml
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE configuration
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
<settings>
|
||||
<!-- 全局映射器启用缓存 -->
|
||||
<setting name="cacheEnabled" value="true"/>
|
||||
|
||||
<!-- 查询时,关闭关联对象即时加载以提高性能 -->
|
||||
<setting name="lazyLoadingEnabled" value="true"/>
|
||||
|
||||
<!-- 对于未知的SQL查询,允许返回不同的结果集以达到通用的效果 -->
|
||||
<setting name="multipleResultSetsEnabled" value="true"/>
|
||||
|
||||
<!-- 允许使用列标签代替列名 -->
|
||||
<setting name="useColumnLabel" value="true"/>
|
||||
|
||||
<!-- 不允许使用自定义的主键值(比如由程序生成的UUID 32位编码作为键值),数据表的PK生成策略将被覆盖 -->
|
||||
<setting name="useGeneratedKeys" value="false"/>
|
||||
|
||||
<!-- 给予被嵌套的resultMap以字段-属性的映射支持 FULL,PARTIAL -->
|
||||
<setting name="autoMappingBehavior" value="PARTIAL"/>
|
||||
|
||||
<!-- 对于批量更新操作缓存SQL以提高性能 BATCH,SIMPLE -->
|
||||
<!-- <setting name="defaultExecutorType" value="BATCH" /> -->
|
||||
|
||||
<!-- 数据库超过25000秒仍未响应则超时 -->
|
||||
<!-- <setting name="defaultStatementTimeout" value="25000" /> -->
|
||||
|
||||
<!-- Allows using RowBounds on nested statements -->
|
||||
<setting name="safeRowBoundsEnabled" value="false"/>
|
||||
|
||||
<!-- Enables automatic mapping from classic database column names A_COLUMN to camel case classic Java property names aColumn. -->
|
||||
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
||||
|
||||
<!-- MyBatis uses local cache to prevent circular references and speed up repeated nested queries. By default (SESSION) all queries executed during a session are cached. If localCacheScope=STATEMENT
|
||||
local session will be used just for statement execution, no data will be shared between two different calls to the same SqlSession. -->
|
||||
<setting name="localCacheScope" value="SESSION"/>
|
||||
|
||||
<!-- Specifies the JDBC type for null values when no specific JDBC type was provided for the parameter. Some drivers require specifying the column JDBC type but others work with generic values
|
||||
like NULL, VARCHAR or OTHER. -->
|
||||
<setting name="jdbcTypeForNull" value="OTHER"/>
|
||||
|
||||
<!-- Specifies which Object's methods trigger a lazy load -->
|
||||
<setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString"/>
|
||||
|
||||
<!-- 设置关联对象加载的形态,此处为按需加载字段(加载字段由SQL指 定),不会加载关联表的所有字段,以提高性能 -->
|
||||
<setting name="aggressiveLazyLoading" value="false"/>
|
||||
|
||||
</settings>
|
||||
|
||||
</configuration>
|
||||
100
op-mapper/src/main/resources/spring-persistent.xml
Normal file
100
op-mapper/src/main/resources/spring-persistent.xml
Normal file
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd">
|
||||
|
||||
<context:property-placeholder location="classpath:jdbc.properties" ignore-unresolvable="true"/>
|
||||
<context:component-scan base-package="cn.feast.coding"/>
|
||||
|
||||
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
|
||||
<property name="driverClassName" value="${jdbc_driverClassName}"/>
|
||||
<property name="url" value="${jdbc_url}"/>
|
||||
<property name="username" value="${jdbc_username}"/>
|
||||
<property name="password" value="${jdbc_password}"/>
|
||||
|
||||
<property name="filters" value="stat"/>
|
||||
|
||||
<property name="maxActive" value="20"/>
|
||||
<property name="initialSize" value="1"/>
|
||||
<property name="maxWait" value="60000"/>
|
||||
<property name="minIdle" value="1"/>
|
||||
|
||||
<property name="timeBetweenEvictionRunsMillis" value="60000"/>
|
||||
<property name="minEvictableIdleTimeMillis" value="300000"/>
|
||||
|
||||
<property name="validationQuery" value="SELECT 'x'"/>
|
||||
<property name="testWhileIdle" value="true"/>
|
||||
<property name="testOnBorrow" value="false"/>
|
||||
<property name="testOnReturn" value="false"/>
|
||||
</bean>
|
||||
|
||||
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="plugins">
|
||||
<array>
|
||||
<bean class="com.github.pagehelper.PageInterceptor">
|
||||
<property name="properties">
|
||||
<!--使用下面的方式配置参数,一行配置一个 -->
|
||||
<value>
|
||||
offsetAsPageNum=true
|
||||
rowBoundsWithCount=true
|
||||
pageSizeZero=true
|
||||
reasonable=true
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
</array>
|
||||
</property>
|
||||
<property name="configLocation" value="classpath:mybatis-config.xml"/>
|
||||
<property name="mapperLocations" value="classpath*:mapper/*/*.xml"/>
|
||||
<property name="typeAliasesPackage" value="cn.feast.coding.model"/>
|
||||
</bean>
|
||||
|
||||
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
||||
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
|
||||
<property name="basePackage" value="cn.feast.coding.mapper"/>
|
||||
</bean>
|
||||
|
||||
<!-- 对dataSource 数据源进行事务管理 -->
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
<!-- 开启AOP监听 只对当前配置文件有效 -->
|
||||
<!--<aop:aspectj-autoproxy expose-proxy="true"/>-->
|
||||
|
||||
<!-- 事务管理 通知 -->
|
||||
<tx:advice id="txAdvice" transaction-manager="transactionManager">
|
||||
<tx:attributes>
|
||||
<!-- 对insert,update,delete 开头的方法进行事务管理,只要有异常就回滚 -->
|
||||
<tx:method name="add*" propagation="REQUIRED" rollback-for="java.lang.Throwable"/>
|
||||
<tx:method name="create*" propagation="REQUIRED" rollback-for="java.lang.Throwable"/>
|
||||
<tx:method name="insert*" propagation="REQUIRED" rollback-for="java.lang.Throwable"/>
|
||||
<tx:method name="update*" propagation="REQUIRED" rollback-for="java.lang.Throwable"/>
|
||||
<tx:method name="delete*" propagation="REQUIRED" rollback-for="java.lang.Throwable"/>
|
||||
<!-- select,count开头的方法,开启只读,提高数据库访问性能 -->
|
||||
<tx:method name="select*" read-only="true"/>
|
||||
<tx:method name="query*" read-only="true"/>
|
||||
<tx:method name="count*" read-only="true"/>
|
||||
<tx:method name="find*" read-only="true"/>
|
||||
<tx:method name="get*" read-only="true"/>
|
||||
<!-- 对其他方法 使用默认的事务管理 -->
|
||||
<tx:method name="*"/>
|
||||
</tx:attributes>
|
||||
</tx:advice>
|
||||
|
||||
<!-- 事务 aop 配置 -->
|
||||
<aop:config>
|
||||
<aop:pointcut id="serviceMethods" expression="execution(* cn.feast.coding.service..*Service*.*(..))"/>
|
||||
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods"/>
|
||||
</aop:config>
|
||||
|
||||
<!-- 启用对事务注解的支持 -->
|
||||
<tx:annotation-driven transaction-manager="transactionManager"/>
|
||||
|
||||
</beans>
|
||||
14
op-model/pom.xml
Normal file
14
op-model/pom.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>OpenPark</artifactId>
|
||||
<groupId>cn.feast.coding</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>op-model</artifactId>
|
||||
|
||||
</project>
|
||||
14
op-model/src/main/java/cn/feast/coding/model/Common.java
Normal file
14
op-model/src/main/java/cn/feast/coding/model/Common.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package cn.feast.coding.model;
|
||||
|
||||
public class Common {
|
||||
public static final String SSH_FRAME = "ssh";
|
||||
|
||||
public String classNameToFiledName(String className) {
|
||||
return uncapFirst(className);
|
||||
}
|
||||
|
||||
public String uncapFirst(String str) {
|
||||
str = str.substring(0, 1).toLowerCase() + str.substring(1);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package cn.feast.coding.model.generator;
|
||||
|
||||
import cn.feast.coding.model.Common;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class Colunm extends Common {
|
||||
private Integer id;
|
||||
private String colunmName;
|
||||
private String pageColunmName;
|
||||
private String filedName;
|
||||
private String colunmType;
|
||||
private String showName;
|
||||
private Integer editStyle;
|
||||
private Integer isPrimary;
|
||||
private Integer isShowed;
|
||||
private Integer tableId;
|
||||
private Table table;
|
||||
|
||||
public void frameAdapter(String frame){
|
||||
if(frame.equals(SSH_FRAME)){
|
||||
this.pageColunmName = classNameToFiledName(table.getClassName()) + "." + colunmName;
|
||||
}else{
|
||||
this.pageColunmName = colunmName;
|
||||
}
|
||||
}
|
||||
public String getPageColunmName() {
|
||||
return pageColunmName;
|
||||
}
|
||||
|
||||
public void setPageColunmName(String pageColunmName) {
|
||||
this.pageColunmName = pageColunmName;
|
||||
}
|
||||
|
||||
public Table getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
public void setTable(Table table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getColunmName() {
|
||||
return colunmName;
|
||||
}
|
||||
|
||||
public void setColunmName(String colunmName) {
|
||||
this.colunmName = colunmName;
|
||||
}
|
||||
|
||||
public String getFiledName() {
|
||||
return filedName;
|
||||
}
|
||||
|
||||
public void setFiledName(String filedName) {
|
||||
this.filedName = filedName;
|
||||
}
|
||||
|
||||
public String getColunmType() {
|
||||
return colunmType;
|
||||
}
|
||||
|
||||
public void setColunmType(String colunmType) {
|
||||
this.colunmType = colunmType;
|
||||
}
|
||||
|
||||
public String getShowName() {
|
||||
return showName;
|
||||
}
|
||||
|
||||
public void setShowName(String showName) {
|
||||
this.showName = showName;
|
||||
}
|
||||
|
||||
public Integer getEditStyle() {
|
||||
return editStyle;
|
||||
}
|
||||
|
||||
public void setEditStyle(Integer editStyle) {
|
||||
this.editStyle = editStyle;
|
||||
}
|
||||
|
||||
public Integer getIsPrimary() {
|
||||
return isPrimary;
|
||||
}
|
||||
|
||||
public void setIsPrimary(Integer isPrimary) {
|
||||
this.isPrimary = isPrimary;
|
||||
}
|
||||
|
||||
public Integer getIsShowed() {
|
||||
return isShowed;
|
||||
}
|
||||
|
||||
public void setIsShowed(Integer isShowed) {
|
||||
this.isShowed = isShowed;
|
||||
}
|
||||
|
||||
public Integer getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
|
||||
public void setTableId(Integer tableId) {
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package cn.feast.coding.model.generator;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class DataSource {
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String jdbcUrl;
|
||||
private String jdbcUser;
|
||||
private String jdbcPass;
|
||||
private Integer isDefault;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getJdbcUrl() {
|
||||
return jdbcUrl;
|
||||
}
|
||||
|
||||
public void setJdbcUrl(String jdbcUrl) {
|
||||
this.jdbcUrl = jdbcUrl;
|
||||
}
|
||||
|
||||
public String getJdbcUser() {
|
||||
return jdbcUser;
|
||||
}
|
||||
|
||||
public void setJdbcUser(String jdbcUser) {
|
||||
this.jdbcUser = jdbcUser;
|
||||
}
|
||||
|
||||
public String getJdbcPass() {
|
||||
return jdbcPass;
|
||||
}
|
||||
|
||||
public void setJdbcPass(String jdbcPass) {
|
||||
this.jdbcPass = jdbcPass;
|
||||
}
|
||||
|
||||
public Integer getIsDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setIsDefault(Integer isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package cn.feast.coding.model.generator;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class Module {
|
||||
private Integer id;
|
||||
private String moduleName;
|
||||
private String moduleDesc;
|
||||
private String moduleMethod;
|
||||
private Integer moduleDefault;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getModuleName() {
|
||||
return moduleName;
|
||||
}
|
||||
|
||||
public void setModuleName(String moduleName) {
|
||||
this.moduleName = moduleName;
|
||||
}
|
||||
|
||||
public String getModuleDesc() {
|
||||
return moduleDesc;
|
||||
}
|
||||
|
||||
public void setModuleDesc(String moduleDesc) {
|
||||
this.moduleDesc = moduleDesc;
|
||||
}
|
||||
|
||||
public String getModuleMethod() {
|
||||
return moduleMethod;
|
||||
}
|
||||
|
||||
public void setModuleMethod(String moduleMethod) {
|
||||
this.moduleMethod = moduleMethod;
|
||||
}
|
||||
|
||||
public Integer getModuleDefault() {
|
||||
return moduleDefault;
|
||||
}
|
||||
|
||||
public void setModuleDefault(Integer moduleDefault) {
|
||||
this.moduleDefault = moduleDefault;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
package cn.feast.coding.model.generator;
|
||||
|
||||
import cn.feast.coding.model.Common;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class ModuleProject extends Common {
|
||||
private Integer id;
|
||||
private Integer moduleId;
|
||||
private Integer projectId;
|
||||
private Integer tableId;
|
||||
private Module module;
|
||||
private Project project;
|
||||
private Table table;
|
||||
private String moduleParam1;
|
||||
private String moduleParam1Page;
|
||||
private String moduleParam1Type;
|
||||
private String moduleParam1Field;
|
||||
private String moduleParam2;
|
||||
private String moduleParam2Page;
|
||||
private String moduleParam2Type;
|
||||
private String moduleParam2Field;
|
||||
private String moduleParam3;
|
||||
private String moduleParam3Page;
|
||||
private String moduleParam3Type;
|
||||
private String moduleParam3Field;
|
||||
private String moduleUrl;
|
||||
|
||||
//兼容ssh表单name不一致问题
|
||||
public void frameAdapter(String frame){
|
||||
if(frame.equals(SSH_FRAME)){
|
||||
if(null != moduleParam1)
|
||||
this.moduleParam1Page = classNameToFiledName(table.getClassName()) + "." + moduleParam1;
|
||||
if(null != moduleParam2)
|
||||
this.moduleParam2Page = classNameToFiledName(table.getClassName()) + "." + moduleParam2;
|
||||
if(null != moduleParam3)
|
||||
this.moduleParam3Page = classNameToFiledName(table.getClassName()) + "." + moduleParam3;
|
||||
}else{
|
||||
if(null != moduleParam1)
|
||||
this.moduleParam1Page = moduleParam1;
|
||||
if(null != moduleParam2)
|
||||
this.moduleParam2Page = moduleParam2;
|
||||
if(null != moduleParam3)
|
||||
this.moduleParam3Page = moduleParam3;
|
||||
}
|
||||
}
|
||||
|
||||
public String getModuleParam1() {
|
||||
return moduleParam1;
|
||||
}
|
||||
|
||||
public void setModuleParam1(String moduleParam1) {
|
||||
this.moduleParam1 = moduleParam1;
|
||||
}
|
||||
|
||||
public String getModuleParam1Type() {
|
||||
return moduleParam1Type;
|
||||
}
|
||||
|
||||
public void setModuleParam1Type(String moduleParam1Type) {
|
||||
this.moduleParam1Type = moduleParam1Type;
|
||||
}
|
||||
|
||||
public String getModuleParam1Field() {
|
||||
return moduleParam1Field;
|
||||
}
|
||||
|
||||
public void setModuleParam1Field(String moduleParam1Field) {
|
||||
this.moduleParam1Field = moduleParam1Field;
|
||||
}
|
||||
|
||||
public String getModuleParam2() {
|
||||
return moduleParam2;
|
||||
}
|
||||
|
||||
public void setModuleParam2(String moduleParam2) {
|
||||
this.moduleParam2 = moduleParam2;
|
||||
}
|
||||
|
||||
public String getModuleParam2Type() {
|
||||
return moduleParam2Type;
|
||||
}
|
||||
|
||||
public void setModuleParam2Type(String moduleParam2Type) {
|
||||
this.moduleParam2Type = moduleParam2Type;
|
||||
}
|
||||
|
||||
public String getModuleParam2Field() {
|
||||
return moduleParam2Field;
|
||||
}
|
||||
|
||||
public void setModuleParam2Field(String moduleParam2Field) {
|
||||
this.moduleParam2Field = moduleParam2Field;
|
||||
}
|
||||
|
||||
public String getModuleParam3() {
|
||||
return moduleParam3;
|
||||
}
|
||||
|
||||
public void setModuleParam3(String moduleParam3) {
|
||||
this.moduleParam3 = moduleParam3;
|
||||
}
|
||||
|
||||
public String getModuleParam3Type() {
|
||||
return moduleParam3Type;
|
||||
}
|
||||
|
||||
public void setModuleParam3Type(String moduleParam3Type) {
|
||||
this.moduleParam3Type = moduleParam3Type;
|
||||
}
|
||||
|
||||
public String getModuleParam3Field() {
|
||||
return moduleParam3Field;
|
||||
}
|
||||
|
||||
public void setModuleParam3Field(String moduleParam3Field) {
|
||||
this.moduleParam3Field = moduleParam3Field;
|
||||
}
|
||||
|
||||
public Module getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public void setModule(Module module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public Table getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
public void setTable(Table table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getModuleId() {
|
||||
return moduleId;
|
||||
}
|
||||
|
||||
public void setModuleId(Integer moduleId) {
|
||||
this.moduleId = moduleId;
|
||||
}
|
||||
|
||||
public Integer getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
public void setProjectId(Integer projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public Integer getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
|
||||
public void setTableId(Integer tableId) {
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
public String getModuleParam1Page() {
|
||||
return moduleParam1Page;
|
||||
}
|
||||
|
||||
public void setModuleParam1Page(String moduleParam1Page) {
|
||||
this.moduleParam1Page = moduleParam1Page;
|
||||
}
|
||||
|
||||
public String getModuleParam2Page() {
|
||||
return moduleParam2Page;
|
||||
}
|
||||
|
||||
public void setModuleParam2Page(String moduleParam2Page) {
|
||||
this.moduleParam2Page = moduleParam2Page;
|
||||
}
|
||||
|
||||
public String getModuleParam3Page() {
|
||||
return moduleParam3Page;
|
||||
}
|
||||
|
||||
public void setModuleParam3Page(String moduleParam3Page) {
|
||||
this.moduleParam3Page = moduleParam3Page;
|
||||
}
|
||||
|
||||
public String getModuleUrl() {
|
||||
return moduleUrl;
|
||||
}
|
||||
|
||||
public void setModuleUrl(String moduleUrl) {
|
||||
this.moduleUrl = moduleUrl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.feast.coding.model.generator;
|
||||
|
||||
public class Page {
|
||||
private int pageNumber = 1;
|
||||
private int totalPage;
|
||||
private int maxRows;
|
||||
private int start;
|
||||
|
||||
public int getPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
public void setPageNumber(int pageNumber) {
|
||||
this.pageNumber = pageNumber;
|
||||
}
|
||||
|
||||
public int getTotalPage() {
|
||||
return totalPage;
|
||||
}
|
||||
|
||||
public void setTotalPage(int totalPage) {
|
||||
this.totalPage = totalPage;
|
||||
}
|
||||
|
||||
public int getMaxRows() {
|
||||
return maxRows;
|
||||
}
|
||||
|
||||
public void setMaxRows(int maxRows) {
|
||||
this.maxRows = maxRows;
|
||||
}
|
||||
|
||||
public int getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public void setStart(int start) {
|
||||
this.start = start;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.feast.coding.model.generator;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class PageTemplate {
|
||||
private Integer id;
|
||||
private String pageName;
|
||||
private String pagePath;
|
||||
private String pageImag;
|
||||
private String pageFrame;
|
||||
private String pageDesc;
|
||||
private Integer pageDefault;
|
||||
|
||||
public String getPageFrame() {
|
||||
return pageFrame;
|
||||
}
|
||||
|
||||
public void setPageFrame(String pageFrame) {
|
||||
this.pageFrame = pageFrame;
|
||||
}
|
||||
|
||||
public Integer getPageDefault() {
|
||||
return pageDefault;
|
||||
}
|
||||
|
||||
public void setPageDefault(Integer pageDefault) {
|
||||
this.pageDefault = pageDefault;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPageName() {
|
||||
return pageName;
|
||||
}
|
||||
|
||||
public void setPageName(String pageName) {
|
||||
this.pageName = pageName;
|
||||
}
|
||||
|
||||
public String getPagePath() {
|
||||
return pagePath;
|
||||
}
|
||||
|
||||
public void setPagePath(String pagePath) {
|
||||
this.pagePath = pagePath;
|
||||
}
|
||||
|
||||
public String getPageImag() {
|
||||
return pageImag;
|
||||
}
|
||||
|
||||
public void setPageImag(String pageImag) {
|
||||
this.pageImag = pageImag;
|
||||
}
|
||||
|
||||
public String getPageDesc() {
|
||||
return pageDesc;
|
||||
}
|
||||
|
||||
public void setPageDesc(String pageDesc) {
|
||||
this.pageDesc = pageDesc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package cn.feast.coding.model.generator;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class Project {
|
||||
private Integer id;
|
||||
private String projectName;
|
||||
private String projectFileName;
|
||||
private String projectDesc;
|
||||
private Integer dataSourse;
|
||||
private DataSource dataSource;
|
||||
private String packName;
|
||||
private String pagePath;
|
||||
private Integer pageStyle;
|
||||
private PageTemplate pageTemplate;
|
||||
private String templateType;
|
||||
|
||||
public String getProjectFileName() {
|
||||
return projectFileName;
|
||||
}
|
||||
|
||||
public void setProjectFileName(String projectFileName) {
|
||||
this.projectFileName = projectFileName;
|
||||
}
|
||||
|
||||
public PageTemplate getPageTemplate() {
|
||||
return pageTemplate;
|
||||
}
|
||||
|
||||
public void setPageTemplate(PageTemplate pageTemplate) {
|
||||
this.pageTemplate = pageTemplate;
|
||||
}
|
||||
|
||||
public DataSource getDataSource() {
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public String getProjectDesc() {
|
||||
return projectDesc;
|
||||
}
|
||||
|
||||
public void setProjectDesc(String projectDesc) {
|
||||
this.projectDesc = projectDesc;
|
||||
}
|
||||
|
||||
public Integer getDataSourse() {
|
||||
return dataSourse;
|
||||
}
|
||||
|
||||
public void setDataSourse(Integer dataSourse) {
|
||||
this.dataSourse = dataSourse;
|
||||
}
|
||||
|
||||
public String getPackName() {
|
||||
return packName;
|
||||
}
|
||||
|
||||
public void setPackName(String packName) {
|
||||
this.packName = packName;
|
||||
}
|
||||
|
||||
public String getPagePath() {
|
||||
return pagePath;
|
||||
}
|
||||
|
||||
public void setPagePath(String pagePath) {
|
||||
this.pagePath = pagePath;
|
||||
}
|
||||
|
||||
public Integer getPageStyle() {
|
||||
return pageStyle;
|
||||
}
|
||||
|
||||
public void setPageStyle(Integer pageStyle) {
|
||||
this.pageStyle = pageStyle;
|
||||
}
|
||||
|
||||
public String getTemplateType() {
|
||||
return templateType;
|
||||
}
|
||||
|
||||
public void setTemplateType(String templateType) {
|
||||
this.templateType = templateType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package cn.feast.coding.model.generator;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class Table {
|
||||
private Integer id;
|
||||
private String tableName;
|
||||
private String className;
|
||||
private String showName;
|
||||
private Integer showStyle;
|
||||
private Integer projectId;
|
||||
private Project project;
|
||||
private String url;
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public void setClassName(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public String getShowName() {
|
||||
return showName;
|
||||
}
|
||||
|
||||
public void setShowName(String showName) {
|
||||
this.showName = showName;
|
||||
}
|
||||
|
||||
public Integer getShowStyle() {
|
||||
return showStyle;
|
||||
}
|
||||
|
||||
public void setShowStyle(Integer showStyle) {
|
||||
this.showStyle = showStyle;
|
||||
}
|
||||
|
||||
public Integer getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
public void setProjectId(Integer projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
}
|
||||
52
op-model/src/main/java/cn/feast/coding/model/links/Link.java
Normal file
52
op-model/src/main/java/cn/feast/coding/model/links/Link.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package cn.feast.coding.model.links;
|
||||
|
||||
import java.util.Date;
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class Link {
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String url;
|
||||
private String description;
|
||||
private Integer times;
|
||||
private Integer typeid;
|
||||
|
||||
public Integer getId(){
|
||||
return id;
|
||||
}
|
||||
public void setId(Integer id){
|
||||
this.id = id;
|
||||
}
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public String getUrl(){
|
||||
return url;
|
||||
}
|
||||
public void setUrl(String url){
|
||||
this.url = url;
|
||||
}
|
||||
public String getDescription(){
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description){
|
||||
this.description = description;
|
||||
}
|
||||
public Integer getTimes(){
|
||||
return times;
|
||||
}
|
||||
public void setTimes(Integer times){
|
||||
this.times = times;
|
||||
}
|
||||
public Integer getTypeid(){
|
||||
return typeid;
|
||||
}
|
||||
public void setTypeid(Integer typeid){
|
||||
this.typeid = typeid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.feast.coding.model.order;
|
||||
|
||||
public class MonthStatis {
|
||||
private Integer month;
|
||||
private Integer orderTotal;
|
||||
|
||||
public Integer getMonth() {
|
||||
return month;
|
||||
}
|
||||
|
||||
public void setMonth(Integer month) {
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
public Integer getOrderTotal() {
|
||||
return orderTotal;
|
||||
}
|
||||
|
||||
public void setOrderTotal(Integer orderTotal) {
|
||||
this.orderTotal = orderTotal;
|
||||
}
|
||||
}
|
||||
115
op-model/src/main/java/cn/feast/coding/model/order/Order.java
Normal file
115
op-model/src/main/java/cn/feast/coding/model/order/Order.java
Normal file
@@ -0,0 +1,115 @@
|
||||
package cn.feast.coding.model.order;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class Order {
|
||||
private Integer id;
|
||||
private String orderDate;
|
||||
private String orderName;
|
||||
private String orderType;
|
||||
private String orderDetail;
|
||||
private Double orderMoney;
|
||||
private Double orderDeposit;
|
||||
private String orderWangwang;
|
||||
private String orderContact;
|
||||
private String orderPrincipal;
|
||||
private String orderShop;
|
||||
private Integer orderStatus;
|
||||
|
||||
public String getOrderShop() {
|
||||
return orderShop;
|
||||
}
|
||||
|
||||
public void setOrderShop(String orderShop) {
|
||||
this.orderShop = orderShop;
|
||||
}
|
||||
|
||||
public String getOrderType() {
|
||||
return orderType;
|
||||
}
|
||||
|
||||
public void setOrderType(String orderType) {
|
||||
this.orderType = orderType;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getOrderDate() {
|
||||
return orderDate;
|
||||
}
|
||||
|
||||
public void setOrderDate(String orderDate) {
|
||||
this.orderDate = orderDate;
|
||||
}
|
||||
|
||||
public String getOrderName() {
|
||||
return orderName;
|
||||
}
|
||||
|
||||
public void setOrderName(String orderName) {
|
||||
this.orderName = orderName;
|
||||
}
|
||||
|
||||
public String getOrderDetail() {
|
||||
return orderDetail;
|
||||
}
|
||||
|
||||
public void setOrderDetail(String orderDetail) {
|
||||
this.orderDetail = orderDetail;
|
||||
}
|
||||
|
||||
public Double getOrderMoney() {
|
||||
return orderMoney;
|
||||
}
|
||||
|
||||
public void setOrderMoney(Double orderMoney) {
|
||||
this.orderMoney = orderMoney;
|
||||
}
|
||||
|
||||
public Double getOrderDeposit() {
|
||||
return orderDeposit;
|
||||
}
|
||||
|
||||
public void setOrderDeposit(Double orderDeposit) {
|
||||
this.orderDeposit = orderDeposit;
|
||||
}
|
||||
|
||||
public String getOrderContact() {
|
||||
return orderContact;
|
||||
}
|
||||
|
||||
public void setOrderContact(String orderContact) {
|
||||
this.orderContact = orderContact;
|
||||
}
|
||||
|
||||
public String getOrderPrincipal() {
|
||||
return orderPrincipal;
|
||||
}
|
||||
|
||||
public void setOrderPrincipal(String orderPrincipal) {
|
||||
this.orderPrincipal = orderPrincipal;
|
||||
}
|
||||
|
||||
public Integer getOrderStatus() {
|
||||
return orderStatus;
|
||||
}
|
||||
|
||||
public void setOrderStatus(Integer orderStatus) {
|
||||
this.orderStatus = orderStatus;
|
||||
}
|
||||
|
||||
public String getOrderWangwang() {
|
||||
return orderWangwang;
|
||||
}
|
||||
|
||||
public void setOrderWangwang(String orderWangwang) {
|
||||
this.orderWangwang = orderWangwang;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.feast.coding.model.order;
|
||||
|
||||
public class OrderStatis {
|
||||
private String orderType;
|
||||
private Object orderTotal;
|
||||
|
||||
public String getOrderType() {
|
||||
return orderType;
|
||||
}
|
||||
|
||||
public void setOrderType(String orderType) {
|
||||
this.orderType = orderType;
|
||||
}
|
||||
|
||||
public Object getOrderTotal() {
|
||||
return orderTotal;
|
||||
}
|
||||
|
||||
public void setOrderTotal(Object orderTotal) {
|
||||
this.orderTotal = orderTotal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.feast.coding.model.stock;
|
||||
|
||||
import java.util.Date;
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class Stock {
|
||||
private Integer id;
|
||||
private String stockCode;
|
||||
private String stockName;
|
||||
private Integer stockState;
|
||||
|
||||
public Integer getId(){
|
||||
return id;
|
||||
}
|
||||
public void setId(Integer id){
|
||||
this.id = id;
|
||||
}
|
||||
public String getStockCode(){
|
||||
return stockCode;
|
||||
}
|
||||
public void setStockCode(String stockCode){
|
||||
this.stockCode = stockCode;
|
||||
}
|
||||
public String getStockName(){
|
||||
return stockName;
|
||||
}
|
||||
public void setStockName(String stockName){
|
||||
this.stockName = stockName;
|
||||
}
|
||||
public Integer getStockState(){
|
||||
return stockState;
|
||||
}
|
||||
public void setStockState(Integer stockState){
|
||||
this.stockState = stockState;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package cn.feast.coding.model.stock;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class StockAnalyse {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String date;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Double price;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Double price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.feast.coding.model.system;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class Permission {
|
||||
private Integer id;
|
||||
private String name;
|
||||
private Integer type;
|
||||
private String url;
|
||||
private String permission;
|
||||
private Integer parentid;
|
||||
private int checked;
|
||||
|
||||
public int getChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
public void setChecked(int checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
public void setPermission(String permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
public Integer getParentid() {
|
||||
return parentid;
|
||||
}
|
||||
|
||||
public void setParentid(Integer parentid) {
|
||||
this.parentid = parentid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.feast.coding.model.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class Role {
|
||||
private Integer id;
|
||||
private String role;
|
||||
private String description;
|
||||
private List<Permission> permissionList;
|
||||
|
||||
public List<Permission> getPermissionList() {
|
||||
return permissionList;
|
||||
}
|
||||
|
||||
public void setPermissionList(List<Permission> permissionList) {
|
||||
this.permissionList = permissionList;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.feast.coding.model.system;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class RolePermission {
|
||||
private Integer roleid;
|
||||
private Integer permissionid;
|
||||
|
||||
public Integer getRoleid(){
|
||||
return roleid;
|
||||
}
|
||||
public void setRoleid(Integer roleid){
|
||||
this.roleid = roleid;
|
||||
}
|
||||
public Integer getPermissionid(){
|
||||
return permissionid;
|
||||
}
|
||||
public void setPermissionid(Integer permissionid){
|
||||
this.permissionid = permissionid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package cn.feast.coding.model.system;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class User {
|
||||
private Integer id;
|
||||
private String userName;
|
||||
private String userPass;
|
||||
private String userSalt;
|
||||
private String userReal;
|
||||
private Integer userGender;
|
||||
private String userPhone;
|
||||
private String userEmail;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getUserPass() {
|
||||
return userPass;
|
||||
}
|
||||
|
||||
public void setUserPass(String userPass) {
|
||||
this.userPass = userPass;
|
||||
}
|
||||
|
||||
public String getUserSalt() {
|
||||
return userSalt;
|
||||
}
|
||||
|
||||
public void setUserSalt(String userSalt) {
|
||||
this.userSalt = userSalt;
|
||||
}
|
||||
|
||||
public String getUserReal() {
|
||||
return userReal;
|
||||
}
|
||||
|
||||
public void setUserReal(String userReal) {
|
||||
this.userReal = userReal;
|
||||
}
|
||||
|
||||
public Integer getUserGender() {
|
||||
return userGender;
|
||||
}
|
||||
|
||||
public void setUserGender(Integer userGender) {
|
||||
this.userGender = userGender;
|
||||
}
|
||||
|
||||
public String getUserPhone() {
|
||||
return userPhone;
|
||||
}
|
||||
|
||||
public void setUserPhone(String userPhone) {
|
||||
this.userPhone = userPhone;
|
||||
}
|
||||
|
||||
public String getUserEmail() {
|
||||
return userEmail;
|
||||
}
|
||||
|
||||
public void setUserEmail(String userEmail) {
|
||||
this.userEmail = userEmail;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.feast.coding.model.system;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
public class UserRole {
|
||||
private Integer userid;
|
||||
private Integer roleid;
|
||||
|
||||
public Integer getUserid(){
|
||||
return userid;
|
||||
}
|
||||
public void setUserid(Integer userid){
|
||||
this.userid = userid;
|
||||
}
|
||||
public Integer getRoleid(){
|
||||
return roleid;
|
||||
}
|
||||
public void setRoleid(Integer roleid){
|
||||
this.roleid = roleid;
|
||||
}
|
||||
|
||||
}
|
||||
31
op-service/pom.xml
Normal file
31
op-service/pom.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>OpenPark</artifactId>
|
||||
<groupId>cn.feast.coding</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>op-service</artifactId>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.feast.coding</groupId>
|
||||
<artifactId>op-mapper</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.feast.coding</groupId>
|
||||
<artifactId>op-tools</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.feast.coding.generator;
|
||||
|
||||
public class BaseGenerator {
|
||||
/**
|
||||
* 拼接包名
|
||||
* @param pack
|
||||
* @param part
|
||||
* @return
|
||||
*/
|
||||
public String getPackName(String pack, String part) {
|
||||
return pack + "." + part;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个字符串首字母小写
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public String uncapFirst(String str) {
|
||||
str = str.substring(0, 1).toLowerCase() + str.substring(1);
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个字符串首字母大写
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public String capFirst(String str) {
|
||||
str = str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.feast.coding.generator;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface Generator {
|
||||
void generateModel(Map<String, Object> map);
|
||||
|
||||
void generateDao(Map<String, Object> map);
|
||||
|
||||
void generateDaoImpl(Map<String, Object> map);
|
||||
|
||||
void generateController(Map<String, Object> map);
|
||||
|
||||
void generateIService(Map<String, Object> map);
|
||||
|
||||
void generateService(Map<String, Object> map);
|
||||
|
||||
void generateJsp(Map<String, Object> map);
|
||||
|
||||
void generateIndex(Map<String, Object> map);
|
||||
|
||||
void generateUtils(Map<String, Object> map);
|
||||
|
||||
void generateCommon(Map<String, Object> map);
|
||||
|
||||
void generateDefined(Map<String, Object> map);
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
package cn.feast.coding.generator;
|
||||
|
||||
import cn.feast.coding.generator.utils.CodeGenerator;
|
||||
import cn.feast.coding.model.generator.*;
|
||||
import cn.feast.coding.service.generator.PageTemplateService;
|
||||
import cn.feast.coding.tools.Contants;
|
||||
import cn.feast.coding.tools.JSPPageTemplate;
|
||||
import cn.feast.coding.tools.PageTemplateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class JSPGenerator extends BaseGenerator implements Generator {
|
||||
@Autowired
|
||||
private PageTemplateService pageTemplateService;
|
||||
|
||||
public void generateModel(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SERVLET_TEMPLATE_PATH);
|
||||
map.put("templateName", JSPPageTemplate.MODEL_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "model"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + ".java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "model"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateDao(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SERVLET_TEMPLATE_PATH);
|
||||
map.put("templateName", JSPPageTemplate.DAO_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "dao"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Dao.java");
|
||||
map.put("updateClause", updateClause(map));
|
||||
map.put("insertClause", insertClause(map));
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "dao"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateDaoImpl(Map<String, Object> map) {
|
||||
|
||||
}
|
||||
|
||||
public void generateController(Map<String, Object> map) {
|
||||
String pack = getPackName(((Project) map.get("project")).getPackName(), "servlet");
|
||||
map.put("templatePath", Contants.SERVLET_TEMPLATE_PATH);
|
||||
map.put("pack", pack);
|
||||
map.put("filePath", pack);
|
||||
String className = ((Table) map.get("table")).getClassName();
|
||||
map.put("templateName", JSPPageTemplate.QUERY_SERVLET_TEMPLATE);
|
||||
map.put("fileName", "Query" + className + "Servlet.java");
|
||||
CodeGenerator.generator(map);
|
||||
map.put("templateName", JSPPageTemplate.ADD_SERVLET_TEMPLATE);
|
||||
map.put("fileName", "Add" + className + "Servlet.java");
|
||||
CodeGenerator.generator(map);
|
||||
map.put("templateName", JSPPageTemplate.EDIT_SERVLET_TEMPLATE);
|
||||
map.put("fileName", "Edit" + className + "Servlet.java");
|
||||
CodeGenerator.generator(map);
|
||||
map.put("templateName", JSPPageTemplate.UPDATE_SERVLET_TEMPLATE);
|
||||
map.put("fileName", "Update" + className + "Servlet.java");
|
||||
CodeGenerator.generator(map);
|
||||
map.put("templateName", JSPPageTemplate.DELETE_SERVLET_TEMPLATE);
|
||||
map.put("fileName", "Delete" + className + "Servlet.java");
|
||||
CodeGenerator.generator(map);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateIService(Map<String, Object> map) {
|
||||
|
||||
}
|
||||
|
||||
public void generateService(Map<String, Object> map) {
|
||||
|
||||
}
|
||||
|
||||
public void generateJsp(Map<String, Object> map) {
|
||||
List<Table> tableList = (List<Table>) map.get("tableList");
|
||||
for (Table t : tableList) {
|
||||
t.setUrl("<%=path %>/query" + t.getClassName() + "Servlet");
|
||||
}
|
||||
map.put("tableList", tableList);
|
||||
PageTemplate pageTemplate = pageTemplateService.queryById(((Project) map.get("project")).getPageStyle());
|
||||
map.put("templatePath", pageTemplate.getPagePath());
|
||||
String className = ((Table) map.get("table")).getClassName();
|
||||
String list_url = "<%=path %>/query" + className + "Servlet";
|
||||
String add_url = "<%=path %>/add" + className + "Servlet";
|
||||
String edit_url = "<%=path %>/edit" + className + "Servlet";
|
||||
String update_url = "<%=path %>/update" + className + "Servlet";
|
||||
String delete_url = "<%=path %>/delete" + className + "Servlet";
|
||||
map.put("list_url", list_url);
|
||||
map.put("add_url", add_url);
|
||||
map.put("edit_url", edit_url);
|
||||
map.put("update_url", update_url);
|
||||
map.put("delete_url", delete_url);
|
||||
String pack = getPackName(((Project) map.get("project")).getPackName(), "jsp");
|
||||
map.put("pack", pack);
|
||||
map.put("filePath", pack);
|
||||
//list页面
|
||||
map.put("templateName", PageTemplateUtils.LIST_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_list.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
//add页面
|
||||
map.put("templateName", PageTemplateUtils.ADD_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_add.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
//edit页面
|
||||
map.put("templateName", PageTemplateUtils.EDIT_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_edit.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateIndex(Map<String, Object> map) {
|
||||
List<Table> tableList = (List<Table>) map.get("tableList");
|
||||
for (Table t : tableList) {
|
||||
t.setUrl("<%=path %>/query" + t.getClassName() + "Servlet");
|
||||
}
|
||||
map.put("tableList", tableList);
|
||||
PageTemplate pageTemplate = pageTemplateService.queryById(((Project) map.get("project")).getPageStyle());
|
||||
map.put("templatePath", pageTemplate.getPagePath());
|
||||
map.put("templateName", PageTemplateUtils.INDEX_PAGE);
|
||||
String pack = getPackName(((Project) map.get("project")).getPackName(), "jsp");
|
||||
map.put("pack", pack);
|
||||
map.put("fileName", "index.jsp");
|
||||
map.put("filePath", pack);
|
||||
CodeGenerator.generator(map);
|
||||
|
||||
//添加登录模块支持(登录页面)
|
||||
ModuleProject loginModule = (ModuleProject) map.get("loginModule");
|
||||
if (null != loginModule) {
|
||||
//登陆页面
|
||||
map.put("login_url", "<%=path %>/loginServlet");
|
||||
map.put("templateName", PageTemplateUtils.LOGIN_PAGE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("fileName", "login.jsp");
|
||||
map.put("filePath", pack);
|
||||
CodeGenerator.generator(map);
|
||||
//登陆servlet
|
||||
map.put("templatePath", Contants.SERVLET_TEMPLATE_PATH);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "servlet"));
|
||||
map.put("templateName", JSPPageTemplate.LOGIN_SERVLET_TEMPLATE);
|
||||
map.put("fileName", "LoginServlet.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "servlet"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
}
|
||||
|
||||
public void generateUtils(Map<String, Object> map) {
|
||||
String pack = getPackName(((Project) map.get("project")).getPackName(), "utils");
|
||||
map.put("pack", pack);
|
||||
map.put("filePath", pack);
|
||||
map.put("templatePath", Contants.SERVLET_TEMPLATE_PATH);
|
||||
map.put("templateName", JSPPageTemplate.DBUTILS_TEMPLATE);
|
||||
map.put("fileName", "DbUtils.java");
|
||||
CodeGenerator.generator(map);
|
||||
map.put("templateName", JSPPageTemplate.PAGE_UTILS_TEMPLATE);
|
||||
map.put("fileName", "PageUtils.java");
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateCommon(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SERVLET_TEMPLATE_PATH);
|
||||
map.put("templateName", JSPPageTemplate.XML_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "xml"));
|
||||
map.put("fileName", "web.xml");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "xml"));
|
||||
CodeGenerator.generator(map);
|
||||
map.put("templateName", JSPPageTemplate.PAGE_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "model"));
|
||||
map.put("fileName", "Page.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "model"));
|
||||
CodeGenerator.generator(map);
|
||||
//添加查询模块支持
|
||||
List<ModuleProject> queryList = (List<ModuleProject>) map.get("queryModule");
|
||||
if (null != queryList && queryList.size() > 0) {
|
||||
for (ModuleProject queryModule : queryList) {
|
||||
map.put("templateName", JSPPageTemplate.QUERY_SERVLET_SELECTED_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "servlet"));
|
||||
map.put("fileName", "query" + queryModule.getTable().getClassName() + "SelectedServlet");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "servlet"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void generateDefined(Map<String, Object> map) {
|
||||
}
|
||||
|
||||
/**
|
||||
* dao层 insert语句拼接
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public String insertClause(Map<String, Object> map) {
|
||||
StringBuilder clause = new StringBuilder();
|
||||
clause.append("(");
|
||||
List<Colunm> colunmList = (List<Colunm>) map.get("colunmList");
|
||||
for (int i = 0; i < colunmList.size(); i++) {
|
||||
clause.append(colunmList.get(i).getFiledName());
|
||||
if (i != colunmList.size() - 1) {
|
||||
clause.append(",");
|
||||
}
|
||||
}
|
||||
clause.append(")").append(Contants.BLACK_SPACE).append("values").append("(");
|
||||
for (int i = 0; i < colunmList.size(); i++) {
|
||||
Colunm colunm = colunmList.get(i);
|
||||
if (colunm.getColunmType().equals(Contants.STRING_TYPE)) {
|
||||
clause.append("'").append("\"").append("+");
|
||||
clause.append("model.get" + capFirst(colunm.getColunmName()) + "()");
|
||||
clause.append("+").append("\"").append("'");
|
||||
} else {
|
||||
clause.append("\"").append("+");
|
||||
clause.append("model.get" + capFirst(colunm.getColunmName()) + "()");
|
||||
clause.append("+").append("\"");
|
||||
}
|
||||
if (i != colunmList.size() - 1) {
|
||||
clause.append(",");
|
||||
}
|
||||
}
|
||||
clause.append(")");
|
||||
return clause.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* dao层 update语句拼接
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public String updateClause(Map<String, Object> map) {
|
||||
StringBuilder clause = new StringBuilder();
|
||||
Colunm primary = (Colunm) map.get("primary");
|
||||
List<Colunm> colunmList = (List<Colunm>) map.get("colunmList");
|
||||
for (int i = 0; i < colunmList.size(); i++) {
|
||||
Colunm colunm = colunmList.get(i);
|
||||
if (!colunm.getColunmName().equals(primary.getColunmName())) {
|
||||
clause.append(colunm.getFiledName()).append("=");
|
||||
if (colunm.getColunmType().equals(Contants.STRING_TYPE)) {
|
||||
clause.append("'").append("\"").append("+");
|
||||
clause.append("model.get" + capFirst(colunm.getColunmName()) + "()");
|
||||
clause.append("+").append("\"").append("'");
|
||||
} else {
|
||||
clause.append("\"").append("+");
|
||||
clause.append("model.get" + capFirst(colunm.getColunmName()) + "()");
|
||||
clause.append("+").append("\"");
|
||||
}
|
||||
if (i != colunmList.size() - 1) {
|
||||
clause.append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
clause.append(Contants.BLACK_SPACE).append("where").append(Contants.BLACK_SPACE);
|
||||
clause.append(primary.getFiledName()).append("=");
|
||||
if (primary.getColunmType().equals(Contants.STRING_TYPE)) {
|
||||
clause.append("'").append("\"").append("+");
|
||||
clause.append("model.get" + capFirst(primary.getColunmName()) + "()");
|
||||
clause.append("+").append("\"").append("'");
|
||||
} else {
|
||||
clause.append("\"").append("+");
|
||||
clause.append("model.get" + capFirst(primary.getColunmName()) + "()");
|
||||
clause.append("+").append("\"");
|
||||
}
|
||||
return clause.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package cn.feast.coding.generator;
|
||||
|
||||
import cn.feast.coding.generator.utils.CodeGenerator;
|
||||
import cn.feast.coding.model.generator.ModuleProject;
|
||||
import cn.feast.coding.model.generator.PageTemplate;
|
||||
import cn.feast.coding.model.generator.Project;
|
||||
import cn.feast.coding.model.generator.Table;
|
||||
import cn.feast.coding.service.generator.PageTemplateService;
|
||||
import cn.feast.coding.tools.Contants;
|
||||
import cn.feast.coding.tools.PageTemplateUtils;
|
||||
import cn.feast.coding.tools.SSHPageTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class SSHGenerator extends BaseGenerator implements Generator {
|
||||
@Autowired
|
||||
private PageTemplateService pageTemplateService;
|
||||
|
||||
public void generateModel(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSH_TEMPLATE_PATH);
|
||||
map.put("templateName", SSHPageTemplate.MODEL_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "bean"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + ".java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "bean"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateDao(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSH_TEMPLATE_PATH);
|
||||
map.put("templateName", SSHPageTemplate.MAPPER_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "dao"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Dao.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "dao"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateDaoImpl(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSH_TEMPLATE_PATH);
|
||||
map.put("templateName", SSHPageTemplate.MAPPER_XML_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "daoImpl"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "DaoImpl.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "daoImpl"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateController(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSH_TEMPLATE_PATH);
|
||||
map.put("templateName", SSHPageTemplate.CONTROLLER_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "action"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Action.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "action"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateIService(Map<String, Object> map) {
|
||||
|
||||
}
|
||||
|
||||
public void generateService(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSH_TEMPLATE_PATH);
|
||||
map.put("templateName", SSHPageTemplate.SERVICE_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "service"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Service.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "service"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateJsp(Map<String, Object> map) {
|
||||
List<Table> tableList = (List<Table>) map.get("tableList");
|
||||
for (Table t : tableList) {
|
||||
t.setUrl("<%=path %>/" + uncapFirst(t.getClassName()) + "/" + uncapFirst(t.getClassName()) + "-list.action");
|
||||
}
|
||||
map.put("tableList", tableList);
|
||||
PageTemplate pageTemplate = pageTemplateService.queryById(((Project) map.get("project")).getPageStyle());
|
||||
map.put("templatePath", pageTemplate.getPagePath());
|
||||
String className = uncapFirst(((Table) map.get("table")).getClassName());
|
||||
String list_url = "<%=path %>/" + className + "/" + className + "-list.action";
|
||||
String add_url = "<%=path %>/" + className + "/" + className + "-add.action";
|
||||
String edit_url = "<%=path %>/" + className + "/" + className + "-edit.action";
|
||||
String update_url = "<%=path %>/" + className + "/" + className + "-update.action";
|
||||
String delete_url = "<%=path %>/" + className + "/" + className + "-delete.action";
|
||||
map.put("list_url", list_url);
|
||||
map.put("add_url", add_url);
|
||||
map.put("edit_url", edit_url);
|
||||
map.put("update_url", update_url);
|
||||
map.put("delete_url", delete_url);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
//list页面
|
||||
map.put("templateName", PageTemplateUtils.LIST_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_list.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
//add页面
|
||||
map.put("templateName", PageTemplateUtils.ADD_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_add.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
//edit页面
|
||||
map.put("templateName", PageTemplateUtils.EDIT_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_edit.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateIndex(Map<String, Object> map) {
|
||||
List<Table> tableList = (List<Table>) map.get("tableList");
|
||||
for (Table t : tableList) {
|
||||
t.setUrl("<%=path %>/" + uncapFirst(t.getClassName()) + "/" + uncapFirst(t.getClassName()) + "-list.action");
|
||||
}
|
||||
map.put("tableList", tableList);
|
||||
PageTemplate pageTemplate = pageTemplateService.queryById(((Project) map.get("project")).getPageStyle());
|
||||
map.put("templatePath", pageTemplate.getPagePath());
|
||||
map.put("templateName", PageTemplateUtils.INDEX_PAGE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("fileName", "index.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
|
||||
//添加登录模块支持(登录页面)
|
||||
ModuleProject loginModule = (ModuleProject) map.get("loginModule");
|
||||
if (null != loginModule) {
|
||||
map.put("login_url", "<%=path %>/" + uncapFirst(loginModule.getTable().getClassName()) + "/" + uncapFirst(loginModule.getTable().getClassName()) + "-login.action");
|
||||
map.put("templateName", PageTemplateUtils.LOGIN_PAGE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("fileName", "login.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
}
|
||||
|
||||
public void generateUtils(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSH_TEMPLATE_PATH);
|
||||
map.put("templateName", SSHPageTemplate.PAGE_UTILS_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "utils"));
|
||||
map.put("fileName", "PageUtils.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "utils"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateCommon(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSH_TEMPLATE_PATH);
|
||||
map.put("templateName", SSHPageTemplate.STRUTS_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "struts"));
|
||||
map.put("fileName", "struts.xml");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "struts"));
|
||||
CodeGenerator.generator(map);
|
||||
map.put("templateName", SSHPageTemplate.PAGE_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "bean"));
|
||||
map.put("fileName", "Page.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "bean"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateDefined(Map<String, Object> map) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package cn.feast.coding.generator;
|
||||
|
||||
import cn.feast.coding.generator.utils.CodeGenerator;
|
||||
import cn.feast.coding.model.generator.ModuleProject;
|
||||
import cn.feast.coding.model.generator.PageTemplate;
|
||||
import cn.feast.coding.model.generator.Project;
|
||||
import cn.feast.coding.model.generator.Table;
|
||||
import cn.feast.coding.service.generator.PageTemplateService;
|
||||
import cn.feast.coding.tools.Contants;
|
||||
import cn.feast.coding.tools.PageTemplateUtils;
|
||||
import cn.feast.coding.tools.SSMCustomPageTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class SSMCustomGenerator extends BaseGenerator implements Generator {
|
||||
@Autowired
|
||||
private PageTemplateService pageTemplateService;
|
||||
|
||||
public void generateModel(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_CUSTOM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMCustomPageTemplate.MODEL_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "model"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + ".java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "model"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateDao(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_CUSTOM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMCustomPageTemplate.MAPPER_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "mapper"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Mapper.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "mapper"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateDaoImpl(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_CUSTOM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMCustomPageTemplate.MAPPER_XML_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "mapping"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Mapper.xml");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "mapping"));
|
||||
CodeGenerator.generator(map);
|
||||
|
||||
}
|
||||
|
||||
public void generateController(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_CUSTOM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMCustomPageTemplate.CONTROLLER_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "controller"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Controller.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "controller"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateIService(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_CUSTOM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMCustomPageTemplate.SERVICE_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "service"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Service.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "service"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateService(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_CUSTOM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMCustomPageTemplate.SERVICE_IMPL_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "service.impl"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "ServiceImpl.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "service.impl"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateJsp(Map<String, Object> map) {
|
||||
//兼容有些页面模板,增加修改查询页面也存在导航的情况
|
||||
List<Table> tableList = (List<Table>) map.get("tableList");
|
||||
for (Table t : tableList) {
|
||||
t.setUrl("<%=path %>/" + uncapFirst(t.getClassName()) + "/list");
|
||||
}
|
||||
map.put("tableList", tableList);
|
||||
PageTemplate pageTemplate = pageTemplateService.queryById(((Project) map.get("project")).getPageStyle());
|
||||
map.put("templatePath", pageTemplate.getPagePath());
|
||||
String className = uncapFirst(((Table) map.get("table")).getClassName());
|
||||
String list_url = "<%=path %>/" + className + "/list";
|
||||
String add_url = "<%=path %>/" + className + "/add";
|
||||
String update_url = "<%=path %>/" + className + "/update";
|
||||
String delete_url = "<%=path %>/" + className + "/delete";
|
||||
map.put("list_url", list_url);
|
||||
map.put("add_url", add_url);
|
||||
map.put("edit_url", update_url);
|
||||
map.put("update_url", update_url);
|
||||
map.put("delete_url", delete_url);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
//list页面
|
||||
map.put("templateName", PageTemplateUtils.LIST_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_list.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
//add页面
|
||||
map.put("templateName", PageTemplateUtils.ADD_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_add.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
//edit页面
|
||||
map.put("templateName", PageTemplateUtils.EDIT_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_edit.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateIndex(Map<String, Object> map) {
|
||||
|
||||
//兼容有些页面模板,增加修改查询页面也存在导航的情况
|
||||
List<Table> tableList = (List<Table>) map.get("tableList");
|
||||
for (Table t : tableList) {
|
||||
t.setUrl("<%=path %>/" + uncapFirst(t.getClassName()) + "/list");
|
||||
}
|
||||
map.put("tableList", tableList);
|
||||
PageTemplate pageTemplate = pageTemplateService.queryById(((Project) map.get("project")).getPageStyle());
|
||||
map.put("templatePath", pageTemplate.getPagePath());
|
||||
map.put("templateName", PageTemplateUtils.INDEX_PAGE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("fileName", "index.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
|
||||
//添加登录模块支持(登录页面)
|
||||
ModuleProject loginModule = (ModuleProject) map.get("loginModule");
|
||||
if (null != loginModule) {
|
||||
map.put("login_url", "<%=path %>/" + uncapFirst(loginModule.getTable().getClassName()) + "/login");
|
||||
map.put("templateName", PageTemplateUtils.LOGIN_PAGE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("fileName", "login.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
}
|
||||
|
||||
public void generateUtils(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_CUSTOM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMCustomPageTemplate.PAGEUTILS_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "utils"));
|
||||
map.put("fileName", "PageUtils.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "utils"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateCommon(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_CUSTOM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMCustomPageTemplate.IMAPPER_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "mapper"));
|
||||
map.put("fileName", "IMapper.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "mapper"));
|
||||
CodeGenerator.generator(map);
|
||||
map.put("templateName", SSMCustomPageTemplate.ISERVICE_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "service"));
|
||||
map.put("fileName", "IService.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "service"));
|
||||
CodeGenerator.generator(map);
|
||||
map.put("templateName", SSMCustomPageTemplate.BASE_CONTROLLER_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "controller"));
|
||||
map.put("fileName", "BaseController.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "controller"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateDefined(Map<String, Object> map) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package cn.feast.coding.generator;
|
||||
|
||||
import cn.feast.coding.generator.utils.CodeGenerator;
|
||||
import cn.feast.coding.model.generator.ModuleProject;
|
||||
import cn.feast.coding.model.generator.PageTemplate;
|
||||
import cn.feast.coding.model.generator.Project;
|
||||
import cn.feast.coding.model.generator.Table;
|
||||
import cn.feast.coding.service.generator.PageTemplateService;
|
||||
import cn.feast.coding.tools.Contants;
|
||||
import cn.feast.coding.tools.PageTemplateUtils;
|
||||
import cn.feast.coding.tools.SSMPageTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class SSMGenerator extends BaseGenerator implements Generator {
|
||||
@Autowired
|
||||
private PageTemplateService pageTemplateService;
|
||||
|
||||
public void generateModel(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMPageTemplate.MODEL_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "model"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + ".java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "model"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateDao(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMPageTemplate.MAPPER_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "mapper"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Mapper.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "mapper"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateDaoImpl(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMPageTemplate.MAPPER_XML_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "mapping"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Mapper.xml");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "mapping"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateController(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMPageTemplate.CONTROLLER_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "controller"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Controller.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "controller"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateIService(Map<String, Object> map) {
|
||||
|
||||
}
|
||||
|
||||
public void generateService(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMPageTemplate.SERVICE_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "service"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Service.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "service"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateJsp(Map<String, Object> map) {
|
||||
//兼容有些页面模板,增加修改查询页面也存在导航的情况
|
||||
List<Table> tableList = (List<Table>) map.get("tableList");
|
||||
for (Table t : tableList) {
|
||||
t.setUrl("<%=path %>/" + uncapFirst(t.getClassName()) + "/list");
|
||||
}
|
||||
map.put("tableList", tableList);
|
||||
PageTemplate pageTemplate = pageTemplateService.queryById(((Project) map.get("project")).getPageStyle());
|
||||
map.put("templatePath", pageTemplate.getPagePath());
|
||||
String className = uncapFirst(((Table) map.get("table")).getClassName());
|
||||
String list_url = "<%=path %>/" + className + "/list";
|
||||
String add_url = "<%=path %>/" + className + "/add";
|
||||
String update_url = "<%=path %>/" + className + "/update";
|
||||
String delete_url = "<%=path %>/" + className + "/delete";
|
||||
map.put("list_url", list_url);
|
||||
map.put("add_url", add_url);
|
||||
map.put("edit_url", update_url);
|
||||
map.put("update_url", update_url);
|
||||
map.put("delete_url", delete_url);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
//list页面
|
||||
map.put("templateName", PageTemplateUtils.LIST_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_list.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
//add页面
|
||||
map.put("templateName", PageTemplateUtils.ADD_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_add.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
//edit页面
|
||||
map.put("templateName", PageTemplateUtils.EDIT_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_edit.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateIndex(Map<String, Object> map) {
|
||||
//兼容有些页面模板,增加修改查询页面也存在导航的情况
|
||||
List<Table> tableList = (List<Table>) map.get("tableList");
|
||||
for (Table t : tableList) {
|
||||
t.setUrl("<%=path %>/" + uncapFirst(t.getClassName()) + "/list");
|
||||
}
|
||||
map.put("tableList", tableList);
|
||||
PageTemplate pageTemplate = pageTemplateService.queryById(((Project) map.get("project")).getPageStyle());
|
||||
map.put("templatePath", pageTemplate.getPagePath());
|
||||
map.put("templateName", PageTemplateUtils.INDEX_PAGE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("fileName", "index.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
|
||||
//添加登录模块支持(登录页面)
|
||||
ModuleProject loginModule = (ModuleProject) map.get("loginModule");
|
||||
if (null != loginModule) {
|
||||
map.put("login_url", "<%=path %>/" + uncapFirst(loginModule.getTable().getClassName()) + "/login");
|
||||
map.put("templateName", PageTemplateUtils.LOGIN_PAGE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("fileName", "login.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
}
|
||||
|
||||
public void generateUtils(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMPageTemplate.PAGE_UTILS_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "utils"));
|
||||
map.put("fileName", "PageUtils.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "utils"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateCommon(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMPageTemplate.PAGE_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "model"));
|
||||
map.put("fileName", "Page.java");
|
||||
map.put("filePath", getPackName(((Project) map.get("project")).getPackName(), "model"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateDefined(Map<String, Object> map) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
package cn.feast.coding.generator;
|
||||
|
||||
import cn.feast.coding.generator.utils.CodeGenerator;
|
||||
import cn.feast.coding.model.generator.ModuleProject;
|
||||
import cn.feast.coding.model.generator.PageTemplate;
|
||||
import cn.feast.coding.model.generator.Project;
|
||||
import cn.feast.coding.model.generator.Table;
|
||||
import cn.feast.coding.service.generator.PageTemplateService;
|
||||
import cn.feast.coding.tools.Contants;
|
||||
import cn.feast.coding.tools.PageTemplateUtils;
|
||||
import cn.feast.coding.tools.SSMMavenPageTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class SSMMavenGenerator extends BaseGenerator implements Generator {
|
||||
@Autowired
|
||||
private PageTemplateService pageTemplateService;
|
||||
|
||||
public void generateModel(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_MAVEN_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMMavenPageTemplate.MODEL_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "model"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + ".java");
|
||||
map.put("filePath", "src.main.java."+getPackName(((Project) map.get("project")).getPackName(), "model"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateDao(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_MAVEN_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMMavenPageTemplate.MAPPER_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "mapper"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Mapper.java");
|
||||
map.put("filePath", "src.main.java."+getPackName(((Project) map.get("project")).getPackName(), "mapper"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateDaoImpl(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_MAVEN_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMMavenPageTemplate.MAPPER_XML_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "mapping"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Mapper.xml");
|
||||
map.put("filePath", "src.main.resources.mapping");
|
||||
CodeGenerator.generator(map);
|
||||
|
||||
}
|
||||
|
||||
public void generateController(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_MAVEN_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMMavenPageTemplate.CONTROLLER_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "controller"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Controller.java");
|
||||
map.put("filePath", "src.main.java."+getPackName(((Project) map.get("project")).getPackName(), "controller"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateIService(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_MAVEN_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMMavenPageTemplate.SERVICE_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "service"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "Service.java");
|
||||
map.put("filePath", "src.main.java."+getPackName(((Project) map.get("project")).getPackName(), "service"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateService(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_MAVEN_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMMavenPageTemplate.SERVICE_IMPL_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "service.impl"));
|
||||
map.put("fileName", ((Table) map.get("table")).getClassName() + "ServiceImpl.java");
|
||||
map.put("filePath", "src.main.java."+getPackName(((Project) map.get("project")).getPackName(), "service.impl"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateJsp(Map<String, Object> map) {
|
||||
//兼容有些页面模板,增加修改查询页面也存在导航的情况
|
||||
List<Table> tableList = (List<Table>) map.get("tableList");
|
||||
for (Table t : tableList) {
|
||||
t.setUrl("<%=path %>/" + uncapFirst(t.getClassName()) + "/list");
|
||||
}
|
||||
map.put("tableList", tableList);
|
||||
PageTemplate pageTemplate = pageTemplateService.queryById(((Project) map.get("project")).getPageStyle());
|
||||
map.put("templatePath", pageTemplate.getPagePath());
|
||||
String className = uncapFirst(((Table) map.get("table")).getClassName());
|
||||
String list_url = "<%=path %>/" + className + "/list";
|
||||
String add_url = "<%=path %>/" + className + "/add";
|
||||
String update_url = "<%=path %>/" + className + "/update";
|
||||
String delete_url = "<%=path %>/" + className + "/delete";
|
||||
String detail_url = "<%=path %>/" + className + "/detail";
|
||||
map.put("list_url", list_url);
|
||||
map.put("add_url", add_url);
|
||||
map.put("edit_url", update_url);
|
||||
map.put("update_url", update_url);
|
||||
map.put("delete_url", delete_url);
|
||||
map.put("detail_url", detail_url);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("filePath", "src.main.webapp.views");
|
||||
//list页面
|
||||
map.put("templateName", PageTemplateUtils.LIST_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_list.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
//add页面
|
||||
map.put("templateName", PageTemplateUtils.ADD_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_add.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
//edit页面
|
||||
map.put("templateName", PageTemplateUtils.EDIT_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_edit.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
//detail页面
|
||||
map.put("templateName", PageTemplateUtils.DETAIL_PAGE);
|
||||
map.put("fileName", uncapFirst(((Table) map.get("table")).getClassName()) + "_detail.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateIndex(Map<String, Object> map) {
|
||||
//兼容有些页面模板,增加修改查询页面也存在导航的情况
|
||||
List<Table> tableList = (List<Table>) map.get("tableList");
|
||||
for (Table t : tableList) {
|
||||
t.setUrl("<%=path %>/" + uncapFirst(t.getClassName()) + "/list");
|
||||
}
|
||||
map.put("tableList", tableList);
|
||||
PageTemplate pageTemplate = pageTemplateService.queryById(((Project) map.get("project")).getPageStyle());
|
||||
map.put("templatePath", pageTemplate.getPagePath());
|
||||
//主页
|
||||
map.put("templateName", PageTemplateUtils.INDEX_PAGE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("fileName", "index.jsp");
|
||||
map.put("filePath", "src.main.webapp.views");
|
||||
CodeGenerator.generator(map);
|
||||
|
||||
//欢迎页面
|
||||
if(pageTemplate.getPagePath().equals("/template/page_maven") || pageTemplate.getPagePath().equals("/template/page_maven1")){
|
||||
map.put("templateName", PageTemplateUtils.WELCOME_PAGE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("fileName", "welcome.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
//添加登录模块支持(登录页面)
|
||||
ModuleProject loginModule = (ModuleProject) map.get("loginModule");
|
||||
if (null != loginModule) {
|
||||
map.put("login_url", "<%=path %>/login");
|
||||
map.put("templateName", PageTemplateUtils.LOGIN_PAGE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("fileName", "login.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
//添加注册模块支持(注册页面)
|
||||
ModuleProject registerModule = (ModuleProject) map.get("registerModule");
|
||||
if (null != registerModule) {
|
||||
map.put("register_url", "<%=path %>/register");
|
||||
map.put("templateName", PageTemplateUtils.REGISTER_PAGE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("fileName", "register.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
//添加修改密码模块支持(修改密码页面)
|
||||
ModuleProject passwordModule = (ModuleProject) map.get("passwordModule");
|
||||
if (null != passwordModule) {
|
||||
map.put("password_url", "<%=path %>/password");
|
||||
map.put("templateName", PageTemplateUtils.PASSWORD_PAGE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "jsp"));
|
||||
map.put("fileName", "password.jsp");
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
}
|
||||
|
||||
public void generateUtils(Map<String, Object> map) {
|
||||
map.put("templatePath", Contants.SSM_MAVEN_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMMavenPageTemplate.PAGEUTILS_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "utils"));
|
||||
map.put("fileName", "PageUtils.java");
|
||||
map.put("filePath", "src.main.java."+getPackName(((Project) map.get("project")).getPackName(), "utils"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
|
||||
public void generateCommon(Map<String, Object> map) {
|
||||
//mapper接口
|
||||
map.put("templatePath", Contants.SSM_MAVEN_TEMPLATE_PATH);
|
||||
map.put("templateName", SSMMavenPageTemplate.IMAPPER_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "mapper"));
|
||||
map.put("fileName", "IMapper.java");
|
||||
map.put("filePath", "src.main.java."+getPackName(((Project) map.get("project")).getPackName(), "mapper"));
|
||||
CodeGenerator.generator(map);
|
||||
//service接口
|
||||
map.put("templateName", SSMMavenPageTemplate.ISERVICE_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "service"));
|
||||
map.put("fileName", "IService.java");
|
||||
map.put("filePath", "src.main.java."+getPackName(((Project) map.get("project")).getPackName(), "service"));
|
||||
CodeGenerator.generator(map);
|
||||
//baseController
|
||||
map.put("templateName", SSMMavenPageTemplate.BASE_CONTROLLER_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "controller"));
|
||||
map.put("fileName", "BaseController.java");
|
||||
map.put("filePath", "src.main.java."+getPackName(((Project) map.get("project")).getPackName(), "controller"));
|
||||
CodeGenerator.generator(map);
|
||||
//pom.xml
|
||||
map.put("templateName", SSMMavenPageTemplate.POM_XML_TEMPLATE);
|
||||
map.put("pack", ((Project) map.get("project")).getPackName());
|
||||
map.put("fileName", "pom.xml");
|
||||
map.put("filePath", "");
|
||||
CodeGenerator.generator(map);
|
||||
//web.xml
|
||||
map.put("templateName", SSMMavenPageTemplate.WEB_XML_TEMPLATE);
|
||||
map.put("pack", ((Project) map.get("project")).getPackName());
|
||||
map.put("fileName", "web.xml");
|
||||
map.put("filePath", "src.main.webapp.WEB-INF");
|
||||
CodeGenerator.generator(map);
|
||||
//spring-core.xml
|
||||
map.put("templateName", SSMMavenPageTemplate.SPRING_CORE_XML_TEMPLATE);
|
||||
map.put("pack", ((Project) map.get("project")).getPackName());
|
||||
map.put("fileName", "spring-core.xml");
|
||||
map.put("filePath", "src.main.resources");
|
||||
CodeGenerator.generator(map);
|
||||
//spring-mvc.xml
|
||||
map.put("templateName", SSMMavenPageTemplate.SPRING_WEB_XML_TEMPLATE);
|
||||
map.put("pack", ((Project) map.get("project")).getPackName());
|
||||
map.put("fileName", "spring-mvc.xml");
|
||||
map.put("filePath", "src.main.resources");
|
||||
CodeGenerator.generator(map);
|
||||
//mybatis-config.xml
|
||||
map.put("templateName", SSMMavenPageTemplate.MYBATIS_CONFIG_XML_TEMPLATE);
|
||||
map.put("pack", ((Project) map.get("project")).getPackName());
|
||||
map.put("fileName", "mybatis-config.xml");
|
||||
map.put("filePath", "src.main.resources");
|
||||
CodeGenerator.generator(map);
|
||||
//jdbc.properties
|
||||
map.put("templateName", SSMMavenPageTemplate.JDBC_PROPERTIES_TEMPLATE);
|
||||
map.put("pack", ((Project) map.get("project")).getPackName());
|
||||
map.put("fileName", "jdbc.properties");
|
||||
map.put("filePath", "src.main.resources");
|
||||
CodeGenerator.generator(map);
|
||||
//logback-spring.xml
|
||||
map.put("templateName", SSMMavenPageTemplate.LOGBACK_XML_TEMPLATE);
|
||||
map.put("pack", ((Project) map.get("project")).getPackName());
|
||||
map.put("fileName", "logback-spring.xml");
|
||||
map.put("filePath", "src.main.resources");
|
||||
CodeGenerator.generator(map);
|
||||
//添加登录模块支持(登录拦截器)
|
||||
ModuleProject loginModule = (ModuleProject) map.get("loginModule");
|
||||
if (null != loginModule) {
|
||||
map.put("templateName", SSMMavenPageTemplate.LOGIN_INTERCEPTOR_TEMPLATE);
|
||||
map.put("pack", getPackName(((Project) map.get("project")).getPackName(), "interceptor"));
|
||||
map.put("fileName", "LoginInterceptor.java");
|
||||
map.put("filePath", "src.main.java."+getPackName(((Project) map.get("project")).getPackName(), "interceptor"));
|
||||
CodeGenerator.generator(map);
|
||||
}
|
||||
}
|
||||
|
||||
public void generateDefined(Map<String, Object> map) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cn.feast.coding.generator.factory;
|
||||
|
||||
import cn.feast.coding.generator.*;
|
||||
import cn.feast.coding.tools.Contants;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class GeneratorFactory {
|
||||
@Autowired
|
||||
private SSMGenerator ssmGenerator;
|
||||
@Autowired
|
||||
private SSHGenerator sshGenerator;
|
||||
@Autowired
|
||||
private JSPGenerator jspGenerator;
|
||||
@Autowired
|
||||
private SSMCustomGenerator ssmCustomGenerator;
|
||||
@Autowired
|
||||
private SSMMavenGenerator ssmMavenGenerator;
|
||||
|
||||
/**
|
||||
* 简单工厂模式 :根据类型选择不同的Generator实现类
|
||||
*
|
||||
* @param generatorType
|
||||
* @return
|
||||
*/
|
||||
public Generator getGenerator(String generatorType) {
|
||||
switch (generatorType) {
|
||||
case Contants.SSM_FRAME:
|
||||
return ssmGenerator;
|
||||
case Contants.SSH_FRAME:
|
||||
return sshGenerator;
|
||||
case Contants.JSP_FRAME:
|
||||
return jspGenerator;
|
||||
case Contants.SSM_CUSTOM_FRAME:
|
||||
return ssmCustomGenerator;
|
||||
case Contants.SSM_MAVEN_FRAME:
|
||||
return ssmMavenGenerator;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package cn.feast.coding.generator.utils;
|
||||
|
||||
import cn.feast.coding.model.generator.Project;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.DefaultObjectWrapper;
|
||||
import freemarker.template.Template;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
|
||||
public class CodeGenerator {
|
||||
/**
|
||||
* 根据模板生成
|
||||
*
|
||||
* @param map 数据
|
||||
*/
|
||||
public static void generator(Map<String, Object> map){
|
||||
Project project = (Project) map.get("project");
|
||||
String fileName = "OpenPark";
|
||||
if(StringUtils.isNotEmpty(project.getProjectFileName())){
|
||||
fileName = project.getProjectFileName();
|
||||
}
|
||||
//获取request
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
String root = request.getSession().getServletContext().getRealPath("/"+ fileName);
|
||||
generator(map, root, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据模板生成
|
||||
*
|
||||
* @param map 数据
|
||||
* @param path 生成路径
|
||||
*/
|
||||
public static void generator(Map<String, Object> map, String path, HttpServletRequest request) {
|
||||
try {
|
||||
String templateName = map.get("templateName").toString();
|
||||
String filePath = map.get("filePath").toString();
|
||||
Configuration cfg = new Configuration();
|
||||
cfg.setDefaultEncoding("UTF-8");
|
||||
//自定义标签
|
||||
// cfg.setSharedVariable("role", myDirectiveModel);
|
||||
// cfg.setSharedVariable("modules", modulesDirectiveModel);
|
||||
cfg.setServletContextForTemplateLoading(request.getSession().getServletContext(), (String) map.get("templatePath"));
|
||||
cfg.setObjectWrapper(new DefaultObjectWrapper());
|
||||
// 获取模板文件
|
||||
Template template = cfg.getTemplate(templateName, "UTF-8");
|
||||
// // 生成输出到控制台
|
||||
// Writer out = new OutputStreamWriter(System.out);
|
||||
// template.process(map, out);
|
||||
// out.flush();
|
||||
|
||||
// 生成输出到文件
|
||||
String root = genPackStr(path, filePath);
|
||||
File fileDir = new File(root);
|
||||
// 创建文件夹,不存在则创建
|
||||
FileUtils.forceMkdir(fileDir);
|
||||
// 指定生成输出的文件
|
||||
File output = new File(fileDir + "/" + map.get("fileName"));
|
||||
Writer writer = new PrintWriter(output, "UTF-8");
|
||||
// Writer writer = new FileWriter(output);
|
||||
template.process(map, writer);
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据包名获取对应的路径名
|
||||
*
|
||||
* @param root 根路径
|
||||
* @param pack 包名
|
||||
* @return
|
||||
*/
|
||||
private static String genPackStr(String root, String pack) {
|
||||
String result = root;
|
||||
String[] dirs = pack.split("\\.");
|
||||
for (String dir : dirs) {
|
||||
result += "/" + dir;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.feast.coding.generator.utils;
|
||||
|
||||
public class GeneratorConstants {
|
||||
public static final Integer SSM_GENERATOR_TYPE = 1;
|
||||
|
||||
public static final Integer SSH_GENERATOR_TYPE = 2;
|
||||
|
||||
public static final Integer JSP_GENERATOR_TYPE = 3;
|
||||
|
||||
public static final Integer SSM_CUSTOM_GENERATOR_TYPE = 4;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.feast.coding.service;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import java.util.List;
|
||||
|
||||
public interface IService<T> {
|
||||
int insert(T t);
|
||||
|
||||
int update(T t);
|
||||
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
List<T> selectAll(T t);
|
||||
|
||||
T selectByPrimaryKey(Integer id);
|
||||
|
||||
List<T> queryAll();
|
||||
|
||||
PageInfo<T> queryPage(T t, int pageNum, int pageSize);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package cn.feast.coding.service.generator;
|
||||
|
||||
import cn.feast.coding.mapper.generator.ColunmMapper;
|
||||
import cn.feast.coding.model.generator.Colunm;
|
||||
import cn.feast.coding.model.generator.Page;
|
||||
import cn.feast.coding.tools.SysContants;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class ColunmService {
|
||||
|
||||
@Autowired
|
||||
private ColunmMapper mapper;
|
||||
|
||||
public Integer save(Colunm colunm) {
|
||||
return mapper.save(colunm);
|
||||
}
|
||||
|
||||
public Integer saveByBatch(List<Colunm> list){
|
||||
return mapper.saveByBatch(list);
|
||||
}
|
||||
|
||||
public void update(Colunm colunm) {
|
||||
mapper.update(colunm);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
mapper.deleteById(id);
|
||||
}
|
||||
|
||||
public int queryByCount(Colunm colunm) {
|
||||
return mapper.queryByCount(colunm);
|
||||
}
|
||||
|
||||
public List<Colunm> queryByList(Page page, Colunm colunm) {
|
||||
String pageQueryCondition = " limit " + page.getStart() + " , " + page.getMaxRows();
|
||||
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
||||
paramsMap.put("colunmName", colunm.getColunmName());
|
||||
paramsMap.put("filedName", colunm.getFiledName());
|
||||
paramsMap.put("colunmType", colunm.getColunmType());
|
||||
paramsMap.put("showName", colunm.getShowName());
|
||||
paramsMap.put("editStyle", colunm.getEditStyle());
|
||||
paramsMap.put("isPrimary", colunm.getIsPrimary());
|
||||
paramsMap.put("isShowed", colunm.getIsShowed());
|
||||
paramsMap.put("tableId", colunm.getTableId());
|
||||
paramsMap.put("pageQueryCondition", pageQueryCondition);
|
||||
return mapper.queryByList(paramsMap);
|
||||
}
|
||||
|
||||
public List<Colunm> queryByColunm(Colunm colunm) {
|
||||
return mapper.queryByColunm(colunm);
|
||||
}
|
||||
|
||||
public Colunm queryById(Integer id) {
|
||||
return mapper.queryById(id);
|
||||
}
|
||||
|
||||
public void deleteProjectRelatedData(Integer projectId) {
|
||||
mapper.deleteProjectRelatedData(projectId);
|
||||
}
|
||||
|
||||
public List<Colunm> queryByTable(Integer tableId) {
|
||||
return mapper.queryByTable(tableId);
|
||||
}
|
||||
|
||||
public PageInfo<Colunm> queryPage(Colunm colunm, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = SysContants.MAX_PAGE_ROWS;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Colunm> list = mapper.queryByColunm(colunm);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package cn.feast.coding.service.generator;
|
||||
|
||||
import cn.feast.coding.mapper.generator.DataSourceMapper;
|
||||
import cn.feast.coding.model.generator.Colunm;
|
||||
import cn.feast.coding.model.generator.DataSource;
|
||||
import cn.feast.coding.model.generator.Page;
|
||||
import cn.feast.coding.tools.DataBaseTools;
|
||||
import cn.feast.coding.tools.SysContants;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class DataSourceService {
|
||||
|
||||
@Autowired
|
||||
private DataSourceMapper mapper;
|
||||
|
||||
public Integer save(DataSource dataSource) {
|
||||
return mapper.save(dataSource);
|
||||
}
|
||||
|
||||
public void update(DataSource dataSource) {
|
||||
mapper.update(dataSource);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
mapper.deleteById(id);
|
||||
}
|
||||
|
||||
public int queryByCount(DataSource dataSource) {
|
||||
return mapper.queryByCount(dataSource);
|
||||
}
|
||||
|
||||
public List<DataSource> queryByList(Page page, DataSource dataSource) {
|
||||
String pageQueryCondition = " limit " + page.getStart() + " , " + page.getMaxRows();
|
||||
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
||||
paramsMap.put("name", dataSource.getName());
|
||||
paramsMap.put("jdbcUrl", dataSource.getJdbcUrl());
|
||||
paramsMap.put("jdbcUser", dataSource.getJdbcUser());
|
||||
paramsMap.put("jdbcPass", dataSource.getJdbcPass());
|
||||
paramsMap.put("isDefault", dataSource.getIsDefault());
|
||||
paramsMap.put("pageQueryCondition", pageQueryCondition);
|
||||
return mapper.queryByList(paramsMap);
|
||||
}
|
||||
|
||||
public List<DataSource> queryByDataSource(DataSource dataSource) {
|
||||
return mapper.queryByDataSource(dataSource);
|
||||
}
|
||||
|
||||
public DataSource queryById(Integer id) {
|
||||
return mapper.queryById(id);
|
||||
}
|
||||
|
||||
public List<DataSource> queryAll() {
|
||||
return mapper.queryAll();
|
||||
}
|
||||
|
||||
public boolean testConnection(DataSource dataSource) {
|
||||
int data = DataBaseTools.testConnection(dataSource);
|
||||
if (data == 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public PageInfo<DataSource> queryPage(DataSource dataSource, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = SysContants.MAX_PAGE_ROWS;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<DataSource> list = mapper.queryByDataSource(dataSource);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
package cn.feast.coding.service.generator;
|
||||
|
||||
import cn.feast.coding.generator.Generator;
|
||||
import cn.feast.coding.generator.factory.GeneratorFactory;
|
||||
import cn.feast.coding.mapper.generator.ColunmMapper;
|
||||
import cn.feast.coding.mapper.generator.ProjectMapper;
|
||||
import cn.feast.coding.mapper.generator.TableMapper;
|
||||
import cn.feast.coding.model.generator.*;
|
||||
import cn.feast.coding.tools.Contants;
|
||||
import cn.feast.coding.tools.ZipTools;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.feast.coding.tools.StringUtils.uncapFirst;
|
||||
|
||||
|
||||
@Service
|
||||
public class GeneratorService {
|
||||
@Autowired
|
||||
private GeneratorFactory generatorFactory;
|
||||
private Generator generator;
|
||||
@Autowired
|
||||
private TableMapper tableMapper;
|
||||
@Autowired
|
||||
private ColunmMapper colunmMapper;
|
||||
@Autowired
|
||||
private ProjectMapper projectMapper;
|
||||
@Autowired
|
||||
private ModuleProjectService moduleProjectService;
|
||||
|
||||
public void generator(Project project, HttpServletRequest request) {
|
||||
project = projectMapper.queryById(project.getId());
|
||||
List<Table> tableList = tableMapper.queryByProject(project.getId());
|
||||
generator(project, tableList, request);
|
||||
}
|
||||
|
||||
public void generator(Project project, List<Table> tableList, HttpServletRequest request) {
|
||||
Map<String, Object> map = new Hashtable<>();
|
||||
map.put("project", project);
|
||||
map.put("tableList", tableList);
|
||||
generator(map, request);
|
||||
}
|
||||
|
||||
public void generator(Map<String, Object> map, HttpServletRequest request) {
|
||||
Project project = (Project) map.get("project");
|
||||
//获取项目框架
|
||||
String templateType = project.getTemplateType();
|
||||
//添加功能模块支持
|
||||
addModuleSupport(project, map);
|
||||
//生成代码
|
||||
generator = generatorFactory.getGenerator(templateType);
|
||||
generate(map, templateType);
|
||||
//打包生成文件
|
||||
packageGenerateFiles(project, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打包生成代码
|
||||
*
|
||||
* @param project
|
||||
* @param request
|
||||
*/
|
||||
public void packageGenerateFiles(Project project, HttpServletRequest request) {
|
||||
String fileName = "OpenPark";
|
||||
if(StringUtils.isNotEmpty(project.getProjectFileName())){
|
||||
fileName = project.getProjectFileName();
|
||||
}
|
||||
String path = request.getSession().getServletContext().getRealPath("/" + fileName);
|
||||
String zipFilPath = request.getSession().getServletContext().getRealPath("/zip") + "/" + project.getProjectName() + ".zip";
|
||||
ZipTools.zipMultiFile(path, zipFilPath, true);
|
||||
}
|
||||
|
||||
private void generate(Map<String, Object> map, String templateType) {
|
||||
List<Table> tableList = (List<Table>) map.get("tableList");
|
||||
for (Table table : tableList) {
|
||||
initMap(table, map, templateType);
|
||||
generator.generateController(map);
|
||||
generator.generateDao(map);
|
||||
generator.generateDaoImpl(map);
|
||||
generator.generateModel(map);
|
||||
generator.generateService(map);
|
||||
generator.generateIService(map);
|
||||
generator.generateJsp(map);
|
||||
}
|
||||
generator.generateIndex(map);
|
||||
generator.generateUtils(map);
|
||||
generator.generateCommon(map);
|
||||
generator.generateDefined(map);
|
||||
}
|
||||
|
||||
private void addModuleSupport(Project project, Map<String, Object> map) {
|
||||
Integer projectId = project.getId();
|
||||
String templateType = project.getTemplateType();
|
||||
//登录功能
|
||||
List<ModuleProject> loginList = addLoginModuleSupport(projectId, templateType);
|
||||
if (!loginList.isEmpty()) {
|
||||
map.put("loginModule", loginList.get(0));
|
||||
}
|
||||
//注册功能
|
||||
List<ModuleProject> registerList = addRegisterModuleSupport(projectId, templateType);
|
||||
if (!registerList.isEmpty()) {
|
||||
map.put("registerModule", registerList.get(0));
|
||||
}
|
||||
//修改密码功能
|
||||
List<ModuleProject> passwordList = addPasswordModuleSupport(projectId, templateType);
|
||||
if (!passwordList.isEmpty()) {
|
||||
map.put("passwordModule", passwordList.get(0));
|
||||
}
|
||||
//查询功能
|
||||
List<ModuleProject> queryList = addQueryModuleSupport(projectId, templateType);
|
||||
if (!queryList.isEmpty()) {
|
||||
map.put("queryModule", queryList);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ModuleProject> addLoginModuleSupport(Integer projectId, String templateType) {
|
||||
List<ModuleProject> loginList = moduleProjectService.queryByProjectAndModule(projectId, Contants.LOGIN_MODULE);
|
||||
if (!loginList.isEmpty()) {
|
||||
for (ModuleProject mp : loginList) {
|
||||
//兼容ssh
|
||||
mp.frameAdapter(templateType);
|
||||
}
|
||||
}
|
||||
return loginList;
|
||||
}
|
||||
|
||||
private List<ModuleProject> addRegisterModuleSupport(Integer projectId, String templateType) {
|
||||
List<ModuleProject> registerList = moduleProjectService.queryByProjectAndModule(projectId, Contants.REGISTER_MODULE);
|
||||
if (!registerList.isEmpty()) {
|
||||
for (ModuleProject mp : registerList) {
|
||||
//兼容ssh
|
||||
mp.frameAdapter(templateType);
|
||||
}
|
||||
}
|
||||
return registerList;
|
||||
}
|
||||
|
||||
private List<ModuleProject> addPasswordModuleSupport(Integer projectId, String templateType) {
|
||||
List<ModuleProject> registerList = moduleProjectService.queryByProjectAndModule(projectId, Contants.PASSWORD_MODULE);
|
||||
if (!registerList.isEmpty()) {
|
||||
for (ModuleProject mp : registerList) {
|
||||
//兼容ssh
|
||||
mp.frameAdapter(templateType);
|
||||
}
|
||||
}
|
||||
return registerList;
|
||||
}
|
||||
|
||||
private List<ModuleProject> addQueryModuleSupport(Integer projectId, String templateType) {
|
||||
List<ModuleProject> queryList = moduleProjectService.queryByProjectAndModule(projectId, Contants.QUERY_MODULE);
|
||||
if (!queryList.isEmpty()) {
|
||||
for (ModuleProject mp : queryList) {
|
||||
//兼容ssh
|
||||
mp.frameAdapter(templateType);
|
||||
String query_url = null;
|
||||
//ssm
|
||||
if (templateType.equals(Contants.SSM_FRAME)) {
|
||||
query_url = "<%=path %>/" + uncapFirst(mp.getTable().getClassName()) + "/list";
|
||||
}
|
||||
//ssh
|
||||
else if (templateType.equals(Contants.SSH_FRAME)) {
|
||||
query_url = "<%=path %>/" + uncapFirst(mp.getTable().getClassName()) + "/" + uncapFirst(mp.getTable().getClassName()) + "-query.action";
|
||||
}
|
||||
//jsp
|
||||
else if (templateType.equals(Contants.JSP_FRAME)) {
|
||||
query_url = "<%=path %>/query" + mp.getTable().getClassName() + "SelectedServlet";
|
||||
}
|
||||
//ssm custom
|
||||
else if (templateType.equals(Contants.SSM_CUSTOM_FRAME)) {
|
||||
query_url = "<%=path %>/" + uncapFirst(mp.getTable().getClassName()) + "/list";
|
||||
}
|
||||
//ssm maven
|
||||
else if (templateType.equals(Contants.SSM_MAVEN_FRAME)) {
|
||||
query_url = "<%=path %>/" + uncapFirst(mp.getTable().getClassName()) + "/list";
|
||||
}
|
||||
mp.setModuleUrl(query_url);
|
||||
}
|
||||
}
|
||||
return queryList;
|
||||
}
|
||||
|
||||
|
||||
private Map<String, Object> initMap(Table table, Map<String, Object> map, String templateType) {
|
||||
List<Colunm> colunmList = colunmMapper.queryByTable(table.getId());
|
||||
Colunm primary = colunmMapper.queryPrimaryKey(table.getId());
|
||||
//为了兼容ssh表单name显示不一致问题
|
||||
primary.frameAdapter(templateType);
|
||||
for (Colunm c : colunmList) {
|
||||
c.frameAdapter(templateType);
|
||||
}
|
||||
map.put("table", table);
|
||||
map.put("colunmList", colunmList);
|
||||
map.put("primary", primary);
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package cn.feast.coding.service.generator;
|
||||
|
||||
import cn.feast.coding.mapper.generator.ModuleMapper;
|
||||
import cn.feast.coding.mapper.generator.ModuleProjectMapper;
|
||||
import cn.feast.coding.mapper.generator.TableMapper;
|
||||
import cn.feast.coding.model.generator.Colunm;
|
||||
import cn.feast.coding.model.generator.ModuleProject;
|
||||
import cn.feast.coding.model.generator.Page;
|
||||
import cn.feast.coding.tools.SysContants;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class ModuleProjectService {
|
||||
|
||||
@Autowired
|
||||
private ModuleProjectMapper mapper;
|
||||
@Autowired
|
||||
private ModuleMapper moduleMapper;
|
||||
@Autowired
|
||||
private TableMapper tableMapper;
|
||||
|
||||
public Integer save(ModuleProject moduleProject) {
|
||||
return mapper.save(moduleProject);
|
||||
}
|
||||
|
||||
public void update(ModuleProject moduleProject) {
|
||||
mapper.update(moduleProject);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
mapper.deleteById(id);
|
||||
}
|
||||
|
||||
public int queryByCount(ModuleProject moduleProject) {
|
||||
return mapper.queryByCount(moduleProject);
|
||||
}
|
||||
|
||||
public List<ModuleProject> queryByList(Page page, ModuleProject moduleProject) {
|
||||
String pageQueryCondition = " limit " + page.getStart() + " , " + page.getMaxRows();
|
||||
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
||||
paramsMap.put("moduleId", moduleProject.getModuleId());
|
||||
paramsMap.put("projectId", moduleProject.getProjectId());
|
||||
paramsMap.put("tableId", moduleProject.getTableId());
|
||||
paramsMap.put("moduleParam1", moduleProject.getModuleParam1());
|
||||
paramsMap.put("moduleParam1Type", moduleProject.getModuleParam1Type());
|
||||
paramsMap.put("moduleParam1Field", moduleProject.getModuleParam1Field());
|
||||
paramsMap.put("moduleParam2", moduleProject.getModuleParam2());
|
||||
paramsMap.put("moduleParam2Type", moduleProject.getModuleParam2Type());
|
||||
paramsMap.put("moduleParam2Field", moduleProject.getModuleParam2Field());
|
||||
paramsMap.put("moduleParam3", moduleProject.getModuleParam3());
|
||||
paramsMap.put("moduleParam3Type", moduleProject.getModuleParam3Type());
|
||||
paramsMap.put("moduleParam3Field", moduleProject.getModuleParam3Field());
|
||||
paramsMap.put("pageQueryCondition", pageQueryCondition);
|
||||
return mapper.queryByList(paramsMap);
|
||||
}
|
||||
|
||||
public List<ModuleProject> queryByModuleProject(ModuleProject moduleProject) {
|
||||
return mapper.queryByModuleProject(moduleProject);
|
||||
}
|
||||
|
||||
public ModuleProject queryById(Integer id) {
|
||||
return mapper.queryById(id);
|
||||
}
|
||||
|
||||
public List<ModuleProject> queryByProject(Integer projectId) {
|
||||
List<ModuleProject> list = mapper.queryByProject(projectId);
|
||||
for (ModuleProject mp : list) {
|
||||
mp.setModule(moduleMapper.queryById(mp.getModuleId()));
|
||||
mp.setTable(tableMapper.queryById(mp.getTableId()));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ModuleProject> queryByModule(Integer moduleId) {
|
||||
return mapper.queryByModule(moduleId);
|
||||
}
|
||||
|
||||
public void deleteProjectRelatedData(Integer projectId) {
|
||||
mapper.deleteProjectRelatedData(projectId);
|
||||
}
|
||||
|
||||
public PageInfo<ModuleProject> queryPage(ModuleProject moduleProject, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = SysContants.MAX_PAGE_ROWS;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<ModuleProject> list = mapper.queryByModuleProject(moduleProject);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
public List<ModuleProject> queryByProjectAndModule(Integer projectId, String moduleName) {
|
||||
return mapper.queryByProjectAndModule(projectId, moduleName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package cn.feast.coding.service.generator;
|
||||
|
||||
import cn.feast.coding.mapper.generator.ModuleMapper;
|
||||
import cn.feast.coding.model.generator.Module;
|
||||
import cn.feast.coding.model.generator.Page;
|
||||
import cn.feast.coding.tools.SysContants;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class ModuleService {
|
||||
|
||||
@Autowired
|
||||
private ModuleMapper mapper;
|
||||
|
||||
public Integer save(Module module) {
|
||||
return mapper.save(module);
|
||||
}
|
||||
|
||||
public void update(Module module) {
|
||||
mapper.update(module);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
mapper.deleteById(id);
|
||||
}
|
||||
|
||||
public int queryByCount(Module module) {
|
||||
return mapper.queryByCount(module);
|
||||
}
|
||||
|
||||
public List<Module> queryByList(Page page, Module module) {
|
||||
String pageQueryCondition = " limit " + page.getStart() + " , " + page.getMaxRows();
|
||||
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
||||
paramsMap.put("moduleName", module.getModuleName());
|
||||
paramsMap.put("moduleDesc", module.getModuleDesc());
|
||||
paramsMap.put("moduleMethod", module.getModuleMethod());
|
||||
paramsMap.put("moduleDefault", module.getModuleDefault());
|
||||
paramsMap.put("pageQueryCondition", pageQueryCondition);
|
||||
return mapper.queryByList(paramsMap);
|
||||
}
|
||||
|
||||
public List<Module> queryByModule(Module module) {
|
||||
return mapper.queryByModule(module);
|
||||
}
|
||||
|
||||
public Module queryById(Integer id) {
|
||||
return mapper.queryById(id);
|
||||
}
|
||||
|
||||
public List<Module> queryAll() {
|
||||
return mapper.queryAll();
|
||||
}
|
||||
|
||||
public PageInfo<Module> queryPage(Module module, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = SysContants.MAX_PAGE_ROWS;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Module> list = mapper.queryByModule(module);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package cn.feast.coding.service.generator;
|
||||
|
||||
import cn.feast.coding.mapper.generator.PageTemplateMapper;
|
||||
import cn.feast.coding.model.generator.DataSource;
|
||||
import cn.feast.coding.model.generator.Page;
|
||||
import cn.feast.coding.model.generator.PageTemplate;
|
||||
import cn.feast.coding.tools.SysContants;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class PageTemplateService {
|
||||
|
||||
@Autowired
|
||||
private PageTemplateMapper mapper;
|
||||
|
||||
public Integer save(PageTemplate pageTemplate) {
|
||||
return mapper.save(pageTemplate);
|
||||
}
|
||||
|
||||
public void update(PageTemplate pageTemplate) {
|
||||
mapper.update(pageTemplate);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
mapper.deleteById(id);
|
||||
}
|
||||
|
||||
public int queryByCount(PageTemplate pageTemplate) {
|
||||
return mapper.queryByCount(pageTemplate);
|
||||
}
|
||||
|
||||
public List<PageTemplate> queryByList(Page page, PageTemplate pageTemplate) {
|
||||
String pageQueryCondition = " limit " + page.getStart() + " , " + page.getMaxRows();
|
||||
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
||||
paramsMap.put("pageName", pageTemplate.getPageName());
|
||||
paramsMap.put("pagePath", pageTemplate.getPagePath());
|
||||
paramsMap.put("pageImag", pageTemplate.getPageImag());
|
||||
paramsMap.put("pageDesc", pageTemplate.getPageDesc());
|
||||
paramsMap.put("pageDefault", pageTemplate.getPageDefault());
|
||||
paramsMap.put("pageQueryCondition", pageQueryCondition);
|
||||
return mapper.queryByList(paramsMap);
|
||||
}
|
||||
|
||||
public List<PageTemplate> queryByPageTemplate(PageTemplate pageTemplate) {
|
||||
return mapper.queryByPageTemplate(pageTemplate);
|
||||
}
|
||||
|
||||
public PageTemplate queryById(Integer id) {
|
||||
return mapper.queryById(id);
|
||||
}
|
||||
|
||||
public List<PageTemplate> queryByAll() {
|
||||
return mapper.queryAll();
|
||||
}
|
||||
|
||||
public PageInfo<PageTemplate> queryPage(PageTemplate pageTemplate, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = SysContants.MAX_PAGE_ROWS;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<PageTemplate> list = mapper.queryByPageTemplate(pageTemplate);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
public List<PageTemplate> getPage(String templateType) {
|
||||
return mapper.getPage(templateType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package cn.feast.coding.service.generator;
|
||||
|
||||
import cn.feast.coding.mapper.generator.ProjectMapper;
|
||||
import cn.feast.coding.model.generator.Colunm;
|
||||
import cn.feast.coding.model.generator.Page;
|
||||
import cn.feast.coding.model.generator.Project;
|
||||
import cn.feast.coding.tools.SysContants;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class ProjectService {
|
||||
|
||||
@Autowired
|
||||
private ProjectMapper mapper;
|
||||
|
||||
public Integer save(Project project) {
|
||||
return mapper.save(project);
|
||||
}
|
||||
|
||||
public void update(Project project) {
|
||||
mapper.update(project);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
mapper.deleteById(id);
|
||||
}
|
||||
|
||||
public int queryByCount(Project project) {
|
||||
return mapper.queryByCount(project);
|
||||
}
|
||||
|
||||
public List<Project> queryByList(Page page, Project project) {
|
||||
String pageQueryCondition = " limit " + page.getStart() + " , " + page.getMaxRows();
|
||||
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
||||
paramsMap.put("projectName", project.getProjectName());
|
||||
paramsMap.put("projectDesc", project.getProjectDesc());
|
||||
paramsMap.put("dataSourse", project.getDataSourse());
|
||||
paramsMap.put("packName", project.getPackName());
|
||||
paramsMap.put("pagePath", project.getPagePath());
|
||||
paramsMap.put("pageStyle", project.getPageStyle());
|
||||
paramsMap.put("pageQueryCondition", pageQueryCondition);
|
||||
return mapper.queryByList(paramsMap);
|
||||
}
|
||||
|
||||
public List<Project> queryByProject(Project project) {
|
||||
return mapper.queryByProject(project);
|
||||
}
|
||||
|
||||
public Project queryById(Integer id) {
|
||||
return mapper.queryById(id);
|
||||
}
|
||||
|
||||
public List<Project> queryByDataSource(Integer dataSourceId) {
|
||||
return mapper.queryByDataSource(dataSourceId);
|
||||
}
|
||||
|
||||
public List<Project> queryByPageTemplate(Integer pageTemplateId) {
|
||||
return mapper.queryByPageTemplate(pageTemplateId);
|
||||
}
|
||||
|
||||
public PageInfo<Project> queryPage(Project project, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = SysContants.MAX_PAGE_ROWS;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Project> list = mapper.queryByProject(project);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
public List<Project> queryAll() {
|
||||
return mapper.queryAll();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package cn.feast.coding.service.generator;
|
||||
|
||||
import cn.feast.coding.mapper.generator.TableMapper;
|
||||
import cn.feast.coding.model.generator.Page;
|
||||
import cn.feast.coding.model.generator.Project;
|
||||
import cn.feast.coding.model.generator.Table;
|
||||
import cn.feast.coding.tools.SysContants;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class TableService {
|
||||
|
||||
@Autowired
|
||||
private TableMapper mapper;
|
||||
|
||||
public Integer save(Table table) {
|
||||
return mapper.save(table);
|
||||
}
|
||||
|
||||
public void update(Table table) {
|
||||
mapper.update(table);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
mapper.deleteById(id);
|
||||
}
|
||||
|
||||
public int queryByCount(Table table) {
|
||||
return mapper.queryByCount(table);
|
||||
}
|
||||
|
||||
public List<Table> queryByList(Page page, Table table) {
|
||||
String pageQueryCondition = " limit " + page.getStart() + " , " + page.getMaxRows();
|
||||
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
||||
paramsMap.put("tableName", table.getTableName());
|
||||
paramsMap.put("className", table.getClassName());
|
||||
paramsMap.put("showStyle", table.getShowStyle());
|
||||
paramsMap.put("projectId", table.getProjectId());
|
||||
paramsMap.put("pageQueryCondition", pageQueryCondition);
|
||||
return mapper.queryByList(paramsMap);
|
||||
}
|
||||
|
||||
public List<Table> queryByTable(Table table) {
|
||||
return mapper.queryByTable(table);
|
||||
}
|
||||
|
||||
public Table queryById(Integer id) {
|
||||
return mapper.queryById(id);
|
||||
}
|
||||
|
||||
public void deleteProjectRelatedData(Integer projectId) {
|
||||
mapper.deleteProjectRelatedData(projectId);
|
||||
}
|
||||
|
||||
public List<Table> queryByProject(Integer projectId) {
|
||||
return mapper.queryByProject(projectId);
|
||||
}
|
||||
|
||||
public PageInfo<Table> queryPage(Table table, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = SysContants.MAX_PAGE_ROWS;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Table> list = mapper.queryByTable(table);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
public int saveByBatch(List<Table> tableList) {
|
||||
return mapper.saveByBatch(tableList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.feast.coding.service.links;
|
||||
|
||||
import cn.feast.coding.model.links.Link;
|
||||
import cn.feast.coding.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LinkService extends IService<Link> {
|
||||
List queryByType(Integer linkType);
|
||||
|
||||
List queryByTypeTimes(Integer urlType);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package cn.feast.coding.service.links.impl;
|
||||
|
||||
import cn.feast.coding.mapper.links.LinkMapper;
|
||||
import cn.feast.coding.model.links.Link;
|
||||
import cn.feast.coding.service.links.LinkService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class LinkServiceImpl implements LinkService {
|
||||
@Autowired
|
||||
private LinkMapper mapper;
|
||||
|
||||
public int insert(Link model){
|
||||
return mapper.insert(model);
|
||||
}
|
||||
|
||||
public int update(Link model){
|
||||
return mapper.update(model);
|
||||
}
|
||||
|
||||
public int deleteByPrimaryKey(Integer id){
|
||||
return mapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Link> selectAll(Link model){
|
||||
return mapper.selectAll(model);
|
||||
}
|
||||
|
||||
public PageInfo<Link> queryPage(Link model, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = 10;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Link> list = mapper.selectAll(model);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
public Link selectByPrimaryKey(Integer id){
|
||||
return mapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Link> queryAll(){
|
||||
return mapper.queryAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List queryByType(Integer linkType) {
|
||||
Link link = new Link();
|
||||
link.setTypeid(linkType);
|
||||
return mapper.selectAll(link);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List queryByTypeTimes(Integer urlType) {
|
||||
return mapper.queryByTypeTimes(urlType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.feast.coding.service.order;
|
||||
|
||||
import cn.feast.coding.model.order.MonthStatis;
|
||||
import cn.feast.coding.model.order.Order;
|
||||
import cn.feast.coding.model.order.OrderStatis;
|
||||
import cn.feast.coding.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface OrderService extends IService<Order> {
|
||||
List<OrderStatis> statisOrderMoney(String year);
|
||||
|
||||
List<OrderStatis> statisOrderCount(String year);
|
||||
|
||||
List<MonthStatis> statisOrderMonthCount(String year, String shop);
|
||||
|
||||
List<MonthStatis> statisOrderMonthMoney(String year, String shop);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package cn.feast.coding.service.order.impl;
|
||||
|
||||
import cn.feast.coding.mapper.order.OrderMapper;
|
||||
import cn.feast.coding.model.order.MonthStatis;
|
||||
import cn.feast.coding.model.order.Order;
|
||||
import cn.feast.coding.model.order.OrderStatis;
|
||||
import cn.feast.coding.service.order.OrderService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class OrderServiceImpl implements OrderService {
|
||||
@Autowired
|
||||
private OrderMapper mapper;
|
||||
|
||||
public int insert(Order model){
|
||||
return mapper.insert(model);
|
||||
}
|
||||
|
||||
public int update(Order model){
|
||||
return mapper.update(model);
|
||||
}
|
||||
|
||||
public int deleteByPrimaryKey(Integer id){
|
||||
return mapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Order> selectAll(Order model){
|
||||
return mapper.selectAll(model);
|
||||
}
|
||||
|
||||
public PageInfo<Order> queryPage(Order model, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = 10;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Order> list = mapper.selectAll(model);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
public Order selectByPrimaryKey(Integer id){
|
||||
return mapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Order> queryAll(){
|
||||
return mapper.queryAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderStatis> statisOrderMoney(String year) {
|
||||
return mapper.statisOrderMoney(year);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderStatis> statisOrderCount(String year) {
|
||||
return mapper.statisOrderCount(year);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MonthStatis> statisOrderMonthCount(String year, String shop) {
|
||||
return mapper.statisOrderMonthCount(year, shop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MonthStatis> statisOrderMonthMoney(String year, String shop) {
|
||||
return mapper.statisOrderMonthMoney(year, shop);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.feast.coding.service.stock;
|
||||
|
||||
import cn.feast.coding.model.stock.StockAnalyse;
|
||||
import cn.feast.coding.service.IService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface StockAnalyseService extends IService<StockAnalyse> {
|
||||
PageInfo<Map<String, Object>> queryAnalyse(StockAnalyse stockAnalyse, int pageNum, int pageSize);
|
||||
|
||||
PageInfo<Map<String, Object>> queryAnalyse1(StockAnalyse stockAnalyse, int pageNum, int pageSize);
|
||||
|
||||
PageInfo<Map<String, Object>> queryAnalyse2(StockAnalyse stockAnalyse, int pageNum, int pageSize);
|
||||
|
||||
PageInfo<Map<String, Object>> sortByTurn(StockAnalyse stockAnalyse, int pageNum, int pageSize);
|
||||
|
||||
PageInfo<Map<String, Object>> sortByPrice(StockAnalyse stockAnalyse, int pageNum, int pageSize);
|
||||
|
||||
PageInfo<Map<String, Object>> querySentiment(StockAnalyse stockAnalyse, int pageNum, int pageSize);
|
||||
|
||||
PageInfo<Map<String, Object>> queryConcept(StockAnalyse stockAnalyse, int pageNum, int pageSize);
|
||||
|
||||
PageInfo<Map<String, Object>> queryStockConcept(String stockCode, int pageNum, int pageSize);
|
||||
|
||||
List<Map<String, Object>> queryConceptStocks(String conceptName);
|
||||
|
||||
List<Map<String, Object>> getKLineData(String stockCode);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cn.feast.coding.service.stock;
|
||||
|
||||
import cn.feast.coding.model.stock.Stock;
|
||||
import cn.feast.coding.service.IService;
|
||||
|
||||
public interface StockService extends IService<Stock> {
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package cn.feast.coding.service.stock.impl;
|
||||
|
||||
import cn.feast.coding.mapper.stock.StockAnalyseMapper;
|
||||
import cn.feast.coding.model.stock.StockAnalyse;
|
||||
import cn.feast.coding.service.stock.StockAnalyseService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class StockAnalyseServiceImpl implements StockAnalyseService {
|
||||
@Autowired
|
||||
private StockAnalyseMapper mapper;
|
||||
|
||||
public int insert(StockAnalyse model){
|
||||
return mapper.insert(model);
|
||||
}
|
||||
|
||||
public int update(StockAnalyse model){
|
||||
return mapper.update(model);
|
||||
}
|
||||
|
||||
public int deleteByPrimaryKey(Integer id){
|
||||
return mapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<StockAnalyse> selectAll(StockAnalyse model){
|
||||
return mapper.selectAll(model);
|
||||
}
|
||||
|
||||
public PageInfo<StockAnalyse> queryPage(StockAnalyse model, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = 10;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<StockAnalyse> list = mapper.selectAll(model);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
public PageInfo<Map<String, Object>> queryAnalyse(StockAnalyse model, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = 10;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Map<String, Object>> list = mapper.queryAnalyse(model.getDate());
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<Map<String, Object>> queryAnalyse1(StockAnalyse model, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = 10;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Map<String, Object>> list = mapper.queryAnalyse1();
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<Map<String, Object>> queryAnalyse2(StockAnalyse model, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = 10;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Map<String, Object>> list = mapper.queryAnalyse2(model.getDate());
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<Map<String, Object>> sortByTurn(StockAnalyse stockAnalyse, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = 10;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Map<String, Object>> list = mapper.sortByTurn();
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<Map<String, Object>> sortByPrice(StockAnalyse stockAnalyse, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = 10;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Map<String, Object>> list = mapper.sortByPrice();
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<Map<String, Object>> querySentiment(StockAnalyse stockAnalyse, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = 10;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Map<String, Object>> list = mapper.querySentiment();
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<Map<String, Object>> queryConcept(StockAnalyse stockAnalyse, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = 10;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Map<String, Object>> list = mapper.queryConcept();
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
public StockAnalyse selectByPrimaryKey(Integer id){
|
||||
return mapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<StockAnalyse> queryAll(){
|
||||
return mapper.queryAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<Map<String, Object>> queryStockConcept(String stockCode, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = 10;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Map<String, Object>> list = mapper.queryStockConcept(stockCode);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> queryConceptStocks(String conceptName) {
|
||||
return mapper.queryConceptStocks(conceptName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getKLineData(String stockCode) {
|
||||
return mapper.getKLineData(stockCode);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package cn.feast.coding.service.stock.impl;
|
||||
|
||||
import cn.feast.coding.mapper.stock.StockMapper;
|
||||
import cn.feast.coding.model.stock.Stock;
|
||||
import cn.feast.coding.service.stock.StockService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class StockServiceImpl implements StockService {
|
||||
@Autowired
|
||||
private StockMapper mapper;
|
||||
|
||||
public int insert(Stock model){
|
||||
return mapper.insert(model);
|
||||
}
|
||||
|
||||
public int update(Stock model){
|
||||
return mapper.update(model);
|
||||
}
|
||||
|
||||
public int deleteByPrimaryKey(Integer id){
|
||||
return mapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Stock> selectAll(Stock model){
|
||||
return mapper.selectAll(model);
|
||||
}
|
||||
|
||||
public PageInfo<Stock> queryPage(Stock model, int pageNum, int pageSize) {
|
||||
if (pageSize < 1)
|
||||
pageSize = 10;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Stock> list = mapper.selectAll(model);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
public Stock selectByPrimaryKey(Integer id){
|
||||
return mapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Stock> queryAll(){
|
||||
return mapper.queryAll();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package cn.feast.coding.service.system;
|
||||
|
||||
import cn.feast.coding.model.system.User;
|
||||
import org.apache.shiro.crypto.RandomNumberGenerator;
|
||||
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
|
||||
import org.apache.shiro.crypto.hash.SimpleHash;
|
||||
import org.apache.shiro.util.ByteSource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class PasswordHelper {
|
||||
|
||||
private RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator();
|
||||
|
||||
private String algorithmName = "md5";
|
||||
private int hashIterations = 2;
|
||||
|
||||
public void setRandomNumberGenerator(RandomNumberGenerator randomNumberGenerator) {
|
||||
this.randomNumberGenerator = randomNumberGenerator;
|
||||
}
|
||||
|
||||
public void setAlgorithmName(String algorithmName) {
|
||||
this.algorithmName = algorithmName;
|
||||
}
|
||||
|
||||
public void setHashIterations(int hashIterations) {
|
||||
this.hashIterations = hashIterations;
|
||||
}
|
||||
|
||||
public void encryptPassword(User user) {
|
||||
|
||||
user.setUserSalt(randomNumberGenerator.nextBytes().toHex());
|
||||
|
||||
String newPassword = new SimpleHash(
|
||||
algorithmName,
|
||||
user.getUserPass(),
|
||||
ByteSource.Util.bytes(user.getUserSalt()),
|
||||
hashIterations).toHex();
|
||||
|
||||
user.setUserPass(newPassword);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
User user = new User();
|
||||
user.setUserName("admin");
|
||||
user.setUserPass("admin");
|
||||
PasswordHelper passwordHelper = new PasswordHelper();
|
||||
passwordHelper.encryptPassword(user);
|
||||
System.out.println(user.getUserPass());
|
||||
System.out.println(user.getUserSalt());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package cn.feast.coding.service.system;
|
||||
|
||||
import cn.feast.coding.mapper.system.PermissionMapper;
|
||||
import cn.feast.coding.model.generator.Page;
|
||||
import cn.feast.coding.model.system.Permission;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class PermissionService {
|
||||
|
||||
@Autowired
|
||||
private PermissionMapper mapper;
|
||||
|
||||
public Integer save(Permission permission) {
|
||||
return mapper.save(permission);
|
||||
}
|
||||
|
||||
public void update(Permission permission) {
|
||||
mapper.update(permission);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
mapper.deleteById(id);
|
||||
}
|
||||
|
||||
public int queryByCount(Permission permission) {
|
||||
return mapper.queryByCount(permission);
|
||||
}
|
||||
|
||||
public List<Permission> queryByList(Page page, Permission permission) {
|
||||
String pageQueryCondition = " limit " + page.getStart() + " , " + page.getMaxRows();
|
||||
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
||||
paramsMap.put("name", permission.getName());
|
||||
paramsMap.put("type", permission.getType());
|
||||
paramsMap.put("url", permission.getUrl());
|
||||
paramsMap.put("permission", permission.getPermission());
|
||||
paramsMap.put("parentid", permission.getParentid());
|
||||
paramsMap.put("pageQueryCondition", pageQueryCondition);
|
||||
return mapper.queryByList(paramsMap);
|
||||
}
|
||||
|
||||
public List<Permission> queryByPermission(Permission permission) {
|
||||
return mapper.queryByPermission(permission);
|
||||
}
|
||||
|
||||
public Permission queryById(Integer id) {
|
||||
return mapper.queryById(id);
|
||||
}
|
||||
|
||||
public List<Permission> queryByMenuPermission() {
|
||||
Permission permission = new Permission();
|
||||
permission.setType(1);
|
||||
return mapper.queryByPermission(permission);
|
||||
}
|
||||
|
||||
public List<Permission> queryBySubPermission() {
|
||||
Permission permission = new Permission();
|
||||
permission.setType(2);
|
||||
return mapper.queryByPermission(permission);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.feast.coding.service.system;
|
||||
|
||||
import cn.feast.coding.mapper.system.RolePermissionMapper;
|
||||
import cn.feast.coding.model.generator.Page;
|
||||
import cn.feast.coding.model.system.RolePermission;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class RolePermissionService {
|
||||
|
||||
@Autowired
|
||||
private RolePermissionMapper mapper;
|
||||
|
||||
public Integer save(RolePermission rolePermission) {
|
||||
return mapper.save(rolePermission);
|
||||
}
|
||||
|
||||
public void update(RolePermission rolePermission) {
|
||||
mapper.update(rolePermission);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
mapper.deleteById(id);
|
||||
}
|
||||
|
||||
public int queryByCount(RolePermission rolePermission) {
|
||||
return mapper.queryByCount(rolePermission);
|
||||
}
|
||||
|
||||
public List<RolePermission> queryByList(Page page, RolePermission rolePermission) {
|
||||
String pageQueryCondition = " limit " + page.getStart() + " , " + page.getMaxRows();
|
||||
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
||||
paramsMap.put("roleid", rolePermission.getRoleid());
|
||||
paramsMap.put("pageQueryCondition", pageQueryCondition);
|
||||
return mapper.queryByList(paramsMap);
|
||||
}
|
||||
|
||||
public List<RolePermission> queryByRolePermission(RolePermission rolePermission) {
|
||||
return mapper.queryByRolePermission(rolePermission);
|
||||
}
|
||||
|
||||
public RolePermission queryById(Integer id) {
|
||||
return mapper.queryById(id);
|
||||
}
|
||||
|
||||
public void deleteByRole(Integer roleid) {
|
||||
mapper.deleteByRole(roleid);
|
||||
}
|
||||
|
||||
public List<RolePermission> queryByRole(Integer roleid) {
|
||||
return mapper.queryByRole(roleid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package cn.feast.coding.service.system;
|
||||
|
||||
import cn.feast.coding.mapper.system.RoleMapper;
|
||||
import cn.feast.coding.model.generator.Page;
|
||||
import cn.feast.coding.model.system.Role;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class RoleService {
|
||||
|
||||
@Autowired
|
||||
private RoleMapper mapper;
|
||||
|
||||
public Integer save(Role role) {
|
||||
return mapper.save(role);
|
||||
}
|
||||
|
||||
public void update(Role role) {
|
||||
mapper.update(role);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
mapper.deleteById(id);
|
||||
}
|
||||
|
||||
public int queryByCount(Role role) {
|
||||
return mapper.queryByCount(role);
|
||||
}
|
||||
|
||||
public List<Role> queryByList(Page page, Role role) {
|
||||
String pageQueryCondition = " limit " + page.getStart() + " , " + page.getMaxRows();
|
||||
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
||||
paramsMap.put("role", role.getRole());
|
||||
paramsMap.put("description", role.getDescription());
|
||||
paramsMap.put("pageQueryCondition", pageQueryCondition);
|
||||
return mapper.queryByList(paramsMap);
|
||||
}
|
||||
|
||||
public List<Role> queryByRole(Role role) {
|
||||
return mapper.queryByRole(role);
|
||||
}
|
||||
|
||||
public Role queryById(Integer id) {
|
||||
return mapper.queryById(id);
|
||||
}
|
||||
|
||||
public List<Role> queryAll() {
|
||||
return mapper.queryByRole(new Role());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.feast.coding.service.system;
|
||||
|
||||
import cn.feast.coding.mapper.system.UserRoleMapper;
|
||||
import cn.feast.coding.model.generator.Page;
|
||||
import cn.feast.coding.model.system.UserRole;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class UserRoleService {
|
||||
|
||||
@Autowired
|
||||
private UserRoleMapper mapper;
|
||||
|
||||
public Integer save(UserRole userRole) {
|
||||
return mapper.save(userRole);
|
||||
}
|
||||
|
||||
public void update(UserRole userRole) {
|
||||
mapper.update(userRole);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
mapper.deleteById(id);
|
||||
}
|
||||
|
||||
public int queryByCount(UserRole userRole) {
|
||||
return mapper.queryByCount(userRole);
|
||||
}
|
||||
|
||||
public List<UserRole> queryByList(Page page, UserRole userRole) {
|
||||
String pageQueryCondition = " limit " + page.getStart() + " , " + page.getMaxRows();
|
||||
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
||||
paramsMap.put("userid", userRole.getUserid());
|
||||
paramsMap.put("pageQueryCondition", pageQueryCondition);
|
||||
return mapper.queryByList(paramsMap);
|
||||
}
|
||||
|
||||
public List<UserRole> queryByUserRole(UserRole userRole) {
|
||||
return mapper.queryByUserRole(userRole);
|
||||
}
|
||||
|
||||
public UserRole queryById(Integer id) {
|
||||
return mapper.queryById(id);
|
||||
}
|
||||
|
||||
public void deleteByUser(Integer userid) {
|
||||
mapper.deleteByUser(userid);
|
||||
}
|
||||
|
||||
public List<UserRole> queryByUser(Integer userid) {
|
||||
return mapper.queryByUser(userid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package cn.feast.coding.service.system;
|
||||
|
||||
import cn.feast.coding.mapper.system.UserMapper;
|
||||
import cn.feast.coding.model.generator.Page;
|
||||
import cn.feast.coding.model.system.Permission;
|
||||
import cn.feast.coding.model.system.Role;
|
||||
import cn.feast.coding.model.system.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created By FeastCoding.
|
||||
*/
|
||||
@Service
|
||||
public class UserService {
|
||||
|
||||
@Autowired
|
||||
private UserMapper mapper;
|
||||
|
||||
public Integer save(User user) {
|
||||
return mapper.save(user);
|
||||
}
|
||||
|
||||
public void update(User user) {
|
||||
mapper.update(user);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
mapper.deleteById(id);
|
||||
}
|
||||
|
||||
public int queryByCount(User user) {
|
||||
return mapper.queryByCount(user);
|
||||
}
|
||||
|
||||
public List<User> queryByList(Page page, User user) {
|
||||
String pageQueryCondition = " limit " + page.getStart() + " , " + page.getMaxRows();
|
||||
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
||||
paramsMap.put("userName", user.getUserName());
|
||||
paramsMap.put("userPass", user.getUserPass());
|
||||
paramsMap.put("userSalt", user.getUserSalt());
|
||||
paramsMap.put("userReal", user.getUserReal());
|
||||
paramsMap.put("userGender", user.getUserGender());
|
||||
paramsMap.put("userPhone", user.getUserPhone());
|
||||
paramsMap.put("userEmail", user.getUserEmail());
|
||||
paramsMap.put("pageQueryCondition", pageQueryCondition);
|
||||
return mapper.queryByList(paramsMap);
|
||||
}
|
||||
|
||||
public List<User> queryByUser(User user) {
|
||||
return mapper.queryByUser(user);
|
||||
}
|
||||
|
||||
public User queryById(Integer id) {
|
||||
return mapper.queryById(id);
|
||||
}
|
||||
|
||||
public User findByUsername(String username) {
|
||||
User user = mapper.findByUsername(username);
|
||||
return user;
|
||||
}
|
||||
|
||||
public Set<String> findRoles(String username) {
|
||||
Set<String> roles = new HashSet<String>();
|
||||
List<Role> roleList = mapper.findRoles(username);
|
||||
for (Role r : roleList) {
|
||||
roles.add(r.getRole());
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
public Set<String> findPermissions(String username) {
|
||||
Set<String> permissions = new HashSet<String>();
|
||||
List<Permission> permissionList = mapper.findPermissions(username);
|
||||
for (Permission p : permissionList) {
|
||||
permissions.add(p.getPermission());
|
||||
}
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public boolean checkName(String userName) {
|
||||
User user = new User();
|
||||
user.setUserName(userName);
|
||||
List<User> list = mapper.queryByUser(user);
|
||||
if(list.size() > 0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
10
op-service/src/main/resources/spring-service.xml
Normal file
10
op-service/src/main/resources/spring-service.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
|
||||
|
||||
<context:component-scan base-package="cn.feast.coding"/>
|
||||
|
||||
</beans>
|
||||
25
op-tools/pom.xml
Normal file
25
op-tools/pom.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>OpenPark</artifactId>
|
||||
<groupId>cn.feast.coding</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>op-tools</artifactId>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.feast.coding</groupId>
|
||||
<artifactId>op-model</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,225 @@
|
||||
package cn.feast.coding.tools;
|
||||
|
||||
import cn.feast.coding.model.generator.Colunm;
|
||||
import cn.feast.coding.model.generator.DataSource;
|
||||
import cn.feast.coding.model.generator.Table;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AlibabaDbConnect {
|
||||
private static DruidDataSource dataSource = null;
|
||||
|
||||
/**
|
||||
* 构造函数完成数据库的连接和连接对象的生成
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public AlibabaDbConnect() {
|
||||
|
||||
}
|
||||
|
||||
public static void GetDbConnect(DataSource data) throws Exception {
|
||||
try {
|
||||
if (dataSource == null) {
|
||||
dataSource = new DruidDataSource();
|
||||
//设置连接参数
|
||||
dataSource.setUrl(data.getJdbcUrl());
|
||||
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
|
||||
dataSource.setUsername(data.getJdbcUser());
|
||||
dataSource.setPassword(data.getJdbcPass());
|
||||
//配置初始化大小、最小、最大
|
||||
dataSource.setInitialSize(1);
|
||||
dataSource.setMinIdle(1);
|
||||
dataSource.setMaxActive(20);
|
||||
//连接泄漏监测
|
||||
dataSource.setRemoveAbandoned(true);
|
||||
dataSource.setRemoveAbandonedTimeout(30);
|
||||
//配置获取连接等待超时的时间
|
||||
dataSource.setMaxWait(20000);
|
||||
//配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||
dataSource.setTimeBetweenEvictionRunsMillis(20000);
|
||||
//防止过期
|
||||
dataSource.setValidationQuery("SELECT 'x'");
|
||||
dataSource.setTestWhileIdle(true);
|
||||
dataSource.setTestOnBorrow(true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库所有数据表名称
|
||||
*
|
||||
* @param dataSource
|
||||
* @return
|
||||
*/
|
||||
public static List<Table> getTables(DataSource dataSource) {
|
||||
List<Table> tables = new ArrayList<Table>();
|
||||
Table table = null;
|
||||
Connection conn = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
conn = getConnect(dataSource);
|
||||
DatabaseMetaData dbMetaData = conn.getMetaData();
|
||||
rs = dbMetaData.getTables(null, null, null, new String[]{"TABLE"});
|
||||
while (rs.next()) {
|
||||
table = new Table();
|
||||
String tableName = rs.getString("TABLE_NAME");
|
||||
table.setTableName(tableName);
|
||||
table.setClassName(getClassName(tableName));
|
||||
tables.add(table);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return tables;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取表数据
|
||||
*
|
||||
* @param dataSource 数据源
|
||||
* @param tableName 表名
|
||||
* @return
|
||||
*/
|
||||
public static List<Colunm> readData(DataSource dataSource,
|
||||
String tableName) {
|
||||
List<Colunm> properties = new ArrayList<Colunm>();
|
||||
Colunm colunm = null;
|
||||
Connection conn = null;
|
||||
ResultSet rs = null;
|
||||
String primaryKey = genFieldName(getPrimaryKey(dataSource, tableName));
|
||||
try {
|
||||
conn = getConnect(dataSource);
|
||||
DatabaseMetaData dbmd = conn.getMetaData();
|
||||
rs = dbmd.getColumns(null, null, tableName, null);
|
||||
while (rs.next()) {
|
||||
colunm = new Colunm();
|
||||
String colunmName = genFieldName(rs.getString("COLUMN_NAME"));
|
||||
colunm.setColunmName(colunmName);
|
||||
colunm.setFiledName(rs.getString("COLUMN_NAME"));
|
||||
if (colunmName.equals(primaryKey)) {
|
||||
colunm.setIsPrimary(1);
|
||||
} else {
|
||||
colunm.setIsPrimary(0);
|
||||
}
|
||||
int dataType = rs.getInt("DATA_TYPE"); //对应的java.sql.Types类型
|
||||
int columnSize = rs.getInt("COLUMN_SIZE");//列大小
|
||||
int decimalDigits = rs.getInt("DECIMAL_DIGITS");//小数位数
|
||||
colunm.setColunmType(JavaType.getType(dataType, columnSize, decimalDigits));
|
||||
colunm.setShowName(rs.getString("REMARKS"));
|
||||
properties.add(colunm);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据表主键
|
||||
*
|
||||
* @param dataSource
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public static String getPrimaryKey(DataSource dataSource, String tableName) {
|
||||
Connection conn = null;
|
||||
ResultSet rs = null;
|
||||
String primaryKeyName = "";
|
||||
try {
|
||||
conn = getConnect(dataSource);
|
||||
rs = conn.getMetaData().getPrimaryKeys(null, null, tableName);
|
||||
if (rs.next()) {
|
||||
primaryKeyName = rs.getString(4);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(primaryKeyName)) {
|
||||
return primaryKeyName;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据表字段名获取java中的字段名
|
||||
*
|
||||
* @param field 字段名
|
||||
* @return
|
||||
*/
|
||||
public static String genFieldName(String field) {
|
||||
//处理字段名忽视部分
|
||||
String[] ignore = Contants.FILED_IGNORE;
|
||||
for (int i = 0; i < ignore.length; i++) {
|
||||
if (field.contains(ignore[i])) {
|
||||
field = field.replace(ignore[i], "");
|
||||
}
|
||||
}
|
||||
//处理字段名
|
||||
String result = "";
|
||||
if (field.contains("_")) {
|
||||
String lowerFeild = field.toLowerCase();
|
||||
String[] fields = lowerFeild.split("_");
|
||||
result += fields[0];
|
||||
if (fields.length > 1) {
|
||||
for (int i = 1; i < fields.length; i++) {
|
||||
result += fields[i].substring(0, 1).toUpperCase() + fields[i].substring(1, fields[i].length());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = field;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据表名获取类名
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @return
|
||||
*/
|
||||
public static String getClassName(String tableName) {
|
||||
String result = "";
|
||||
String lowerFeild = tableName.toLowerCase();
|
||||
//处理表名
|
||||
String[] ignore = Contants.TABLE_IGNORE;
|
||||
for (int i = 0; i < ignore.length; i++) {
|
||||
if (lowerFeild.contains(ignore[i])) {
|
||||
lowerFeild = lowerFeild.replace(ignore[i], "");
|
||||
}
|
||||
}
|
||||
String[] fields = lowerFeild.split("_");
|
||||
if (fields.length >= 1) {
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
result += fields[i].substring(0, 1).toUpperCase() + fields[i].substring(1, fields[i].length());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 取得已经构造生成的数据库连接
|
||||
*
|
||||
* @return 返回数据库连接对象
|
||||
* @throws Exception
|
||||
*/
|
||||
public static Connection getConnect(DataSource data) throws Exception {
|
||||
Connection con = null;
|
||||
try {
|
||||
GetDbConnect(data);
|
||||
con = dataSource.getConnection();
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
return con;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user