生成模板优化
This commit is contained in:
@@ -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> {
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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 个字符")
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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, "删除数据成功!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user