Forráskód Böngészése

feat:托管邮箱配置管理开发

chenjianhua 3 hete
szülő
commit
85e7a83acd

+ 23 - 0
service-base/src/main/java/com/simuwang/base/mapper/daq/HostedEmailInfoMapper.java

@@ -0,0 +1,23 @@
+package com.simuwang.base.mapper.daq;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.simuwang.base.pojo.dos.HostedEmailInfoDO;
+import com.simuwang.base.pojo.dto.query.HostedEmailPageQuery;
+import com.smppw.common.pojo.ResultVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface HostedEmailInfoMapper extends BaseMapper<HostedEmailInfoDO> {
+    HostedEmailInfoDO selectHostedEmailInfoDO(@Param("companyId") String companyId, @Param("email") String email);
+
+    void saveHostedEmailInfoDO(HostedEmailInfoDO hostedEmailInfoDO);
+
+    void deleteHostEmail(@Param("idList") List<Integer> idList, @Param("userId")Integer userId);
+
+    List<HostedEmailInfoDO> searchHostEmailPage(HostedEmailPageQuery hostedEmailPageQuery);
+
+    long countHostEmailPage(HostedEmailPageQuery hostedEmailPageQuery);
+}

+ 71 - 0
service-base/src/main/java/com/simuwang/base/pojo/dos/HostedEmailInfoDO.java

@@ -0,0 +1,71 @@
+package com.simuwang.base.pojo.dos;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.simuwang.base.common.util.DateUtils;
+import com.simuwang.base.pojo.vo.HostedEmailInfoVO;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@TableName("hosted_email_info")
+public class HostedEmailInfoDO {
+    /**
+     * ID
+     */
+    @TableId(value = "id",type = IdType.AUTO)
+    private Integer id;
+    /**
+     * 公司ID
+     */
+    @TableField("company_id")
+    private String companyId;
+    /**
+     * 公司名称
+     */
+    @TableField(exist = false)
+    private String companyName;
+    /**
+     * 托管邮箱
+     */
+    @TableField("email")
+    private String email;
+    /**
+     * 托管邮箱
+     */
+    @TableField("open_status")
+    private Integer openStatus;
+
+    @TableField("isvalid")
+    private Integer isvalid;
+
+    @TableField("createtime")
+    private Date createTime;
+
+    @TableField("updatetime")
+    private Date updateTime;
+
+    @TableField("creatorid")
+    private Integer creatorId;
+
+    @TableField("updaterid")
+    private Integer updaterId;
+
+    public HostedEmailInfoVO toVO() {
+        HostedEmailInfoVO vo = new HostedEmailInfoVO();
+        vo.setId(id);
+        vo.setCompanyId(companyId);
+        vo.setCompanyName(companyName);
+        vo.setEmail(email);
+        vo.setOpenStatus(openStatus);
+        vo.setIsvalid(isvalid);
+        vo.setCreatorId(creatorId);
+        vo.setUpdaterId(updaterId);
+        vo.setCreateTime(DateUtils.format(createTime, "yyyy-MM-dd HH:mm:ss"));
+        vo.setUpdateTime(DateUtils.format(createTime, "yyyy-MM-dd HH:mm:ss"));
+        return vo;
+    }
+}

+ 36 - 0
service-base/src/main/java/com/simuwang/base/pojo/dto/query/HostedEmailPageQuery.java

@@ -0,0 +1,36 @@
+package com.simuwang.base.pojo.dto.query;
+
+import com.simuwang.base.common.support.query.PageQuery;
+
+public class HostedEmailPageQuery extends PageQuery {
+
+    private String companyName;
+
+    private String email ;
+
+    private Integer openStatus;
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    public Integer getOpenStatus() {
+        return openStatus;
+    }
+
+    public void setOpenStatus(Integer openStatus) {
+        this.openStatus = openStatus;
+    }
+}

+ 37 - 0
service-base/src/main/java/com/simuwang/base/pojo/vo/HostedEmailInfoVO.java

@@ -0,0 +1,37 @@
+package com.simuwang.base.pojo.vo;
+
+import lombok.Data;
+
+@Data
+public class HostedEmailInfoVO {
+    /**
+     * ID
+     */
+    private Integer id;
+    /**
+     * 公司ID
+     */
+    private String companyId;
+    /**
+     * 公司名称
+     */
+    private String companyName;
+    /**
+     * 托管邮箱
+     */
+    private String email;
+    /**
+     * 托管邮箱
+     */
+    private Integer openStatus;
+
+    private Integer isvalid;
+
+    private String createTime;
+
+    private String updateTime;
+
+    private Integer creatorId;
+
+    private Integer updaterId;
+}

+ 87 - 0
service-base/src/main/resources/mapper/daq/HostedEmailInfoMapper.xml

@@ -0,0 +1,87 @@
+<?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.simuwang.base.mapper.daq.HostedEmailInfoMapper">
+    <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.HostedEmailInfoDO" >
+        <id column="id" property="id" jdbcType="INTEGER" />
+        <result column="company_id" property="companyId" jdbcType="VARCHAR" />
+        <result column="company_name" property="companyName" jdbcType="VARCHAR" />
+        <result column="email" property="email" jdbcType="VARCHAR" />
+        <result column="creatorid" property="creatorId" jdbcType="INTEGER" />
+        <result column="createtime" property="createTime" jdbcType="TIMESTAMP" />
+        <result column="updaterid" property="updaterId" jdbcType="INTEGER" />
+        <result column="updatetime" property="updateTime" jdbcType="TIMESTAMP" />
+        <result column="isvalid" property="isvalid" jdbcType="INTEGER" />
+        <result column="open_status" property="openStatus" jdbcType="INTEGER" />
+    </resultMap>
+    <insert id="saveHostedEmailInfoDO">
+        insert into hosted_email_info(company_id,email,creatorid,createtime,updaterid,updatetime,isvalid,open_status)
+        values
+            (#{companyId},#{email},#{creatorId},#{createTime},#{updaterId},#{updateTime},#{isvalid},#{openStatus})
+    </insert>
+    <update id="deleteHostEmail">
+        update hosted_email_info set isvalid=0,updaterid=#{userId} where id in
+        <foreach item="id" collection="idList" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+    <select id="selectHostedEmailInfoDO" resultMap="BaseResultMap">
+        select hei.id,
+               hei.company_id,
+               ci.company_name,
+               hei.open_status,
+               hei.email,
+               hei.creatorid,
+               hei.createtime,
+               hei.updaterid,
+               hei.updatetime,
+               hei.isvalid
+        from hosted_email_info hei
+        join pvn_company_info ci
+        on ci.company_id = hei.company_id
+        where hei.isvalid=1 and ci.isvalid=1 and hei.company_id =#{companyId} and hei.email=#{email}
+    </select>
+    <select id="searchHostEmailPage" resultMap="BaseResultMap">
+        select hei.id,
+        hei.company_id,
+        ci.company_name,
+        hei.email,
+        hei.open_status,
+        hei.creatorid,
+        hei.createtime,
+        hei.updaterid,
+        hei.updatetime,
+        hei.isvalid
+        from hosted_email_info hei
+                 join pvn_company_info ci
+                      on ci.company_id = hei.company_id
+        where hei.isvalid=1 and ci.isvalid=1
+        <if test="companyName != null and companyName != ''">
+            and (ci.company_name like concat(#{companyName},'%') or ci.company_short_name like concat(#{companyName},'%'))
+        </if>
+        <if test="email != null and email != ''">
+            and hei.email like concat(#{email},'%')
+        </if>
+        <if test="openStatus != null">
+            and hei.open_status =#{openStatus}
+        </if>
+        limit #{offset},#{pageSize}
+    </select>
+    <select id="countHostEmailPage" resultType="java.lang.Long">
+        select count(hei.id)
+        from hosted_email_info hei
+        join pvn_company_info ci
+        on ci.company_id = hei.company_id
+        where hei.isvalid=1 and ci.isvalid=1
+        <if test="companyName != null and companyName != ''">
+            and (ci.company_name like concat(#{companyName},'%') or ci.company_short_name like concat(#{companyName},'%'))
+        </if>
+        <if test="email != null and email != ''">
+            and hei.email like concat(#{email},'%')
+        </if>
+        <if test="openStatus != null">
+            and hei.open_status =#{openStatus}
+        </if>
+    </select>
+
+
+</mapper>

+ 34 - 0
service-base/src/main/resources/mapper/daq/UserChannelMappingMapper.xml

@@ -0,0 +1,34 @@
+<?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.simuwang.base.mapper.daq.UserChannelMappingMapper" >
+  <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.UserChannelMappingDO" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    <id column="ID" property="id" jdbcType="INTEGER" />
+    <result column="USER_ID" property="userId" jdbcType="INTEGER" />
+    <result column="CHANNEL_ID" property="channelId" jdbcType="INTEGER" />
+    <result column="ISVALID" property="isvalid" jdbcType="INTEGER" />
+    <result column="CREATETIME" property="createtime" jdbcType="TIMESTAMP" />
+    <result column="UPDATETIME" property="updatetime" jdbcType="TIMESTAMP" />
+    <result column="CREATORID" property="creatorid" jdbcType="INTEGER" />
+    <result column="UPDATERID" property="updaterid" jdbcType="INTEGER" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    ID, USER_ID, CHANNEL_ID, ISVALID, CREATETIME, UPDATETIME, CREATORID, UPDATERID
+  </sql>
+  <update id="removeUserChannel">
+    update user_channel_mapping set isvalid=0,updatetime=now(),updaterid=#{loginUserId} where user_id=#{userId} and isvalid=1
+  </update>
+  <select id="selectUserChannelMappingDO" resultMap="BaseResultMap">
+    select <include refid="Base_Column_List"></include> from user_channel_mapping where user_id=#{userId} and channel_id=#{channelId} and isvalid=1
+  </select>
+  <select id="getUserChannelId" resultType="java.lang.Integer">
+    select channel_id from user_channel_mapping where user_id=#{userId} and isvalid=1
+  </select>
+</mapper>

+ 62 - 0
service-manage/src/main/java/com/simuwang/manage/api/hostedEmail/HostedEmailController.java

@@ -0,0 +1,62 @@
+package com.simuwang.manage.api.hostedEmail;
+
+import com.simuwang.base.common.support.MybatisPage;
+import com.simuwang.base.pojo.dto.query.ChannelIdPageQuery;
+import com.simuwang.base.pojo.dto.query.ChannelPageQuery;
+import com.simuwang.base.pojo.dto.query.HostedEmailPageQuery;
+import com.simuwang.base.pojo.vo.*;
+import com.simuwang.logging.SystemLog;
+import com.simuwang.manage.service.ChannelService;
+import com.simuwang.manage.service.HostedEmailService;
+import com.smppw.common.pojo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@SystemLog(value = "渠道管理")
+@RestController
+@RequestMapping("/v1/hosted-email")
+public class HostedEmailController {
+    @Autowired
+    private HostedEmailService hostedEmailService;
+
+    /**
+     * 保存托管信息
+     * @param hostedEmailInfoVO
+     * @return
+     */
+    @SystemLog(value = "保存托管邮箱信息", type = SystemLog.Type.INSERT)
+    @PostMapping("save-hosted-email")
+    public ResultVo saveHostEmail(@RequestBody HostedEmailInfoVO hostedEmailInfoVO) {
+        ResultVo vo = hostedEmailService.saveHostEmail(hostedEmailInfoVO);
+        return vo;
+    }
+
+    /**
+     * 删除托管信息
+     * @param idListVO
+     * @return
+     */
+    @SystemLog(value = "删除托管信息", type = SystemLog.Type.INSERT)
+    @PostMapping("delete-hosted-email")
+    public ResultVo deleteHostEmail(@RequestBody IdListVO idListVO) {
+        ResultVo vo = hostedEmailService.deleteHostEmail(idListVO.getIdList());
+        return vo;
+    }
+
+    /**
+     * 查询渠道信息
+     * @param  hostedEmailPageQuery
+     * @return
+     */
+    @SystemLog(value = "查询渠道信息")
+    @RequestMapping("search-hosted-email-page")
+    public MybatisPage<HostedEmailInfoVO> searchHostEmailPage(HostedEmailPageQuery hostedEmailPageQuery){
+        MybatisPage<HostedEmailInfoVO> result = hostedEmailService.searchHostEmailPage(hostedEmailPageQuery);
+        return result;
+    }
+}

+ 16 - 0
service-manage/src/main/java/com/simuwang/manage/service/HostedEmailService.java

@@ -0,0 +1,16 @@
+package com.simuwang.manage.service;
+
+import com.simuwang.base.common.support.MybatisPage;
+import com.simuwang.base.pojo.dto.query.HostedEmailPageQuery;
+import com.simuwang.base.pojo.vo.HostedEmailInfoVO;
+import com.smppw.common.pojo.ResultVo;
+
+import java.util.List;
+
+public interface HostedEmailService {
+    ResultVo saveHostEmail(HostedEmailInfoVO hostedEmailInfoVO);
+
+    ResultVo deleteHostEmail(List<Integer> idList);
+
+    MybatisPage<HostedEmailInfoVO> searchHostEmailPage(HostedEmailPageQuery hostedEmailPageQuery);
+}

+ 72 - 0
service-manage/src/main/java/com/simuwang/manage/service/impl/HostedEmailServiceImpl.java

@@ -0,0 +1,72 @@
+package com.simuwang.manage.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.simuwang.base.common.support.MybatisPage;
+import com.simuwang.base.mapper.daq.HostedEmailInfoMapper;
+import com.simuwang.base.pojo.dos.ChannelInfoDO;
+import com.simuwang.base.pojo.dos.ChannelPageInfoDO;
+import com.simuwang.base.pojo.dos.HostedEmailInfoDO;
+import com.simuwang.base.pojo.dto.query.HostedEmailPageQuery;
+import com.simuwang.base.pojo.vo.ChannelPageInfoVO;
+import com.simuwang.base.pojo.vo.HostedEmailInfoVO;
+import com.simuwang.manage.service.HostedEmailService;
+import com.simuwang.shiro.utils.UserUtils;
+import com.smppw.common.pojo.ResultVo;
+import com.smppw.common.pojo.enums.status.ResultCode;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+@Service
+public class HostedEmailServiceImpl implements HostedEmailService {
+    @Autowired
+    private HostedEmailInfoMapper hostedEmailInfoMapper;
+
+    @Override
+    public ResultVo saveHostEmail(HostedEmailInfoVO hostedEmailInfoVO) {
+        ResultVo vo = new ResultVo(ResultCode.SAVE_SUCCESS.getCode());
+        Integer userId = UserUtils.getLoginUser().getUserId();
+        HostedEmailInfoDO hostedEmailInfoDO = BeanUtil.copyProperties(hostedEmailInfoVO,HostedEmailInfoDO.class);
+        hostedEmailInfoDO.setUpdateTime(new Date());
+        hostedEmailInfoDO.setUpdaterId(userId);
+        hostedEmailInfoDO.setIsvalid(1);
+        if(hostedEmailInfoDO.getId() == null){
+            //判断渠道是否已经存在
+            HostedEmailInfoDO oldHostedEmailInfoDO = hostedEmailInfoMapper.selectHostedEmailInfoDO(hostedEmailInfoDO.getCompanyId(),hostedEmailInfoDO.getEmail());
+            if(oldHostedEmailInfoDO != null){
+                vo.setCode(ResultCode.SAVE_FAILED.getCode());
+                vo.setMsg("托管机构邮箱已经存在无需添加");
+                vo.setData(false);
+                return vo;
+            }
+            hostedEmailInfoDO.setCreatorId(userId);
+            hostedEmailInfoDO.setCreateTime(new Date());
+            hostedEmailInfoMapper.saveHostedEmailInfoDO(hostedEmailInfoDO);
+        }else{
+            hostedEmailInfoMapper.updateById(hostedEmailInfoDO);
+        }
+        vo.setData(true);
+        return vo;
+    }
+
+    @Override
+    public ResultVo deleteHostEmail(List<Integer> idList) {
+        ResultVo vo = new ResultVo(ResultCode.DELETE_SUCCESS.getCode());
+        Integer userId = UserUtils.getLoginUser().getUserId();
+        hostedEmailInfoMapper.deleteHostEmail(idList,userId);
+        vo.setData(true);
+        return vo;
+    }
+
+    @Override
+    public MybatisPage<HostedEmailInfoVO> searchHostEmailPage(HostedEmailPageQuery hostedEmailPageQuery) {
+        List<HostedEmailInfoDO> dataList = hostedEmailInfoMapper.searchHostEmailPage(hostedEmailPageQuery);
+        List<HostedEmailInfoVO> voList = dataList.stream().filter(Objects::nonNull).map(HostedEmailInfoDO::toVO).collect(Collectors.toList());
+        long total = hostedEmailInfoMapper.countHostEmailPage(hostedEmailPageQuery);
+        return MybatisPage.of(total, voList);
+    }
+}