wuxw
2022-08-13 077ec2ba2bba2311f2f1a10f61cf1274f80aa520
优化代码
9个文件已添加
709 ■■■■■ 已修改文件
java110-bean/src/main/java/com/java110/dto/privilegeRel/PrivilegeRelDto.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-bean/src/main/java/com/java110/po/privilegeRel/PrivilegeRelPo.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-db/src/main/resources/mapper/user/PrivilegeRelV1ServiceDaoImplMapper.xml 88 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-interface/src/main/java/com/java110/intf/user/IPrivilegeRelV1InnerServiceSMO.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-user/src/main/java/com/java110/user/cmd/privilege/DeletePrivilegeGroupInfoCmd.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-user/src/main/java/com/java110/user/cmd/privilege/EditPrivilegeGroupInfoCmd.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-user/src/main/java/com/java110/user/dao/IPrivilegeRelV1ServiceDao.java 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-user/src/main/java/com/java110/user/dao/impl/PrivilegeRelV1ServiceDaoImpl.java 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-user/src/main/java/com/java110/user/smo/impl/PrivilegeRelV1InnerServiceSMOImpl.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-bean/src/main/java/com/java110/dto/privilegeRel/PrivilegeRelDto.java
New file
@@ -0,0 +1,65 @@
package com.java110.dto.privilegeRel;
import com.java110.dto.PageDto;
import java.io.Serializable;
import java.util.Date;
/**
 * @ClassName FloorDto
 * @Description 功能权限数据层封装
 * @Author wuxw
 * @Date 2019/4/24 8:52
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
public class PrivilegeRelDto extends PageDto implements Serializable {
    private String relId;
private String pgId;
private String pId;
    private Date createTime;
    private String statusCd = "0";
    public String getRelId() {
        return relId;
    }
    public void setRelId(String relId) {
        this.relId = relId;
    }
    public String getPgId() {
        return pgId;
    }
    public void setPgId(String pgId) {
        this.pgId = pgId;
    }
    public String getpId() {
        return pId;
    }
    public void setpId(String pId) {
        this.pId = pId;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getStatusCd() {
        return statusCd;
    }
    public void setStatusCd(String statusCd) {
        this.statusCd = statusCd;
    }
}
java110-bean/src/main/java/com/java110/po/privilegeRel/PrivilegeRelPo.java
New file
@@ -0,0 +1,61 @@
/*
 * Copyright 2017-2020 吴学文 and java110 team.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.java110.po.privilegeRel;
import java.io.Serializable;
import java.util.Date;
/**
 * 类表述: Po 数据模型实体对象 基本保持与数据库模型一直 用于 增加修改删除 等时的数据载体
 * add by 吴学文 at 2022-08-13 00:41:10 mail: 928255095@qq.com
 * open source address: https://gitee.com/wuxw7/MicroCommunity
 * 官网:http://www.homecommunity.cn
 * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
 * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
 */
public class PrivilegeRelPo implements Serializable {
    private String relId;
private String pgId;
private String pId;
private String statusCd = "0";
public String getRelId() {
        return relId;
    }
public void setRelId(String relId) {
        this.relId = relId;
    }
public String getPgId() {
        return pgId;
    }
public void setPgId(String pgId) {
        this.pgId = pgId;
    }
public String getPId() {
        return pId;
    }
public void setPId(String pId) {
        this.pId = pId;
    }
public String getStatusCd() {
        return statusCd;
    }
public void setStatusCd(String statusCd) {
        this.statusCd = statusCd;
    }
}
java110-db/src/main/resources/mapper/user/PrivilegeRelV1ServiceDaoImplMapper.xml
New file
@@ -0,0 +1,88 @@
<?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="privilegeRelV1ServiceDaoImpl">
    <!-- 保存功能权限信息 add by wuxw 2018-07-03 -->
    <insert id="savePrivilegeRelInfo" parameterType="Map">
        insert into p_privilege_rel(
rel_id,pg_id,p_id
) values (
#{relId},#{pgId},#{pId}
)
    </insert>
    <!-- 查询功能权限信息 add by wuxw 2018-07-03 -->
    <select id="getPrivilegeRelInfo" parameterType="Map" resultType="Map">
        select  t.rel_id,t.rel_id relId,t.pg_id,t.pg_id pgId,t.p_id,t.p_id pId,t.status_cd,t.status_cd statusCd
from p_privilege_rel t
where 1 =1
<if test="relId !=null and relId != ''">
   and t.rel_id= #{relId}
</if>
<if test="pgId !=null and pgId != ''">
   and t.pg_id= #{pgId}
</if>
<if test="pId !=null and pId != ''">
   and t.p_id= #{pId}
</if>
<if test="statusCd !=null and statusCd != ''">
   and t.status_cd= #{statusCd}
</if>
order by t.create_time desc
<if test="page != -1 and page != null ">
   limit #{page}, #{row}
</if>
    </select>
    <!-- 修改功能权限信息 add by wuxw 2018-07-03 -->
    <update id="updatePrivilegeRelInfo" parameterType="Map">
        update  p_privilege_rel t set t.status_cd = #{statusCd}
<if test="newBId != null and newBId != ''">
,t.b_id = #{newBId}
</if>
<if test="relId !=null and relId != ''">
, t.rel_id= #{relId}
</if>
<if test="pgId !=null and pgId != ''">
, t.pg_id= #{pgId}
</if>
<if test="pId !=null and pId != ''">
, t.p_id= #{pId}
</if>
 where 1=1
    </update>
    <!-- 查询功能权限数量 add by wuxw 2018-07-03 -->
     <select id="queryPrivilegeRelsCount" parameterType="Map" resultType="Map">
        select  count(1) count
from p_privilege_rel t
where 1 =1
<if test="relId !=null and relId != ''">
   and t.rel_id= #{relId}
</if>
<if test="pgId !=null and pgId != ''">
   and t.pg_id= #{pgId}
</if>
<if test="pId !=null and pId != ''">
   and t.p_id= #{pId}
</if>
<if test="statusCd !=null and statusCd != ''">
   and t.status_cd= #{statusCd}
</if>
     </select>
</mapper>
java110-interface/src/main/java/com/java110/intf/user/IPrivilegeRelV1InnerServiceSMO.java
New file
@@ -0,0 +1,68 @@
/*
 * Copyright 2017-2020 吴学文 and java110 team.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.java110.intf.user;
import com.java110.config.feign.FeignConfiguration;
import com.java110.dto.privilegeRel.PrivilegeRelDto;
import com.java110.po.privilegeRel.PrivilegeRelPo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;
/**
 * 类表述: 服务之前调用的接口类,不对外提供接口能力 只用于接口建调用
 * add by 吴学文 at 2022-08-13 00:41:10 mail: 928255095@qq.com
 * open source address: https://gitee.com/wuxw7/MicroCommunity
 * 官网:http://www.homecommunity.cn
 * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
 * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
 */
@FeignClient(name = "user-service", configuration = {FeignConfiguration.class})
@RequestMapping("/privilegeRelV1Api")
public interface IPrivilegeRelV1InnerServiceSMO {
    @RequestMapping(value = "/savePrivilegeRel", method = RequestMethod.POST)
    public int savePrivilegeRel(@RequestBody PrivilegeRelPo privilegeRelPo);
    @RequestMapping(value = "/updatePrivilegeRel", method = RequestMethod.POST)
    public int updatePrivilegeRel(@RequestBody PrivilegeRelPo privilegeRelPo);
    @RequestMapping(value = "/deletePrivilegeRel", method = RequestMethod.POST)
    public int deletePrivilegeRel(@RequestBody PrivilegeRelPo privilegeRelPo);
    /**
     * <p>查询小区楼信息</p>
     *
     *
     * @param privilegeRelDto 数据对象分享
     * @return PrivilegeRelDto 对象数据
     */
    @RequestMapping(value = "/queryPrivilegeRels", method = RequestMethod.POST)
    List<PrivilegeRelDto> queryPrivilegeRels(@RequestBody PrivilegeRelDto privilegeRelDto);
    /**
     * 查询<p>小区楼</p>总记录数
     *
     * @param privilegeRelDto 数据对象分享
     * @return 小区下的小区楼记录数
     */
    @RequestMapping(value = "/queryPrivilegeRelsCount", method = RequestMethod.POST)
    int queryPrivilegeRelsCount(@RequestBody PrivilegeRelDto privilegeRelDto);
}
service-user/src/main/java/com/java110/user/cmd/privilege/DeletePrivilegeGroupInfoCmd.java
New file
@@ -0,0 +1,80 @@
package com.java110.user.cmd.privilege;
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.dto.privilegeRel.PrivilegeRelDto;
import com.java110.dto.store.StoreDto;
import com.java110.intf.order.IPrivilegeInnerServiceSMO;
import com.java110.intf.store.IStoreV1InnerServiceSMO;
import com.java110.intf.user.IPrivilegeGroupV1InnerServiceSMO;
import com.java110.intf.user.IPrivilegeRelV1InnerServiceSMO;
import com.java110.po.privilegeGroup.PrivilegeGroupPo;
import com.java110.po.privilegeRel.PrivilegeRelPo;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import java.text.ParseException;
import java.util.List;
@Java110Cmd(serviceCode = "delete.privilegeGroup.info")
public class DeletePrivilegeGroupInfoCmd extends Cmd{
    @Autowired
    private IStoreV1InnerServiceSMO storeV1InnerServiceSMOImpl;
    @Autowired
    private IPrivilegeInnerServiceSMO privilegeInnerServiceSMOImpl;
    @Autowired
    private IPrivilegeGroupV1InnerServiceSMO privilegeGroupV1InnerServiceSMOImpl;
    @Autowired
    private IPrivilegeRelV1InnerServiceSMO privilegeRelV1InnerServiceSMOImpl;
    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
        Assert.hasKeyAndValue(reqJson,"pgId","角色不存在");
    }
    @Override
    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
        PrivilegeGroupPo privilegeGroupPo = BeanConvertUtil.covertBean(reqJson,PrivilegeGroupPo.class);
        int flag = privilegeGroupV1InnerServiceSMOImpl.deletePrivilegeGroup(privilegeGroupPo);
        if(flag  < 1){
            throw new CmdException("删除失败");
        }
        PrivilegeRelDto privilegeRelDto = new PrivilegeRelDto();
        privilegeRelDto.setPgId(reqJson.getString("pgId"));
        List<PrivilegeRelDto> privilegeRelDtos = privilegeRelV1InnerServiceSMOImpl.queryPrivilegeRels(privilegeRelDto);
        if(privilegeRelDtos == null || privilegeRelDtos.size()<1){
            return ;
        }
        PrivilegeRelPo privilegeRelPo = null;
        for(PrivilegeRelDto tmpPrivilegeDto: privilegeRelDtos){
            privilegeRelPo = new PrivilegeRelPo();
            privilegeRelPo.setRelId(tmpPrivilegeDto.getRelId());
            flag = privilegeRelV1InnerServiceSMOImpl.deletePrivilegeRel(privilegeRelPo);
            if(flag <1){
                throw new CmdException("删除失败");
            }
        }
    }
}
service-user/src/main/java/com/java110/user/cmd/privilege/EditPrivilegeGroupInfoCmd.java
New file
@@ -0,0 +1,69 @@
package com.java110.user.cmd.privilege;
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.dto.privilegeGroup.PrivilegeGroupDto;
import com.java110.dto.store.StoreDto;
import com.java110.intf.order.IPrivilegeInnerServiceSMO;
import com.java110.intf.store.IStoreV1InnerServiceSMO;
import com.java110.intf.user.IPrivilegeGroupV1InnerServiceSMO;
import com.java110.po.privilegeGroup.PrivilegeGroupPo;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import java.text.ParseException;
import java.util.List;
@Java110Cmd(serviceCode = "edit.privilegeGroup.info")
public class EditPrivilegeGroupInfoCmd extends Cmd{
    @Autowired
    private IStoreV1InnerServiceSMO storeV1InnerServiceSMOImpl;
    @Autowired
    private IPrivilegeInnerServiceSMO privilegeInnerServiceSMOImpl;
    @Autowired
    private IPrivilegeGroupV1InnerServiceSMO privilegeGroupV1InnerServiceSMOImpl;
    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
        Assert.jsonObjectHaveKey(reqJson, "name", "请求报文中未包含name节点");
        Assert.hasKeyAndValue(reqJson,"pgId","角色不存在");
        String storeId = context.getReqHeaders().get("store-id");
        StoreDto storeDto = new StoreDto();
        storeDto.setStoreId(storeId);
        storeDto.setPage(1);
        storeDto.setRow(1);
        List<StoreDto> storeDtos = storeV1InnerServiceSMOImpl.queryStores(storeDto);
        Assert.listOnlyOne(storeDtos,"商户不存在");
        reqJson.put("storeId",storeDtos.get(0).getStoreId());
        reqJson.put("storeTypeCd",storeDtos.get(0).getStoreTypeCd());
    }
    @Override
    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
        PrivilegeGroupPo privilegeGroupPo = BeanConvertUtil.covertBean(reqJson,PrivilegeGroupPo.class);
        int flag = privilegeGroupV1InnerServiceSMOImpl.updatePrivilegeGroup(privilegeGroupPo);
        if(flag  < 1){
            throw new CmdException("保存失败");
        }
    }
}
service-user/src/main/java/com/java110/user/dao/IPrivilegeRelV1ServiceDao.java
New file
@@ -0,0 +1,77 @@
/*
 * Copyright 2017-2020 吴学文 and java110 team.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.java110.user.dao;
import com.java110.utils.exception.DAOException;
import com.java110.entity.merchant.BoMerchant;
import com.java110.entity.merchant.BoMerchantAttr;
import com.java110.entity.merchant.Merchant;
import com.java110.entity.merchant.MerchantAttr;
import java.util.List;
import java.util.Map;
/**
 * 类表述:
 * add by 吴学文 at 2022-08-13 00:41:10 mail: 928255095@qq.com
 * open source address: https://gitee.com/wuxw7/MicroCommunity
 * 官网:http://www.homecommunity.cn
 * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
 * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
 */
public interface IPrivilegeRelV1ServiceDao {
    /**
     * 保存 功能权限信息
     * @param info
     * @throws DAOException DAO异常
     */
    int savePrivilegeRelInfo(Map info) throws DAOException;
    /**
     * 查询功能权限信息(instance过程)
     * 根据bId 查询功能权限信息
     * @param info bId 信息
     * @return 功能权限信息
     * @throws DAOException DAO异常
     */
    List<Map> getPrivilegeRelInfo(Map info) throws DAOException;
    /**
     * 修改功能权限信息
     * @param info 修改信息
     * @throws DAOException DAO异常
     */
    int updatePrivilegeRelInfo(Map info) throws DAOException;
    /**
     * 查询功能权限总数
     *
     * @param info 功能权限信息
     * @return 功能权限数量
     */
    int queryPrivilegeRelsCount(Map info);
}
service-user/src/main/java/com/java110/user/dao/impl/PrivilegeRelV1ServiceDaoImpl.java
New file
@@ -0,0 +1,112 @@
/*
 * Copyright 2017-2020 吴学文 and java110 team.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.java110.user.dao.impl;
import com.alibaba.fastjson.JSONObject;
import com.java110.utils.constant.ResponseConstant;
import com.java110.utils.exception.DAOException;
import com.java110.utils.util.DateUtil;
import com.java110.core.base.dao.BaseServiceDao;
import com.java110.user.dao.IPrivilegeRelV1ServiceDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
 * 类表述:
 * add by 吴学文 at 2022-08-13 00:41:10 mail: 928255095@qq.com
 * open source address: https://gitee.com/wuxw7/MicroCommunity
 * 官网:http://www.homecommunity.cn
 * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
 * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
 */
@Service("privilegeRelV1ServiceDaoImpl")
public class PrivilegeRelV1ServiceDaoImpl extends BaseServiceDao implements IPrivilegeRelV1ServiceDao {
    private static Logger logger = LoggerFactory.getLogger(PrivilegeRelV1ServiceDaoImpl.class);
    /**
     * 保存功能权限信息 到 instance
     * @param info   bId 信息
     * @throws DAOException DAO异常
     */
    @Override
    public int savePrivilegeRelInfo(Map info) throws DAOException {
        logger.debug("保存 savePrivilegeRelInfo 入参 info : {}",info);
        int saveFlag = sqlSessionTemplate.insert("privilegeRelV1ServiceDaoImpl.savePrivilegeRelInfo",info);
        return saveFlag;
    }
    /**
     * 查询功能权限信息(instance)
     * @param info bId 信息
     * @return List<Map>
     * @throws DAOException DAO异常
     */
    @Override
    public List<Map> getPrivilegeRelInfo(Map info) throws DAOException {
        logger.debug("查询 getPrivilegeRelInfo 入参 info : {}",info);
        List<Map> businessPrivilegeRelInfos = sqlSessionTemplate.selectList("privilegeRelV1ServiceDaoImpl.getPrivilegeRelInfo",info);
        return businessPrivilegeRelInfos;
    }
    /**
     * 修改功能权限信息
     * @param info 修改信息
     * @throws DAOException DAO异常
     */
    @Override
    public int updatePrivilegeRelInfo(Map info) throws DAOException {
        logger.debug("修改 updatePrivilegeRelInfo 入参 info : {}",info);
        int saveFlag = sqlSessionTemplate.update("privilegeRelV1ServiceDaoImpl.updatePrivilegeRelInfo",info);
        return saveFlag;
    }
     /**
     * 查询功能权限数量
     * @param info 功能权限信息
     * @return 功能权限数量
     */
    @Override
    public int queryPrivilegeRelsCount(Map info) {
        logger.debug("查询 queryPrivilegeRelsCount 入参 info : {}",info);
        List<Map> businessPrivilegeRelInfos = sqlSessionTemplate.selectList("privilegeRelV1ServiceDaoImpl.queryPrivilegeRelsCount", info);
        if (businessPrivilegeRelInfos.size() < 1) {
            return 0;
        }
        return Integer.parseInt(businessPrivilegeRelInfos.get(0).get("count").toString());
    }
}
service-user/src/main/java/com/java110/user/smo/impl/PrivilegeRelV1InnerServiceSMOImpl.java
New file
@@ -0,0 +1,89 @@
/*
 * Copyright 2017-2020 吴学文 and java110 team.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.java110.user.smo.impl;
import com.java110.user.dao.IPrivilegeRelV1ServiceDao;
import com.java110.intf.user.IPrivilegeRelV1InnerServiceSMO;
import com.java110.dto.privilegeRel.PrivilegeRelDto;
import com.java110.po.privilegeRel.PrivilegeRelPo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.user.UserDto;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
 * 类表述: 服务之前调用的接口实现类,不对外提供接口能力 只用于接口建调用
 * add by 吴学文 at 2022-08-13 00:41:10 mail: 928255095@qq.com
 * open source address: https://gitee.com/wuxw7/MicroCommunity
 * 官网:http://www.homecommunity.cn
 * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
 * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
 */
@RestController
public class PrivilegeRelV1InnerServiceSMOImpl extends BaseServiceSMO implements IPrivilegeRelV1InnerServiceSMO {
    @Autowired
    private IPrivilegeRelV1ServiceDao privilegeRelV1ServiceDaoImpl;
    @Override
    public int savePrivilegeRel(@RequestBody  PrivilegeRelPo privilegeRelPo) {
        int saveFlag = privilegeRelV1ServiceDaoImpl.savePrivilegeRelInfo(BeanConvertUtil.beanCovertMap(privilegeRelPo));
        return saveFlag;
    }
     @Override
    public int updatePrivilegeRel(@RequestBody  PrivilegeRelPo privilegeRelPo) {
        int saveFlag = privilegeRelV1ServiceDaoImpl.updatePrivilegeRelInfo(BeanConvertUtil.beanCovertMap(privilegeRelPo));
        return saveFlag;
    }
     @Override
    public int deletePrivilegeRel(@RequestBody  PrivilegeRelPo privilegeRelPo) {
       privilegeRelPo.setStatusCd("1");
       int saveFlag = privilegeRelV1ServiceDaoImpl.updatePrivilegeRelInfo(BeanConvertUtil.beanCovertMap(privilegeRelPo));
       return saveFlag;
    }
    @Override
    public List<PrivilegeRelDto> queryPrivilegeRels(@RequestBody  PrivilegeRelDto privilegeRelDto) {
        //校验是否传了 分页信息
        int page = privilegeRelDto.getPage();
        if (page != PageDto.DEFAULT_PAGE) {
            privilegeRelDto.setPage((page - 1) * privilegeRelDto.getRow());
        }
        List<PrivilegeRelDto> privilegeRels = BeanConvertUtil.covertBeanList(privilegeRelV1ServiceDaoImpl.getPrivilegeRelInfo(BeanConvertUtil.beanCovertMap(privilegeRelDto)), PrivilegeRelDto.class);
        return privilegeRels;
    }
    @Override
    public int queryPrivilegeRelsCount(@RequestBody PrivilegeRelDto privilegeRelDto) {
        return privilegeRelV1ServiceDaoImpl.queryPrivilegeRelsCount(BeanConvertUtil.beanCovertMap(privilegeRelDto));    }
}