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

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

java">package ***.alatus.web;

import ***.alatus.constant.Constants;
import ***.alatus.model.TActivityRemark;
import ***.alatus.query.ActivityRemarkQuery;
import ***.alatus.result.R;
import ***.alatus.service.ActivityRemarkService;
import ***.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 ***.alatus.web;

import ***.alatus.constant.Constants;
import ***.alatus.model.TActivityRemark;
import ***.alatus.query.ActivityRemarkQuery;
import ***.alatus.result.R;
import ***.alatus.service.ActivityRemarkService;
import ***.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 ***.alatus.service.impl;

import ***.alatus.constant.Constants;
import ***.alatus.mapper.TActivityRemarkMapper;
import ***.alatus.model.TActivityRemark;
import ***.alatus.query.ActivityRemarkQuery;
import ***.alatus.query.BaseQuery;
import ***.alatus.service.ActivityRemarkService;
import ***.alatus.util.JWTUtils;
import ***.github.pagehelper.PageHelper;
import ***.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 ***.alatus.service.impl;

import ***.alatus.constant.Constants;
import ***.alatus.mapper.TActivityRemarkMapper;
import ***.alatus.model.TActivityRemark;
import ***.alatus.query.ActivityRemarkQuery;
import ***.alatus.query.BaseQuery;
import ***.alatus.service.ActivityRemarkService;
import ***.alatus.util.JWTUtils;
import ***.github.pagehelper.PageHelper;
import ***.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 ***.alatus.mapper;

import ***.alatus.***mons.DataScope;
import ***.alatus.model.TActivityRemark;
import ***.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 ***.alatus.mapper;

import ***.alatus.***mons.DataScope;
import ***.alatus.model.TActivityRemark;
import ***.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="***.alatus.mapper.TActivityRemarkMapper">
  <resultMap id="BaseResultMap" type="***.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="***.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="***.alatus.model.TUser">
      <id column="createId" jdbcType="INTEGER" property="id" />
      <result column="createName" jdbcType="VARCHAR" property="name" />
    </association>
    <association property="editByDO" javaType="***.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="***.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="***.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="***.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="***.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="***.alatus.mapper.TActivityRemarkMapper">
  <resultMap id="BaseResultMap" type="***.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="***.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="***.alatus.model.TUser">
      <id column="createId" jdbcType="INTEGER" property="id" />
      <result column="createName" jdbcType="VARCHAR" property="name" />
    </association>
    <association property="editByDO" javaType="***.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="***.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="***.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="***.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="***.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 ***.alatus.service;

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

import java.util.List;

public interface ActivityRemarkService {
    int saveActivityRemark(ActivityRemarkQuery activityRemarkQuery);

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

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

import java.util.List;

public interface ActivityRemarkService {
    int saveActivityRemark(ActivityRemarkQuery activityRemarkQuery);

    PageInfo<TActivityRemark> getActivityRemarkByPage(Integer current,ActivityRemarkQuery activityRemarkQuery);
}
转载请说明出处内容投诉
CSS教程_站长资源网 » CRM项目后端根据提交的活动Id和对应的权限对活动备注进行分页查询并回传到前端------CRM项目

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买