CRM项目后端根据提交的活动Id和对应的权限对活动备注进行分页查询并回传到前端------CRM项目

package com.alatus.web;

import com.alatus.constant.Constants;
import com.alatus.model.TActivityRemark;
import com.alatus.query.ActivityRemarkQuery;
import com.alatus.result.R;
import com.alatus.service.ActivityRemarkService;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
public class ActivityRemarkController {
    @Resource
    private ActivityRemarkService activityRemarkService;

    @PostMapping(value = "/api/activity/remark")
    public R addActivityRemark(@RequestBody ActivityRemarkQuery activityRemarkQuery, @RequestHeader(value = Constants.TOKEN_NAME)String token){
        activityRemarkQuery.setToken(token);
        int save = activityRemarkService.saveActivityRemark(activityRemarkQuery);
        return save >= 1 ? R.OK() : R.FAIL();
    }

    @GetMapping(value = "/api/acitivity/remark")
    public R activityRemarkPage(@RequestParam(value = "current",required = false)Integer current,@RequestParam(value = "activityId")Integer id){
        if(current == null){
            current = 1;
        }
        ActivityRemarkQuery activityRemarkQuery = new ActivityRemarkQuery();
        activityRemarkQuery.setActivityId(id);
        PageInfo<TActivityRemark> remarkList = activityRemarkService.getActivityRemarkByPage(current,activityRemarkQuery);
        return R.OK(remarkList);
    }
}
package com.alatus.web;

import com.alatus.constant.Constants;
import com.alatus.model.TActivityRemark;
import com.alatus.query.ActivityRemarkQuery;
import com.alatus.result.R;
import com.alatus.service.ActivityRemarkService;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
public class ActivityRemarkController {
    @Resource
    private ActivityRemarkService activityRemarkService;

    @PostMapping(value = "/api/activity/remark")
    public R addActivityRemark(@RequestBody ActivityRemarkQuery activityRemarkQuery, @RequestHeader(value = Constants.TOKEN_NAME)String token){
        activityRemarkQuery.setToken(token);
        int save = activityRemarkService.saveActivityRemark(activityRemarkQuery);
        return save >= 1 ? R.OK() : R.FAIL();
    }

    @GetMapping(value = "/api/acitivity/remark")
    public R activityRemarkPage(@RequestParam(value = "current",required = false)Integer current,@RequestParam(value = "activityId")Integer id){
        if(current == null){
            current = 1;
        }
        ActivityRemarkQuery activityRemarkQuery = new ActivityRemarkQuery();
        activityRemarkQuery.setActivityId(id);
        PageInfo<TActivityRemark> remarkList = activityRemarkService.getActivityRemarkByPage(current,activityRemarkQuery);
        return R.OK(remarkList);
    }
}
package com.alatus.service.impl;

import com.alatus.constant.Constants;
import com.alatus.mapper.TActivityRemarkMapper;
import com.alatus.model.TActivityRemark;
import com.alatus.query.ActivityRemarkQuery;
import com.alatus.query.BaseQuery;
import com.alatus.service.ActivityRemarkService;
import com.alatus.util.JWTUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ActivityRemarkServiceImpl implements ActivityRemarkService {
    @Resource
    private TActivityRemarkMapper tActivityRemarkMapper;
    @Override
    public int saveActivityRemark(ActivityRemarkQuery activityRemarkQuery) {
        TActivityRemark tActivityRemark = new TActivityRemark();
        tActivityRemark.setCreateBy(JWTUtils.parseUserFromJWT(activityRemarkQuery.getToken()).getId());
        tActivityRemark.setCreateTime(new Date());
        BeanUtils.copyProperties(activityRemarkQuery,tActivityRemark);
        return tActivityRemarkMapper.insert(tActivityRemark);
    }

    @Override
    public PageInfo<TActivityRemark> getActivityRemarkByPage(Integer current,ActivityRemarkQuery activityRemarkQuery) {
//        设置PageHelper和分页情况
        PageHelper.startPage(current, Constants.PAGE_SIZE);
        List<TActivityRemark> list = tActivityRemarkMapper.selectActivityRemarkByPage(activityRemarkQuery);
        PageInfo<TActivityRemark> info = new PageInfo<>(list);
        return info;
    }

}
package com.alatus.service.impl;

import com.alatus.constant.Constants;
import com.alatus.mapper.TActivityRemarkMapper;
import com.alatus.model.TActivityRemark;
import com.alatus.query.ActivityRemarkQuery;
import com.alatus.query.BaseQuery;
import com.alatus.service.ActivityRemarkService;
import com.alatus.util.JWTUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ActivityRemarkServiceImpl implements ActivityRemarkService {
    @Resource
    private TActivityRemarkMapper tActivityRemarkMapper;
    @Override
    public int saveActivityRemark(ActivityRemarkQuery activityRemarkQuery) {
        TActivityRemark tActivityRemark = new TActivityRemark();
        tActivityRemark.setCreateBy(JWTUtils.parseUserFromJWT(activityRemarkQuery.getToken()).getId());
        tActivityRemark.setCreateTime(new Date());
        BeanUtils.copyProperties(activityRemarkQuery,tActivityRemark);
        return tActivityRemarkMapper.insert(tActivityRemark);
    }

    @Override
    public PageInfo<TActivityRemark> getActivityRemarkByPage(Integer current,ActivityRemarkQuery activityRemarkQuery) {
//        设置PageHelper和分页情况
        PageHelper.startPage(current, Constants.PAGE_SIZE);
        List<TActivityRemark> list = tActivityRemarkMapper.selectActivityRemarkByPage(activityRemarkQuery);
        PageInfo<TActivityRemark> info = new PageInfo<>(list);
        return info;
    }

}
package com.alatus.mapper;

import com.alatus.commons.DataScope;
import com.alatus.model.TActivityRemark;
import com.alatus.query.ActivityRemarkQuery;

import java.util.List;

public interface TActivityRemarkMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(TActivityRemark record);

    int insertSelective(TActivityRemark record);

    TActivityRemark selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(TActivityRemark record);

    int updateByPrimaryKey(TActivityRemark record);

    @DataScope(tableAlias = "tar",tableField = "create_by")
    List<TActivityRemark> selectActivityRemarkByPage(ActivityRemarkQuery activityRemarkQuery);
}
package com.alatus.mapper;

import com.alatus.commons.DataScope;
import com.alatus.model.TActivityRemark;
import com.alatus.query.ActivityRemarkQuery;

import java.util.List;

public interface TActivityRemarkMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(TActivityRemark record);

    int insertSelective(TActivityRemark record);

    TActivityRemark selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(TActivityRemark record);

    int updateByPrimaryKey(TActivityRemark record);

    @DataScope(tableAlias = "tar",tableField = "create_by")
    List<TActivityRemark> selectActivityRemarkByPage(ActivityRemarkQuery activityRemarkQuery);
}

<?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.alatus.mapper.TActivityRemarkMapper">
  <resultMap id="BaseResultMap" type="com.alatus.model.TActivityRemark">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="activity_id" jdbcType="INTEGER" property="activityId" />
    <result column="note_content" jdbcType="VARCHAR" property="noteContent" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_by" jdbcType="INTEGER" property="createBy" />
    <result column="edit_time" jdbcType="TIMESTAMP" property="editTime" />
    <result column="edit_by" jdbcType="INTEGER" property="editBy" />
    <result column="deleted" jdbcType="INTEGER" property="deleted" />
  </resultMap>

  <resultMap id="ActivityRemarkResultMap" type="com.alatus.model.TActivityRemark">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="activity_id" jdbcType="INTEGER" property="activityId" />
    <result column="note_content" jdbcType="VARCHAR" property="noteContent" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_by" jdbcType="INTEGER" property="createBy" />
    <result column="edit_time" jdbcType="TIMESTAMP" property="editTime" />
    <result column="edit_by" jdbcType="INTEGER" property="editBy" />
    <result column="deleted" jdbcType="INTEGER" property="deleted" />
    <association property="createByDO" javaType="com.alatus.model.TUser">
      <id column="createId" jdbcType="INTEGER" property="id" />
      <result column="createName" jdbcType="VARCHAR" property="name" />
    </association>
    <association property="editByDO" javaType="com.alatus.model.TUser">
      <id column="editId" jdbcType="INTEGER" property="id" />
      <result column="editName" jdbcType="VARCHAR" property="name" />
    </association>
  </resultMap>

  <sql id="Base_Column_List">
    id, activity_id, note_content, create_time, create_by, edit_time, edit_by, deleted
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from t_activity_remark
    where id = #{id,jdbcType=INTEGER}
  </select>


    <select id="selectActivityRemarkByPage" resultMap="ActivityRemarkResultMap">
      select
        tar.*,
        tu1.id createById,tu1.name createByName,
        tu2.id editById,tu2.name editByName
      from t_activity_remark tar left join t_user tu1 on tar.create_by = tu1.id
                                left join t_user tu2 on tar.edit_by = tu2.id
      where tar.id = #{activityId,jdbcType=INTEGER}
      <where>
        ${filterSQL}
      </where>
    </select>


    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_activity_remark
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.alatus.model.TActivityRemark" useGeneratedKeys="true">
    insert into t_activity_remark (activity_id, note_content, create_time,
      create_by, edit_time, edit_by, 
      deleted)
    values (#{activityId,jdbcType=INTEGER}, #{noteContent,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
      #{createBy,jdbcType=INTEGER}, #{editTime,jdbcType=TIMESTAMP}, #{editBy,jdbcType=INTEGER}, 
      #{deleted,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.alatus.model.TActivityRemark" useGeneratedKeys="true">
    insert into t_activity_remark
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="activityId != null">
        activity_id,
      </if>
      <if test="noteContent != null">
        note_content,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="editTime != null">
        edit_time,
      </if>
      <if test="editBy != null">
        edit_by,
      </if>
      <if test="deleted != null">
        deleted,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="activityId != null">
        #{activityId,jdbcType=INTEGER},
      </if>
      <if test="noteContent != null">
        #{noteContent,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=INTEGER},
      </if>
      <if test="editTime != null">
        #{editTime,jdbcType=TIMESTAMP},
      </if>
      <if test="editBy != null">
        #{editBy,jdbcType=INTEGER},
      </if>
      <if test="deleted != null">
        #{deleted,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.alatus.model.TActivityRemark">
    update t_activity_remark
    <set>
      <if test="activityId != null">
        activity_id = #{activityId,jdbcType=INTEGER},
      </if>
      <if test="noteContent != null">
        note_content = #{noteContent,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=INTEGER},
      </if>
      <if test="editTime != null">
        edit_time = #{editTime,jdbcType=TIMESTAMP},
      </if>
      <if test="editBy != null">
        edit_by = #{editBy,jdbcType=INTEGER},
      </if>
      <if test="deleted != null">
        deleted = #{deleted,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.alatus.model.TActivityRemark">
    update t_activity_remark
    set activity_id = #{activityId,jdbcType=INTEGER},
      note_content = #{noteContent,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_by = #{createBy,jdbcType=INTEGER},
      edit_time = #{editTime,jdbcType=TIMESTAMP},
      edit_by = #{editBy,jdbcType=INTEGER},
      deleted = #{deleted,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>
<?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.alatus.mapper.TActivityRemarkMapper">
  <resultMap id="BaseResultMap" type="com.alatus.model.TActivityRemark">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="activity_id" jdbcType="INTEGER" property="activityId" />
    <result column="note_content" jdbcType="VARCHAR" property="noteContent" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_by" jdbcType="INTEGER" property="createBy" />
    <result column="edit_time" jdbcType="TIMESTAMP" property="editTime" />
    <result column="edit_by" jdbcType="INTEGER" property="editBy" />
    <result column="deleted" jdbcType="INTEGER" property="deleted" />
  </resultMap>

  <resultMap id="ActivityRemarkResultMap" type="com.alatus.model.TActivityRemark">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="activity_id" jdbcType="INTEGER" property="activityId" />
    <result column="note_content" jdbcType="VARCHAR" property="noteContent" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_by" jdbcType="INTEGER" property="createBy" />
    <result column="edit_time" jdbcType="TIMESTAMP" property="editTime" />
    <result column="edit_by" jdbcType="INTEGER" property="editBy" />
    <result column="deleted" jdbcType="INTEGER" property="deleted" />
    <association property="createByDO" javaType="com.alatus.model.TUser">
      <id column="createId" jdbcType="INTEGER" property="id" />
      <result column="createName" jdbcType="VARCHAR" property="name" />
    </association>
    <association property="editByDO" javaType="com.alatus.model.TUser">
      <id column="editId" jdbcType="INTEGER" property="id" />
      <result column="editName" jdbcType="VARCHAR" property="name" />
    </association>
  </resultMap>

  <sql id="Base_Column_List">
    id, activity_id, note_content, create_time, create_by, edit_time, edit_by, deleted
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from t_activity_remark
    where id = #{id,jdbcType=INTEGER}
  </select>


    <select id="selectActivityRemarkByPage" resultMap="ActivityRemarkResultMap">
      select
        tar.*,
        tu1.id createById,tu1.name createByName,
        tu2.id editById,tu2.name editByName
      from t_activity_remark tar left join t_user tu1 on tar.create_by = tu1.id
                                left join t_user tu2 on tar.edit_by = tu2.id
      where tar.id = #{activityId,jdbcType=INTEGER}
      <where>
        ${filterSQL}
      </where>
    </select>


    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_activity_remark
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.alatus.model.TActivityRemark" useGeneratedKeys="true">
    insert into t_activity_remark (activity_id, note_content, create_time,
      create_by, edit_time, edit_by, 
      deleted)
    values (#{activityId,jdbcType=INTEGER}, #{noteContent,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
      #{createBy,jdbcType=INTEGER}, #{editTime,jdbcType=TIMESTAMP}, #{editBy,jdbcType=INTEGER}, 
      #{deleted,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.alatus.model.TActivityRemark" useGeneratedKeys="true">
    insert into t_activity_remark
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="activityId != null">
        activity_id,
      </if>
      <if test="noteContent != null">
        note_content,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="editTime != null">
        edit_time,
      </if>
      <if test="editBy != null">
        edit_by,
      </if>
      <if test="deleted != null">
        deleted,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="activityId != null">
        #{activityId,jdbcType=INTEGER},
      </if>
      <if test="noteContent != null">
        #{noteContent,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=INTEGER},
      </if>
      <if test="editTime != null">
        #{editTime,jdbcType=TIMESTAMP},
      </if>
      <if test="editBy != null">
        #{editBy,jdbcType=INTEGER},
      </if>
      <if test="deleted != null">
        #{deleted,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.alatus.model.TActivityRemark">
    update t_activity_remark
    <set>
      <if test="activityId != null">
        activity_id = #{activityId,jdbcType=INTEGER},
      </if>
      <if test="noteContent != null">
        note_content = #{noteContent,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=INTEGER},
      </if>
      <if test="editTime != null">
        edit_time = #{editTime,jdbcType=TIMESTAMP},
      </if>
      <if test="editBy != null">
        edit_by = #{editBy,jdbcType=INTEGER},
      </if>
      <if test="deleted != null">
        deleted = #{deleted,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.alatus.model.TActivityRemark">
    update t_activity_remark
    set activity_id = #{activityId,jdbcType=INTEGER},
      note_content = #{noteContent,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_by = #{createBy,jdbcType=INTEGER},
      edit_time = #{editTime,jdbcType=TIMESTAMP},
      edit_by = #{editBy,jdbcType=INTEGER},
      deleted = #{deleted,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>
package com.alatus.service;

import com.alatus.model.TActivityRemark;
import com.alatus.query.ActivityRemarkQuery;
import com.github.pagehelper.PageInfo;

import java.util.List;

public interface ActivityRemarkService {
    int saveActivityRemark(ActivityRemarkQuery activityRemarkQuery);

    PageInfo<TActivityRemark> getActivityRemarkByPage(Integer current,ActivityRemarkQuery activityRemarkQuery);
}
package com.alatus.service;

import com.alatus.model.TActivityRemark;
import com.alatus.query.ActivityRemarkQuery;
import com.github.pagehelper.PageInfo;

import java.util.List;

public interface ActivityRemarkService {
    int saveActivityRemark(ActivityRemarkQuery activityRemarkQuery);

    PageInfo<TActivityRemark> getActivityRemarkByPage(Integer current,ActivityRemarkQuery activityRemarkQuery);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值