wuxw
2022-08-13 e0f3768db16f55cd7b7bf5e7c66190b9c1dea4b1
优化代码
2个文件已修改
8个文件已添加
719 ■■■■■ 已修改文件
java110-bean/src/main/java/com/java110/dto/privilegeGroup/PrivilegeGroupDto.java 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-bean/src/main/java/com/java110/po/privilegeGroup/PrivilegeGroupPo.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-db/src/main/resources/mapper/user/PrivilegeGroupV1ServiceDaoImplMapper.xml 111 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-interface/src/main/java/com/java110/intf/order/IPrivilegeInnerServiceSMO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-interface/src/main/java/com/java110/intf/user/IPrivilegeGroupV1InnerServiceSMO.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-order/src/main/java/com/java110/order/smo/impl/PrivilegeInnerServiceSMOImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-user/src/main/java/com/java110/user/cmd/privilege/SavePrivilegeGroupInfoCmd.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-user/src/main/java/com/java110/user/dao/IPrivilegeGroupV1ServiceDao.java 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-user/src/main/java/com/java110/user/dao/impl/PrivilegeGroupV1ServiceDaoImpl.java 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-user/src/main/java/com/java110/user/smo/impl/PrivilegeGroupV1InnerServiceSMOImpl.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-bean/src/main/java/com/java110/dto/privilegeGroup/PrivilegeGroupDto.java
New file
@@ -0,0 +1,97 @@
package com.java110.dto.privilegeGroup;
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 PrivilegeGroupDto extends PageDto implements Serializable {
    public final static String ROLE_TYPE_USER = "USER";
    private String pgId;
    private String domain;
    private String name;
    private String description;
    private String storeId;
    private String roleType;
    private Date createTime;
    private String statusCd = "0";
    public String getPgId() {
        return pgId;
    }
    public void setPgId(String pgId) {
        this.pgId = pgId;
    }
    public String getDomain() {
        return domain;
    }
    public void setDomain(String domain) {
        this.domain = domain;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public String getStoreId() {
        return storeId;
    }
    public void setStoreId(String storeId) {
        this.storeId = storeId;
    }
    public String getRoleType() {
        return roleType;
    }
    public void setRoleType(String roleType) {
        this.roleType = roleType;
    }
    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/privilegeGroup/PrivilegeGroupPo.java
New file
@@ -0,0 +1,82 @@
/*
 * 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.privilegeGroup;
import java.io.Serializable;
import java.util.Date;
/**
 * 类表述: Po 数据模型实体对象 基本保持与数据库模型一直 用于 增加修改删除 等时的数据载体
 * add by 吴学文 at 2022-08-13 00:14:11 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 PrivilegeGroupPo implements Serializable {
    private String pgId;
private String domain;
private String name;
private String description;
private String statusCd = "0";
private String storeId;
private String roleType;
public String getPgId() {
        return pgId;
    }
public void setPgId(String pgId) {
        this.pgId = pgId;
    }
public String getDomain() {
        return domain;
    }
public void setDomain(String domain) {
        this.domain = domain;
    }
public String getName() {
        return name;
    }
public void setName(String name) {
        this.name = name;
    }
public String getDescription() {
        return description;
    }
public void setDescription(String description) {
        this.description = description;
    }
public String getStatusCd() {
        return statusCd;
    }
public void setStatusCd(String statusCd) {
        this.statusCd = statusCd;
    }
public String getStoreId() {
        return storeId;
    }
public void setStoreId(String storeId) {
        this.storeId = storeId;
    }
public String getRoleType() {
        return roleType;
    }
public void setRoleType(String roleType) {
        this.roleType = roleType;
    }
}
java110-db/src/main/resources/mapper/user/PrivilegeGroupV1ServiceDaoImplMapper.xml
New file
@@ -0,0 +1,111 @@
<?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="privilegeGroupV1ServiceDaoImpl">
    <!-- 保存角色信息 add by wuxw 2018-07-03 -->
    <insert id="savePrivilegeGroupInfo" parameterType="Map">
        insert into p_privilege_group(
        pg_id,domain,name,description,store_id,role_type
        ) values (
        #{pgId},#{domain},#{name},#{description},#{storeId},#{roleType}
        )
    </insert>
    <!-- 查询角色信息 add by wuxw 2018-07-03 -->
    <select id="getPrivilegeGroupInfo" parameterType="Map" resultType="Map">
        select t.pg_id,t.pg_id pgId,t.domain,t.name,t.description,t.status_cd,t.status_cd statusCd,t.store_id,t.store_id
        storeId,t.role_type,t.role_type roleType
        from p_privilege_group t
        where 1 =1
        <if test="pgId !=null and pgId != ''">
            and t.pg_id= #{pgId}
        </if>
        <if test="domain !=null and domain != ''">
            and t.domain= #{domain}
        </if>
        <if test="name !=null and name != ''">
            and t.name= #{name}
        </if>
        <if test="description !=null and description != ''">
            and t.description= #{description}
        </if>
        <if test="statusCd !=null and statusCd != ''">
            and t.status_cd= #{statusCd}
        </if>
        <if test="storeId !=null and storeId != ''">
            and t.store_id= #{storeId}
        </if>
        <if test="roleType !=null and roleType != ''">
            and t.role_type= #{roleType}
        </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="updatePrivilegeGroupInfo" parameterType="Map">
        update p_privilege_group t set t.status_cd = #{statusCd}
        <if test="newBId != null and newBId != ''">
            ,t.b_id = #{newBId}
        </if>
        <if test="domain !=null and domain != ''">
            , t.domain= #{domain}
        </if>
        <if test="name !=null and name != ''">
            , t.name= #{name}
        </if>
        <if test="description !=null and description != ''">
            , t.description= #{description}
        </if>
        <if test="storeId !=null and storeId != ''">
            , t.store_id= #{storeId}
        </if>
        <if test="roleType !=null and roleType != ''">
            , t.role_type= #{roleType}
        </if>
        where 1=1
        <if test="pgId !=null and pgId != ''">
            and t.pg_id= #{pgId}
        </if>
    </update>
    <!-- 查询角色数量 add by wuxw 2018-07-03 -->
    <select id="queryPrivilegeGroupsCount" parameterType="Map" resultType="Map">
        select count(1) count
        from p_privilege_group t
        where 1 =1
        <if test="pgId !=null and pgId != ''">
            and t.pg_id= #{pgId}
        </if>
        <if test="domain !=null and domain != ''">
            and t.domain= #{domain}
        </if>
        <if test="name !=null and name != ''">
            and t.name= #{name}
        </if>
        <if test="description !=null and description != ''">
            and t.description= #{description}
        </if>
        <if test="statusCd !=null and statusCd != ''">
            and t.status_cd= #{statusCd}
        </if>
        <if test="storeId !=null and storeId != ''">
            and t.store_id= #{storeId}
        </if>
        <if test="roleType !=null and roleType != ''">
            and t.role_type= #{roleType}
        </if>
    </select>
</mapper>
java110-interface/src/main/java/com/java110/intf/order/IPrivilegeInnerServiceSMO.java
@@ -24,6 +24,7 @@
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;
import java.util.Map;
/**
 * @ClassName IPrivilegeInnerServiceSMO
@@ -48,4 +49,7 @@
    @RequestMapping(value = "/queryPrivilegeUsers", method = RequestMethod.POST)
    List<UserDto> queryPrivilegeUsers(@RequestBody BasePrivilegeDto privilegeDto);
}
java110-interface/src/main/java/com/java110/intf/user/IPrivilegeGroupV1InnerServiceSMO.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.privilegeGroup.PrivilegeGroupDto;
import com.java110.po.privilegeGroup.PrivilegeGroupPo;
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:08:06 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("/privilegeGroupV1Api")
public interface IPrivilegeGroupV1InnerServiceSMO {
    @RequestMapping(value = "/savePrivilegeGroup", method = RequestMethod.POST)
    public int savePrivilegeGroup(@RequestBody PrivilegeGroupPo privilegeGroupPo);
    @RequestMapping(value = "/updatePrivilegeGroup", method = RequestMethod.POST)
    public int updatePrivilegeGroup(@RequestBody PrivilegeGroupPo privilegeGroupPo);
    @RequestMapping(value = "/deletePrivilegeGroup", method = RequestMethod.POST)
    public int deletePrivilegeGroup(@RequestBody PrivilegeGroupPo privilegeGroupPo);
    /**
     * <p>查询小区楼信息</p>
     *
     *
     * @param privilegeGroupDto 数据对象分享
     * @return PrivilegeGroupDto 对象数据
     */
    @RequestMapping(value = "/queryPrivilegeGroups", method = RequestMethod.POST)
    List<PrivilegeGroupDto> queryPrivilegeGroups(@RequestBody PrivilegeGroupDto privilegeGroupDto);
    /**
     * 查询<p>小区楼</p>总记录数
     *
     * @param privilegeGroupDto 数据对象分享
     * @return 小区下的小区楼记录数
     */
    @RequestMapping(value = "/queryPrivilegeGroupsCount", method = RequestMethod.POST)
    int queryPrivilegeGroupsCount(@RequestBody PrivilegeGroupDto privilegeGroupDto);
}
service-order/src/main/java/com/java110/order/smo/impl/PrivilegeInnerServiceSMOImpl.java
@@ -15,11 +15,14 @@
 */
package com.java110.order.smo.impl;
import com.alibaba.fastjson.JSONObject;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.basePrivilege.BasePrivilegeDto;
import com.java110.dto.user.UserDto;
import com.java110.intf.order.IPrivilegeInnerServiceSMO;
import com.java110.order.dao.IPrivilegeDAO;
import com.java110.utils.constant.ResponseConstant;
import com.java110.utils.exception.DAOException;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
@@ -45,4 +48,6 @@
        List<Map> userIds = privilegeDAOImpl.queryPrivilegeUsers(BeanConvertUtil.beanCovertMap(privilegeDto));
        return BeanConvertUtil.covertBeanList(userIds, UserDto.class);
    }
}
service-user/src/main/java/com/java110/user/cmd/privilege/SavePrivilegeGroupInfoCmd.java
New file
@@ -0,0 +1,74 @@
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 = "save.privilegeGroup.info")
public class SavePrivilegeGroupInfoCmd 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节点");
        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 {
        reqJson.put("pgId", GenerateCodeFactory.getPgId());
        PrivilegeGroupPo privilegeGroupPo = BeanConvertUtil.covertBean(reqJson,PrivilegeGroupPo.class);
        privilegeGroupPo.setDomain(reqJson.getString("storeTypeCd"));
        privilegeGroupPo.setRoleType(PrivilegeGroupDto.ROLE_TYPE_USER);
        int flag = privilegeGroupV1InnerServiceSMOImpl.savePrivilegeGroup(privilegeGroupPo);
        if(flag  < 1){
            throw new CmdException("保存失败");
        }
    }
}
service-user/src/main/java/com/java110/user/dao/IPrivilegeGroupV1ServiceDao.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:08:06 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 IPrivilegeGroupV1ServiceDao {
    /**
     * 保存 角色信息
     * @param info
     * @throws DAOException DAO异常
     */
    int savePrivilegeGroupInfo(Map info) throws DAOException;
    /**
     * 查询角色信息(instance过程)
     * 根据bId 查询角色信息
     * @param info bId 信息
     * @return 角色信息
     * @throws DAOException DAO异常
     */
    List<Map> getPrivilegeGroupInfo(Map info) throws DAOException;
    /**
     * 修改角色信息
     * @param info 修改信息
     * @throws DAOException DAO异常
     */
    int updatePrivilegeGroupInfo(Map info) throws DAOException;
    /**
     * 查询角色总数
     *
     * @param info 角色信息
     * @return 角色数量
     */
    int queryPrivilegeGroupsCount(Map info);
}
service-user/src/main/java/com/java110/user/dao/impl/PrivilegeGroupV1ServiceDaoImpl.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.IPrivilegeGroupV1ServiceDao;
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:08:06 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("privilegeGroupV1ServiceDaoImpl")
public class PrivilegeGroupV1ServiceDaoImpl extends BaseServiceDao implements IPrivilegeGroupV1ServiceDao {
    private static Logger logger = LoggerFactory.getLogger(PrivilegeGroupV1ServiceDaoImpl.class);
    /**
     * 保存角色信息 到 instance
     * @param info   bId 信息
     * @throws DAOException DAO异常
     */
    @Override
    public int savePrivilegeGroupInfo(Map info) throws DAOException {
        logger.debug("保存 savePrivilegeGroupInfo 入参 info : {}",info);
        int saveFlag = sqlSessionTemplate.insert("privilegeGroupV1ServiceDaoImpl.savePrivilegeGroupInfo",info);
        return saveFlag;
    }
    /**
     * 查询角色信息(instance)
     * @param info bId 信息
     * @return List<Map>
     * @throws DAOException DAO异常
     */
    @Override
    public List<Map> getPrivilegeGroupInfo(Map info) throws DAOException {
        logger.debug("查询 getPrivilegeGroupInfo 入参 info : {}",info);
        List<Map> businessPrivilegeGroupInfos = sqlSessionTemplate.selectList("privilegeGroupV1ServiceDaoImpl.getPrivilegeGroupInfo",info);
        return businessPrivilegeGroupInfos;
    }
    /**
     * 修改角色信息
     * @param info 修改信息
     * @throws DAOException DAO异常
     */
    @Override
    public int updatePrivilegeGroupInfo(Map info) throws DAOException {
        logger.debug("修改 updatePrivilegeGroupInfo 入参 info : {}",info);
        int saveFlag = sqlSessionTemplate.update("privilegeGroupV1ServiceDaoImpl.updatePrivilegeGroupInfo",info);
        return saveFlag;
    }
     /**
     * 查询角色数量
     * @param info 角色信息
     * @return 角色数量
     */
    @Override
    public int queryPrivilegeGroupsCount(Map info) {
        logger.debug("查询 queryPrivilegeGroupsCount 入参 info : {}",info);
        List<Map> businessPrivilegeGroupInfos = sqlSessionTemplate.selectList("privilegeGroupV1ServiceDaoImpl.queryPrivilegeGroupsCount", info);
        if (businessPrivilegeGroupInfos.size() < 1) {
            return 0;
        }
        return Integer.parseInt(businessPrivilegeGroupInfos.get(0).get("count").toString());
    }
}
service-user/src/main/java/com/java110/user/smo/impl/PrivilegeGroupV1InnerServiceSMOImpl.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.IPrivilegeGroupV1ServiceDao;
import com.java110.intf.user.IPrivilegeGroupV1InnerServiceSMO;
import com.java110.dto.privilegeGroup.PrivilegeGroupDto;
import com.java110.po.privilegeGroup.PrivilegeGroupPo;
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:08:06 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 PrivilegeGroupV1InnerServiceSMOImpl extends BaseServiceSMO implements IPrivilegeGroupV1InnerServiceSMO {
    @Autowired
    private IPrivilegeGroupV1ServiceDao privilegeGroupV1ServiceDaoImpl;
    @Override
    public int savePrivilegeGroup(@RequestBody  PrivilegeGroupPo privilegeGroupPo) {
        int saveFlag = privilegeGroupV1ServiceDaoImpl.savePrivilegeGroupInfo(BeanConvertUtil.beanCovertMap(privilegeGroupPo));
        return saveFlag;
    }
     @Override
    public int updatePrivilegeGroup(@RequestBody  PrivilegeGroupPo privilegeGroupPo) {
        int saveFlag = privilegeGroupV1ServiceDaoImpl.updatePrivilegeGroupInfo(BeanConvertUtil.beanCovertMap(privilegeGroupPo));
        return saveFlag;
    }
     @Override
    public int deletePrivilegeGroup(@RequestBody  PrivilegeGroupPo privilegeGroupPo) {
       privilegeGroupPo.setStatusCd("1");
       int saveFlag = privilegeGroupV1ServiceDaoImpl.updatePrivilegeGroupInfo(BeanConvertUtil.beanCovertMap(privilegeGroupPo));
       return saveFlag;
    }
    @Override
    public List<PrivilegeGroupDto> queryPrivilegeGroups(@RequestBody  PrivilegeGroupDto privilegeGroupDto) {
        //校验是否传了 分页信息
        int page = privilegeGroupDto.getPage();
        if (page != PageDto.DEFAULT_PAGE) {
            privilegeGroupDto.setPage((page - 1) * privilegeGroupDto.getRow());
        }
        List<PrivilegeGroupDto> privilegeGroups = BeanConvertUtil.covertBeanList(privilegeGroupV1ServiceDaoImpl.getPrivilegeGroupInfo(BeanConvertUtil.beanCovertMap(privilegeGroupDto)), PrivilegeGroupDto.class);
        return privilegeGroups;
    }
    @Override
    public int queryPrivilegeGroupsCount(@RequestBody PrivilegeGroupDto privilegeGroupDto) {
        return privilegeGroupV1ServiceDaoImpl.queryPrivilegeGroupsCount(BeanConvertUtil.beanCovertMap(privilegeGroupDto));    }
}