7 changed files with 355 additions and 5 deletions
@ -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); |
||||
|
|
||||
|
|
||||
|
} |
@ -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; |
||||
|
|
||||
|
|
||||
|
} |
@ -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); |
||||
|
} |
@ -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); |
||||
|
} |
||||
|
|
||||
|
} |
@ -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…
Reference in new issue