Sfoglia il codice sorgente

新增营销团队

anderx 1 anno fa
parent
commit
41a37a46ed

+ 85 - 0
src/main/java/com/goafanti/common/dao/SalesTeamMapper.java

@@ -0,0 +1,85 @@
+package com.goafanti.common.dao;
+
+import com.goafanti.common.model.SalesTeam;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+
+/**
+ * 营销团队(SalesTeam)表数据库访问层
+ *
+ * @author makejava
+ * @since 2024-12-09 10:59:45
+ */
+public interface SalesTeamMapper {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    SalesTeam queryById(Integer id);
+
+
+    /**
+     * 查询指定行数据
+     *
+     * @param salesTeam 查询条件
+     * @param pageable  分页对象
+     * @return 对象列表
+     */
+    List<SalesTeam> findSalesTeamList(SalesTeam salesTeam, @Param("pageable") Pageable pageable);
+
+    /**
+     * 统计总行数
+     *
+     * @param salesTeam 查询条件
+     * @return 总行数
+     */
+    int findSalesTeamCount(SalesTeam salesTeam);
+
+    /**
+     * 新增数据
+     *
+     * @param salesTeam 实例对象
+     * @return 影响行数
+     */
+    int insert(SalesTeam salesTeam);
+
+    /**
+     * 批量新增数据(MyBatis原生foreach方法)
+     *
+     * @param entities List<SalesTeam> 实例对象列表
+     * @return 影响行数
+     */
+    int insertBatch(@Param("entities") List<SalesTeam> entities);
+
+    /**
+     * 批量新增或按主键更新数据(MyBatis原生foreach方法)
+     *
+     * @param entities List<SalesTeam> 实例对象列表
+     * @return 影响行数
+     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
+     */
+    int insertOrUpdateBatch(@Param("entities") List<SalesTeam> entities);
+
+    /**
+     * 修改数据
+     *
+     * @param salesTeam 实例对象
+     * @return 影响行数
+     */
+    int update(SalesTeam salesTeam);
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 影响行数
+     */
+    int deleteById(Integer id);
+
+}
+

+ 166 - 0
src/main/java/com/goafanti/common/mapper/SalesTeamMapper.xml

@@ -0,0 +1,166 @@
+<?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.goafanti.common.dao.SalesTeamMapper">
+
+    <resultMap type="com.goafanti.common.model.SalesTeam" id="SalesTeamMap">
+        <result property="id" column="id" jdbcType="INTEGER"/>
+        <result property="name" column="name" jdbcType="VARCHAR"/>
+        <result property="aid" column="aid" jdbcType="VARCHAR"/>
+        <result property="lvl" column="lvl" jdbcType="INTEGER"/>
+        <result property="depId" column="dep_id" jdbcType="VARCHAR"/>
+        <result property="superId" column="super_id" jdbcType="INTEGER"/>
+        <result property="status" column="status" jdbcType="INTEGER"/>
+        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="SalesTeamAllSql">
+        id, name, aid, lvl, dep_id, super_id, status, create_time
+    </sql>
+
+    <!--查询单个-->
+    <select id="queryById" resultMap="SalesTeamMap">
+        select
+        <include refid="SalesTeamAllSql"/>
+        from sales_team
+        where id = #{id}
+    </select>
+
+    <!--查询指定行数据-->
+    <select id="findSalesTeamList" resultMap="SalesTeamMap">
+        select
+        <include refid="SalesTeamAllSql"/>
+
+        from sales_team
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="name != null and name != ''">
+                and name = #{name}
+            </if>
+            <if test="aid != null and aid != ''">
+                and aid = #{aid}
+            </if>
+            <if test="lvl != null">
+                and lvl = #{lvl}
+            </if>
+            <if test="depId != null and depId != ''">
+                and dep_id = #{depId}
+            </if>
+            <if test="superId != null">
+                and super_id = #{superId}
+            </if>
+            <if test="status != null">
+                and status = #{status}
+            </if>
+            <if test="createTime != null">
+                and create_time = #{createTime}
+            </if>
+        </where>
+        <if test="page_sql != null">
+            ${page_sql}
+        </if>
+    </select>
+
+    <!--统计总行数-->
+    <select id="findSalesTeamCount" resultType="java.lang.Integer">
+        select count(1)
+        from sales_team
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="name != null and name != ''">
+                and name = #{name}
+            </if>
+            <if test="aid != null and aid != ''">
+                and aid = #{aid}
+            </if>
+            <if test="lvl != null">
+                and lvl = #{lvl}
+            </if>
+            <if test="depId != null and depId != ''">
+                and dep_id = #{depId}
+            </if>
+            <if test="superId != null">
+                and super_id = #{superId}
+            </if>
+            <if test="status != null">
+                and status = #{status}
+            </if>
+            <if test="createTime != null">
+                and create_time = #{createTime}
+            </if>
+        </where>
+    </select>
+
+    <!--新增所有列-->
+    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
+        insert into sales_team(name, aid, lvl, dep_id, super_id, status, create_time)
+        values (#{name}, #{aid}, #{lvl}, #{depId}, #{superId}, #{status}, #{createTime})
+    </insert>
+
+    <insert id="insertBatch">
+        insert into sales_team(name, aid, lvl, dep_id, super_id, status, create_time)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+            (#{entity.name}, #{entity.aid}, #{entity.lvl}, #{entity.depId}, #{entity.superId}, #{entity.status},
+            #{entity.createTime})
+        </foreach>
+    </insert>
+
+    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
+        insert into sales_team(name, aid, lvl, dep_id, super_id, status, create_time)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+            (#{entity.name}, #{entity.aid}, #{entity.lvl}, #{entity.depId}, #{entity.superId}, #{entity.status},
+            #{entity.createTime})
+        </foreach>
+        on duplicate key update
+        name = values(name),
+        aid = values(aid),
+        lvl = values(lvl),
+        dep_id = values(dep_id),
+        super_id = values(super_id),
+        status = values(status),
+        create_time = values(create_time)
+    </insert>
+
+    <!--通过主键修改数据-->
+    <update id="update">
+        update sales_team
+        <set>
+            <if test="name != null and name != ''">
+                name = #{name},
+            </if>
+            <if test="aid != null and aid != ''">
+                aid = #{aid},
+            </if>
+            <if test="lvl != null">
+                lvl = #{lvl},
+            </if>
+            <if test="depId != null and depId != ''">
+                dep_id = #{depId},
+            </if>
+            <if test="superId != null">
+                super_id = #{superId},
+            </if>
+            <if test="status != null">
+                status = #{status},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
+
+    <!--通过主键删除-->
+    <delete id="deleteById">
+        delete
+        from sales_team
+        where id = #{id}
+    </delete>
+
+</mapper>
+

+ 114 - 0
src/main/java/com/goafanti/common/model/SalesTeam.java

@@ -0,0 +1,114 @@
+package com.goafanti.common.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * 营销团队(SalesTeam)实体类
+ *
+ * @author makejava
+ * @since 2024-12-09 10:59:45
+ */
+public class SalesTeam implements Serializable {
+    private static final long serialVersionUID = 745174932950662005L;
+    /**
+     * id
+     */
+    private Integer id;
+    /**
+     * 团队名称
+     */
+    private String name;
+    /**
+     * 团队队长编号
+     */
+    private String aid;
+    /**
+     * 等级 0=无,1=一级,2=二级,3=三级
+     */
+    private Integer lvl;
+    /**
+     * 部门编号
+     */
+    private String depId;
+    /**
+     * 上级团队
+     */
+    private Integer superId;
+    /**
+     * 状态 0=正常,1=解散
+     */
+    private Integer status;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getAid() {
+        return aid;
+    }
+
+    public void setAid(String aid) {
+        this.aid = aid;
+    }
+
+    public Integer getLvl() {
+        return lvl;
+    }
+
+    public void setLvl(Integer lvl) {
+        this.lvl = lvl;
+    }
+
+    public String getDepId() {
+        return depId;
+    }
+
+    public void setDepId(String depId) {
+        this.depId = depId;
+    }
+
+    public Integer getSuperId() {
+        return superId;
+    }
+
+    public void setSuperId(Integer superId) {
+        this.superId = superId;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+}
+