This commit is contained in:
parent
6a0e6312c2
commit
1b7b607e29
|
|
@ -0,0 +1,54 @@
|
||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询关联查询父列表
|
||||||
|
export function listFather(query) {
|
||||||
|
console.log(query)
|
||||||
|
return request({
|
||||||
|
url: '/test/father/list',
|
||||||
|
method: 'put',
|
||||||
|
data: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询关联查询父详细
|
||||||
|
export function getFather(id) {
|
||||||
|
return request({
|
||||||
|
url: '/test/father/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增关联查询父
|
||||||
|
export function addFather(data) {
|
||||||
|
return request({
|
||||||
|
url: '/test/father',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改关联查询父
|
||||||
|
export function updateFather(data) {
|
||||||
|
return request({
|
||||||
|
url: '/test/father',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除关联查询父
|
||||||
|
export function delFather(id) {
|
||||||
|
return request({
|
||||||
|
url: '/test/father/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出关联查询父
|
||||||
|
export function exportFather(query) {
|
||||||
|
return request({
|
||||||
|
url: '/test/father/export',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -67,14 +67,15 @@ export function addDateRange(params, dateRange) {
|
||||||
// 添加搜索创建时间日期范围
|
// 添加搜索创建时间日期范围
|
||||||
export function addCreateDateRange(params, dateRange) {
|
export function addCreateDateRange(params, dateRange) {
|
||||||
var search = params;
|
var search = params;
|
||||||
search.parameter= {
|
let data = {
|
||||||
beginCreateTime : "",
|
beginCreateTime : "",
|
||||||
endCreateTime : "",
|
endCreateTime : "",
|
||||||
};
|
};
|
||||||
if (null != dateRange && '' != dateRange) {
|
if (null != dateRange && '' != dateRange) {
|
||||||
search.parameter.beginCreateTime = dateRange[0];
|
data.beginCreateTime = dateRange[0];
|
||||||
search.parameter.endCreateTime = dateRange[1];
|
data.endCreateTime = dateRange[1];
|
||||||
}
|
}
|
||||||
|
search.parameter= JSON.stringify(data)
|
||||||
return search;
|
return search;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,348 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="名称" prop="name">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.name"
|
||||||
|
placeholder="请输入名称"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="信息" prop="info">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.info"
|
||||||
|
placeholder="请输入信息"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="daterangeCreateTime"
|
||||||
|
size="small"
|
||||||
|
style="width: 240px"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="名称" prop="sname">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.assSun.sname"
|
||||||
|
placeholder="请输入名称"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="assCreateTime"
|
||||||
|
size="small"
|
||||||
|
style="width: 240px"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="el-icon-plus"
|
||||||
|
size="mini"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['test:father:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="el-icon-edit"
|
||||||
|
size="mini"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['test:father:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['test:father:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
icon="el-icon-download"
|
||||||
|
size="mini"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['test:father:export']"
|
||||||
|
>导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="fatherList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="名称" align="center" prop="name" />
|
||||||
|
<el-table-column label="信息" align="center" prop="info" />
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="名称" align="center" prop="assSun.sname" :formatter="snameFormat" />
|
||||||
|
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['test:father:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['test:father:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 添加或修改关联查询父对话框 -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="主键" prop="id">
|
||||||
|
<el-input v-model="form.id" placeholder="请输入主键" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="名称" prop="name">
|
||||||
|
<el-input v-model="form.name" placeholder="请输入名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="信息" prop="info">
|
||||||
|
<el-input v-model="form.info" placeholder="请输入信息" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { listFather, getFather, delFather, addFather, updateFather, exportFather } from "@/api/test/father";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "Father",
|
||||||
|
components: {
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 关联查询父表格数据
|
||||||
|
fatherList: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 创建时间时间范围
|
||||||
|
daterangeCreateTime: [],
|
||||||
|
assCreateTime: [],
|
||||||
|
// 主键字典
|
||||||
|
idOptions: [],
|
||||||
|
// 父id字典
|
||||||
|
fIdOptions: [],
|
||||||
|
// 名称字典
|
||||||
|
snameOptions: [],
|
||||||
|
// 创建时间字典
|
||||||
|
createTimeOptions: [],
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
params:{
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
},
|
||||||
|
name: null,
|
||||||
|
info: null,
|
||||||
|
assSun: {
|
||||||
|
sname: null,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
name: [
|
||||||
|
{ required: true, message: "名称不能为空}", trigger: "blur" },
|
||||||
|
],
|
||||||
|
info: [
|
||||||
|
{ required: true, message: "信息不能为空}", trigger: "blur" },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询关联查询父列表 */
|
||||||
|
getList() {
|
||||||
|
if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
|
||||||
|
this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
|
||||||
|
this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
|
||||||
|
}
|
||||||
|
if (null != this.assCreateTime && '' != this.assCreateTime) {
|
||||||
|
this.queryParams.params["assbeginCreateTime"] = this.assCreateTime[0];
|
||||||
|
this.queryParams.params["assendCreateTime"] = this.assCreateTime[1];
|
||||||
|
}
|
||||||
|
listFather(this.queryParams).then(response => {
|
||||||
|
this.fatherList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: null,
|
||||||
|
name: null,
|
||||||
|
info: null,
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.daterangeCreateTime = [];
|
||||||
|
this.assdaterangeCreateTime = [];
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
this.single = selection.length!==1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加关联查询父";
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const id = row.id || this.ids
|
||||||
|
getFather(id).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改关联查询父";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.id != null) {
|
||||||
|
updateFather(this.form).then(response => {
|
||||||
|
this.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addFather(this.form).then(response => {
|
||||||
|
this.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const ids = row.id || this.ids;
|
||||||
|
this.$confirm('是否确认删除关联查询父编号为"' + ids + '"的数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return delFather(ids);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
const queryParams = this.queryParams;
|
||||||
|
this.$confirm('是否确认导出所有关联查询父数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return exportFather(queryParams);
|
||||||
|
}).then(response => {
|
||||||
|
this.download(response.msg);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
@ -71,13 +71,12 @@
|
||||||
<groupId>com.hchyun</groupId>
|
<groupId>com.hchyun</groupId>
|
||||||
<artifactId>hchyun-test</artifactId>
|
<artifactId>hchyun-test</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- 代码生成-->
|
<!-- 代码生成-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.hchyun</groupId>
|
<groupId>com.hchyun</groupId>
|
||||||
<artifactId>hchyun-generator</artifactId>
|
<artifactId>hchyun-generator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,11 @@ import org.springframework.web.bind.WebDataBinder;
|
||||||
import org.springframework.web.bind.annotation.InitBinder;
|
import org.springframework.web.bind.annotation.InitBinder;
|
||||||
|
|
||||||
import java.beans.PropertyEditorSupport;
|
import java.beans.PropertyEditorSupport;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class HcyBaseController {
|
public class HcyBaseController {
|
||||||
|
|
||||||
|
|
@ -23,14 +26,11 @@ public class HcyBaseController {
|
||||||
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||||
*/
|
*/
|
||||||
@InitBinder
|
@InitBinder
|
||||||
public void initBinder(WebDataBinder binder)
|
public void initBinder(WebDataBinder binder) {
|
||||||
{
|
|
||||||
// Date 类型转换
|
// Date 类型转换
|
||||||
binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
|
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void setAsText(String text)
|
public void setAsText(String text) {
|
||||||
{
|
|
||||||
setValue(DateUtils.parseDate(text));
|
setValue(DateUtils.parseDate(text));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -39,24 +39,22 @@ public class HcyBaseController {
|
||||||
/**
|
/**
|
||||||
* 设置请求分页数据
|
* 设置请求分页数据
|
||||||
*/
|
*/
|
||||||
protected void startPage()
|
protected void startPage() {
|
||||||
{
|
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
Integer pageNum = pageDomain.getPageNum();
|
Integer pageNum = pageDomain.getPageNum();
|
||||||
Integer pageSize = pageDomain.getPageSize();
|
Integer pageSize = pageDomain.getPageSize();
|
||||||
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
|
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
|
||||||
{
|
|
||||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
PageHelper.startPage(pageNum, pageSize, orderBy);
|
PageHelper.startPage(pageNum, pageSize, orderBy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应请求分页数据
|
* 响应请求分页数据
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
protected TableDataInfo getDataTable(List<?> list)
|
protected TableDataInfo getDataTable(List<?> list) {
|
||||||
{
|
|
||||||
TableDataInfo rspData = new TableDataInfo();
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
rspData.setCode(HttpStatus.SUCCESS);
|
rspData.setCode(HttpStatus.SUCCESS);
|
||||||
rspData.setMsg("查询成功");
|
rspData.setMsg("查询成功");
|
||||||
|
|
@ -65,6 +63,8 @@ public class HcyBaseController {
|
||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * 响应返回结果
|
// * 响应返回结果
|
||||||
// *
|
// *
|
||||||
|
|
@ -79,8 +79,7 @@ public class HcyBaseController {
|
||||||
/**
|
/**
|
||||||
* 页面跳转
|
* 页面跳转
|
||||||
*/
|
*/
|
||||||
public String redirect(String url)
|
public String redirect(String url) {
|
||||||
{
|
|
||||||
return StringUtils.format("redirect:{}", url);
|
return StringUtils.format("redirect:{}", url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,6 @@ public class BaseEntity implements Serializable {
|
||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/**
|
|
||||||
* 参数
|
|
||||||
*/
|
|
||||||
private String parameter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始时间
|
* 开始时间
|
||||||
*/
|
*/
|
||||||
|
|
@ -71,20 +66,6 @@ public class BaseEntity implements Serializable {
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> params;
|
private Map<String, Object> params;
|
||||||
|
|
||||||
public void setParameter(String parameter) {
|
|
||||||
if (parameter != null || parameter.equals("")) {
|
|
||||||
this.parameter = parameter;
|
|
||||||
JSONObject jsonObject = JSONObject.parseObject(parameter);
|
|
||||||
Object beginCreateTime = jsonObject.get("beginCreateTime");
|
|
||||||
Object endCreateTime = jsonObject.get("endCreateTime");
|
|
||||||
if (beginCreateTime != null && !beginCreateTime.equals("") && endCreateTime != null && !endCreateTime.equals("")) {
|
|
||||||
params = new HashMap<>();
|
|
||||||
params.put("beginCreateTime", beginCreateTime);
|
|
||||||
params.put("endCreateTime", endCreateTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSearchValue() {
|
public String getSearchValue() {
|
||||||
return searchValue;
|
return searchValue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,15 +57,18 @@ public class ${ClassName}Controller extends HcyBaseController {
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询${functionName}列表")
|
@ApiOperation("查询${functionName}列表")
|
||||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
||||||
@GetMapping("/list")
|
|
||||||
#if($table.crud || $table.sub || $table.tplCategory.equals("ass"))
|
#if($table.crud || $table.sub || $table.tplCategory.equals("ass"))
|
||||||
#if($table.tplCategory.equals("ass"))
|
#if($table.tplCategory.equals("ass"))
|
||||||
public Serializable list(@Validated ${ClassName} ${className}) {
|
@PutMapping("/list")
|
||||||
|
public Serializable list(@Validated @RequestBody ${ClassName} ${className}) {
|
||||||
|
try {
|
||||||
|
startPage(assFather.getParams());
|
||||||
#else
|
#else
|
||||||
|
@GetMapping("/list")
|
||||||
public Serializable list(${ClassName} ${className}) {
|
public Serializable list(${ClassName} ${className}) {
|
||||||
#end
|
|
||||||
try {
|
try {
|
||||||
startPage();
|
startPage();
|
||||||
|
#end
|
||||||
ServerResult<List<${ClassName}>> serverResult = ${className}Service.select${ClassName}List(${className});
|
ServerResult<List<${ClassName}>> serverResult = ${className}Service.select${ClassName}List(${className});
|
||||||
if (serverResult.isStart()) {
|
if (serverResult.isStart()) {
|
||||||
return getDataTable(serverResult.getData());
|
return getDataTable(serverResult.getData());
|
||||||
|
|
@ -78,6 +81,7 @@ public class ${ClassName}Controller extends HcyBaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
|
@GetMapping("/list")
|
||||||
public AjaxResult list(${ClassName} ${className}) {
|
public AjaxResult list(${ClassName} ${className}) {
|
||||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
|
|
@ -238,4 +242,19 @@ public class ${ClassName}Controller extends HcyBaseController {
|
||||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if($table.tplCategory.equals("ass"))
|
||||||
|
/**
|
||||||
|
* 设置请求分页数据
|
||||||
|
*/
|
||||||
|
public void startPage(Map<String,Object> map) {
|
||||||
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
|
Integer pageNum = (Integer) map.get("pageNum");
|
||||||
|
Integer pageSize = (Integer) map.get("pageSize");
|
||||||
|
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
|
||||||
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
|
PageHelper.startPage(pageNum, pageSize, orderBy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,16 @@
|
||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
|
||||||
// 查询${functionName}列表
|
// 查询${functionName}列表
|
||||||
|
#if($table.tplCategory.equals("ass"))
|
||||||
|
export function list${BusinessName}(data) {
|
||||||
|
return request({
|
||||||
|
url: '/${moduleName}/${businessName}/list',
|
||||||
|
method: 'put',
|
||||||
|
params: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
#else
|
||||||
export function list${BusinessName}(query) {
|
export function list${BusinessName}(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/${moduleName}/${businessName}/list',
|
url: '/${moduleName}/${businessName}/list',
|
||||||
|
|
@ -8,6 +18,7 @@ export function list${BusinessName}(query) {
|
||||||
params: query
|
params: query
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
// 查询${functionName}详细
|
// 查询${functionName}详细
|
||||||
export function get${BusinessName}(${pkColumn.javaField}) {
|
export function get${BusinessName}(${pkColumn.javaField}) {
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="assdaterange${AttrName}"
|
v-model="ass${AttrName}"
|
||||||
size="small"
|
size="small"
|
||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
|
|
@ -493,7 +493,7 @@ export default {
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
// $comment时间范围
|
// $comment时间范围
|
||||||
assdaterange${AttrName}: [],
|
ass${AttrName}: [],
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
// 查询参数
|
// 查询参数
|
||||||
|
|
@ -555,23 +555,41 @@ export default {
|
||||||
/** 查询${functionName}列表 */
|
/** 查询${functionName}列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
#set($variable = 0)
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($variable = 1)
|
||||||
#break
|
#break
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $table.assColumns)
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
#set($VariableName= "daterange"+$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set($variable = 1)
|
||||||
#set($variable = true)
|
|
||||||
#break
|
#break
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#if($variable)
|
#if($variable == 1)
|
||||||
list${BusinessName}(this.addCreateDateRange(this.queryParams,this.$VariableName)).then(response =>{
|
this.queryParams.params = {};
|
||||||
#else
|
#end
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
|
||||||
|
this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0];
|
||||||
|
this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach ($column in $table.assColumns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
if (null != this.ass${AttrName} && '' != this.ass${AttrName}) {
|
||||||
|
this.queryParams.params["assbegin${AttrName}"] = this.ass${AttrName}[0];
|
||||||
|
this.queryParams.params["assend${AttrName}"] = this.ass${AttrName}[1];
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
#end
|
||||||
list${BusinessName}(this.queryParams).then(response => {
|
list${BusinessName}(this.queryParams).then(response => {
|
||||||
#end
|
|
||||||
this.${businessName}List = response.rows;
|
this.${businessName}List = response.rows;
|
||||||
this.total = response.total;
|
this.total = response.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<sql id="select${ClassName}Vo">
|
<sql id="select${ClassName}Vo">
|
||||||
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
|
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
|
||||||
</sql>
|
</sql>
|
||||||
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
|
|
||||||
#if($table.tplCategory.equals("ass"))
|
#if($table.tplCategory.equals("ass"))
|
||||||
|
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}${assClassName}Result">
|
||||||
select#foreach($column in $columns) ${tableMapping}.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
select#foreach($column in $columns) ${tableMapping}.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
||||||
#foreach($column in $table.assColumns) ${assMapping}.$column.columnName#if($velocityCount != $table.assColumns.size()),#end#end
|
#foreach($column in $table.assColumns) ${assMapping}.$column.columnName#if($velocityCount != $table.assColumns.size()),#end#end
|
||||||
|
|
||||||
|
|
@ -91,12 +91,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
#elseif($queryType == "LIKE")
|
#elseif($queryType == "LIKE")
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if>
|
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if>
|
||||||
#elseif($queryType == "BETWEEN")
|
#elseif($queryType == "BETWEEN")
|
||||||
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
|
<if test="params.assbegin$AttrName != null and params.assbegin$AttrName != '' and params.assend$AttrName != null and params.assend$AttrName != ''"> and $columnName between #{params.assbegin$AttrName} and #{params.assend$AttrName}</if>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
</where>
|
|
||||||
#else
|
#else
|
||||||
|
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
|
||||||
<include refid="select${ClassName}Vo"/>
|
<include refid="select${ClassName}Vo"/>
|
||||||
<where>
|
<where>
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
|
|
@ -125,8 +125,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
</where>
|
|
||||||
#end
|
#end
|
||||||
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
|
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,222 @@
|
||||||
|
package com.hchyun.test.controller;
|
||||||
|
|
||||||
|
import java.beans.BeanInfo;
|
||||||
|
import java.beans.Introspector;
|
||||||
|
import java.beans.PropertyDescriptor;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.hchyun.common.constant.ReturnConstants;
|
||||||
|
import com.hchyun.common.core.controller.HcyBaseController;
|
||||||
|
import com.hchyun.common.core.page.PageDomain;
|
||||||
|
import com.hchyun.common.core.page.TableSupport;
|
||||||
|
import com.hchyun.common.utils.ServerResult;
|
||||||
|
import com.hchyun.common.utils.StringUtils;
|
||||||
|
import com.hchyun.common.utils.sql.SqlUtil;
|
||||||
|
import com.hchyun.test.test.Maptest;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.hchyun.common.annotation.Log;
|
||||||
|
import com.hchyun.common.core.entity.AjaxResult;
|
||||||
|
import com.hchyun.common.enums.BusinessType;
|
||||||
|
import com.hchyun.test.entity.AssFather;
|
||||||
|
import com.hchyun.test.service.AssFatherService;
|
||||||
|
import com.hchyun.common.utils.poi.ExcelUtil;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联查询父Controller
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-02-09
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Api(value = "关联查询父管理", tags = "关联查询父管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/test/father")
|
||||||
|
public class AssFatherController extends HcyBaseController {
|
||||||
|
protected final Logger logger = LoggerFactory.getLogger(AssFatherController.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AssFatherService assFatherService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询关联查询父列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("查询关联查询父列表")
|
||||||
|
@PreAuthorize("@ss.hasPermi('test:father:list')")
|
||||||
|
@PutMapping("/list")
|
||||||
|
public Serializable list(@Validated @RequestBody AssFather assFather) {
|
||||||
|
try {
|
||||||
|
startPage(assFather.getParams());
|
||||||
|
ServerResult<List<AssFather>> serverResult = assFatherService.selectAssFatherList(assFather);
|
||||||
|
if (serverResult.isStart()) {
|
||||||
|
return getDataTable(serverResult.getData());
|
||||||
|
} else {
|
||||||
|
return AjaxResult.info(serverResult.getMsg());
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出关联查询父列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("导出关联查询父列表")
|
||||||
|
@PreAuthorize("@ss.hasPermi('test:father:export')")
|
||||||
|
@Log(title = "关联查询父", businessType = BusinessType.EXPORT)
|
||||||
|
@GetMapping("/export")
|
||||||
|
public AjaxResult export(AssFather assFather) {
|
||||||
|
try {
|
||||||
|
ServerResult<List<AssFather>> serverResult = assFatherService.selectAssFatherList(assFather);
|
||||||
|
ExcelUtil<AssFather> util = new ExcelUtil<AssFather>(AssFather.class);
|
||||||
|
if (serverResult.isStart()) {
|
||||||
|
return util.exportExcel(serverResult.getData(), "father");
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error(serverResult.getMsg());
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取关联查询父详细信息
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取关联查询父详细信息")
|
||||||
|
@ApiImplicitParam(name = "id", value = "关联查询父id", required = true, dataType = "Long", paramType = "path")
|
||||||
|
@PreAuthorize("@ss.hasPermi('test:father:query')")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||||
|
try {
|
||||||
|
ServerResult<AssFather> serverResult = assFatherService.selectAssFatherById(id);
|
||||||
|
if (serverResult.isStart()) {
|
||||||
|
return AjaxResult.success(serverResult.getData());
|
||||||
|
} else {
|
||||||
|
return AjaxResult.info(serverResult.getMsg());
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增关联查询父
|
||||||
|
*/
|
||||||
|
@ApiOperation("新增关联查询父")
|
||||||
|
@ApiImplicitParam(name = "assFather", value = "新增关联查询父信息", dataType = "AssFather")
|
||||||
|
@PreAuthorize("@ss.hasPermi('test:father:add')")
|
||||||
|
@Log(title = "关联查询父", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody AssFather assFather) {
|
||||||
|
if (assFather.getName() == null || assFather.getName().equals("")) {
|
||||||
|
return AjaxResult.error("名称不能为空!");
|
||||||
|
}
|
||||||
|
if (assFather.getInfo() == null || assFather.getInfo().equals("")) {
|
||||||
|
return AjaxResult.error("信息不能为空!");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ServerResult<Integer> serverResult = assFatherService.insertAssFather(assFather);
|
||||||
|
if (serverResult.isStart()) {
|
||||||
|
return AjaxResult.success();
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error(serverResult.getMsg());
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改关联查询父
|
||||||
|
*/
|
||||||
|
@ApiOperation("修改关联查询父")
|
||||||
|
@ApiImplicitParam(name = "assFather", value = "修改关联查询父信息", dataType = "AssFather")
|
||||||
|
@PreAuthorize("@ss.hasPermi('test:father:edit')")
|
||||||
|
@Log(title = "关联查询父", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody AssFather assFather) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (assFather.getName() == null || assFather.getName().equals("")) {
|
||||||
|
return AjaxResult.error("名称不能为空!");
|
||||||
|
}
|
||||||
|
if (assFather.getInfo() == null || assFather.getInfo().equals("")) {
|
||||||
|
return AjaxResult.error("信息不能为空!");
|
||||||
|
}
|
||||||
|
ServerResult<Integer> serverResult = assFatherService.updateAssFather(assFather);
|
||||||
|
if (serverResult.isStart()) {
|
||||||
|
return AjaxResult.success();
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error(serverResult.getMsg());
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除关联查询父
|
||||||
|
*/
|
||||||
|
@ApiOperation("删除关联查询父")
|
||||||
|
@ApiImplicitParam(name = "ids", value = "关联查询父ids", required = true, dataType = "Long", paramType = "path")
|
||||||
|
@PreAuthorize("@ss.hasPermi('test:father:remove')")
|
||||||
|
@Log(title = "关联查询父", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
|
try {
|
||||||
|
if (ids.length < 0) {
|
||||||
|
return AjaxResult.error("id不能为空!");
|
||||||
|
}
|
||||||
|
ServerResult<Integer> serverResult = assFatherService.deleteAssFatherByIds(ids);
|
||||||
|
if (serverResult.isStart()) {
|
||||||
|
return AjaxResult.success();
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error(serverResult.getMsg());
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置请求分页数据
|
||||||
|
*/
|
||||||
|
public void startPage(Map<String,Object> map) {
|
||||||
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
|
Integer pageNum = (Integer) map.get("pageNum");
|
||||||
|
Integer pageSize = (Integer) map.get("pageSize");
|
||||||
|
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
|
||||||
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
|
PageHelper.startPage(pageNum, pageSize, orderBy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.hchyun.test.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.hchyun.test.entity.AssFather;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联查询父Mapper接口
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-02-09
|
||||||
|
*/
|
||||||
|
public interface AssFatherDao {
|
||||||
|
/**
|
||||||
|
* 查询关联查询父
|
||||||
|
*
|
||||||
|
* @param id 关联查询父ID
|
||||||
|
* @return 关联查询父
|
||||||
|
*/
|
||||||
|
AssFather selectAssFatherById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询关联查询父列表
|
||||||
|
*
|
||||||
|
* @param assFather 关联查询父
|
||||||
|
* @return 关联查询父集合
|
||||||
|
*/
|
||||||
|
List<AssFather> selectAssFatherList(AssFather assFather);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增关联查询父
|
||||||
|
*
|
||||||
|
* @param assFather 关联查询父
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int insertAssFather(AssFather assFather);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改关联查询父
|
||||||
|
*
|
||||||
|
* @param assFather 关联查询父
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int updateAssFather(AssFather assFather);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除关联查询父
|
||||||
|
*
|
||||||
|
* @param id 关联查询父ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteAssFatherById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除关联查询父
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteAssFatherByIds(Long[] ids);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.hchyun.test.entity;
|
||||||
|
|
||||||
|
import com.hchyun.common.annotation.Excel;
|
||||||
|
import com.hchyun.test.entity.AssSun;
|
||||||
|
import com.hchyun.common.core.entity.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联查询父对象 test_ass_father
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-02-09
|
||||||
|
*/
|
||||||
|
@ApiModel("关联查询父")
|
||||||
|
public class AssFather extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键 */
|
||||||
|
@ApiModelProperty("主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 名称 */
|
||||||
|
@Excel(name = "名称")
|
||||||
|
@ApiModelProperty("名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 信息 */
|
||||||
|
@Excel(name = "信息")
|
||||||
|
@ApiModelProperty("信息")
|
||||||
|
private String info;
|
||||||
|
|
||||||
|
private AssSun assSun;
|
||||||
|
|
||||||
|
public void setId(Long id){
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId(){
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setName(String name){
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName(){
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public void setInfo(String info){
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInfo(){
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssSun getAssSun(){
|
||||||
|
return assSun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAssSun(AssSun assSun){
|
||||||
|
this.assSun = assSun;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("id", getId())
|
||||||
|
.append("name", getName())
|
||||||
|
.append("info", getInfo())
|
||||||
|
.append("createTime", getCreateTime())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.hchyun.test.entity;
|
||||||
|
|
||||||
|
import com.hchyun.common.annotation.Excel;
|
||||||
|
import com.hchyun.common.core.entity.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-02-09
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class AssSun extends BaseEntity{
|
||||||
|
|
||||||
|
/** 主键 */
|
||||||
|
@Excel(name = "主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 父id */
|
||||||
|
@Excel(name = "父id")
|
||||||
|
private Long fId;
|
||||||
|
|
||||||
|
/** 名称 */
|
||||||
|
@Excel(name = "名称")
|
||||||
|
private String sname;
|
||||||
|
|
||||||
|
|
||||||
|
public void setId(Long id){
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId(){
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setfId(Long fId){
|
||||||
|
this.fId = fId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getfId(){
|
||||||
|
return fId;
|
||||||
|
}
|
||||||
|
public void setSname(String sname){
|
||||||
|
this.sname = sname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSname(){
|
||||||
|
return sname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.hchyun.test.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hchyun.common.utils.ServerResult;
|
||||||
|
import com.hchyun.test.entity.AssFather;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联查询父Service接口
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-02-09
|
||||||
|
*/
|
||||||
|
public interface AssFatherService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询关联查询父
|
||||||
|
*
|
||||||
|
* @param id 关联查询父ID
|
||||||
|
* @return 关联查询父
|
||||||
|
*/
|
||||||
|
ServerResult<AssFather> selectAssFatherById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询关联查询父列表
|
||||||
|
*
|
||||||
|
* @param assFather 关联查询父
|
||||||
|
* @return 关联查询父集合
|
||||||
|
*/
|
||||||
|
ServerResult<List<AssFather>> selectAssFatherList(AssFather assFather);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增关联查询父
|
||||||
|
*
|
||||||
|
* @param assFather 关联查询父
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
ServerResult<Integer> insertAssFather(AssFather assFather);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改关联查询父
|
||||||
|
*
|
||||||
|
* @param assFather 关联查询父
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
ServerResult<Integer> updateAssFather(AssFather assFather);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除关联查询父
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的关联查询父ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
ServerResult<Integer> deleteAssFatherByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除关联查询父信息
|
||||||
|
*
|
||||||
|
* @param id 关联查询父ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
ServerResult<Integer> deleteAssFatherById(Long id);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,154 @@
|
||||||
|
package com.hchyun.test.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hchyun.common.constant.ReturnConstants;
|
||||||
|
import com.hchyun.common.utils.DateUtils;
|
||||||
|
import com.hchyun.common.utils.ServerResult;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.hchyun.test.dao.AssFatherDao;
|
||||||
|
import com.hchyun.test.entity.AssFather;
|
||||||
|
import com.hchyun.test.service.AssFatherService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联查询父Service业务层处理
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-02-09
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class AssFatherServiceImpl implements AssFatherService {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(AssFatherServiceImpl.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AssFatherDao assFatherDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询关联查询父
|
||||||
|
*
|
||||||
|
* @param id 关联查询父ID
|
||||||
|
* @return 关联查询父
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<AssFather> selectAssFatherById(Long id) {
|
||||||
|
try {
|
||||||
|
AssFather assFather = assFatherDao.selectAssFatherById(id);
|
||||||
|
if (assFather != null){
|
||||||
|
return new ServerResult<AssFather>(true,assFather);
|
||||||
|
}else {
|
||||||
|
return new ServerResult<AssFather>(false, ReturnConstants.RESULT_EMPTY);
|
||||||
|
}
|
||||||
|
}catch (RuntimeException e){
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return new ServerResult<AssFather>(false,ReturnConstants.DB_EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询关联查询父列表
|
||||||
|
*
|
||||||
|
* @param assFather 关联查询父
|
||||||
|
* @return 关联查询父
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<List<AssFather>> selectAssFatherList(AssFather assFather) {
|
||||||
|
try {
|
||||||
|
List<AssFather> assFatherList = assFatherDao.selectAssFatherList(assFather);
|
||||||
|
if (assFatherList.size()>0){
|
||||||
|
return new ServerResult<List<AssFather>>(true,assFatherList);
|
||||||
|
}else {
|
||||||
|
return new ServerResult<List<AssFather>>(false,ReturnConstants.RESULT_EMPTY);
|
||||||
|
}
|
||||||
|
}catch (RuntimeException e){
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return new ServerResult<List<AssFather>>(false,ReturnConstants.DB_EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增关联查询父
|
||||||
|
*
|
||||||
|
* @param assFather 关联查询父
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<Integer> insertAssFather(AssFather assFather) {
|
||||||
|
try {
|
||||||
|
Integer renewal = assFatherDao.insertAssFather(assFather);
|
||||||
|
if (renewal >0){
|
||||||
|
return new ServerResult<Integer>(true,renewal);
|
||||||
|
}else {
|
||||||
|
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||||
|
}
|
||||||
|
}catch (RuntimeException e){
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改关联查询父
|
||||||
|
*
|
||||||
|
* @param assFather 关联查询父
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<Integer> updateAssFather(AssFather assFather) {
|
||||||
|
try {
|
||||||
|
Integer renewal = assFatherDao.updateAssFather(assFather);
|
||||||
|
if (renewal >0){
|
||||||
|
return new ServerResult<Integer>(true,renewal);
|
||||||
|
}else {
|
||||||
|
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||||
|
}
|
||||||
|
}catch (RuntimeException e){
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除关联查询父
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的关联查询父ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<Integer> deleteAssFatherByIds(Long[] ids) {
|
||||||
|
try {
|
||||||
|
Integer renewal = assFatherDao.deleteAssFatherByIds(ids);
|
||||||
|
if (renewal >0){
|
||||||
|
return new ServerResult<Integer>(true,renewal);
|
||||||
|
}else {
|
||||||
|
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||||
|
}
|
||||||
|
}catch (RuntimeException e){
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除关联查询父信息
|
||||||
|
*
|
||||||
|
* @param id 关联查询父ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<Integer> deleteAssFatherById(Long id) {
|
||||||
|
try {
|
||||||
|
Integer renewal = assFatherDao.deleteAssFatherById(id);
|
||||||
|
if (renewal >0){
|
||||||
|
return new ServerResult<Integer>(true,renewal);
|
||||||
|
}else {
|
||||||
|
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||||
|
}
|
||||||
|
}catch (RuntimeException e){
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
package com.hchyun.test.test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author 18209
|
||||||
|
* @Date 2021/2/9 20:23
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
public class IneniudBuid {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private Double age;
|
||||||
|
|
||||||
|
private String addess;
|
||||||
|
|
||||||
|
// public IneniudBuid(Integer id, String name, Double age, String addess) {
|
||||||
|
// this.id = id;
|
||||||
|
// this.name = name;
|
||||||
|
// this.age = age;
|
||||||
|
// this.addess = addess;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getAge() {
|
||||||
|
return age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAge(Double age) {
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddess() {
|
||||||
|
return addess;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddess(String addess) {
|
||||||
|
this.addess = addess;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IneniudBuid() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "IneniudBuid{" +
|
||||||
|
"id=" + id +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", age=" + age +
|
||||||
|
", addess='" + addess + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
package com.hchyun.test.test;
|
||||||
|
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
|
||||||
|
import java.beans.BeanInfo;
|
||||||
|
import java.beans.Introspector;
|
||||||
|
import java.beans.PropertyDescriptor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author 18209
|
||||||
|
* @Date 2021/2/9 20:22
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
public class Maptest {
|
||||||
|
public static <T> void setObject(T t, Map map){
|
||||||
|
Class cl = t.getClass();
|
||||||
|
map.forEach((k,v)->{
|
||||||
|
try {
|
||||||
|
String name = k.toString().substring(0,1).toUpperCase() + k.toString().substring(1);
|
||||||
|
Method mo = cl.getMethod("get"+name);
|
||||||
|
//类型判断可扩展
|
||||||
|
if(mo.getReturnType().getName().equals(Integer.class.getName())){
|
||||||
|
mo = cl.getMethod("set"+name,Integer.class);
|
||||||
|
mo.invoke(t,v);
|
||||||
|
}else if(mo.getReturnType().getName().equals(String.class.getName())){
|
||||||
|
mo = cl.getMethod("set"+name,String.class);
|
||||||
|
mo.invoke(t,v);
|
||||||
|
}else if(mo.getReturnType().getName().equals(Long.class.getName())){
|
||||||
|
mo = cl.getMethod("set"+name,Long.class);
|
||||||
|
mo.invoke(t,v);
|
||||||
|
}else if(mo.getReturnType().getName().equals(Double.class.getName())){
|
||||||
|
mo = cl.getMethod("set"+name,Double.class);
|
||||||
|
mo.invoke(t,v);
|
||||||
|
}else if(mo.getReturnType().getName().equals(Date.class.getName())){
|
||||||
|
mo = cl.getMethod("set"+name, Date.class);
|
||||||
|
mo.invoke(t,v);
|
||||||
|
}else if(mo.getReturnType().getName().equals(Float.class.getName())){
|
||||||
|
mo = cl.getMethod("set"+name,Float.class);
|
||||||
|
mo.invoke(t,v);
|
||||||
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
System.out.println("当前字段属性:"+k+",不在类中");
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object mapToObject(Map<String, Object> map, Class<?> beanClass) throws Exception {
|
||||||
|
if (map == null)
|
||||||
|
return null;
|
||||||
|
Object obj = beanClass.newInstance();
|
||||||
|
BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
|
||||||
|
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
|
||||||
|
for (PropertyDescriptor property : propertyDescriptors) {
|
||||||
|
Method setter = property.getWriteMethod();
|
||||||
|
if (setter != null) {
|
||||||
|
setter.invoke(obj, map.get(property.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
private static<T> void populate1(Map<String, String> map, T t) throws Exception {
|
||||||
|
|
||||||
|
//拿到 BeanInfo
|
||||||
|
BeanInfo beanInfo = Introspector.getBeanInfo(t.getClass());
|
||||||
|
|
||||||
|
//通过 beaninfo 获取所有的描述器
|
||||||
|
PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
|
||||||
|
|
||||||
|
for (PropertyDescriptor pd : pds) {
|
||||||
|
|
||||||
|
//获取属性的名字
|
||||||
|
String name = pd.getName();
|
||||||
|
|
||||||
|
//判断是否有这个属性
|
||||||
|
if (map.containsKey(name)){
|
||||||
|
//获取属性的 写的方法
|
||||||
|
Method wMethod = pd.getWriteMethod();
|
||||||
|
if (pd.getPropertyType() == int.class){
|
||||||
|
wMethod.invoke(t,Integer.valueOf(map.get(name)));
|
||||||
|
}else if (pd.getPropertyType() == double.class){
|
||||||
|
wMethod.invoke(t,Double.valueOf(map.get(name)));
|
||||||
|
}else {
|
||||||
|
wMethod.invoke(t,map.get(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void main(String[] age) throws Exception {
|
||||||
|
IneniudBuid buid = new IneniudBuid();
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("id",123);
|
||||||
|
map.put("name","十大法d师");
|
||||||
|
map.put("begnd","ssdfa");
|
||||||
|
map.put("age",3.32);
|
||||||
|
map.put("addess","为东风qw股份");
|
||||||
|
map.put("begnddd","ssdfa");
|
||||||
|
// setObject(buid,map);
|
||||||
|
populate1(map,buid);
|
||||||
|
System.out.println(buid.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
<?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.hchyun.test.dao.AssFatherDao">
|
||||||
|
|
||||||
|
<resultMap type="com.hchyun.test.entity.AssFather" id="AssFatherResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="name" column="name" />
|
||||||
|
<result property="info" column="info" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
</resultMap>
|
||||||
|
<resultMap id="AssFatherAssSunResult" type="com.hchyun.test.entity.AssFather" extends="AssFatherResult">
|
||||||
|
<collection property="assSun" notNullColumn="id" javaType="com.hchyun.test.entity.AssSun" resultMap="AssSunResult" />
|
||||||
|
</resultMap>
|
||||||
|
<resultMap type="com.hchyun.test.entity.AssSun" id="AssSunResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="fId" column="f_id" />
|
||||||
|
<result property="sname" column="sname" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectAssFatherVo">
|
||||||
|
select id, name, info, create_time from test_ass_father
|
||||||
|
</sql>
|
||||||
|
<select id="selectAssFatherList" parameterType="AssFather" resultMap="AssFatherAssSunResult">
|
||||||
|
select taf.id, taf.name, taf.info, taf.create_time,
|
||||||
|
tas.id, tas.f_id, tas.sname, tas.create_time
|
||||||
|
from test_ass_father taf
|
||||||
|
left join test_ass_sun tas on tas.f_id = taf.id
|
||||||
|
<where>
|
||||||
|
<if test="name != null and name != ''"> and taf.name like concat('%', #{name}, '%')</if>
|
||||||
|
<if test="info != null and info != ''"> and taf.info = #{info}</if>
|
||||||
|
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and taf.create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
||||||
|
<if test="assSun.sname != null and assSun.sname != ''"> and tas.sname like concat('%', #{assSun.sname}, '%')</if>
|
||||||
|
<if test="params.assbeginCreateTime != null and params.assbeginCreateTime != '' and params.assendCreateTime != null and params.assendCreateTime != ''"> and tas.create_time between #{params.assbeginCreateTime} and #{params.assendCreateTime}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAssFatherById" parameterType="Long" resultMap="AssFatherResult">
|
||||||
|
select taf.id, taf.name, taf.info, taf.create_time,
|
||||||
|
tas.id, tas.f_id, tas.sname, tas.create_time
|
||||||
|
from test_ass_father taf
|
||||||
|
left join test_ass_sun tas on tas.f_id = taf.id
|
||||||
|
where taf.id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertAssFather" parameterType="AssFather">
|
||||||
|
insert into test_ass_father
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">id,</if>
|
||||||
|
<if test="name != null and name != ''">name,</if>
|
||||||
|
<if test="info != null and info != ''">info,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">#{id},</if>
|
||||||
|
<if test="name != null and name != ''">#{name},</if>
|
||||||
|
<if test="info != null and info != ''">#{info},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateAssFather" parameterType="AssFather">
|
||||||
|
update test_ass_father
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="name != null and name != ''">name = #{name},</if>
|
||||||
|
<if test="info != null and info != ''">info = #{info},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteAssFatherById" parameterType="Long">
|
||||||
|
delete from test_ass_father where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteAssFatherByIds" parameterType="String">
|
||||||
|
delete from test_ass_father where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue