各种优化修复

This commit is contained in:
thinkgem
2018-01-30 22:04:24 +08:00
parent 9944c08c6a
commit 2f9a1a9167
21 changed files with 452 additions and 87 deletions

View File

@@ -0,0 +1,18 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
*/
package com.jeesite.modules.test.dao;
import com.jeesite.common.dao.CrudDao;
import com.jeesite.common.mybatis.annotation.MyBatisDao;
import com.jeesite.modules.test.entity.TestDataChild;
/**
* 测试数据DAO接口
* @author ThinkGem
* @version 2018-01-30
*/
@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-28
* @version 2018-01-30
*/
@MyBatisDao
public interface TestDataDao extends CrudDao<TestData> {

View File

@@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonFormat;
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;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
@@ -20,7 +22,7 @@ import com.jeesite.common.mybatis.mapper.query.QueryType;
/**
* 测试数据Entity
* @author ThinkGem
* @version 2018-01-28
* @version 2018-01-30
*/
@Table(name="test_data", alias="a", columns={
@Column(name="id", attrName="id", label="编号", isPK=true),
@@ -67,6 +69,7 @@ public class TestData extends DataEntity<TestData> {
private String testAreaCode; // 区域选择
private String testAreaName; // 区域名称
private Extend extend; // 扩展字段
private List<TestDataChild> testDataChildList = ListUtils.newArrayList(); // 子表列表
public TestData() {
this(null);
@@ -222,4 +225,12 @@ public class TestData extends DataEntity<TestData> {
sqlMap.getWhere().and("test_datetime", QueryType.LTE, testDatetime);
}
public List<TestDataChild> getTestDataChildList() {
return testDataChildList;
}
public void setTestDataChildList(List<TestDataChild> testDataChildList) {
this.testDataChildList = testDataChildList;
}
}

View File

@@ -0,0 +1,192 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
*/
package com.jeesite.modules.test.entity;
import org.hibernate.validator.constraints.Length;
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 com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
/**
* 测试数据Entity
* @author ThinkGem
* @version 2018-01-30
*/
@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_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_area_code", attrName="testAreaCode", label="区域选择"),
@Column(name="test_area_name", attrName="testAreaName", label="区域名称", queryType=QueryType.LIKE),
}, orderBy="a.id ASC"
)
public class TestDataChild extends DataEntity<TestDataChild> {
private static final long serialVersionUID = 1L;
private Integer testSort; // 排序号
private TestData testData; // 父表主键 父类
private String testInput; // 单行文本
private String testTextarea; // 多行文本
private String testSelect; // 下拉框
private String testSelectMultiple; // 下拉多选
private String testRadio; // 单选框
private String testCheckbox; // 复选框
private Date testDate; // 日期选择
private Date testDatetime; // 日期时间
private String testUserCode; // 用户选择
private String testOfficeCode; // 部门选择
private String testAreaCode; // 区域选择
private String testAreaName; // 区域名称
public TestDataChild() {
this(null);
}
public TestDataChild(TestData testData){
this.testData = testData;
}
public Integer getTestSort() {
return testSort;
}
public void setTestSort(Integer testSort) {
this.testSort = testSort;
}
@Length(min=0, max=64, message="父表主键长度不能超过 64 个字符")
public TestData getTestData() {
return testData;
}
public void setTestData(TestData testData) {
this.testData = testData;
}
@Length(min=0, max=200, message="单行文本长度不能超过 200 个字符")
public String getTestInput() {
return testInput;
}
public void setTestInput(String testInput) {
this.testInput = testInput;
}
@Length(min=0, max=200, message="多行文本长度不能超过 200 个字符")
public String getTestTextarea() {
return testTextarea;
}
public void setTestTextarea(String testTextarea) {
this.testTextarea = testTextarea;
}
@Length(min=0, max=10, message="下拉框长度不能超过 10 个字符")
public String getTestSelect() {
return testSelect;
}
public void setTestSelect(String testSelect) {
this.testSelect = testSelect;
}
@Length(min=0, max=200, message="下拉多选长度不能超过 200 个字符")
public String getTestSelectMultiple() {
return testSelectMultiple;
}
public void setTestSelectMultiple(String testSelectMultiple) {
this.testSelectMultiple = testSelectMultiple;
}
@Length(min=0, max=10, message="单选框长度不能超过 10 个字符")
public String getTestRadio() {
return testRadio;
}
public void setTestRadio(String testRadio) {
this.testRadio = testRadio;
}
@Length(min=0, max=200, message="复选框长度不能超过 200 个字符")
public String getTestCheckbox() {
return testCheckbox;
}
public void setTestCheckbox(String testCheckbox) {
this.testCheckbox = testCheckbox;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
public Date getTestDate() {
return testDate;
}
public void setTestDate(Date testDate) {
this.testDate = testDate;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
public Date getTestDatetime() {
return testDatetime;
}
public void setTestDatetime(Date testDatetime) {
this.testDatetime = testDatetime;
}
@Length(min=0, max=64, message="用户选择长度不能超过 64 个字符")
public String getTestUserCode() {
return testUserCode;
}
public void setTestUserCode(String testUserCode) {
this.testUserCode = testUserCode;
}
@Length(min=0, max=64, message="部门选择长度不能超过 64 个字符")
public String getTestOfficeCode() {
return testOfficeCode;
}
public void setTestOfficeCode(String testOfficeCode) {
this.testOfficeCode = testOfficeCode;
}
@Length(min=0, max=64, message="区域选择长度不能超过 64 个字符")
public String getTestAreaCode() {
return testAreaCode;
}
public void setTestAreaCode(String testAreaCode) {
this.testAreaCode = testAreaCode;
}
@Length(min=0, max=100, message="区域名称长度不能超过 100 个字符")
public String getTestAreaName() {
return testAreaName;
}
public void setTestAreaName(String testAreaName) {
this.testAreaName = testAreaName;
}
}

View File

@@ -5,6 +5,7 @@ package com.jeesite.modules.test.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -13,23 +14,34 @@ import com.jeesite.common.service.CrudService;
import com.jeesite.modules.test.entity.TestData;
import com.jeesite.modules.test.dao.TestDataDao;
import com.jeesite.modules.file.utils.FileUploadUtils;
import com.jeesite.modules.test.entity.TestDataChild;
import com.jeesite.modules.test.dao.TestDataChildDao;
/**
* 测试数据Service
* @author ThinkGem
* @version 2018-01-28
* @version 2018-01-30
*/
@Service
@Transactional(readOnly=true)
public class TestDataService extends CrudService<TestDataDao, TestData> {
@Autowired
private TestDataChildDao testDataChildDao;
/**
* 获取单条数据
* @param testData
* @return
*/
public TestData get(TestData testData) {
return super.get(testData);
TestData entity = super.get(testData);
if (entity != null){
TestDataChild testDataChild = new TestDataChild(entity);
testDataChild.setStatus(TestDataChild.STATUS_NORMAL);
entity.setTestDataChildList(testDataChildDao.findList(testDataChild));
}
return entity;
}
/**
@@ -53,6 +65,21 @@ public class TestDataService extends CrudService<TestDataDao, TestData> {
FileUploadUtils.saveFileUpload(testData.getId(), "testData_image");
// 保存上传附件
FileUploadUtils.saveFileUpload(testData.getId(), "testData_file");
// 保存 TestData子表
for (TestDataChild testDataChild : testData.getTestDataChildList()){
if (!TestDataChild.STATUS_DELETE.equals(testDataChild.getStatus())){
testDataChild.setTestData(testData);
if (testDataChild.getIsNewRecord()){
testDataChild.preInsert();
testDataChildDao.insert(testDataChild);
}else{
testDataChild.preUpdate();
testDataChildDao.update(testDataChild);
}
}else{
testDataChildDao.delete(testDataChild);
}
}
}
/**
@@ -71,6 +98,9 @@ public class TestDataService extends CrudService<TestDataDao, TestData> {
@Transactional(readOnly=false)
public void delete(TestData testData) {
super.delete(testData);
TestDataChild testDataChild = new TestDataChild();
testDataChild.setTestData(testData);
testDataChildDao.delete(testDataChild);
}
}

View File

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