CRM related SQL statements

CustomerReport.xml

select ${groupType} groupType,count(c.id) number
    from customer c
    left join employee e
    on c.seller_id = e.id
    <where>
      c.status = 0
      <if test="keyword!=null">
        and e.name like concat('%',#{keyword},'%')
      </if>
      <if test="beginDate!=null">
        and c.input_time &gt;=#{beginDate}
      </if>
      <if test="endDate!=null">
        and c.intput_time &lt;=#{endDate}
      </if>
    </where>
    group by ${groupType}

EmployeeMapper

 <select id="selectByName" resultMap="BaseResultMap">
      select * from employee where name = #{name}
    </select>

PermissionMapper

<select id="list" resultType="cn.wolfcode.domain.Permission">
      select * from permission
    </select>
  <select id="selectExpressionByCurrentuserId" resultType="java.lang.String">
    select p.expression
    from employee_role er
    left join role_permission rp
    on er.role_id = rp.role_id
    left join permission p
    on rp.permission_id = p.id
    where er.employee_id = #{id}
  </select>
  <select id="selectAllExpression" resultType="java.lang.String">
    select expression from permission
  </select>

RoleMapper

 <select id="selectByEmployeeId" resultType="cn.wolfcode.domain.Role">
    select r.*
    from employee_role er
    left join role r
    on er.employee_id = r.id
    where er.employee_id = #{id}
  </select>

Read More: