每天进步一点点。

This commit is contained in:
thinkgem
2018-01-31 23:35:22 +08:00
parent 2f9a1a9167
commit 5fe3f27b0f
16 changed files with 586 additions and 490 deletions

View File

@@ -10,7 +10,7 @@ import com.jeesite.modules.test.entity.TestDataChild;
/**
* 测试数据DAO接口
* @author ThinkGem
* @version 2018-01-30
* @version 2018-01-31
*/
@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-01-30
* @version 2018-01-31
*/
@MyBatisDao
public interface TestDataDao extends CrudDao<TestData> {

View File

@@ -8,9 +8,9 @@ import java.util.Date;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.validation.constraints.NotNull;
import com.jeesite.modules.sys.entity.User;
import com.jeesite.modules.sys.entity.Office;
import com.jeesite.common.entity.Extend;
import java.util.List;
import com.jeesite.common.collect.ListUtils;
@@ -22,7 +22,7 @@ import com.jeesite.common.mybatis.mapper.query.QueryType;
/**
* 测试数据Entity
* @author ThinkGem
* @version 2018-01-30
* @version 2018-01-31
*/
@Table(name="test_data", alias="a", columns={
@Column(name="id", attrName="id", label="编号", isPK=true),
@@ -39,7 +39,6 @@ import com.jeesite.common.mybatis.mapper.query.QueryType;
@Column(name="test_area_code", attrName="testAreaCode", label="区域选择"),
@Column(name="test_area_name", attrName="testAreaName", label="区域名称", isQuery=false),
@Column(includeEntity=DataEntity.class),
@Column(includeEntity=Extend.class, attrName="extend"),
}, joinTable={
@JoinTable(type=Type.LEFT_JOIN, entity=User.class, attrName="testUser", alias="u10",
on="u10.user_code = a.test_user_code", columns={
@@ -68,7 +67,6 @@ public class TestData extends DataEntity<TestData> {
private Office testOffice; // 部门选择
private String testAreaCode; // 区域选择
private String testAreaName; // 区域名称
private Extend extend; // 扩展字段
private List<TestDataChild> testDataChildList = ListUtils.newArrayList(); // 子表列表
public TestData() {
@@ -134,6 +132,7 @@ public class TestData extends DataEntity<TestData> {
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@NotNull(message="日期选择不能为空")
public Date getTestDate() {
return testDate;
}
@@ -143,6 +142,7 @@ public class TestData extends DataEntity<TestData> {
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@NotNull(message="日期时间不能为空")
public Date getTestDatetime() {
return testDatetime;
}
@@ -185,14 +185,6 @@ public class TestData extends DataEntity<TestData> {
this.testAreaName = testAreaName;
}
public Extend getExtend() {
return extend;
}
public void setExtend(Extend extend) {
this.extend = extend;
}
public Date getTestDate_gte() {
return sqlMap.getWhere().getValue("test_date", QueryType.GTE);
}

View File

@@ -8,6 +8,9 @@ import java.util.Date;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.validation.constraints.NotNull;
import com.jeesite.modules.sys.entity.User;
import com.jeesite.modules.sys.entity.Office;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
@@ -17,31 +20,42 @@ import com.jeesite.common.mybatis.mapper.query.QueryType;
/**
* 测试数据Entity
* @author ThinkGem
* @version 2018-01-30
* @version 2018-01-31
*/
@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="testData.id", label="父表主键"),
@Column(name="test_input", attrName="testInput", label="单行文本"),
@Column(name="test_textarea", attrName="testTextarea", label="多行文本"),
@Column(name="test_data_id", attrName="testDataId.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="下拉框"),
@Column(name="test_select_multiple", attrName="testSelectMultiple", label="下拉多选"),
@Column(name="test_radio", attrName="testRadio", label="单选框"),
@Column(name="test_checkbox", attrName="testCheckbox", label="复选框"),
@Column(name="test_date", attrName="testDate", label="日期选择"),
@Column(name="test_datetime", attrName="testDatetime", label="日期时间"),
@Column(name="test_user_code", attrName="testUserCode", label="用户选择"),
@Column(name="test_office_code", attrName="testOfficeCode", label="部门选择"),
@Column(name="test_user_code", attrName="testUser.userCode", label="用户选择"),
@Column(name="test_office_code", attrName="testOffice.officeCode", label="部门选择"),
@Column(name="test_area_code", attrName="testAreaCode", label="区域选择"),
@Column(name="test_area_name", attrName="testAreaName", label="区域名称", queryType=QueryType.LIKE),
@Column(name="test_area_name", attrName="testAreaName", label="区域名称", isQuery=false),
}, joinTable={
@JoinTable(type=Type.LEFT_JOIN, entity=User.class, attrName="testUser", alias="u12",
on="u12.user_code = a.test_user_code", columns={
@Column(name="user_code", label="用户编码", isPK=true),
@Column(name="user_name", label="用户名称", isQuery=false),
}),
@JoinTable(type=Type.LEFT_JOIN, entity=Office.class, attrName="testOffice", alias="u13",
on="u13.office_code = a.test_office_code", columns={
@Column(name="office_code", label="部门编码", isPK=true),
@Column(name="office_name", label="部门名称", isQuery=false),
}),
}, orderBy="a.id ASC"
)
public class TestDataChild extends DataEntity<TestDataChild> {
private static final long serialVersionUID = 1L;
private Integer testSort; // 排序号
private TestData testData; // 父表主键 父类
private Long testSort; // 排序号
private TestData testDataId; // 父表主键 父类
private String testInput; // 单行文本
private String testTextarea; // 多行文本
private String testSelect; // 下拉框
@@ -50,8 +64,8 @@ public class TestDataChild extends DataEntity<TestDataChild> {
private String testCheckbox; // 复选框
private Date testDate; // 日期选择
private Date testDatetime; // 日期时间
private String testUserCode; // 用户选择
private String testOfficeCode; // 部门选择
private User testUser; // 用户选择
private Office testOffice; // 部门选择
private String testAreaCode; // 区域选择
private String testAreaName; // 区域名称
@@ -60,25 +74,25 @@ public class TestDataChild extends DataEntity<TestDataChild> {
}
public TestDataChild(TestData testData){
this.testData = testData;
public TestDataChild(TestData testDataId){
this.testDataId = testDataId;
}
public Integer getTestSort() {
public Long getTestSort() {
return testSort;
}
public void setTestSort(Integer testSort) {
public void setTestSort(Long testSort) {
this.testSort = testSort;
}
@Length(min=0, max=64, message="父表主键长度不能超过 64 个字符")
public TestData getTestData() {
return testData;
public TestData getTestDataId() {
return testDataId;
}
public void setTestData(TestData testData) {
this.testData = testData;
public void setTestDataId(TestData testDataId) {
this.testDataId = testDataId;
}
@Length(min=0, max=200, message="单行文本长度不能超过 200 个字符")
@@ -136,6 +150,7 @@ public class TestDataChild extends DataEntity<TestDataChild> {
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@NotNull(message="日期选择不能为空")
public Date getTestDate() {
return testDate;
}
@@ -145,6 +160,7 @@ public class TestDataChild extends DataEntity<TestDataChild> {
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@NotNull(message="日期时间不能为空")
public Date getTestDatetime() {
return testDatetime;
}
@@ -153,22 +169,20 @@ public class TestDataChild extends DataEntity<TestDataChild> {
this.testDatetime = testDatetime;
}
@Length(min=0, max=64, message="用户选择长度不能超过 64 个字符")
public String getTestUserCode() {
return testUserCode;
public User getTestUser() {
return testUser;
}
public void setTestUserCode(String testUserCode) {
this.testUserCode = testUserCode;
public void setTestUser(User testUser) {
this.testUser = testUser;
}
@Length(min=0, max=64, message="部门选择长度不能超过 64 个字符")
public String getTestOfficeCode() {
return testOfficeCode;
public Office getTestOffice() {
return testOffice;
}
public void setTestOfficeCode(String testOfficeCode) {
this.testOfficeCode = testOfficeCode;
public void setTestOffice(Office testOffice) {
this.testOffice = testOffice;
}
@Length(min=0, max=64, message="区域选择长度不能超过 64 个字符")
@@ -189,4 +203,36 @@ public class TestDataChild extends DataEntity<TestDataChild> {
this.testAreaName = testAreaName;
}
public Date getTestDate_gte() {
return sqlMap.getWhere().getValue("test_date", QueryType.GTE);
}
public void setTestDate_gte(Date testDate) {
sqlMap.getWhere().and("test_date", QueryType.GTE, testDate);
}
public Date getTestDate_lte() {
return sqlMap.getWhere().getValue("test_date", QueryType.LTE);
}
public void setTestDate_lte(Date testDate) {
sqlMap.getWhere().and("test_date", QueryType.LTE, testDate);
}
public Date getTestDatetime_gte() {
return sqlMap.getWhere().getValue("test_datetime", QueryType.GTE);
}
public void setTestDatetime_gte(Date testDatetime) {
sqlMap.getWhere().and("test_datetime", QueryType.GTE, testDatetime);
}
public Date getTestDatetime_lte() {
return sqlMap.getWhere().getValue("test_datetime", QueryType.LTE);
}
public void setTestDatetime_lte(Date testDatetime) {
sqlMap.getWhere().and("test_datetime", QueryType.LTE, testDatetime);
}
}

View File

@@ -0,0 +1,71 @@
/**
* 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-01-30
* @version 2018-01-31
*/
@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.setTestData(testData);
testDataChild.setTestDataId(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.setTestData(testData);
testDataChild.setTestDataId(testData);
testDataChildDao.delete(testDataChild);
}

View File

@@ -0,0 +1,99 @@
/**
* 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

@@ -26,7 +26,7 @@ import com.jeesite.modules.test.service.TestDataService;
/**
* 测试数据Controller
* @author ThinkGem
* @version 2018-01-30
* @version 2018-01-31
*/
@Controller
@RequestMapping(value = "${adminPath}/test/testData")