This commit is contained in:
王鹏
2025-08-14 14:32:37 +08:00
commit 48822a3444
925 changed files with 352599 additions and 0 deletions

26
op-mapper/pom.xml Normal file
View 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>

View 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();
}

View File

@@ -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);
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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();
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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> {
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View 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>

View File

@@ -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>

View 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>

View File

@@ -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>

View File

@@ -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>

View 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>

View 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>

View 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>

View 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>

View 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 &lt; 500
-- AND ((sc.param3 - s5.maxLow) / s5.maxLow * 100) &lt; 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 &lt; 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) &lt; 3 ## 回撤比例小于3%
-- AND (s1.market_value > 50 AND s1.market_value &lt; 200 ) ## 市值大于50亿小于200亿
AND (s1.applies > 7 AND s1.applies &lt; 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 &lt; 300
-- AND ((sc.param3 - s5.maxLow) / s5.maxLow * 100) &lt; 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>

View 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>

View 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>

View 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>

View 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.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>

View 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>

View 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>

View 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>

View 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>