针对智慧工地对公司框架进行优化
This commit is contained in:
parent
92d77786b8
commit
c1e6fbbec7
|
|
@ -108,26 +108,6 @@ public class SysDept extends BaseEntity {
|
|||
*/
|
||||
private String logo;
|
||||
|
||||
/**
|
||||
*密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
*姓名
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
*账号
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
*手机号
|
||||
*/
|
||||
private String phonenumber;
|
||||
|
||||
/**
|
||||
*角色名称
|
||||
*/
|
||||
|
|
@ -143,6 +123,8 @@ public class SysDept extends BaseEntity {
|
|||
*/
|
||||
private Long roleId;
|
||||
|
||||
private SysUser sysUser;
|
||||
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class MimeTypeUtils
|
|||
|
||||
public static final String IMAGE_GIF = "image/gif";
|
||||
|
||||
public static final String[] IMAGE_EXTENSION = { "bmp", "gif", "jpg", "jpeg", "png" };
|
||||
public static final String[] IMAGE_EXTENSION = { "bmp", "gif", "jpg", "jpeg", "png", "svg","SVG"};
|
||||
|
||||
public static final String[] FLASH_EXTENSION = { "swf", "flv" };
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ public class MimeTypeUtils
|
|||
|
||||
public static final String[] DEFAULT_ALLOWED_EXTENSION = {
|
||||
// 图片
|
||||
"bmp", "gif", "jpg", "jpeg", "png",
|
||||
"bmp", "gif", "jpg", "jpeg", "png","svg","SVG",
|
||||
// word excel powerpoint
|
||||
"doc", "docx", "xls", "xlsx","csv", "ppt", "pptx", "html", "htm", "txt",
|
||||
// 压缩文件
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@ package com.bonus.system.controller;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.common.security.annotation.InnerAuth;
|
||||
import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
|
||||
import com.bonus.common.security.annotation.RequiresRoles;
|
||||
import com.bonus.system.service.ISysUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -28,19 +30,24 @@ import com.bonus.common.security.utils.SecurityUtils;
|
|||
import com.bonus.system.api.domain.SysDept;
|
||||
import com.bonus.system.service.ISysDeptService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 部门信息
|
||||
*
|
||||
* @author bonus
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dept")
|
||||
@RequestMapping("/dept")
|
||||
@Slf4j
|
||||
public class SysDeptController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
@Resource
|
||||
private ISysUserService userService;
|
||||
|
||||
/**
|
||||
* 获取部门列表
|
||||
* 根据部门id或上级部门id或部门名或状态(正常或停用)获取部门信息
|
||||
|
|
@ -99,6 +106,11 @@ public class SysDeptController extends BaseController
|
|||
try{
|
||||
if (!deptService.checkDeptNameUnique(dept)) {
|
||||
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
}else if (StringUtils.isNotNull(dept.getSysUser()) &&!userService.checkUserNameUnique(dept.getSysUser())) {
|
||||
throw new ServiceException("新增用户'" + dept.getSysUser().getUserName() + "'失败,登录账号已存在");
|
||||
} else if (StringUtils.isNotEmpty(dept.getSysUser().getPhonenumber()) && !userService.checkPhoneUnique(dept.getSysUser())) {
|
||||
throw new ServiceException("新增用户'" + dept.getSysUser().getUserName() + "'失败,手机号码已存在");
|
||||
|
||||
}
|
||||
dept.setCreateBy(SecurityUtils.getUsername());
|
||||
return toAjax(deptService.insertDept(dept));
|
||||
|
|
@ -124,8 +136,12 @@ public class SysDeptController extends BaseController
|
|||
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) {
|
||||
return error("该部门包含未停用的子部门!");
|
||||
}else if (StringUtils.isNotNull(dept.getSysUser()) &&!userService.checkUserNameUnique(dept.getSysUser())) {
|
||||
throw new ServiceException("修改部门'" + dept.getSysUser().getUserName() + "'失败,登录账号已存在");
|
||||
} else if (StringUtils.isNotEmpty(dept.getSysUser().getPhonenumber()) && !userService.checkPhoneUnique(dept.getSysUser())) {
|
||||
throw new ServiceException("修改部门'" + dept.getSysUser().getUserName() + "'失败,手机号码已存在");
|
||||
}
|
||||
dept.setUpdateBy(SecurityUtils.getUsername());
|
||||
dept.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(deptService.updateDept(dept));
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.bonus.system.mapper;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bonus.system.api.domain.SysDept;
|
||||
|
||||
|
|
@ -137,5 +138,5 @@ public interface SysDeptMapper
|
|||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
SysDept selectDeptAndUserById(Long deptId);
|
||||
SysUser selectDeptAndUserById(Long deptId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.bonus.system.domain.SysRoleDept;
|
|||
import com.bonus.system.domain.SysRoleMenu;
|
||||
import com.bonus.system.mapper.*;
|
||||
import com.bonus.common.datascope.utils.CommonDataPermissionInfo;
|
||||
import com.bonus.system.service.ISysUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -63,6 +64,8 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
private SysUserRoleMapper userRoleMapper;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
*
|
||||
|
|
@ -192,10 +195,8 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
{
|
||||
SysDept sysDept = deptMapper.selectDeptById(deptId);
|
||||
if (systemConfig.isCreateUserAndRole() && sysDept.getParentId()==0L){
|
||||
sysDept = deptMapper.selectDeptAndUserById(deptId);
|
||||
if (sysDept.getPassword()!=null){
|
||||
sysDept.setPassword(SecurityUtils.decryptPassword(sysDept.getPassword()));
|
||||
}
|
||||
SysUser sysUser = deptMapper.selectDeptAndUserById(deptId);
|
||||
sysDept.setSysUser(sysUser);
|
||||
}
|
||||
return sysDept;
|
||||
}
|
||||
|
|
@ -392,12 +393,8 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
*/
|
||||
private SysUser createUser(SysDept dept) {
|
||||
log.info("创建用户:{}",dept);
|
||||
SysUser user = new SysUser();
|
||||
SysUser user = dept.getSysUser();
|
||||
user.setCreateBy(SecurityUtils.getUsername());
|
||||
user.setPassword(SecurityUtils.encryptPassword(dept.getPassword()));
|
||||
user.setNickName(dept.getNickName());
|
||||
user.setUserName(dept.getUserName());
|
||||
user.setPhonenumber(dept.getPhonenumber());
|
||||
user.setDeptId(dept.getDeptId());
|
||||
userMapper.insertUser(user);
|
||||
return user;
|
||||
|
|
@ -441,19 +438,15 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
* @param dept
|
||||
*/
|
||||
private void updateUserAndRole(SysDept dept) {
|
||||
SysUser user = new SysUser();
|
||||
SysUser user = dept.getSysUser();
|
||||
user.setUpdateBy(SecurityUtils.getUsername());
|
||||
user.setPassword(SecurityUtils.encryptPassword(dept.getPassword()));
|
||||
user.setNickName(dept.getNickName());
|
||||
user.setUserName(dept.getUserName());
|
||||
user.setPhonenumber(dept.getPhonenumber());
|
||||
user.setDeptId(dept.getDeptId());
|
||||
SysRole role = new SysRole();
|
||||
role.setRoleName(dept.getRoleName());
|
||||
role.setUpdateBy(SecurityUtils.getUsername());
|
||||
dept = deptMapper.selectDeptAndUserById(dept.getDeptId());
|
||||
role.setRoleId(dept.getRoleId());
|
||||
user.setUserId(dept.getUserId());
|
||||
SysUser oldSysUser = deptMapper.selectDeptAndUserById(dept.getDeptId());
|
||||
role.setRoleId(oldSysUser.getRoleId());
|
||||
user.setUserId(oldSysUser.getUserId());
|
||||
userMapper.updateUser(user);
|
||||
roleMapper.updateRole(role);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,14 +148,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="getDeptList" resultType="com.bonus.system.api.domain.SysDept">
|
||||
select * from sys_dept where parent_id='0'
|
||||
</select>
|
||||
<select id="selectDeptAndUserById" resultType="com.bonus.system.api.domain.SysDept">
|
||||
select sd.*,su.nick_name as nickName,su.user_name as userName,su.password as password,
|
||||
sr.role_name as roleName,su.user_id as userId,sr.role_id as roleId from sys_dept sd
|
||||
<select id="selectDeptAndUserById" resultType="com.bonus.system.api.domain.SysUser">
|
||||
select su.nick_name as nickName,su.user_name as userName,su.password as password,su.phonenumber as phonenumber,
|
||||
sr.role_name as roleName,su.user_id as userId,sr.role_id as roleId, sd.dept_id as deptId from sys_dept sd
|
||||
left join sys_role_dept srd on sd.dept_id = srd.dept_id
|
||||
left join sys_role sr on srd.role_id = sr.role_id and role_key = 'admin'
|
||||
left join sys_role sr on srd.role_id = sr.role_id and sr.role_key LIKE '%admin%'
|
||||
left join sys_user_role sur on sur.role_id = sr.role_id
|
||||
left join sys_user su on su.user_id = sur.user_id
|
||||
where dept_id = #{deptId}
|
||||
where sd.dept_id = #{deptId}
|
||||
</select>
|
||||
<insert id="insertDept" parameterType="com.bonus.system.api.domain.SysDept" useGeneratedKeys="true" keyProperty="deptId">
|
||||
insert into sys_dept(
|
||||
|
|
@ -173,6 +173,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="address != null and address != ''">address,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="deptAbbreviation != null and deptAbbreviation != ''">dept_abbreviation,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="logo != null and logo != ''">logo,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="deptId != null and deptId != 0">#{deptId},</if>
|
||||
|
|
@ -189,6 +192,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="address != null and address != ''">#{address},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="deptAbbreviation != null and deptAbbreviation != ''">#{deptAbbreviation},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="logo != null and logo != ''">#{logo},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
|
@ -209,6 +215,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="address != null">address = #{address},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="deptAbbreviation != null and deptAbbreviation != ''">dept_abbreviation = #{deptAbbreviation},</if>
|
||||
<if test="remark != null and remark != ''">remark = #{remark},</if>
|
||||
<if test="logo != null and logo != ''">logo = #{logo},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where dept_id = #{deptId}
|
||||
|
|
|
|||
Loading…
Reference in New Issue