diff --git a/ruoyi-ui/src/views/system/dept/index.vue b/ruoyi-ui/src/views/system/dept/index.vue index a8c065ec1..a652aa928 100644 --- a/ruoyi-ui/src/views/system/dept/index.vue +++ b/ruoyi-ui/src/views/system/dept/index.vue @@ -1,319 +1,339 @@ -<template> - <div class="app-container"> - <el-form :inline="true"> - <el-form-item label="部门名称"> - <el-input - v-model="queryParams.deptName" - placeholder="请输入部门名称" - clearable - size="small" - @keyup.enter.native="handleQuery" - /> - </el-form-item> - <el-form-item label="状态"> - <el-select v-model="queryParams.status" placeholder="部门状态" clearable size="small"> - <el-option - v-for="dict in statusOptions" - :key="dict.dictValue" - :label="dict.dictLabel" - :value="dict.dictValue" - /> - </el-select> - </el-form-item> - <el-form-item> - <el-button - class="filter-item" - type="primary" - icon="el-icon-search" - size="mini" - @click="handleQuery" - >搜索</el-button> - <el-button - class="filter-item" - type="primary" - icon="el-icon-plus" - size="mini" - @click="handleAdd" - v-hasPermi="['system:dept:add']" - >新增</el-button> - </el-form-item> - </el-form> - - <el-table - v-loading="loading" - :data="deptList" - row-key="deptId" - default-expand-all - :tree-props="{children: 'children', hasChildren: 'hasChildren'}" - > - <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column> - <el-table-column prop="orderNum" label="排序" width="200"></el-table-column> - <el-table-column prop="status" label="状态" :formatter="statusFormat" width="100"></el-table-column> - <el-table-column label="创建时间" align="center" prop="createTime" width="200"> - <template slot-scope="scope"> - <span>{{ parseTime(scope.row.createTime) }}</span> - </template> - </el-table-column> - <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="['system:dept:edit']" - >修改</el-button> - <el-button - size="mini" - type="text" - icon="el-icon-plus" - @click="handleAdd(scope.row)" - v-hasPermi="['system:dept:add']" - >新增</el-button> - <el-button - v-if="scope.row.parentId != 0" - size="mini" - type="text" - icon="el-icon-delete" - @click="handleDelete(scope.row)" - v-hasPermi="['system:dept:remove']" - >删除</el-button> - </template> - </el-table-column> - </el-table> - - <!-- 添加或修改部门对话框 --> - <el-dialog :title="title" :visible.sync="open" width="600px"> - <el-form ref="form" :model="form" :rules="rules" label-width="80px"> - <el-row> - <el-col :span="24" v-if="form.parentId !== 0"> - <el-form-item label="上级部门" prop="parentId"> - <treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级部门" /> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="部门名称" prop="deptName"> - <el-input v-model="form.deptName" placeholder="请输入部门名称" /> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="显示排序" prop="orderNum"> - <el-input-number v-model="form.orderNum" controls-position="right" :min="0" /> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="负责人" prop="leader"> - <el-input v-model="form.leader" placeholder="请输入负责人" maxlength="20" /> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="联系电话" prop="phone"> - <el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" /> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="邮箱" prop="email"> - <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" /> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="部门状态"> - <el-radio-group v-model="form.status"> - <el-radio - v-for="dict in statusOptions" - :key="dict.dictValue" - :label="dict.dictValue" - >{{dict.dictLabel}}</el-radio> - </el-radio-group> - </el-form-item> - </el-col> - </el-row> - </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 { listDept, getDept, delDept, addDept, updateDept } from "@/api/system/dept"; -import Treeselect from "@riophae/vue-treeselect"; -import "@riophae/vue-treeselect/dist/vue-treeselect.css"; - -export default { - name: "Dept", - components: { Treeselect }, - data() { - return { - // 遮罩层 - loading: true, - // 表格树数据 - deptList: [], - // 部门树选项 - deptOptions: [], - // 弹出层标题 - title: "", - // 是否显示弹出层 - open: false, - // 状态数据字典 - statusOptions: [], - // 查询参数 - queryParams: { - deptName: undefined, - status: undefined - }, - // 表单参数 - form: {}, - // 表单校验 - rules: { - parentId: [ - { required: true, message: "上级部门不能为空", trigger: "blur" } - ], - deptName: [ - { required: true, message: "部门名称不能为空", trigger: "blur" } - ], - orderNum: [ - { required: true, message: "菜单顺序不能为空", trigger: "blur" } - ], - email: [ - { - type: "email", - message: "'请输入正确的邮箱地址", - trigger: ["blur", "change"] - } - ], - phone: [ - { - pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, - message: "请输入正确的手机号码", - trigger: "blur" - } - ] - } - }; - }, - created() { - this.getList(); - this.getDicts("sys_normal_disable").then(response => { - this.statusOptions = response.data; - }); - }, - methods: { - /** 查询部门列表 */ - getList() { - this.loading = true; - listDept(this.queryParams).then(response => { - this.deptList = this.handleTree(response.data, "deptId"); - this.loading = false; - }); - }, - /** 转换部门数据结构 */ - normalizer(node) { - if (node.children && !node.children.length) { - delete node.children; - } - return { - id: node.deptId, - label: node.deptName, - children: node.children - }; - }, - /** 查询部门下拉树结构 */ - getTreeselect() { - listDept().then(response => { - this.deptOptions = this.handleTree(response.data, "deptId"); - }); - }, - // 字典状态字典翻译 - statusFormat(row, column) { - return this.selectDictLabel(this.statusOptions, row.status); - }, - // 取消按钮 - cancel() { - this.open = false; - this.reset(); - }, - // 表单重置 - reset() { - this.form = { - deptId: undefined, - parentId: undefined, - deptName: undefined, - orderNum: undefined, - leader: undefined, - phone: undefined, - email: undefined, - status: "0" - }; - this.resetForm("form"); - }, - /** 搜索按钮操作 */ - handleQuery() { - this.getList(); - }, - /** 新增按钮操作 */ - handleAdd(row) { - this.reset(); - this.getTreeselect(); - if (row != undefined) { - this.form.parentId = row.deptId; - } - this.open = true; - this.title = "添加部门"; - }, - /** 修改按钮操作 */ - handleUpdate(row) { - this.reset(); - this.getTreeselect(); - getDept(row.deptId).then(response => { - this.form = response.data; - this.open = true; - this.title = "修改部门"; - }); - }, - /** 提交按钮 */ - submitForm: function() { - this.$refs["form"].validate(valid => { - if (valid) { - if (this.form.deptId != undefined) { - updateDept(this.form).then(response => { - if (response.code === 200) { - this.msgSuccess("修改成功"); - this.open = false; - this.getList(); - } else { - this.msgError(response.msg); - } - }); - } else { - addDept(this.form).then(response => { - if (response.code === 200) { - this.msgSuccess("新增成功"); - this.open = false; - this.getList(); - } else { - this.msgError(response.msg); - } - }); - } - } - }); - }, - /** 删除按钮操作 */ - handleDelete(row) { - this.$confirm('是否确认删除名称为"' + row.deptName + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return delDept(row.deptId); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(function() {}); - } - } -}; +<template> + <div class="app-container"> + <el-form :inline="true"> + <el-form-item label="部门名称"> + <el-input + v-model="queryParams.deptName" + placeholder="请输入部门名称" + clearable + size="small" + @keyup.enter.native="handleQuery" + /> + </el-form-item> + <el-form-item label="状态"> + <el-select v-model="queryParams.status" placeholder="部门状态" clearable size="small"> + <el-option + v-for="dict in statusOptions" + :key="dict.dictValue" + :label="dict.dictLabel" + :value="dict.dictValue" + /> + </el-select> + </el-form-item> + <el-form-item> + <el-button + class="filter-item" + type="primary" + icon="el-icon-search" + size="mini" + @click="handleQuery" + >搜索</el-button> + <el-button + class="filter-item" + type="primary" + icon="el-icon-plus" + size="mini" + @click="handleAdd" + v-hasPermi="['system:dept:add']" + >新增</el-button> + </el-form-item> + </el-form> + + <el-table + v-loading="loading" + :data="deptList" + row-key="deptId" + default-expand-all + :tree-props="{children: 'children', hasChildren: 'hasChildren'}" + > + <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column> + <el-table-column prop="orderNum" label="排序" width="200"></el-table-column> + <el-table-column prop="status" label="状态" :formatter="statusFormat" width="100"></el-table-column> + <el-table-column label="创建时间" align="center" prop="createTime" width="200"> + <template slot-scope="scope"> + <span>{{ parseTime(scope.row.createTime) }}</span> + </template> + </el-table-column> + <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="['system:dept:edit']" + >修改</el-button> + <el-button + size="mini" + type="text" + icon="el-icon-plus" + @click="handleAdd(scope.row)" + v-hasPermi="['system:dept:add']" + >新增</el-button> + <el-button + v-if="scope.row.parentId != 0" + size="mini" + type="text" + icon="el-icon-delete" + @click="handleDelete(scope.row)" + v-hasPermi="['system:dept:remove']" + >删除</el-button> + </template> + </el-table-column> + </el-table> + + <!-- 添加或修改部门对话框 --> + <el-dialog :title="title" :visible.sync="open" width="600px"> + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> + <el-row> + <el-col :span="24" v-if="form.parentId !== 0"> + <el-form-item label="上级部门" prop="parentId"> + <treeselect + v-model="form.parentId" + :options="deptOptions" + :normalizer="normalizer" + placeholder="选择上级部门" + /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="部门名称" prop="deptName"> + <el-input v-model="form.deptName" placeholder="请输入部门名称" /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="显示排序" prop="orderNum"> + <el-input-number v-model="form.orderNum" controls-position="right" :min="0" /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="负责人" prop="leader"> + <el-input v-model="form.leader" placeholder="请输入负责人" maxlength="20" /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="联系电话" prop="phone"> + <el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="邮箱" prop="email"> + <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="部门状态"> + <el-radio-group v-model="form.status"> + <el-radio + v-for="dict in statusOptions" + :key="dict.dictValue" + :label="dict.dictValue" + >{{dict.dictLabel}}</el-radio> + </el-radio-group> + </el-form-item> + </el-col> + </el-row> + </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 { + listDept, + getDept, + delDept, + addDept, + updateDept +} from "@/api/system/dept"; +import Treeselect from "@riophae/vue-treeselect"; +import "@riophae/vue-treeselect/dist/vue-treeselect.css"; + +export default { + name: "Dept", + components: { Treeselect }, + data() { + return { + // 遮罩层 + loading: true, + // 表格树数据 + deptList: [], + // 部门树选项 + deptOptions: [], + // 弹出层标题 + title: "", + // 是否显示弹出层 + open: false, + // 状态数据字典 + statusOptions: [], + // 查询参数 + queryParams: { + deptName: undefined, + status: undefined, + schoolId: undefined + }, + // 表单参数 + form: {}, + // 表单校验 + rules: { + parentId: [ + { required: true, message: "上级部门不能为空", trigger: "blur" } + ], + deptName: [ + { required: true, message: "部门名称不能为空", trigger: "blur" } + ], + orderNum: [ + { required: true, message: "菜单顺序不能为空", trigger: "blur" } + ], + email: [ + { + type: "email", + message: "'请输入正确的邮箱地址", + trigger: ["blur", "change"] + } + ], + phone: [ + { + pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, + message: "请输入正确的手机号码", + trigger: "blur" + } + ] + } + }; + }, + created() { + this.getList(); + this.getDicts("sys_normal_disable").then(response => { + this.statusOptions = response.data; + }); + }, + methods: { + /** 查询部门列表 */ + getList() { + this.loading = true; + listDept(this.queryParams).then(response => { + this.deptList = this.handleTree(response.data, "deptId"); + this.loading = false; + }); + }, + /** 转换部门数据结构 */ + normalizer(node) { + if (node.children && !node.children.length) { + delete node.children; + } + return { + id: node.deptId, + label: node.deptName, + children: node.children + }; + }, + /** 查询部门下拉树结构 */ + getTreeselect() { + listDept().then(response => { + this.deptOptions = this.handleTree(response.data, "deptId"); + }); + }, + // 字典状态字典翻译 + statusFormat(row, column) { + return this.selectDictLabel(this.statusOptions, row.status); + }, + // 取消按钮 + cancel() { + this.open = false; + this.reset(); + }, + // 表单重置 + reset() { + this.form = { + deptId: undefined, + parentId: undefined, + deptName: undefined, + orderNum: undefined, + leader: undefined, + phone: undefined, + email: undefined, + status: "0", + schoolId: undefined + }; + this.resetForm("form"); + }, + /** 搜索按钮操作 */ + handleQuery() { + this.getList(); + }, + /** 新增按钮操作 */ + handleAdd(row) { + this.reset(); + this.getTreeselect(); + if (row != undefined) { + this.form.parentId = row.deptId; + } + this.open = true; + this.title = "添加部门"; + }, + /** 修改按钮操作 */ + handleUpdate(row) { + this.reset(); + this.getTreeselect(); + getDept(row.deptId).then(response => { + this.form = response.data; + this.open = true; + this.title = "修改部门"; + }); + }, + /** 提交按钮 */ + submitForm: function() { + this.$refs["form"].validate(valid => { + if (valid) { + if (this.form.deptId != undefined) { + updateDept(this.form).then(response => { + if (response.code === 200) { + this.msgSuccess("修改成功"); + this.open = false; + this.getList(); + } else { + this.msgError(response.msg); + } + }); + } else { + addDept(this.form).then(response => { + if (response.code === 200) { + this.msgSuccess("新增成功"); + this.open = false; + this.getList(); + } else { + this.msgError(response.msg); + } + }); + } + } + }); + }, + /** 删除按钮操作 */ + handleDelete(row) { + this.$confirm( + '是否确认删除名称为"' + row.deptName + '"的数据项?', + "警告", + { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + } + ) + .then(function() { + return delDept(row.deptId); + }) + .then(() => { + this.getList(); + this.msgSuccess("删除成功"); + }) + .catch(function() {}); + } + } +}; </script> \ No newline at end of file diff --git a/ruoyi-ui/src/views/system/school/index.vue b/ruoyi-ui/src/views/system/school/index.vue index af8a88b06..b8d65c147 100644 --- a/ruoyi-ui/src/views/system/school/index.vue +++ b/ruoyi-ui/src/views/system/school/index.vue @@ -206,7 +206,7 @@ </el-radio-group> </el-form-item> <el-form-item label="幼儿园规模" prop="scale"> - <el-select v-model="form.scale" placeholder="请选择"> + <el-select v-model="form.scale"> <el-option v-for="dict in scaleOptions" :key="dict.dictValue" @@ -334,6 +334,7 @@ export default { queryParams: { pageNum: 1, pageSize: 10, + xxdm: undefined, schoolName: undefined, nameShort: undefined, type: undefined, @@ -428,6 +429,7 @@ export default { reset() { this.form = { id: undefined, + xxdm: undefined, schoolName: undefined, nameShort: undefined, type: "1", diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/controller/BaseController.java b/ruoyi/src/main/java/com/ruoyi/framework/web/controller/BaseController.java index ccc60a37d..69c186f5f 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/web/controller/BaseController.java +++ b/ruoyi/src/main/java/com/ruoyi/framework/web/controller/BaseController.java @@ -1,85 +1,94 @@ -package com.ruoyi.framework.web.controller; - -import java.beans.PropertyEditorSupport; -import java.util.Date; -import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.InitBinder; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; -import com.ruoyi.common.constant.HttpStatus; -import com.ruoyi.common.utils.DateUtils; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.sql.SqlUtil; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.framework.web.page.PageDomain; -import com.ruoyi.framework.web.page.TableDataInfo; -import com.ruoyi.framework.web.page.TableSupport; - -/** - * web层通用数据处理 - * - * @author ruoyi - */ -public class BaseController -{ - protected final Logger logger = LoggerFactory.getLogger(BaseController.class); - - /** - * 将前台传递过来的日期格式的字符串,自动转化为Date类型 - */ - @InitBinder - public void initBinder(WebDataBinder binder) - { - // Date 类型转换 - binder.registerCustomEditor(Date.class, new PropertyEditorSupport() - { - @Override - public void setAsText(String text) - { - setValue(DateUtils.parseDate(text)); - } - }); - } - - /** - * 设置请求分页数据 - */ - protected void startPage() - { - PageDomain pageDomain = TableSupport.buildPageRequest(); - Integer pageNum = pageDomain.getPageNum(); - Integer pageSize = pageDomain.getPageSize(); - if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) - { - String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); - PageHelper.startPage(pageNum, pageSize, orderBy); - } - } - - /** - * 响应请求分页数据 - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - protected TableDataInfo getDataTable(List<?> list) - { - TableDataInfo rspData = new TableDataInfo(); - rspData.setCode(HttpStatus.SUCCESS); - rspData.setRows(list); - rspData.setTotal(new PageInfo(list).getTotal()); - return rspData; - } - - /** - * 响应返回结果 - * - * @param rows 影响行数 - * @return 操作结果 - */ - protected AjaxResult toAjax(int rows) - { - return rows > 0 ? AjaxResult.success() : AjaxResult.error(); - } -} +package com.ruoyi.framework.web.controller; + +import java.beans.PropertyEditorSupport; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +import com.ruoyi.project.system.domain.BySchool; +import com.ruoyi.project.system.domain.SysDept; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.InitBinder; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.sql.SqlUtil; +import com.ruoyi.framework.web.domain.AjaxResult; +import com.ruoyi.framework.web.page.PageDomain; +import com.ruoyi.framework.web.page.TableDataInfo; +import com.ruoyi.framework.web.page.TableSupport; + +/** + * web层通用数据处理 + * + * @author ruoyi + */ +public class BaseController +{ + protected final Logger logger = LoggerFactory.getLogger(BaseController.class); + + public static String getUUID32() + { + return UUID.randomUUID().toString().replace("-", "").toLowerCase(); + } + + /** + * 将前台传递过来的日期格式的字符串,自动转化为Date类型 + */ + @InitBinder + public void initBinder(WebDataBinder binder) + { + // Date 类型转换 + binder.registerCustomEditor(Date.class, new PropertyEditorSupport() + { + @Override + public void setAsText(String text) + { + setValue(DateUtils.parseDate(text)); + } + }); + } + + /** + * 设置请求分页数据 + */ + protected void startPage() + { + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) + { + String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); + PageHelper.startPage(pageNum, pageSize, orderBy); + } + } + + /** + * 响应请求分页数据 + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected TableDataInfo getDataTable(List<?> list) + { + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.SUCCESS); + rspData.setRows(list); + rspData.setTotal(new PageInfo(list).getTotal()); + return rspData; + } + + /** + * 响应返回结果 + * + * @param rows 影响行数 + * @return 操作结果 + */ + protected AjaxResult toAjax(int rows) + { + return rows > 0 ? AjaxResult.success() : AjaxResult.error(); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/BySchoolController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/BySchoolController.java index 13d6413f4..6551b3c2b 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/BySchoolController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/BySchoolController.java @@ -4,6 +4,7 @@ import java.util.Date; import java.util.List; import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.project.system.service.ISysDeptService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -22,6 +23,7 @@ import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.framework.web.page.TableDataInfo; +import com.ruoyi.project.system.domain.SysDept; /** * 幼儿园机构Controller @@ -36,6 +38,11 @@ public class BySchoolController extends BaseController @Autowired private IBySchoolService bySchoolService; + @Autowired + private ISysDeptService deptService; + + + /** * 查询幼儿园机构列表 */ @@ -79,9 +86,27 @@ public class BySchoolController extends BaseController @PostMapping public AjaxResult add(@RequestBody BySchool bySchool) { + String uuid = getUUID32(); + + //将UUID赋值给xxdm + bySchool.setXxdm(uuid); bySchool.setCreateUser(SecurityUtils.getLoginUser().getUser().getUserId()); bySchool.setApprovalUser(SecurityUtils.getLoginUser().getUser().getUserId()); bySchool.setCreateTime(new Date()); + //bySchoolService.insertBySchool(bySchool); + + SysDept dept = new SysDept(); + dept.setSchoolId(bySchool.getXxdm()); + dept.setCreateBy(SecurityUtils.getUsername()); + //dept.setDeptId(bySchool.getDept().getDeptId()); + dept.setParentId(200L); + dept.setAncestors("0,100,200"); + dept.setDeptName(bySchool.getSchoolName()); + //dept.setPhone(bySchool.getTel()); + //dept.setOrderNum(String.valueOf(bySchool.getId())); + dept.setLeader(SecurityUtils.getUsername()); + deptService.insertDept(dept); + return toAjax(bySchoolService.insertBySchool(bySchool)); } diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java index 686748a50..6ddd2c40e 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java @@ -1,134 +1,137 @@ -package com.ruoyi.project.system.controller; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.project.system.domain.SysDept; -import com.ruoyi.project.system.service.ISysDeptService; - -/** - * 部门信息 - * - * @author ruoyi - */ -@RestController -@RequestMapping("/system/dept") -public class SysDeptController extends BaseController -{ - @Autowired - private ISysDeptService deptService; - - /** - * 获取部门列表 - */ - @PreAuthorize("@ss.hasPermi('system:dept:list')") - @GetMapping("/list") - public AjaxResult list(SysDept dept) - { - List<SysDept> depts = deptService.selectDeptList(dept); - return AjaxResult.success(depts); - } - - /** - * 根据部门编号获取详细信息 - */ - @PreAuthorize("@ss.hasPermi('system:dept:query')") - @GetMapping(value = "/{deptId}") - public AjaxResult getInfo(@PathVariable Long deptId) - { - return AjaxResult.success(deptService.selectDeptById(deptId)); - } - - /** - * 获取部门下拉树列表 - */ - @GetMapping("/treeselect") - public AjaxResult treeselect(SysDept dept) - { - List<SysDept> depts = deptService.selectDeptList(dept); - return AjaxResult.success(deptService.buildDeptTreeSelect(depts)); - } - - /** - * 加载对应角色部门列表树 - */ - @GetMapping(value = "/roleDeptTreeselect/{roleId}") - public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) - { - List<SysDept> depts = deptService.selectDeptList(new SysDept()); - AjaxResult ajax = AjaxResult.success(); - ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); - ajax.put("depts", deptService.buildDeptTreeSelect(depts)); - return ajax; - } - - /** - * 新增部门 - */ - @PreAuthorize("@ss.hasPermi('system:dept:add')") - @Log(title = "部门管理", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@Validated @RequestBody SysDept dept) - { - if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) - { - return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); - } - dept.setCreateBy(SecurityUtils.getUsername()); - return toAjax(deptService.insertDept(dept)); - } - - /** - * 修改部门 - */ - @PreAuthorize("@ss.hasPermi('system:dept:edit')") - @Log(title = "部门管理", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@Validated @RequestBody SysDept dept) - { - if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) - { - return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); - } - else if (dept.getParentId().equals(dept.getDeptId())) - { - return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); - } - dept.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(deptService.updateDept(dept)); - } - - /** - * 删除部门 - */ - @PreAuthorize("@ss.hasPermi('system:dept:remove')") - @Log(title = "部门管理", businessType = BusinessType.DELETE) - @DeleteMapping("/{deptId}") - public AjaxResult remove(@PathVariable Long deptId) - { - if (deptService.hasChildByDeptId(deptId)) - { - return AjaxResult.error("存在下级部门,不允许删除"); - } - if (deptService.checkDeptExistUser(deptId)) - { - return AjaxResult.error("部门存在用户,不允许删除"); - } - return toAjax(deptService.deleteDeptById(deptId)); - } -} +package com.ruoyi.project.system.controller; + +import java.util.List; + +import com.ruoyi.project.system.service.IBySchoolService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.framework.aspectj.lang.annotation.Log; +import com.ruoyi.framework.aspectj.lang.enums.BusinessType; +import com.ruoyi.framework.web.controller.BaseController; +import com.ruoyi.framework.web.domain.AjaxResult; +import com.ruoyi.project.system.domain.SysDept; +import com.ruoyi.project.system.service.ISysDeptService; + +/** + * 部门信息 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/system/dept") +public class SysDeptController extends BaseController +{ + @Autowired + private ISysDeptService deptService; + + + /** + * 获取部门列表 + */ + @PreAuthorize("@ss.hasPermi('system:dept:list')") + @GetMapping("/list") + public AjaxResult list(SysDept dept) + { + List<SysDept> depts = deptService.selectDeptList(dept); + return AjaxResult.success(depts); + } + + /** + * 根据部门编号获取详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:dept:query')") + @GetMapping(value = "/{deptId}") + public AjaxResult getInfo(@PathVariable Long deptId) + { + return AjaxResult.success(deptService.selectDeptById(deptId)); + } + + /** + * 获取部门下拉树列表 + */ + @GetMapping("/treeselect") + public AjaxResult treeselect(SysDept dept) + { + List<SysDept> depts = deptService.selectDeptList(dept); + return AjaxResult.success(deptService.buildDeptTreeSelect(depts)); + } + + /** + * 加载对应角色部门列表树 + */ + @GetMapping(value = "/roleDeptTreeselect/{roleId}") + public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) + { + List<SysDept> depts = deptService.selectDeptList(new SysDept()); + AjaxResult ajax = AjaxResult.success(); + ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); + ajax.put("depts", deptService.buildDeptTreeSelect(depts)); + return ajax; + } + + /** + * 新增部门 + */ + @PreAuthorize("@ss.hasPermi('system:dept:add')") + @Log(title = "部门管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysDept dept) + { + if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) + { + return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); + } + dept.setCreateBy(SecurityUtils.getUsername()); + return toAjax(deptService.insertDept(dept)); + } + + /** + * 修改部门 + */ + @PreAuthorize("@ss.hasPermi('system:dept:edit')") + @Log(title = "部门管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysDept dept) + { + if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) + { + return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); + } + else if (dept.getParentId().equals(dept.getDeptId())) + { + return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); + } + dept.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(deptService.updateDept(dept)); + } + + /** + * 删除部门 + */ + @PreAuthorize("@ss.hasPermi('system:dept:remove')") + @Log(title = "部门管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{deptId}") + public AjaxResult remove(@PathVariable Long deptId) + { + if (deptService.hasChildByDeptId(deptId)) + { + return AjaxResult.error("存在下级部门,不允许删除"); + } + if (deptService.checkDeptExistUser(deptId)) + { + return AjaxResult.error("部门存在用户,不允许删除"); + } + return toAjax(deptService.deleteDeptById(deptId)); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/BySchool.java b/ruoyi/src/main/java/com/ruoyi/project/system/domain/BySchool.java index ce0409af3..1691c72b9 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/BySchool.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/domain/BySchool.java @@ -19,6 +19,9 @@ public class BySchool extends BaseEntity /** 幼儿园ID */ private Long id; +// 学校代码(与dept相关联) + private String xxdm; + /** 机构名称 */ @Excel(name = "机构名称") private String schoolName; @@ -131,6 +134,17 @@ public class BySchool extends BaseEntity @Excel(name = "当前学期") private String dqxq; + //部门 + private SysDept dept; + + public SysDept getDept() { + return dept; + } + + public void setDept(SysDept dept) { + this.dept = dept; + } + public void setId(Long id) { this.id = id; @@ -393,10 +407,21 @@ public class BySchool extends BaseEntity return dqxq; } + public String getXxdm() { + return xxdm; + } + + public void setXxdm(String xxdm) { + this.xxdm = xxdm; + } + + + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) + .append("xxdm",getXxdm()) .append("schoolName", getSchoolName()) .append("nameShort", getNameShort()) .append("type", getType()) @@ -427,6 +452,9 @@ public class BySchool extends BaseEntity .append("openDeadline", getOpenDeadline()) .append("dqxn", getDqxn()) .append("dqxq", getDqxq()) + .append("dept", getDept()) .toString(); } + + } diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDept.java b/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDept.java index ba12f1549..0880f1361 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDept.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDept.java @@ -1,202 +1,216 @@ -package com.ruoyi.project.system.domain; - -import java.util.ArrayList; -import java.util.List; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.framework.web.domain.BaseEntity; - -/** - * 部门表 sys_dept - * - * @author ruoyi - */ -public class SysDept extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 部门ID */ - private Long deptId; - - /** 父部门ID */ - private Long parentId; - - /** 祖级列表 */ - private String ancestors; - - /** 部门名称 */ - private String deptName; - - /** 显示顺序 */ - private String orderNum; - - /** 负责人 */ - private String leader; - - /** 联系电话 */ - private String phone; - - /** 邮箱 */ - private String email; - - /** 部门状态:0正常,1停用 */ - private String status; - - /** 删除标志(0代表存在 2代表删除) */ - private String delFlag; - - /** 父部门名称 */ - private String parentName; - - /** 子部门 */ - private List<SysDept> children = new ArrayList<SysDept>(); - - public Long getDeptId() - { - return deptId; - } - - public void setDeptId(Long deptId) - { - this.deptId = deptId; - } - - public Long getParentId() - { - return parentId; - } - - public void setParentId(Long parentId) - { - this.parentId = parentId; - } - - public String getAncestors() - { - return ancestors; - } - - public void setAncestors(String ancestors) - { - this.ancestors = ancestors; - } - - @NotBlank(message = "部门名称不能为空") - @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符") - public String getDeptName() - { - return deptName; - } - - public void setDeptName(String deptName) - { - this.deptName = deptName; - } - - @NotBlank(message = "显示顺序不能为空") - public String getOrderNum() - { - return orderNum; - } - - public void setOrderNum(String orderNum) - { - this.orderNum = orderNum; - } - - public String getLeader() - { - return leader; - } - - public void setLeader(String leader) - { - this.leader = leader; - } - - @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符") - public String getPhone() - { - return phone; - } - - public void setPhone(String phone) - { - this.phone = phone; - } - - @Email(message = "邮箱格式不正确") - @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") - public String getEmail() - { - return email; - } - - public void setEmail(String email) - { - this.email = email; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - public String getDelFlag() - { - return delFlag; - } - - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; - } - - public String getParentName() - { - return parentName; - } - - public void setParentName(String parentName) - { - this.parentName = parentName; - } - - public List<SysDept> getChildren() - { - return children; - } - - public void setChildren(List<SysDept> children) - { - this.children = children; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("deptId", getDeptId()) - .append("parentId", getParentId()) - .append("ancestors", getAncestors()) - .append("deptName", getDeptName()) - .append("orderNum", getOrderNum()) - .append("leader", getLeader()) - .append("phone", getPhone()) - .append("email", getEmail()) - .append("status", getStatus()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .toString(); - } -} +package com.ruoyi.project.system.domain; + +import java.util.ArrayList; +import java.util.List; +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.framework.web.domain.BaseEntity; + +/** + * 部门表 sys_dept + * + * @author ruoyi + */ +public class SysDept extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 部门ID */ + private Long deptId; + + /** 父部门ID */ + private Long parentId; + + /** 祖级列表 */ + private String ancestors; + + /** 部门名称 */ + private String deptName; + + /** 显示顺序 */ + private String orderNum; + + /** 负责人 */ + private String leader; + + /** 联系电话 */ + private String phone; + + /** 邮箱 */ + private String email; + + /** 部门状态:0正常,1停用 */ + private String status; + + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; + + /** 父部门名称 */ + private String parentName; + + /** 子部门 */ + private List<SysDept> children = new ArrayList<SysDept>(); + + /** 学校ID(与school表关联) */ + private String schoolId; + + public String getSchoolId() { + return schoolId; + } + + public void setSchoolId(String schoolId) { + this.schoolId = schoolId; + } + + public Long getDeptId() + { + return deptId; + } + + public void setDeptId(Long deptId) + { + this.deptId = deptId; + } + + public Long getParentId() + { + return parentId; + } + + public void setParentId(Long parentId) + { + this.parentId = parentId; + } + + public String getAncestors() + { + return ancestors; + } + + public void setAncestors(String ancestors) + { + this.ancestors = ancestors; + } + + @NotBlank(message = "部门名称不能为空") + @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符") + public String getDeptName() + { + return deptName; + } + + public void setDeptName(String deptName) + { + this.deptName = deptName; + } + + @NotBlank(message = "显示顺序不能为空") + public String getOrderNum() + { + return orderNum; + } + + public void setOrderNum(String orderNum) + { + this.orderNum = orderNum; + } + + public String getLeader() + { + return leader; + } + + public void setLeader(String leader) + { + this.leader = leader; + } + + @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符") + public String getPhone() + { + return phone; + } + + public void setPhone(String phone) + { + this.phone = phone; + } + + @Email(message = "邮箱格式不正确") + @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getDelFlag() + { + return delFlag; + } + + public void setDelFlag(String delFlag) + { + this.delFlag = delFlag; + } + + public String getParentName() + { + return parentName; + } + + public void setParentName(String parentName) + { + this.parentName = parentName; + } + + public List<SysDept> getChildren() + { + return children; + } + + public void setChildren(List<SysDept> children) + { + this.children = children; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("deptId", getDeptId()) + .append("parentId", getParentId()) + .append("ancestors", getAncestors()) + .append("deptName", getDeptName()) + .append("orderNum", getOrderNum()) + .append("leader", getLeader()) + .append("phone", getPhone()) + .append("email", getEmail()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("school_id", getSchoolId()) + .toString(); + } + + +} diff --git a/ruoyi/src/main/resources/mybatis/system/BySchoolMapper.xml b/ruoyi/src/main/resources/mybatis/system/BySchoolMapper.xml index ca9e34430..810be9187 100644 --- a/ruoyi/src/main/resources/mybatis/system/BySchoolMapper.xml +++ b/ruoyi/src/main/resources/mybatis/system/BySchoolMapper.xml @@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <resultMap type="BySchool" id="BySchoolResult"> <result property="id" column="id" /> + <result property="xxdm" column="xxdm" /> <result property="schoolName" column="school_name" /> <result property="nameShort" column="name_short" /> <result property="type" column="type" /> @@ -39,12 +40,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" </resultMap> <sql id="selectBySchoolVo"> - select id, school_name, name_short, type, parent_id, province, provincename, regionid, regionname, area, areaname, address, mastername, tel, em_man, em_tel, status, scale, create_time, create_user, approval_user, approval_time, remark, location, is_demonstr, businesslicenseimg, open_book, fee_status, open_deadline, dqxn, dqxq from by_school + select id, xxdm, school_name, name_short, type, parent_id, province, provincename, regionid, regionname, area, areaname, address, mastername, tel, em_man, em_tel, status, scale, create_time, create_user, approval_user, approval_time, remark, location, is_demonstr, businesslicenseimg, open_book, fee_status, open_deadline, dqxn, dqxq from by_school </sql> <select id="selectBySchoolList" parameterType="BySchool" resultMap="BySchoolResult"> <include refid="selectBySchoolVo"/> - <where> + <where> + <if test="xxdm != null and xxdm != ''"> and xxdm like concat('%', #{xxdm}, '%')</if> <if test="schoolName != null and schoolName != ''"> and school_name like concat('%', #{schoolName}, '%')</if> <if test="nameShort != null and nameShort != ''"> and name_short = #{nameShort}</if> <if test="type != null "> and type = #{type}</if> @@ -84,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <insert id="insertBySchool" parameterType="BySchool" useGeneratedKeys="true" keyProperty="id"> insert into by_school <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="xxdm != null and xxdm != ''">xxdm,</if> <if test="schoolName != null and schoolName != ''">school_name,</if> <if test="nameShort != null and nameShort != ''">name_short,</if> <if test="type != null ">type,</if> @@ -116,6 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <if test="dqxq != null and dqxq != ''">dqxq,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="xxdm != null and xxdm != ''">#{xxdm},</if> <if test="schoolName != null and schoolName != ''">#{schoolName},</if> <if test="nameShort != null and nameShort != ''">#{nameShort},</if> <if test="type != null ">#{type},</if> @@ -152,6 +156,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <update id="updateBySchool" parameterType="BySchool"> update by_school <trim prefix="SET" suffixOverrides=","> + <if test="xxdm != null and schoolName != ''">xxdm = #{xxdm},</if> <if test="schoolName != null and schoolName != ''">school_name = #{schoolName},</if> <if test="nameShort != null and nameShort != ''">name_short = #{nameShort},</if> <if test="type != null ">type = #{type},</if> diff --git a/ruoyi/src/main/resources/mybatis/system/SysDeptMapper.xml b/ruoyi/src/main/resources/mybatis/system/SysDeptMapper.xml index 247bb6966..22de8ac16 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysDeptMapper.xml +++ b/ruoyi/src/main/resources/mybatis/system/SysDeptMapper.xml @@ -1,151 +1,155 @@ -<?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.ruoyi.project.system.mapper.SysDeptMapper"> - - <resultMap type="SysDept" id="SysDeptResult"> - <id property="deptId" column="dept_id" /> - <result property="parentId" column="parent_id" /> - <result property="ancestors" column="ancestors" /> - <result property="deptName" column="dept_name" /> - <result property="orderNum" column="order_num" /> - <result property="leader" column="leader" /> - <result property="phone" column="phone" /> - <result property="email" column="email" /> - <result property="status" column="status" /> - <result property="delFlag" column="del_flag" /> - <result property="parentName" column="parent_name" /> - <result property="createBy" column="create_by" /> - <result property="createTime" column="create_time" /> - <result property="updateBy" column="update_by" /> - <result property="updateTime" column="update_time" /> - </resultMap> - - <sql id="selectDeptVo"> - select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time - from sys_dept d - </sql> - - <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult"> - <include refid="selectDeptVo"/> - where d.del_flag = '0' - <if test="parentId != null and parentId != 0"> - AND parent_id = #{parentId} - </if> - <if test="deptName != null and deptName != ''"> - AND dept_name like concat('%', #{deptName}, '%') - </if> - <if test="status != null and status != ''"> - AND status = #{status} - </if> - <!-- 数据范围过滤 --> - ${dataScope} - order by d.parent_id, d.order_num - </select> - - <select id="selectDeptListByRoleId" parameterType="Long" resultType="Integer"> - select d.dept_id, d.parent_id - from sys_dept d - left join sys_role_dept rd on d.dept_id = rd.dept_id - where rd.role_id = #{roleId} - and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId}) - order by d.parent_id, d.order_num - </select> - - <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult"> - <include refid="selectDeptVo"/> - where dept_id = #{deptId} - </select> - - <select id="checkDeptExistUser" parameterType="Long" resultType="int"> - select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0' - </select> - - <select id="hasChildByDeptId" parameterType="Long" resultType="int"> - select count(1) from sys_dept - where del_flag = '0' and parent_id = #{deptId} - </select> - - <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult"> - select * from sys_dept where find_in_set(#{deptId}, ancestors) - </select> - - <select id="checkDeptNameUnique" resultMap="SysDeptResult"> - <include refid="selectDeptVo"/> - where dept_name=#{deptName} and parent_id = #{parentId} - </select> - - <insert id="insertDept" parameterType="SysDept"> - insert into sys_dept( - <if test="deptId != null and deptId != 0">dept_id,</if> - <if test="parentId != null and parentId != 0">parent_id,</if> - <if test="deptName != null and deptName != ''">dept_name,</if> - <if test="ancestors != null and ancestors != ''">ancestors,</if> - <if test="orderNum != null and orderNum != ''">order_num,</if> - <if test="leader != null and leader != ''">leader,</if> - <if test="phone != null and phone != ''">phone,</if> - <if test="email != null and email != ''">email,</if> - <if test="status != null">status,</if> - <if test="createBy != null and createBy != ''">create_by,</if> - create_time - )values( - <if test="deptId != null and deptId != 0">#{deptId},</if> - <if test="parentId != null and parentId != 0">#{parentId},</if> - <if test="deptName != null and deptName != ''">#{deptName},</if> - <if test="ancestors != null and ancestors != ''">#{ancestors},</if> - <if test="orderNum != null and orderNum != ''">#{orderNum},</if> - <if test="leader != null and leader != ''">#{leader},</if> - <if test="phone != null and phone != ''">#{phone},</if> - <if test="email != null and email != ''">#{email},</if> - <if test="status != null">#{status},</if> - <if test="createBy != null and createBy != ''">#{createBy},</if> - sysdate() - ) - </insert> - - <update id="updateDept" parameterType="SysDept"> - update sys_dept - <set> - <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if> - <if test="deptName != null and deptName != ''">dept_name = #{deptName},</if> - <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if> - <if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if> - <if test="leader != null">leader = #{leader},</if> - <if test="phone != null">phone = #{phone},</if> - <if test="email != null">email = #{email},</if> - <if test="status != null and status != ''">status = #{status},</if> - <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> - update_time = sysdate() - </set> - where dept_id = #{deptId} - </update> - - <update id="updateDeptChildren" parameterType="java.util.List"> - update sys_dept set ancestors = - <foreach collection="depts" item="item" index="index" - separator=" " open="case dept_id" close="end"> - when #{item.deptId} then #{item.ancestors} - </foreach> - where dept_id in - <foreach collection="depts" item="item" index="index" - separator="," open="(" close=")"> - #{item.deptId} - </foreach> - </update> - - <update id="updateDeptStatus" parameterType="SysDept"> - update sys_dept - <set> - <if test="status != null and status != ''">status = #{status},</if> - <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> - update_time = sysdate() - </set> - where dept_id in (${ancestors}) - </update> - - <delete id="deleteDeptById" parameterType="Long"> - update sys_dept set del_flag = '2' where dept_id = #{deptId} - </delete> - +<?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.ruoyi.project.system.mapper.SysDeptMapper"> + + <resultMap type="SysDept" id="SysDeptResult"> + <id property="deptId" column="dept_id" /> + <result property="parentId" column="parent_id" /> + <result property="ancestors" column="ancestors" /> + <result property="deptName" column="dept_name" /> + <result property="orderNum" column="order_num" /> + <result property="leader" column="leader" /> + <result property="phone" column="phone" /> + <result property="email" column="email" /> + <result property="status" column="status" /> + <result property="delFlag" column="del_flag" /> + <result property="parentName" column="parent_name" /> + <result property="createBy" column="create_by" /> + <result property="createTime" column="create_time" /> + <result property="updateBy" column="update_by" /> + <result property="updateTime" column="update_time" /> + <result property="schoolId" column="school_id" /> + </resultMap> + + <sql id="selectDeptVo"> + select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time, d.school_id + from sys_dept d + </sql> + + <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult"> + <include refid="selectDeptVo"/> + where d.del_flag = '0' + <if test="parentId != null and parentId != 0"> + AND parent_id = #{parentId} + </if> + <if test="deptName != null and deptName != ''"> + AND dept_name like concat('%', #{deptName}, '%') + </if> + <if test="status != null and status != ''"> + AND status = #{status} + </if> + <!-- 数据范围过滤 --> + ${dataScope} + order by d.parent_id, d.order_num + </select> + + <select id="selectDeptListByRoleId" parameterType="Long" resultType="Integer"> + select d.dept_id, d.parent_id + from sys_dept d + left join sys_role_dept rd on d.dept_id = rd.dept_id + where rd.role_id = #{roleId} + and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId}) + order by d.parent_id, d.order_num + </select> + + <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult"> + <include refid="selectDeptVo"/> + where dept_id = #{deptId} + </select> + + <select id="checkDeptExistUser" parameterType="Long" resultType="int"> + select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0' + </select> + + <select id="hasChildByDeptId" parameterType="Long" resultType="int"> + select count(1) from sys_dept + where del_flag = '0' and parent_id = #{deptId} + </select> + + <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult"> + select * from sys_dept where find_in_set(#{deptId}, ancestors) + </select> + + <select id="checkDeptNameUnique" resultMap="SysDeptResult"> + <include refid="selectDeptVo"/> + where dept_name=#{deptName} and parent_id = #{parentId} + </select> + + <insert id="insertDept" parameterType="SysDept"> + insert into sys_dept( + <if test="deptId != null and deptId != 0">dept_id,</if> + <if test="parentId != null and parentId != 0">parent_id,</if> + <if test="deptName != null and deptName != ''">dept_name,</if> + <if test="ancestors != null and ancestors != ''">ancestors,</if> + <if test="orderNum != null and orderNum != ''">order_num,</if> + <if test="leader != null and leader != ''">leader,</if> + <if test="phone != null and phone != ''">phone,</if> + <if test="email != null and email != ''">email,</if> + <if test="status != null">status,</if> + <if test="createBy != null and createBy != ''">create_by,</if> + <if test="schoolId != null and schoolId != ''">school_id,</if> + create_time + )values( + <if test="deptId != null and deptId != 0">#{deptId},</if> + <if test="parentId != null and parentId != 0">#{parentId},</if> + <if test="deptName != null and deptName != ''">#{deptName},</if> + <if test="ancestors != null and ancestors != ''">#{ancestors},</if> + <if test="orderNum != null and orderNum != ''">#{orderNum},</if> + <if test="leader != null and leader != ''">#{leader},</if> + <if test="phone != null and phone != ''">#{phone},</if> + <if test="email != null and email != ''">#{email},</if> + <if test="status != null">#{status},</if> + <if test="createBy != null and createBy != ''">#{createBy},</if> + <if test="schoolId != null and schoolId != ''">#{schoolId},</if> + sysdate() + ) + </insert> + + <update id="updateDept" parameterType="SysDept"> + update sys_dept + <set> + <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if> + <if test="deptName != null and deptName != ''">dept_name = #{deptName},</if> + <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if> + <if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if> + <if test="leader != null">leader = #{leader},</if> + <if test="phone != null">phone = #{phone},</if> + <if test="email != null">email = #{email},</if> + <if test="status != null and status != ''">status = #{status},</if> + <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> + <if test="schoolId != null and schoolId != ''">school_id = #{schoolId},</if> + update_time = sysdate() + </set> + where dept_id = #{deptId} + </update> + + <update id="updateDeptChildren" parameterType="java.util.List"> + update sys_dept set ancestors = + <foreach collection="depts" item="item" index="index" + separator=" " open="case dept_id" close="end"> + when #{item.deptId} then #{item.ancestors} + </foreach> + where dept_id in + <foreach collection="depts" item="item" index="index" + separator="," open="(" close=")"> + #{item.deptId} + </foreach> + </update> + + <update id="updateDeptStatus" parameterType="SysDept"> + update sys_dept + <set> + <if test="status != null and status != ''">status = #{status},</if> + <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> + update_time = sysdate() + </set> + where dept_id in (${ancestors}) + </update> + + <delete id="deleteDeptById" parameterType="Long"> + update sys_dept set del_flag = '2' where dept_id = #{deptId} + </delete> + </mapper> \ No newline at end of file