小部分代码优化

This commit is contained in:
lsy
2018-02-19 17:09:10 +08:00
parent 558701aa1c
commit 03435fdc7c
10 changed files with 49 additions and 375 deletions
@@ -43,6 +43,7 @@ public class MybatisGeneratorExtend {
PropertiesUtil.getProperty("mybatisGenerator.daoPackage"));
MybatisGeneratorExtend.mybatisGenerator.setTablesPrefix(
PropertiesUtil.getProperty("mybatisGenerator.tablesPrefix"));
MybatisGeneratorExtend.mybatisGenerator.setIsOverWrite("true");
}
/**
@@ -79,12 +80,12 @@ public class MybatisGeneratorExtend {
Map<String,Object> mybatisGeneratorModel = new HashMap<>();
mybatisGeneratorModel.put("db",MybatisGeneratorExtend.db);
mybatisGeneratorModel.put("mybatisGenerator",MybatisGeneratorExtend.mybatisGenerator);
boolean mybatisGeneratorFileSuccess = FreemarkerUtil.createFile("mybatisGenerator.ftl", mybatisGeneratorModel, "mybatisGenerator.properties",projectPath,null,mybatisGenerator.getIsOverWrite());
boolean mybatisGeneratorFileSuccess = FreemarkerUtil.createFile("mybatisGenerator.ftl", mybatisGeneratorModel, "mybatisGenerator.properties",projectPath,null,"true");
File file = new File(JarUtil.getThisJarPathParent() + "/templates" + "/mybatisGenerator.ftl");
if (file.exists()){
file.delete();
}
boolean generatorConfigFileSuccess = FreemarkerUtil.createFile("generatorConfig.ftl", mybatisGeneratorModel, "generatorConfig.xml",projectPath,null,mybatisGenerator.getIsOverWrite());
boolean generatorConfigFileSuccess = FreemarkerUtil.createFile("generatorConfig.ftl", mybatisGeneratorModel, "generatorConfig.xml",projectPath,null,"true");
File file1 = new File(JarUtil.getThisJarPathParent() + "/templates" + "/generatorConfig.ftl");
if (file1.exists()){
file1.delete();
+1 -1
View File
@@ -100,7 +100,7 @@
<configuration>
<!--冗余的-->
<verbose>true</verbose>
<overwrite>false</overwrite>
<overwrite>true</overwrite>
</configuration>
</plugin>
<plugin>
@@ -55,7 +55,7 @@ public class UpmsSystemController {
@ApiOperation("修改信息")
@PutMapping("/{id}")
public ServerResponse updateSystem(@Valid UpmsSystem upmsSystem,
public ServerResponse updateSystem( UpmsSystem upmsSystem,
@NotBlank(message = BaseConst.BASEMSG_PREFIX+"请传入id") String id){
upmsSystem.setId(Integer.valueOf(id));
return upmsSystemService.update(upmsSystem);
@@ -4,15 +4,22 @@ import com.micro.fast.common.dao.SsmMapper;
import com.micro.fast.upms.pojo.UpmsPermission;
public interface UpmsPermissionMapper extends SsmMapper<UpmsPermission,Integer> {
@Override
int deleteByPrimaryKey(Integer id);
@Override
int insert(UpmsPermission record);
@Override
int insertSelective(UpmsPermission record);
@Override
UpmsPermission selectByPrimaryKey(Integer id);
@Override
int updateByPrimaryKeySelective(UpmsPermission record);
@Override
int updateByPrimaryKey(UpmsPermission record);
}
}
@@ -11,6 +11,8 @@ public class UpmsPermission implements Serializable {
private String name;
private String description;
private Byte type;
private String permissionValue;
@@ -27,11 +29,12 @@ public class UpmsPermission implements Serializable {
private static final long serialVersionUID = 1L;
public UpmsPermission(Integer id, Integer systemId, Integer pid, String name, Byte type, String permissionValue, String uri, String icon, Byte status, Long ctime, Long orders) {
public UpmsPermission(Integer id, Integer systemId, Integer pid, String name, String description, Byte type, String permissionValue, String uri, String icon, Byte status, Long ctime, Long orders) {
this.id = id;
this.systemId = systemId;
this.pid = pid;
this.name = name;
this.description = description;
this.type = type;
this.permissionValue = permissionValue;
this.uri = uri;
@@ -77,6 +80,14 @@ public class UpmsPermission implements Serializable {
this.name = name == null ? null : name.trim();
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
public Byte getType() {
return type;
}
@@ -143,6 +154,7 @@ public class UpmsPermission implements Serializable {
sb.append(", systemId=").append(systemId);
sb.append(", pid=").append(pid);
sb.append(", name=").append(name);
sb.append(", description=").append(description);
sb.append(", type=").append(type);
sb.append(", permissionValue=").append(permissionValue);
sb.append(", uri=").append(uri);
@@ -3,7 +3,6 @@ package com.micro.fast.upms.pojo;
import com.micro.fast.boot.starter.common.response.BaseConst;
import org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
public class UpmsSystem implements Serializable {
@@ -24,7 +23,7 @@ public class UpmsSystem implements Serializable {
private String name;
@NotBlank(message = BaseConst.BASEMSG_PREFIX+"请填写系统路由")
private String title;
private String route;
@NotBlank(message = BaseConst.BASEMSG_PREFIX+"请填写系统描述")
private String description;
@@ -33,9 +32,11 @@ public class UpmsSystem implements Serializable {
private Long orders;
private String title;
private static final long serialVersionUID = 1L;
public UpmsSystem(Integer id, String icon, String banner, String theme, String basepath, Byte status, String name, String title, String description, Long ctime, Long orders) {
public UpmsSystem(Integer id, String icon, String banner, String theme, String basepath, Byte status, String name, String route, String description, Long ctime, Long orders, String title) {
this.id = id;
this.icon = icon;
this.banner = banner;
@@ -43,10 +44,11 @@ public class UpmsSystem implements Serializable {
this.basepath = basepath;
this.status = status;
this.name = name;
this.title = title;
this.route = route;
this.description = description;
this.ctime = ctime;
this.orders = orders;
this.title = title;
}
public UpmsSystem() {
@@ -109,12 +111,12 @@ public class UpmsSystem implements Serializable {
this.name = name == null ? null : name.trim();
}
public String getTitle() {
return title;
public String getRoute() {
return route;
}
public void setTitle(String title) {
this.title = title == null ? null : title.trim();
public void setRoute(String route) {
this.route = route == null ? null : route.trim();
}
public String getDescription() {
@@ -141,6 +143,14 @@ public class UpmsSystem implements Serializable {
this.orders = orders;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title == null ? null : title.trim();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -154,10 +164,11 @@ public class UpmsSystem implements Serializable {
sb.append(", basepath=").append(basepath);
sb.append(", status=").append(status);
sb.append(", name=").append(name);
sb.append(", title=").append(title);
sb.append(", route=").append(route);
sb.append(", description=").append(description);
sb.append(", ctime=").append(ctime);
sb.append(", orders=").append(orders);
sb.append(", title=").append(title);
sb.append("]");
return sb.toString();
}
@@ -66,6 +66,6 @@
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<table tableName="persistent_logins" domainObjectName="PersistentLogins" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_permission" domainObjectName="UpmsPermission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
@@ -1,165 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.micro.fast.upms.dao.UpmsPermissionMapper" >
<resultMap id="BaseResultMap" type="com.micro.fast.upms.pojo.UpmsPermission" >
<constructor >
<idArg column="id" jdbcType="INTEGER" javaType="java.lang.Integer" />
<arg column="system_id" jdbcType="INTEGER" javaType="java.lang.Integer" />
<arg column="pid" jdbcType="INTEGER" javaType="java.lang.Integer" />
<arg column="name" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="type" jdbcType="TINYINT" javaType="java.lang.Byte" />
<arg column="permission_value" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="uri" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="icon" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="status" jdbcType="TINYINT" javaType="java.lang.Byte" />
<arg column="ctime" jdbcType="BIGINT" javaType="java.lang.Long" />
<arg column="orders" jdbcType="BIGINT" javaType="java.lang.Long" />
</constructor>
</resultMap>
<sql id="Base_Column_List" >
id, system_id, pid, name, type, permission_value, uri, icon, status, ctime, orders
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from upms_permission
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from upms_permission
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.micro.fast.upms.pojo.UpmsPermission" >
insert into upms_permission (id, system_id, pid,
name, type, permission_value,
uri, icon, status,
ctime, orders)
values (#{id,jdbcType=INTEGER}, #{systemId,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER},
#{name,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, #{permissionValue,jdbcType=VARCHAR},
#{uri,jdbcType=VARCHAR}, #{icon,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT},
#{ctime,jdbcType=BIGINT}, #{orders,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="com.micro.fast.upms.pojo.UpmsPermission" >
insert into upms_permission
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="systemId != null" >
system_id,
</if>
<if test="pid != null" >
pid,
</if>
<if test="name != null" >
name,
</if>
<if test="type != null" >
type,
</if>
<if test="permissionValue != null" >
permission_value,
</if>
<if test="uri != null" >
uri,
</if>
<if test="icon != null" >
icon,
</if>
<if test="status != null" >
status,
</if>
<if test="ctime != null" >
ctime,
</if>
<if test="orders != null" >
orders,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="systemId != null" >
#{systemId,jdbcType=INTEGER},
</if>
<if test="pid != null" >
#{pid,jdbcType=INTEGER},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="type != null" >
#{type,jdbcType=TINYINT},
</if>
<if test="permissionValue != null" >
#{permissionValue,jdbcType=VARCHAR},
</if>
<if test="uri != null" >
#{uri,jdbcType=VARCHAR},
</if>
<if test="icon != null" >
#{icon,jdbcType=VARCHAR},
</if>
<if test="status != null" >
#{status,jdbcType=TINYINT},
</if>
<if test="ctime != null" >
#{ctime,jdbcType=BIGINT},
</if>
<if test="orders != null" >
#{orders,jdbcType=BIGINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.micro.fast.upms.pojo.UpmsPermission" >
update upms_permission
<set >
<if test="systemId != null" >
system_id = #{systemId,jdbcType=INTEGER},
</if>
<if test="pid != null" >
pid = #{pid,jdbcType=INTEGER},
</if>
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="type != null" >
type = #{type,jdbcType=TINYINT},
</if>
<if test="permissionValue != null" >
permission_value = #{permissionValue,jdbcType=VARCHAR},
</if>
<if test="uri != null" >
uri = #{uri,jdbcType=VARCHAR},
</if>
<if test="icon != null" >
icon = #{icon,jdbcType=VARCHAR},
</if>
<if test="status != null" >
status = #{status,jdbcType=TINYINT},
</if>
<if test="ctime != null" >
ctime = #{ctime,jdbcType=BIGINT},
</if>
<if test="orders != null" >
orders = #{orders,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.micro.fast.upms.pojo.UpmsPermission" >
update upms_permission
set system_id = #{systemId,jdbcType=INTEGER},
pid = #{pid,jdbcType=INTEGER},
name = #{name,jdbcType=VARCHAR},
type = #{type,jdbcType=TINYINT},
permission_value = #{permissionValue,jdbcType=VARCHAR},
uri = #{uri,jdbcType=VARCHAR},
icon = #{icon,jdbcType=VARCHAR},
status = #{status,jdbcType=TINYINT},
ctime = #{ctime,jdbcType=BIGINT},
orders = #{orders,jdbcType=BIGINT}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
@@ -1,192 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.micro.fast.upms.dao.UpmsSystemMapper" >
<resultMap id="BaseResultMap" type="com.micro.fast.upms.pojo.UpmsSystem" >
<constructor >
<idArg column="id" jdbcType="INTEGER" javaType="java.lang.Integer" />
<arg column="icon" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="banner" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="theme" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="basepath" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="status" jdbcType="TINYINT" javaType="java.lang.Byte" />
<arg column="name" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="title" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="description" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="ctime" jdbcType="BIGINT" javaType="java.lang.Long" />
<arg column="orders" jdbcType="BIGINT" javaType="java.lang.Long" />
</constructor>
</resultMap>
<sql id="Base_Column_List" >
id, icon, banner, theme, basepath, status, name, title, description, ctime, orders
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from upms_system
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from upms_system
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.micro.fast.upms.pojo.UpmsSystem" >
insert into upms_system (id, icon, banner,
theme, basepath, status,
name, title, description,
ctime, orders)
values (#{id,jdbcType=INTEGER}, #{icon,jdbcType=VARCHAR}, #{banner,jdbcType=VARCHAR},
#{theme,jdbcType=VARCHAR}, #{basepath,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT},
#{name,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
#{ctime,jdbcType=BIGINT}, #{orders,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="com.micro.fast.upms.pojo.UpmsSystem" >
insert into upms_system
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="icon != null" >
icon,
</if>
<if test="banner != null" >
banner,
</if>
<if test="theme != null" >
theme,
</if>
<if test="basepath != null" >
basepath,
</if>
<if test="status != null" >
status,
</if>
<if test="name != null" >
name,
</if>
<if test="title != null" >
title,
</if>
<if test="description != null" >
description,
</if>
<if test="ctime != null" >
ctime,
</if>
<if test="orders != null" >
orders,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="icon != null" >
#{icon,jdbcType=VARCHAR},
</if>
<if test="banner != null" >
#{banner,jdbcType=VARCHAR},
</if>
<if test="theme != null" >
#{theme,jdbcType=VARCHAR},
</if>
<if test="basepath != null" >
#{basepath,jdbcType=VARCHAR},
</if>
<if test="status != null" >
#{status,jdbcType=TINYINT},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="title != null" >
#{title,jdbcType=VARCHAR},
</if>
<if test="description != null" >
#{description,jdbcType=VARCHAR},
</if>
<if test="ctime != null" >
#{ctime,jdbcType=BIGINT},
</if>
<if test="orders != null" >
#{orders,jdbcType=BIGINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.micro.fast.upms.pojo.UpmsSystem" >
update upms_system
<set >
<if test="icon != null" >
icon = #{icon,jdbcType=VARCHAR},
</if>
<if test="banner != null" >
banner = #{banner,jdbcType=VARCHAR},
</if>
<if test="theme != null" >
theme = #{theme,jdbcType=VARCHAR},
</if>
<if test="basepath != null" >
basepath = #{basepath,jdbcType=VARCHAR},
</if>
<if test="status != null" >
status = #{status,jdbcType=TINYINT},
</if>
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="title != null" >
title = #{title,jdbcType=VARCHAR},
</if>
<if test="description != null" >
description = #{description,jdbcType=VARCHAR},
</if>
<if test="ctime != null" >
ctime = #{ctime,jdbcType=BIGINT},
</if>
<if test="orders != null" >
orders = #{orders,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.micro.fast.upms.pojo.UpmsSystem" >
update upms_system
set icon = #{icon,jdbcType=VARCHAR},
banner = #{banner,jdbcType=VARCHAR},
theme = #{theme,jdbcType=VARCHAR},
basepath = #{basepath,jdbcType=VARCHAR},
status = #{status,jdbcType=TINYINT},
name = #{name,jdbcType=VARCHAR},
title = #{title,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
ctime = #{ctime,jdbcType=BIGINT},
orders = #{orders,jdbcType=BIGINT}
where id = #{id,jdbcType=INTEGER}
</update>
<!--自定义的-->
<!--根据条件分页查询信息-->
<select id="selectByCondition" resultType="com.micro.fast.upms.pojo.UpmsSystem">
SELECT <include refid="Base_Column_List"/> FROM upms_system
<where>
<if test="title != null">
and title like #{title}
</if>
<if test="basepath !=null">
and basepath like #{basepath}
</if>
<if test="name != null">
and name like #{name}
</if>
<if test="status != null">
and status = #{status}
</if>
</where>
</select>
<delete id="deleteByPrimaryKeys" parameterType="java.util.List">
DELETE FROM upms_system
WHERE id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
</mapper>
@@ -6,10 +6,10 @@ db.username=root
db.password=studyj2e
mybatisGenerator.pojoPackage=com.micro.fast.upms.pojo
mybatisGenerator.daoPackage=com.micro.fast.upms.dao
mybatisGenerator.tablesPrefix=upms_system
mybatisGenerator.tablesPrefix=upms_permission
# \uFFFD\uFFFD\uFFFD\uFFFDservice\uFFFD\uFFFDcontroller\uFFFD\uFFFD
mybatisGenerator.servicePackage=com.micro.fast.upms.service
mybatisGenerator.controllerPackage=com.micro.fast.upms.controller
mybatisGenerator.serviceImplPackage=com.micro.fast.upms.service.impl
mybatisGenerator.primaryKeyType=Integer
mybatisGenerator.isOverWrite=false
mybatisGenerator.isOverWrite=true