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/add")
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);
}
// 根据ID获取活动备注
// @GetMapping(value = "/api/activty/remark/detail/{id}")
// public R remarkDetail(@PathVariable(value = "id")Integer id){
// TActivityRemark tActivityRemark = activityRemarkService.getActivityRemarkById(id);
// return R.OK(tActivityRemark);
// }
@PutMapping(value = "/api/activity/remark/edit")
public R editActivityRemark(@RequestBody ActivityRemarkQuery activityRemarkQuery, @RequestHeader(value = Constants.TOKEN_NAME)String token){
activityRemarkQuery.setToken(token);
int update = activityRemarkService.updateActivityRemark(activityRemarkQuery);
return update >= 1 ? R.OK() : R.FAIL();
}
}
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/add")
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);
}
// 根据ID获取活动备注
// @GetMapping(value = "/api/activty/remark/detail/{id}")
// public R remarkDetail(@PathVariable(value = "id")Integer id){
// TActivityRemark tActivityRemark = activityRemarkService.getActivityRemarkById(id);
// return R.OK(tActivityRemark);
// }
@PutMapping(value = "/api/activity/remark/edit")
public R editActivityRemark(@RequestBody ActivityRemarkQuery activityRemarkQuery, @RequestHeader(value = Constants.TOKEN_NAME)String token){
activityRemarkQuery.setToken(token);
int update = activityRemarkService.updateActivityRemark(activityRemarkQuery);
return update >= 1 ? R.OK() : R.FAIL();
}
}
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);
int updateActivityRemark(ActivityRemarkQuery activityRemarkQuery);
// TActivityRemark getActivityRemarkById(Integer );
}
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);
int updateActivityRemark(ActivityRemarkQuery activityRemarkQuery);
// TActivityRemark getActivityRemarkById(Integer );
}
package ***.alatus.service.impl;
import ***.alatus.constant.Constants;
import ***.alatus.mapper.TActivityRemarkMapper;
import ***.alatus.model.TActivityRemark;
import ***.alatus.query.ActivityRemarkQuery;
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;
}
@Override
public int updateActivityRemark(ActivityRemarkQuery activityRemarkQuery) {
TActivityRemark tActivityRemark = new TActivityRemark();
BeanUtils.copyProperties(activityRemarkQuery,tActivityRemark);
tActivityRemark.setEditTime(new Date());
tActivityRemark.setEditBy(JWTUtils.parseUserFromJWT(activityRemarkQuery.getToken()).getId());
return tActivityRemarkMapper.updateByPrimaryKeySelective(tActivityRemark);
}
// @Override
// public TActivityRemark getActivityRemarkById(Integer id) {
// return tActivityRemarkMapper.selectByPrimaryKey(id);
// }
}
package ***.alatus.service.impl;
import ***.alatus.constant.Constants;
import ***.alatus.mapper.TActivityRemarkMapper;
import ***.alatus.model.TActivityRemark;
import ***.alatus.query.ActivityRemarkQuery;
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;
}
@Override
public int updateActivityRemark(ActivityRemarkQuery activityRemarkQuery) {
TActivityRemark tActivityRemark = new TActivityRemark();
BeanUtils.copyProperties(activityRemarkQuery,tActivityRemark);
tActivityRemark.setEditTime(new Date());
tActivityRemark.setEditBy(JWTUtils.parseUserFromJWT(activityRemarkQuery.getToken()).getId());
return tActivityRemarkMapper.updateByPrimaryKeySelective(tActivityRemark);
}
// @Override
// public TActivityRemark getActivityRemarkById(Integer id) {
// return tActivityRemarkMapper.selectByPrimaryKey(id);
// }
}