Browse Source

榆山大屏 增加物业用户关系 admin代码提交

feature/test
zhangfh 4 years ago
parent
commit
a865b17eb8
  1. 4
      epdc-cloud-admin/src/main/java/com/elink/esua/epdc/controller/SysUserController.java
  2. 40
      epdc-cloud-admin/src/main/java/com/elink/esua/epdc/dao/SysPropertyUserDao.java
  3. 50
      epdc-cloud-admin/src/main/java/com/elink/esua/epdc/entity/SysPropertyUserEntity.java
  4. 108
      epdc-cloud-admin/src/main/java/com/elink/esua/epdc/service/SysPropertyUserService.java
  5. 121
      epdc-cloud-admin/src/main/java/com/elink/esua/epdc/service/impl/SysPropertyUserServiceImpl.java
  6. 12
      epdc-cloud-admin/src/main/java/com/elink/esua/epdc/service/impl/SysUserServiceImpl.java
  7. 25
      epdc-cloud-admin/src/main/resources/mapper/SysPropertyUserDao.xml

4
epdc-cloud-admin/src/main/java/com/elink/esua/epdc/controller/SysUserController.java

@ -66,6 +66,8 @@ public class SysUserController {
private OptSysDeptService optSysDeptService; private OptSysDeptService optSysDeptService;
@Autowired @Autowired
private SysEpmetUserRelationService sysEpmetUserRelationService; private SysEpmetUserRelationService sysEpmetUserRelationService;
@Autowired
private SysPropertyUserService sysPropertyUserService;
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ -86,6 +88,8 @@ public class SysUserController {
@ApiOperation("信息") @ApiOperation("信息")
public Result<SysUserDTO> get(@PathVariable("id") Long id) { public Result<SysUserDTO> get(@PathVariable("id") Long id) {
SysUserDTO data = sysUserService.get(id); SysUserDTO data = sysUserService.get(id);
//设置物业id
data.setProjectId(sysPropertyUserService.getByUserId(id.toString()));
//用户角色列表 //用户角色列表
List<Long> roleIdList = sysRoleUserService.getRoleIdList(id); List<Long> roleIdList = sysRoleUserService.getRoleIdList(id);

40
epdc-cloud-admin/src/main/java/com/elink/esua/epdc/dao/SysPropertyUserDao.java

@ -0,0 +1,40 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.dto.SysPropertyUserDTO;
import com.elink.esua.epdc.entity.SysPropertyUserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 物业项目-用户关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2021-09-10
*/
@Mapper
public interface SysPropertyUserDao extends BaseDao<SysPropertyUserEntity> {
int updateByUserId(SysPropertyUserDTO dto);
String selectByUserId(@Param("userId") String UserId);
}

50
epdc-cloud-admin/src/main/java/com/elink/esua/epdc/entity/SysPropertyUserEntity.java

@ -0,0 +1,50 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 物业项目-用户关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2021-09-10
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("sys_property_user")
public class SysPropertyUserEntity extends BaseEpdcEntity {
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
private String userId;
/**
* 业务项目id
*/
private String projectId;
}

108
epdc-cloud-admin/src/main/java/com/elink/esua/epdc/service/SysPropertyUserService.java

@ -0,0 +1,108 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.dto.SysPropertyUserDTO;
import com.elink.esua.epdc.entity.SysPropertyUserEntity;
import java.util.List;
import java.util.Map;
/**
* 物业项目-用户关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2021-09-10
*/
public interface SysPropertyUserService extends BaseService<SysPropertyUserEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<SysPropertyUserDTO>
* @author generator
* @date 2021-09-10
*/
PageData<SysPropertyUserDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<SysPropertyUserDTO>
* @author generator
* @date 2021-09-10
*/
List<SysPropertyUserDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return SysPropertyUserDTO
* @author generator
* @date 2021-09-10
*/
SysPropertyUserDTO get(String id);
/**
* @Author zhangfenghe
* @Description 获取物业id
* @Date 15:16 2021/9/15
* @Param [userId]
* @return java.lang.String
**/
String getByUserId(String userId);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2021-09-10
*/
void save(SysPropertyUserDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2021-09-10
*/
void update(SysPropertyUserDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2021-09-10
*/
void delete(String[] ids);
void savePropertyUser(String userId,String projectId);
void updatePropertyUser(String userId,String projectId);
}

121
epdc-cloud-admin/src/main/java/com/elink/esua/epdc/service/impl/SysPropertyUserServiceImpl.java

@ -0,0 +1,121 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.dao.SysPropertyUserDao;
import com.elink.esua.epdc.dto.SysPropertyUserDTO;
import com.elink.esua.epdc.entity.SysPropertyUserEntity;
import com.elink.esua.epdc.service.SysPropertyUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 物业项目-用户关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2021-09-10
*/
@Service
public class SysPropertyUserServiceImpl extends BaseServiceImpl<SysPropertyUserDao, SysPropertyUserEntity> implements SysPropertyUserService {
@Override
public PageData<SysPropertyUserDTO> page(Map<String, Object> params) {
IPage<SysPropertyUserEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, SysPropertyUserDTO.class);
}
@Override
public List<SysPropertyUserDTO> list(Map<String, Object> params) {
List<SysPropertyUserEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, SysPropertyUserDTO.class);
}
private QueryWrapper<SysPropertyUserEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<SysPropertyUserEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public SysPropertyUserDTO get(String id) {
SysPropertyUserEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, SysPropertyUserDTO.class);
}
@Override
public String getByUserId(String userId) {
return baseDao.selectByUserId(userId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(SysPropertyUserDTO dto) {
SysPropertyUserEntity entity = ConvertUtils.sourceToTarget(dto, SysPropertyUserEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(SysPropertyUserDTO dto) {
SysPropertyUserEntity entity = ConvertUtils.sourceToTarget(dto, SysPropertyUserEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
public void savePropertyUser(String userId,String projectId) {
SysPropertyUserDTO dto = new SysPropertyUserDTO();
dto.setUserId(userId);
dto.setProjectId(projectId);
SysPropertyUserEntity entity = ConvertUtils.sourceToTarget(dto, SysPropertyUserEntity.class);
insert(entity);
}
@Override
public void updatePropertyUser(String userId, String projectId) {
SysPropertyUserDTO dto = new SysPropertyUserDTO();
dto.setUserId(userId);
dto.setProjectId(projectId);
baseDao.updateByUserId(dto);
}
}

12
epdc-cloud-admin/src/main/java/com/elink/esua/epdc/service/impl/SysUserServiceImpl.java

@ -31,10 +31,7 @@ import com.elink.esua.epdc.dto.epdc.GridLeaderRegisterDTO;
import com.elink.esua.epdc.dto.epdc.form.EpdcAppGridManFormDTO; import com.elink.esua.epdc.dto.epdc.form.EpdcAppGridManFormDTO;
import com.elink.esua.epdc.dto.epdc.result.EpdcAppGridManListResultDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcAppGridManListResultDTO;
import com.elink.esua.epdc.entity.SysUserEntity; import com.elink.esua.epdc.entity.SysUserEntity;
import com.elink.esua.epdc.service.SysDeptService; import com.elink.esua.epdc.service.*;
import com.elink.esua.epdc.service.SysEpmetUserRelationService;
import com.elink.esua.epdc.service.SysRoleUserService;
import com.elink.esua.epdc.service.SysUserService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -56,7 +53,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
private SysRoleUserService sysRoleUserService; private SysRoleUserService sysRoleUserService;
@Autowired @Autowired
private SysDeptService sysDeptService; private SysDeptService sysDeptService;
@Autowired
private SysPropertyUserService sysPropertyUserService;
@Autowired @Autowired
private SysEpmetUserRelationService sysEpmetUserRelationService; private SysEpmetUserRelationService sysEpmetUserRelationService;
@ -124,6 +122,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
entity.setSuperAdmin(SuperAdminEnum.NO.value()); entity.setSuperAdmin(SuperAdminEnum.NO.value());
insert(entity); insert(entity);
//保存物业项目和用户关系
sysPropertyUserService.savePropertyUser(entity.getId().toString(),dto.getProjectId());
//保存角色用户关系 //保存角色用户关系
sysRoleUserService.saveOrUpdate(entity.getId(), dto.getRoleIdList()); sysRoleUserService.saveOrUpdate(entity.getId(), dto.getRoleIdList());
@ -150,6 +150,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
//更新用户 //更新用户
updateById(entity); updateById(entity);
//更新用户物业关系
sysPropertyUserService.updatePropertyUser(entity.getId().toString(),dto.getProjectId());
//更新角色用户关系 //更新角色用户关系
sysRoleUserService.saveOrUpdate(entity.getId(), dto.getRoleIdList()); sysRoleUserService.saveOrUpdate(entity.getId(), dto.getRoleIdList());

25
epdc-cloud-admin/src/main/resources/mapper/SysPropertyUserDao.xml

@ -0,0 +1,25 @@
<?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.elink.esua.epdc.dao.SysPropertyUserDao">
<resultMap type="com.elink.esua.epdc.entity.SysPropertyUserEntity" id="sysPropertyUserMap">
<result property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="projectId" column="project_id"/>
<result property="creator" column="creator"/>
<result property="createDate" column="create_date"/>
</resultMap>
<update id="updateByUserId" parameterType="com.elink.esua.epdc.entity.SysPropertyUserEntity">
update yushan_esua_epdc_admin.sys_property_user
set project_id = #{projectId}
where user_id = #{userId}
</update>
<select id="selectByUserId" resultType="String">
select
project_id
from yushan_esua_epdc_admin.sys_property_user
where user_id = #{userId}
</select>
</mapper>
Loading…
Cancel
Save