生成模板优化

This commit is contained in:
thinkgem
2018-02-07 21:04:18 +08:00
parent 23a849c815
commit 52f7248079
18 changed files with 48 additions and 209 deletions

View File

@@ -5,6 +5,7 @@ package com.jeesite.common.security;
import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
@@ -24,6 +25,8 @@ public class AesUtils {
private static final String AES = "AES";
private static final String AES_CBC = "AES/CBC/PKCS5Padding";
private static final int DEFAULT_AES_KEYSIZE = 128; // 生成AES密钥, 默认长度为128位(16字节).
private static final int DEFAULT_IVSIZE = 16; // 生成随机向量, 默认大小为cipher.getBlockSize(), 16字节
private static final SecureRandom RANDOM = new SecureRandom(); // 用于 生成 generateIV随机数对象
private static final String DEFAULT_URL_ENCODING = "UTF-8";
private static final byte[] DEFAULT_KEY = new byte[]{-97,88,-94,9,70,-76,126,25,0,3,-20,113,108,28,69,125};
@@ -110,6 +113,15 @@ public class AesUtils {
}
}
/**
* 生成随机向量,默认大小为cipher.getBlockSize(), 16字节.
*/
public static byte[] genIV() {
byte[] bytes = new byte[DEFAULT_IVSIZE];
RANDOM.nextBytes(bytes);
return bytes;
}
/**
* 使用AES加密原始字符串.
*

View File

@@ -10,7 +10,7 @@ import com.jeesite.modules.test.entity.TestDataChild;
/**
* 测试数据DAO接口
* @author ThinkGem
* @version 2018-02-05
* @version 2018-02-07
*/
@MyBatisDao
public interface TestDataChildDao extends CrudDao<TestDataChild> {

View File

@@ -10,7 +10,7 @@ import com.jeesite.modules.test.entity.TestData;
/**
* 测试数据DAO接口
* @author ThinkGem
* @version 2018-02-05
* @version 2018-02-07
*/
@MyBatisDao
public interface TestDataDao extends CrudDao<TestData> {

View File

@@ -10,7 +10,7 @@ import com.jeesite.modules.test.entity.TestTree;
/**
* 测试树表DAO接口
* @author ThinkGem
* @version 2018-02-06
* @version 2018-02-07
*/
@MyBatisDao
public interface TestTreeDao extends TreeDao<TestTree> {

View File

@@ -22,7 +22,7 @@ import com.jeesite.common.mybatis.mapper.query.QueryType;
/**
* 测试数据Entity
* @author ThinkGem
* @version 2018-02-05
* @version 2018-02-07
*/
@Table(name="test_data", alias="a", columns={
@Column(name="id", attrName="id", label="编号", isPK=true),

View File

@@ -20,12 +20,12 @@ import com.jeesite.common.mybatis.mapper.query.QueryType;
/**
* 测试数据Entity
* @author ThinkGem
* @version 2018-02-05
* @version 2018-02-07
*/
@Table(name="test_data_child", alias="a", columns={
@Column(name="id", attrName="id", label="编号", isPK=true),
@Column(name="test_sort", attrName="testSort", label="排序号"),
@Column(name="test_data_id", attrName="testDataId.id", label="父表主键"),
@Column(name="test_data_id", attrName="testData.id", label="父表主键"),
@Column(name="test_input", attrName="testInput", label="单行文本", queryType=QueryType.LIKE),
@Column(name="test_textarea", attrName="testTextarea", label="多行文本", queryType=QueryType.LIKE),
@Column(name="test_select", attrName="testSelect", label="下拉框"),
@@ -55,7 +55,7 @@ public class TestDataChild extends DataEntity<TestDataChild> {
private static final long serialVersionUID = 1L;
private Long testSort; // 排序号
private TestData testDataId; // 父表主键 父类
private TestData testData; // 父表主键 父类
private String testInput; // 单行文本
private String testTextarea; // 多行文本
private String testSelect; // 下拉框
@@ -74,8 +74,8 @@ public class TestDataChild extends DataEntity<TestDataChild> {
}
public TestDataChild(TestData testDataId){
this.testDataId = testDataId;
public TestDataChild(TestData testData){
this.testData = testData;
}
public Long getTestSort() {
@@ -87,12 +87,12 @@ public class TestDataChild extends DataEntity<TestDataChild> {
}
@Length(min=0, max=64, message="父表主键长度不能超过 64 个字符")
public TestData getTestDataId() {
return testDataId;
public TestData getTestData() {
return testData;
}
public void setTestDataId(TestData testDataId) {
this.testDataId = testDataId;
public void setTestData(TestData testData) {
this.testData = testData;
}
@Length(min=0, max=200, message="单行文本长度不能超过 200 个字符")

View File

@@ -15,12 +15,12 @@ import com.jeesite.common.mybatis.mapper.query.QueryType;
/**
* 测试树表Entity
* @author ThinkGem
* @version 2018-02-06
* @version 2018-02-07
*/
@Table(name="test_tree", alias="a", columns={
@Column(name="tree_code", attrName="treeCode", label="节点编码", isPK=true),
@Column(includeEntity=TreeEntity.class),
@Column(name="tree_name", attrName="treeName", label="节点名", queryType=QueryType.LIKE, isTreeName=true),
@Column(name="tree_name", attrName="treeName", label="节点名", queryType=QueryType.LIKE, isTreeName=true),
@Column(includeEntity=DataEntity.class),
}, orderBy="a.tree_sorts, a.tree_code"
)
@@ -28,7 +28,7 @@ public class TestTree extends TreeEntity<TestTree> {
private static final long serialVersionUID = 1L;
private String treeCode; // 节点编码
private String treeName; // 节点名
private String treeName; // 节点名
public TestTree() {
this(null);
@@ -54,8 +54,8 @@ public class TestTree extends TreeEntity<TestTree> {
this.treeCode = treeCode;
}
@NotBlank(message="节点名不能为空")
@Length(min=0, max=200, message="节点名长度不能超过 200 个字符")
@NotBlank(message="节点名不能为空")
@Length(min=0, max=200, message="节点名长度不能超过 200 个字符")
public String getTreeName() {
return treeName;
}

View File

@@ -1,71 +0,0 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
*/
package com.jeesite.modules.test.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.test.entity.TestDataChild;
import com.jeesite.modules.test.dao.TestDataChildDao;
/**
* 测试子表Service
* @author ThinkGem
* @version 2018-01-31
*/
@Service
@Transactional(readOnly=true)
public class TestDataChildService extends CrudService<TestDataChildDao, TestDataChild> {
/**
* 获取单条数据
* @param testDataChild
* @return
*/
public TestDataChild get(TestDataChild testDataChild) {
return super.get(testDataChild);
}
/**
* 查询分页数据
* @param page 分页对象
* @param testDataChild
* @return
*/
public Page<TestDataChild> findPage(Page<TestDataChild> page, TestDataChild testDataChild) {
return super.findPage(page, testDataChild);
}
/**
* 保存数据(插入或更新)
* @param testDataChild
*/
@Transactional(readOnly=false)
public void save(TestDataChild testDataChild) {
super.save(testDataChild);
}
/**
* 更新状态
* @param testDataChild
*/
@Transactional(readOnly=false)
public void updateStatus(TestDataChild testDataChild) {
super.updateStatus(testDataChild);
}
/**
* 删除数据
* @param testDataChild
*/
@Transactional(readOnly=false)
public void delete(TestDataChild testDataChild) {
super.delete(testDataChild);
}
}

View File

@@ -20,7 +20,7 @@ import com.jeesite.modules.test.dao.TestDataChildDao;
/**
* 测试数据Service
* @author ThinkGem
* @version 2018-02-05
* @version 2018-02-07
*/
@Service
@Transactional(readOnly=true)
@@ -68,7 +68,7 @@ public class TestDataService extends CrudService<TestDataDao, TestData> {
// 保存 TestData子表
for (TestDataChild testDataChild : testData.getTestDataChildList()){
if (!TestDataChild.STATUS_DELETE.equals(testDataChild.getStatus())){
testDataChild.setTestDataId(testData);
testDataChild.setTestData(testData);
if (testDataChild.getIsNewRecord()){
testDataChild.preInsert();
testDataChildDao.insert(testDataChild);
@@ -99,7 +99,7 @@ public class TestDataService extends CrudService<TestDataDao, TestData> {
public void delete(TestData testData) {
super.delete(testData);
TestDataChild testDataChild = new TestDataChild();
testDataChild.setTestDataId(testData);
testDataChild.setTestData(testData);
testDataChildDao.delete(testDataChild);
}

View File

@@ -17,7 +17,7 @@ import com.jeesite.modules.file.utils.FileUploadUtils;
/**
* 测试树表Service
* @author ThinkGem
* @version 2018-02-06
* @version 2018-02-07
*/
@Service
@Transactional(readOnly=true)

View File

@@ -1,99 +0,0 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
*/
package com.jeesite.modules.test.web;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.sys.utils.UserUtils;
import com.jeesite.modules.test.entity.TestDataChild;
import com.jeesite.modules.test.service.TestDataChildService;
/**
* 测试子表Controller
* @author ThinkGem
* @version 2018-01-31
*/
@Controller
@RequestMapping(value = "${adminPath}/test/testDataChild")
public class TestDataChildController extends BaseController {
@Autowired
private TestDataChildService testDataChildService;
/**
* 获取数据
*/
@ModelAttribute
public TestDataChild get(String id, boolean isNewRecord) {
return testDataChildService.get(id, isNewRecord);
}
/**
* 查询列表
*/
@RequiresPermissions("test:testDataChild:view")
@RequestMapping(value = {"list", ""})
public String list(TestDataChild testDataChild, Model model) {
model.addAttribute("testDataChild", testDataChild);
return "modules/test/testDataChildList";
}
/**
* 查询列表数据
*/
@RequiresPermissions("test:testDataChild:view")
@RequestMapping(value = "listData")
@ResponseBody
public Page<TestDataChild> listData(TestDataChild testDataChild, HttpServletRequest request, HttpServletResponse response) {
Page<TestDataChild> page = testDataChildService.findPage(new Page<TestDataChild>(request, response), testDataChild);
return page;
}
/**
* 查看编辑表单
*/
@RequiresPermissions("test:testDataChild:view")
@RequestMapping(value = "form")
public String form(TestDataChild testDataChild, Model model) {
model.addAttribute("testDataChild", testDataChild);
return "modules/test/testDataChildForm";
}
/**
* 保存数据
*/
@RequiresPermissions("test:testDataChild:edit")
@PostMapping(value = "save")
@ResponseBody
public String save(@Validated TestDataChild testDataChild) {
testDataChildService.save(testDataChild);
return renderResult(Global.TRUE, "保存数据成功!");
}
/**
* 删除数据
*/
@RequiresPermissions("test:testDataChild:edit")
@RequestMapping(value = "delete")
@ResponseBody
public String delete(TestDataChild testDataChild) {
testDataChildService.delete(testDataChild);
return renderResult(Global.TRUE, "删除数据成功!");
}
}

View File

@@ -19,14 +19,13 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.sys.utils.UserUtils;
import com.jeesite.modules.test.entity.TestData;
import com.jeesite.modules.test.service.TestDataService;
/**
* 测试数据Controller
* @author ThinkGem
* @version 2018-02-05
* @version 2018-02-07
*/
@Controller
@RequestMapping(value = "${adminPath}/test/testData")

View File

@@ -29,7 +29,7 @@ import com.jeesite.modules.test.service.TestTreeService;
/**
* 测试树表Controller
* @author ThinkGem
* @version 2018-02-06
* @version 2018-02-07
*/
@Controller
@RequestMapping(value = "${adminPath}/test/testTree")

View File

@@ -205,7 +205,7 @@ $("#testDataChildDataGrid").dataGrid({
{header:'状态', name:'status', editable:true, hidden:true},
{header:'主键', name:'id', editable:true, hidden:true},
{header:'排序号', name:'testSort', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'11', 'class':'form-control digits'}},
{header:'父表主键', name:'testDataId.id', editable:true, hidden:true},
{header:'父表主键', name:'testData.id', editable:true, hidden:true},
{header:'单行文本', name:'testInput', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control'}},
{header:'多行文本', name:'testTextarea', width:150, editable:true, edittype:'textarea', editoptions:{'maxlength':'200', 'class':'form-control', 'rows':'1'}},
{header:'下拉框', name:'testSelect', width:100,
@@ -317,7 +317,7 @@ $("#testDataChildDataGrid").dataGrid({
// 编辑表格的提交数据参数
editGridInputFormListName: 'testDataChildList', // 提交的数据列表名
editGridInputFormListAttrs: 'status,id,testSort,testDataId.id,testInput,testTextarea,testSelect,testSelectMultiple,testRadio,testCheckbox,testDate,testDatetime,testUser.userCode,testOffice.officeCode,testAreaCode,testAreaName,', // 提交数据列表的属性字段
editGridInputFormListAttrs: 'status,id,testSort,testData.id,testInput,testTextarea,testSelect,testSelectMultiple,testRadio,testCheckbox,testDate,testDatetime,testUser.userCode,testOffice.officeCode,testAreaCode,testAreaName,', // 提交数据列表的属性字段
// 加载成功后执行事件
ajaxSuccess: function(data){

View File

@@ -139,8 +139,8 @@ $('#dataGrid').dataGrid({
{header:'复选框', name:'testCheckbox', index:'a.test_checkbox', width:150, align:"center", formatter: function(val, obj, row, act){
return js.getDictLabel(${@DictUtils.getDictListJson('sys_menu_type')}, val, '未知', true);
}},
{header:'日期选择', name:'testDate', index:'a.test_date', width:150, align:"left"},
{header:'日期时间', name:'testDatetime', index:'a.test_datetime', width:150, align:"left"},
{header:'日期选择', name:'testDate', index:'a.test_date', width:150, align:"center"},
{header:'日期时间', name:'testDatetime', index:'a.test_datetime', width:150, align:"center"},
{header:'用户选择', name:'testUser.userName', index:'a.test_user_code', width:150, align:"center"},
{header:'部门选择', name:'testOffice.officeName', index:'a.test_office_code', width:150, align:"center"},
{header:'区域选择', name:'testAreaName', index:'a.test_area_code', width:150, align:"center"},
@@ -148,7 +148,7 @@ $('#dataGrid').dataGrid({
{header:'状态', name:'status', index:'a.status', width:150, align:"center", formatter: function(val, obj, row, act){
return js.getDictLabel(${@DictUtils.getDictListJson('sys_search_status')}, val, '未知', true);
}},
{header:'创建时间', name:'createDate', index:'a.create_date', width:150, align:"left"},
{header:'创建时间', name:'createDate', index:'a.create_date', width:150, align:"center"},
{header:'备注信息', name:'remarks', index:'a.remarks', width:150, align:"left"},
{header:'操作', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
var actions = [];

View File

@@ -51,7 +51,7 @@
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required ">*</span> 节点名:<i class="fa icon-question hide"></i></label>
<span class="required ">*</span> 节点名<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<#form:input path="treeName" maxlength="200" class="form-control required"/>
</div>

View File

@@ -19,7 +19,7 @@
<#form:form id="searchForm" model="${testTree}" action="${ctx}/test/testTree/listData" method="post" class="form-inline hide"
data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
<div class="form-group">
<label class="control-label">节点名:</label>
<label class="control-label">节点名</label>
<div class="control-inline">
<#form:input path="treeName" maxlength="200" class="form-control width-120"/>
</div>
@@ -51,17 +51,15 @@
$('#dataGrid').dataGrid({
searchForm: $("#searchForm"),
columnModel: [
{header:'父级编号', name:'parentCode', index:'a.parent_code', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
return '<a href="${ctx}/test/testTree/form?treeCode='+row.treeCode+'" class="btnList" data-title="编辑数据">'+(val||row.id)+'</a>';
{header:'节点名称', name:'treeName', index:'a.tree_name', width:250, align:"left", frozen:true, formatter: function(val, obj, row, act){
return '( '+row.treeCode+' ) '+'<a href="${ctx}/test/testTree/form?treeCode='+row.treeCode+'" class="btnList" data-title="编辑数据">'+(val||row.id)+'</a>';
}},
{header:'所有父级编号', name:'parentCodes', index:'a.parent_codes', width:150, align:"left"},
{header:'本级排序号', name:'treeSort', index:'a.tree_sort', width:150, align:"left"},
{header:'全节点名', name:'treeNames', index:'a.tree_names', width:150, align:"left"},
{header:'树节点名', name:'treeName', index:'a.tree_name', width:150, align:"left"},
{header:'本级排序号', name:'treeSort', index:'a.tree_sort', width:150, align:"center"},
{header:'节点名称', name:'treeName', index:'a.tree_name', width:150, align:"left"},
{header:'状态', name:'status', index:'a.status', width:150, align:"center", formatter: function(val, obj, row, act){
return js.getDictLabel(${@DictUtils.getDictListJson('sys_search_status')}, val, '未知', true);
}},
{header:'创建时间', name:'createDate', index:'a.create_date', width:150, align:"left"},
{header:'创建时间', name:'createDate', index:'a.create_date', width:150, align:"center"},
{header:'备注信息', name:'remarks', index:'a.remarks', width:150, align:"left"},
{header:'操作', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
var actions = [];