From d56ad9351615d56f995d5524302e94c9c9e2e928 Mon Sep 17 00:00:00 2001 From: sk1551 <15175617877@163.com> Date: Wed, 15 Apr 2020 18:02:55 +0800 Subject: [PATCH 1/2] 20200407-lc-1 --- ruoyi-ui/src/views/system/dept/index.vue | 656 +++++++++--------- ruoyi-ui/src/views/system/school/index.vue | 4 +- .../web/controller/BaseController.java | 179 ++--- .../system/controller/BySchoolController.java | 25 + .../system/controller/SysDeptController.java | 271 ++++---- .../ruoyi/project/system/domain/BySchool.java | 28 + .../ruoyi/project/system/domain/SysDept.java | 418 +++++------ .../mybatis/system/BySchoolMapper.xml | 9 +- .../mybatis/system/SysDeptMapper.xml | 304 ++++---- 9 files changed, 1002 insertions(+), 892 deletions(-) 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 @@ - - - \ 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 @@ - + 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 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 depts = deptService.selectDeptList(dept); - return AjaxResult.success(deptService.buildDeptTreeSelect(depts)); - } - - /** - * 加载对应角色部门列表树 - */ - @GetMapping(value = "/roleDeptTreeselect/{roleId}") - public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) - { - List 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 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 depts = deptService.selectDeptList(dept); + return AjaxResult.success(deptService.buildDeptTreeSelect(depts)); + } + + /** + * 加载对应角色部门列表树 + */ + @GetMapping(value = "/roleDeptTreeselect/{roleId}") + public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) + { + List 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 children = new ArrayList(); - - 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 getChildren() - { - return children; - } - - public void setChildren(List 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 children = new ArrayList(); + + /** 学校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 getChildren() + { + return children; + } + + public void setChildren(List 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" + @@ -39,12 +40,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - 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 - - where d.del_flag = '0' - - AND parent_id = #{parentId} - - - AND dept_name like concat('%', #{deptName}, '%') - - - AND status = #{status} - - - ${dataScope} - order by d.parent_id, d.order_num - - - - - - - - - - - - - - - - insert into sys_dept( - dept_id, - parent_id, - dept_name, - ancestors, - order_num, - leader, - phone, - email, - status, - create_by, - create_time - )values( - #{deptId}, - #{parentId}, - #{deptName}, - #{ancestors}, - #{orderNum}, - #{leader}, - #{phone}, - #{email}, - #{status}, - #{createBy}, - sysdate() - ) - - - - update sys_dept - - parent_id = #{parentId}, - dept_name = #{deptName}, - ancestors = #{ancestors}, - order_num = #{orderNum}, - leader = #{leader}, - phone = #{phone}, - email = #{email}, - status = #{status}, - update_by = #{updateBy}, - update_time = sysdate() - - where dept_id = #{deptId} - - - - update sys_dept set ancestors = - - when #{item.deptId} then #{item.ancestors} - - where dept_id in - - #{item.deptId} - - - - - update sys_dept - - status = #{status}, - update_by = #{updateBy}, - update_time = sysdate() - - where dept_id in (${ancestors}) - - - - update sys_dept set del_flag = '2' where dept_id = #{deptId} - - + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + + + + + + + + + + + insert into sys_dept( + dept_id, + parent_id, + dept_name, + ancestors, + order_num, + leader, + phone, + email, + status, + create_by, + school_id, + create_time + )values( + #{deptId}, + #{parentId}, + #{deptName}, + #{ancestors}, + #{orderNum}, + #{leader}, + #{phone}, + #{email}, + #{status}, + #{createBy}, + #{schoolId}, + sysdate() + ) + + + + update sys_dept + + parent_id = #{parentId}, + dept_name = #{deptName}, + ancestors = #{ancestors}, + order_num = #{orderNum}, + leader = #{leader}, + phone = #{phone}, + email = #{email}, + status = #{status}, + update_by = #{updateBy}, + school_id = #{schoolId}, + update_time = sysdate() + + where dept_id = #{deptId} + + + + update sys_dept set ancestors = + + when #{item.deptId} then #{item.ancestors} + + where dept_id in + + #{item.deptId} + + + + + update sys_dept + + status = #{status}, + update_by = #{updateBy}, + update_time = sysdate() + + where dept_id in (${ancestors}) + + + + update sys_dept set del_flag = '2' where dept_id = #{deptId} + + \ No newline at end of file From 16f4cc0d9a93b2ec80591eef209ccaeb1ea7d37e Mon Sep 17 00:00:00 2001 From: sk1551 <15175617877@163.com> Date: Thu, 16 Apr 2020 09:11:04 +0800 Subject: [PATCH 2/2] 20200407-lc-1 --- ruoyi-ui/src/views/system/school/index.vue | 16 +- ruoyi/pom.xml | 577 +++++++++--------- .../system/controller/BySchoolController.java | 26 +- .../ruoyi/project/system/domain/BySchool.java | 6 + 4 files changed, 333 insertions(+), 292 deletions(-) diff --git a/ruoyi-ui/src/views/system/school/index.vue b/ruoyi-ui/src/views/system/school/index.vue index b8d65c147..33f40f9ee 100644 --- a/ruoyi-ui/src/views/system/school/index.vue +++ b/ruoyi-ui/src/views/system/school/index.vue @@ -188,7 +188,7 @@ - + @@ -370,7 +370,19 @@ export default { // 表单校验 rules: { schoolName: [ - { required: true, message: "机构名称不能为空", trigger: "blur" } + { + required: true, + message: "机构名称不能为空", + trigger: "blur" + } + ], + tel: [ + { + required: true, + pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, + message: "请输入正确的手机号码", + trigger: "blur" + } ] } }; diff --git a/ruoyi/pom.xml b/ruoyi/pom.xml index 15470d888..52eaa7e40 100644 --- a/ruoyi/pom.xml +++ b/ruoyi/pom.xml @@ -1,287 +1,292 @@ - - - 4.0.0 - - com.ruoyi - ruoyi - 2.2.0 - jar - - ruoyi - http://www.benyiedu.com - 本一智慧平台管理系统 - - - org.springframework.boot - spring-boot-starter-parent - 2.1.1.RELEASE - - - - - UTF-8 - UTF-8 - 1.8 - 1.3.2 - 1.2.5 - 1.2.47 - 1.1.14 - 2.5 - 1.3.3 - 1.19 - 0.9.0 - 2.9.2 - 3.17 - 3.9.1 - 1.7 - - - - - - - org.springframework.boot - spring-boot-starter - - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - org.springframework.boot - spring-boot-starter-aop - - - - - org.springframework.boot - spring-boot-starter-web - - - - - org.springframework.boot - spring-boot-devtools - true - - - - - org.springframework.boot - spring-boot-starter-security - - - - - org.springframework.boot - spring-boot-starter-data-redis - - - - - org.apache.commons - commons-pool2 - - - - - mysql - mysql-connector-java - runtime - - - - - org.mybatis.spring.boot - mybatis-spring-boot-starter - ${mybatis.spring.boot.starter.version} - - - - - com.github.pagehelper - pagehelper-spring-boot-starter - ${pagehelper.spring.boot.starter.version} - - - - - com.alibaba - druid-spring-boot-starter - ${druid.version} - - - - - org.apache.commons - commons-lang3 - - - - - commons-io - commons-io - ${commons.io.version} - - - - - commons-fileupload - commons-fileupload - ${commons.fileupload.version} - - - - - eu.bitwalker - UserAgentUtils - ${bitwalker.version} - - - - - com.alibaba - fastjson - ${fastjson.version} - - - - - org.springframework - spring-context-support - - - - - io.jsonwebtoken - jjwt - ${jwt.version} - - - - - io.springfox - springfox-swagger2 - ${swagger.version} - - - io.swagger - swagger-annotations - - - io.swagger - swagger-models - - - - - - - io.swagger - swagger-annotations - 1.5.21 - - - - io.swagger - swagger-models - 1.5.21 - - - - - io.springfox - springfox-swagger-ui - ${swagger.version} - - - - - com.github.oshi - oshi-core - ${oshi.version} - - - - net.java.dev.jna - jna - - - - net.java.dev.jna - jna-platform - - - - - org.apache.poi - poi-ooxml - ${poi.version} - - - - - org.apache.velocity - velocity - ${velocity.version} - - - - - org.quartz-scheduler - quartz - - - com.mchange - c3p0 - - - - - - - - ${project.artifactId} - - - org.springframework.boot - spring-boot-maven-plugin - - true - - - - - - - - public - aliyun nexus - http://maven.aliyun.com/nexus/content/groups/public/ - - true - - - - - - - public - aliyun nexus - http://maven.aliyun.com/nexus/content/groups/public/ - - true - - - false - - - - + + + 4.0.0 + + com.ruoyi + ruoyi + 2.2.0 + jar + + ruoyi + http://www.benyiedu.com + 本一智慧平台管理系统 + + + org.springframework.boot + spring-boot-starter-parent + 2.1.1.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + 1.3.2 + 1.2.5 + 1.2.47 + 1.1.14 + 2.5 + 1.3.3 + 1.19 + 0.9.0 + 2.9.2 + 3.17 + 3.9.1 + 1.7 + + + + + + + org.springframework.boot + spring-boot-starter + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + org.springframework.boot + spring-boot-starter-aop + + + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springframework.boot + spring-boot-devtools + true + + + + + org.springframework.boot + spring-boot-starter-security + + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + + org.apache.commons + commons-pool2 + + + + + mysql + mysql-connector-java + runtime + + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + ${mybatis.spring.boot.starter.version} + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + ${pagehelper.spring.boot.starter.version} + + + + + com.alibaba + druid-spring-boot-starter + ${druid.version} + + + + + org.apache.commons + commons-lang3 + + + + + commons-io + commons-io + ${commons.io.version} + + + + + commons-fileupload + commons-fileupload + ${commons.fileupload.version} + + + + + eu.bitwalker + UserAgentUtils + ${bitwalker.version} + + + + + com.alibaba + fastjson + ${fastjson.version} + + + + + org.springframework + spring-context-support + + + + + io.jsonwebtoken + jjwt + ${jwt.version} + + + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + io.swagger + swagger-annotations + + + io.swagger + swagger-models + + + + + + + io.swagger + swagger-annotations + 1.5.21 + + + + io.swagger + swagger-models + 1.5.21 + + + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + + + com.github.oshi + oshi-core + ${oshi.version} + + + + net.java.dev.jna + jna + + + + net.java.dev.jna + jna-platform + + + + + org.apache.poi + poi-ooxml + ${poi.version} + + + + + org.apache.velocity + velocity + ${velocity.version} + + + + + org.quartz-scheduler + quartz + + + com.mchange + c3p0 + + + + + org.springframework + spring-jdbc + 5.1.5.RELEASE + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + + + + public + aliyun nexus + http://maven.aliyun.com/nexus/content/groups/public/ + + true + + + + + + + public + aliyun nexus + http://maven.aliyun.com/nexus/content/groups/public/ + + true + + + false + + + + \ No newline at end of file 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 6551b3c2b..3f4dd0a5b 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 @@ -5,6 +5,7 @@ import java.util.List; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.project.system.service.ISysDeptService; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -25,12 +26,19 @@ import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.project.system.domain.SysDept; +import javax.annotation.Resource; + /** * 幼儿园机构Controller * * @author tsbz * @date 2020-04-08 */ + + + + + @RestController @RequestMapping("/system/school") public class BySchoolController extends BaseController @@ -78,14 +86,24 @@ public class BySchoolController extends BaseController return AjaxResult.success(bySchoolService.selectBySchoolById(id)); } + + /** * 新增幼儿园机构 */ + + //调取jdbctemplate方法 读取数据库中的ID值 + @Resource + private JdbcTemplate jdbcTemplate; + @PreAuthorize("@ss.hasPermi('system:school:add')") @Log(title = "幼儿园机构", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody BySchool bySchool) { + //从school表中取出当前最大的ID值 并且将其赋值给dept中的ordernumber + String maxId = jdbcTemplate.queryForObject(String.format("select MAX(id) from by_school"),String.class); + String uuid = getUUID32(); //将UUID赋值给xxdm @@ -93,18 +111,18 @@ public class BySchoolController extends BaseController bySchool.setCreateUser(SecurityUtils.getLoginUser().getUser().getUserId()); bySchool.setApprovalUser(SecurityUtils.getLoginUser().getUser().getUserId()); bySchool.setCreateTime(new Date()); - //bySchoolService.insertBySchool(bySchool); + //创建dept实例 并且向要添加的dept中设置各个参数 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.setOrderNum(maxId); + dept.setPhone(bySchool.getTel()); dept.setLeader(SecurityUtils.getUsername()); + //插入数据 deptService.insertDept(dept); return toAjax(bySchoolService.insertBySchool(bySchool)); 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 1691c72b9..00f5c33fc 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 @@ -4,6 +4,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.framework.aspectj.lang.annotation.Excel; import com.ruoyi.framework.web.domain.BaseEntity; + import java.util.Date; /** @@ -12,10 +13,15 @@ import java.util.Date; * @author tsbz * @date 2020-04-08 */ + + + public class BySchool extends BaseEntity { private static final long serialVersionUID = 1L; + + /** 幼儿园ID */ private Long id;