18655803770 4 months ago
parent 3c19495e91
commit 686832b883

@ -9,27 +9,38 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupp
import com.interceptor.AuthorizationInterceptor;
@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport{
@Bean
public class InterceptorConfig extends WebMvcConfigurationSupport {
// 定义一个 Bean 方法,返回 AuthorizationInterceptor 的实例
@Bean
public AuthorizationInterceptor getAuthorizationInterceptor() {
return new AuthorizationInterceptor();
return new AuthorizationInterceptor(); // 创建并返回一个新的 AuthorizationInterceptor 实例
}
@Override
// 重写 addInterceptors 方法,添加自定义拦截器
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(getAuthorizationInterceptor()).addPathPatterns("/**").excludePathPatterns("/static/**");
super.addInterceptors(registry);
}
// 将 AuthorizationInterceptor 添加到拦截器链中
registry.addInterceptor(getAuthorizationInterceptor())
.addPathPatterns("/**") // 匹配所有路径
.excludePathPatterns("/static/**"); // 排除对 /static/** 路径的拦截
super.addInterceptors(registry); // 调用父类方法继续处理其他拦截器
}
@Override
/**
* 使 Spring Boot 2.0 WebMvcConfigurationSupport
* addResourceHandlers 访
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/resources/")
.addResourceLocations("classpath:/static/")
.addResourceLocations("classpath:/admin/")
.addResourceLocations("classpath:/front/")
.addResourceLocations("classpath:/public/");
super.addResourceHandlers(registry);
// 添加资源处理器,处理所有路径的静态资源请求
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/resources/") // 从 classpath:/resources/ 目录加载资源
.addResourceLocations("classpath:/static/") // 从 classpath:/static/ 目录加载资源
.addResourceLocations("classpath:/admin/") // 从 classpath:/admin/ 目录加载资源
.addResourceLocations("classpath:/front/") // 从 classpath:/front/ 目录加载资源
.addResourceLocations("classpath:/public/"); // 从 classpath:/public/ 目录加载资源
super.addResourceHandlers(registry); // 调用父类方法继续处理其他资源处理器
}
}

@ -7,12 +7,18 @@ import org.springframework.context.annotation.Configuration;
import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
/**
* mybatis-plus
*/
@Configuration
public class MybatisPlusConfig {
/**
*
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
return new PaginationInterceptor(); // 创建并返回一个新的 PaginationInterceptor 实例
}
}

@ -35,208 +35,258 @@ import com.utils.BaiduUtil;
import com.utils.FileUtil;
import com.utils.R;
/**
*
*/
@RestController
public class CommonController{
public class CommonController {
@Autowired
private CommonService commonService; // 注入通用服务
private static AipFace client = null; // 百度人脸API客户端实例
@Autowired
private CommonService commonService;
private ConfigService configService; // 注入配置服务
private static AipFace client = null;
@Autowired
private ConfigService configService;
/**
* tablecolumn()
* @param tableName
* @param columnName
* @param level
* @param parent
* @return
*/
@IgnoreAuth
@RequestMapping("/option/{tableName}/{columnName}")
public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,String level,String parent) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("column", columnName);
if(StringUtils.isNotBlank(level)) {
params.put("level", level);
public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,
String level, String parent) {
Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("table", tableName); // 添加表名
params.put("column", columnName); // 添加列名
if (StringUtils.isNotBlank(level)) { // 如果层级不为空
params.put("level", level); // 添加层级
}
if(StringUtils.isNotBlank(parent)) {
params.put("parent", parent);
if (StringUtils.isNotBlank(parent)) { // 如果父节点不为空
params.put("parent", parent); // 添加父节点
}
List<String> data = commonService.getOption(params);
return R.ok().put("data", data);
List<String> data = commonService.getOption(params); // 调用服务获取数据
return R.ok().put("data", data); // 返回成功结果
}
/**
* tablecolumn
* @param tableName
* @param columnName
* @param columnValue
* @return
*/
@IgnoreAuth
@RequestMapping("/follow/{tableName}/{columnName}")
public R getFollowByOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, @RequestParam String columnValue) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("column", columnName);
params.put("columnValue", columnValue);
Map<String, Object> result = commonService.getFollowByOption(params);
return R.ok().put("data", result);
public R getFollowByOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,
@RequestParam String columnValue) {
Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("table", tableName); // 添加表名
params.put("column", columnName); // 添加列名
params.put("columnValue", columnValue); // 添加列值
Map<String, Object> result = commonService.getFollowByOption(params); // 调用服务获取结果
return R.ok().put("data", result); // 返回成功结果
}
/**
* tablesfsh
* @param tableName
* @param map
* @return
*/
@RequestMapping("/sh/{tableName}")
public R sh(@PathVariable("tableName") String tableName, @RequestBody Map<String, Object> map) {
map.put("table", tableName);
commonService.sh(map);
return R.ok();
map.put("table", tableName); // 添加表名
commonService.sh(map); // 调用服务修改状态
return R.ok(); // 返回成功结果
}
/**
*
* @param tableName
* @param columnName
* @param type 1:, 2:
* @param map
* @return
*/
@IgnoreAuth
@RequestMapping("/remind/{tableName}/{columnName}/{type}")
public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("table", tableName);
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("table", tableName); // 添加表名
map.put("column", columnName); // 添加列名
map.put("type", type); // 添加提醒类型
if ("2".equals(type)) { // 如果类型为日期
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 日期格式化工具
Calendar c = Calendar.getInstance(); // 日历实例
Date remindStartDate = null; // 提醒开始日期
Date remindEndDate = null; // 提醒结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前时间为基准
c.add(Calendar.DAY_OF_MONTH, remindStart); // 增加天数
remindStartDate = c.getTime(); // 获取新的日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并更新参数
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前时间为基准
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 增加天数
remindEndDate = c.getTime(); // 获取新的日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并更新参数
}
}
int count = commonService.remindCount(map);
return R.ok().put("count", count);
int count = commonService.remindCount(map); // 调用服务获取提醒记录数
return R.ok().put("count", count); // 返回成功结果
}
/**
*
* @param tableName
* @param columnName
* @return
*/
@IgnoreAuth
@RequestMapping("/cal/{tableName}/{columnName}")
public R cal(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("column", columnName);
Map<String, Object> result = commonService.selectCal(params);
return R.ok().put("data", result);
Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("table", tableName); // 添加表名
params.put("column", columnName); // 添加列名
Map<String, Object> result = commonService.selectCal(params); // 调用服务获取求和结果
return R.ok().put("data", result); // 返回成功结果
}
/**
*
* @param tableName
* @param columnName
* @return
*/
@IgnoreAuth
@RequestMapping("/group/{tableName}/{columnName}")
public R group(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("column", columnName);
List<Map<String, Object>> result = commonService.selectGroup(params);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(Map<String, Object> m : result) {
for(String k : m.keySet()) {
if(m.get(k) instanceof Date) {
m.put(k, sdf.format((Date)m.get(k)));
Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("table", tableName); // 添加表名
params.put("column", columnName); // 添加列名
List<Map<String, Object>> result = commonService.selectGroup(params); // 调用服务获取分组统计结果
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 日期格式化工具
for (Map<String, Object> m : result) { // 遍历结果
for (String k : m.keySet()) { // 遍历键
if (m.get(k) instanceof Date) { // 如果值是日期类型
m.put(k, sdf.format((Date) m.get(k))); // 格式化日期
}
}
}
return R.ok().put("data", result);
return R.ok().put("data", result); // 返回成功结果
}
/**
*
* @param tableName
* @param yColumnName Y
* @param xColumnName X
* @return
*/
@IgnoreAuth
@RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}")
public R value(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("xColumn", xColumnName);
params.put("yColumn", yColumnName);
List<Map<String, Object>> result = commonService.selectValue(params);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(Map<String, Object> m : result) {
for(String k : m.keySet()) {
if(m.get(k) instanceof Date) {
m.put(k, sdf.format((Date)m.get(k)));
public R value(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName,
@PathVariable("xColumnName") String xColumnName) {
Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("table", tableName); // 添加表名
params.put("xColumn", xColumnName); // 添加X轴列名
params.put("yColumn", yColumnName); // 添加Y轴列名
List<Map<String, Object>> result = commonService.selectValue(params); // 调用服务获取按值统计结果
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 日期格式化工具
for (Map<String, Object> m : result) { // 遍历结果
for (String k : m.keySet()) { // 遍历键
if (m.get(k) instanceof Date) { // 如果值是日期类型
m.put(k, sdf.format((Date) m.get(k))); // 格式化日期
}
}
}
return R.ok().put("data", result);
return R.ok().put("data", result); // 返回成功结果
}
/**
*
*
* @param tableName
* @param xColumnName X
* @param yColumnName Y
* @param timeStatType
* @return
*/
@IgnoreAuth
@RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}/{timeStatType}")
public R valueDay(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("xColumn", xColumnName);
params.put("yColumn", yColumnName);
params.put("timeStatType", timeStatType);
List<Map<String, Object>> result = commonService.selectTimeStatValue(params);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(Map<String, Object> m : result) {
for(String k : m.keySet()) {
if(m.get(k) instanceof Date) {
m.put(k, sdf.format((Date)m.get(k)));
public R valueDay(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName,
@PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType) {
Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("table", tableName); // 添加表名
params.put("xColumn", xColumnName); // 添加X轴列名
params.put("yColumn", yColumnName); // 添加Y轴列名
params.put("timeStatType", timeStatType); // 添加时间统计类型
List<Map<String, Object>> result = commonService.selectTimeStatValue(params); // 调用服务获取按值统计结果
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 日期格式化工具
for (Map<String, Object> m : result) { // 遍历结果
for (String k : m.keySet()) { // 遍历键
if (m.get(k) instanceof Date) { // 如果值是日期类型
m.put(k, sdf.format((Date) m.get(k))); // 格式化日期
}
}
}
return R.ok().put("data", result);
return R.ok().put("data", result); // 返回成功结果
}
/**
*
* @param face1 1
* @param face2 2
* @param request HTTP
* @return
*/
@RequestMapping("/matchFace")
@IgnoreAuth
public R matchFace(String face1, String face2, HttpServletRequest request) {
if (client == null) { // 如果客户端未初始化
/*String AppID = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "AppID")).getValue();*/
String APIKey = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "APIKey")).getValue(); // 获取API Key
String SecretKey = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "SecretKey")).getValue(); // 获取Secret Key
String token = BaiduUtil.getAuth(APIKey, SecretKey); // 获取访问令牌
if (token == null) { // 如果令牌为空
return R.error("请在配置管理中正确配置APIKey和SecretKey"); // 返回错误信息
}
client = new AipFace(null, APIKey, SecretKey); // 初始化客户端
client.setConnectionTimeoutInMillis(2000); // 设置连接超时时间
client.setSocketTimeoutInMillis(60000); // 设置套接字超时时间
}
JSONObject res = null; // 响应结果
try {
File path = new File(ResourceUtils.getURL("classpath:static").getPath()); // 获取静态资源路径
if (!path.exists()) { // 如果路径不存在
path = new File(""); // 使用当前目录
}
File upload = new File(path.getAbsolutePath(), "/upload/"); // 创建上传目录
File file1 = new File(upload.getAbsolutePath(), face1); // 文件1
File file2 = new File(upload.getAbsolutePath(), face2); // 文件2
String img1 = Base64Util.encode(FileUtil.FileToByte(file1)); // 将文件1转换为Base64
String img2 = Base64Util.encode(FileUtil.FileToByte(file2)); // 将文件2转换为Base64
MatchRequest req1 = new MatchRequest(img1, "BASE64"); // 第一个人脸请求
MatchRequest req2 = new MatchRequest(img2, "BASE64"); // 第二个人脸请求
ArrayList<MatchRequest> requests = new ArrayList<MatchRequest>(); // 请求列表
requests.add(req1); // 添加第一个请求
requests.add(req2); // 添加第二个请求
res = client.match(requests); // 调用人脸比对接口
System.out.println(res.get("result")); // 打印比对结果
} catch (FileNotFoundException e) { // 文件未找到异常
e.printStackTrace(); // 打印堆栈信息
return R.error("文件不存在"); // 返回错误信息
} catch (IOException e) { // IO异常
e.printStackTrace(); // 打印堆栈信息
}
return R.ok().put("score", com.alibaba.fastjson.JSONObject.parse(res.getJSONObject("result").get("score").toString())); // 返回比对分数
}
/**
*
*
* @param face1 1
* @param face2 2
* @return
*/
@RequestMapping("/matchFace")
@IgnoreAuth
public R matchFace(String face1, String face2,HttpServletRequest request) {
if(client==null) {
/*String AppID = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "AppID")).getValue();*/
String APIKey = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "APIKey")).getValue();
String SecretKey = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "SecretKey")).getValue();
String token = BaiduUtil.getAuth(APIKey, SecretKey);
if(token==null) {
return R.error("请在配置管理中正确配置APIKey和SecretKey");
}
client = new AipFace(null, APIKey, SecretKey);
client.setConnectionTimeoutInMillis(2000);
client.setSocketTimeoutInMillis(60000);
}
JSONObject res = null;
try {
File path = new File(ResourceUtils.getURL("classpath:static").getPath());
if(!path.exists()) {
path = new File("");
}
File upload = new File(path.getAbsolutePath(),"/upload/");
File file1 = new File(upload.getAbsolutePath()+"/"+face1);
File file2 = new File(upload.getAbsolutePath()+"/"+face2);
String img1 = Base64Util.encode(FileUtil.FileToByte(file1));
String img2 = Base64Util.encode(FileUtil.FileToByte(file2));
MatchRequest req1 = new MatchRequest(img1, "BASE64");
MatchRequest req2 = new MatchRequest(img2, "BASE64");
ArrayList<MatchRequest> requests = new ArrayList<MatchRequest>();
requests.add(req1);
requests.add(req2);
res = client.match(requests);
System.out.println(res.get("result"));
} catch (FileNotFoundException e) {
e.printStackTrace();
return R.error("文件不存在");
} catch (IOException e) {
e.printStackTrace();
}
return R.ok().put("score", com.alibaba.fastjson.JSONObject.parse(res.getJSONObject("result").get("score").toString()));
}
}

@ -1,7 +1,5 @@
package com.controller;
import java.util.Arrays;
import java.util.Map;
@ -23,64 +21,108 @@ import com.utils.R;
import com.utils.ValidatorUtils;
/**
*
*
*/
@RequestMapping("config")
@RestController
public class ConfigController{
@Autowired
private ConfigService configService;
public class ConfigController {
@Autowired
private ConfigService configService; // 注入配置服务
/**
*
* @param params
* @param config
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,ConfigEntity config){
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>();
PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params));
return R.ok().put("data", page);
public R page(@RequestParam Map<String, Object> params, ConfigEntity config) {
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); // 创建查询条件
PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params)); // 查询分页数据
return R.ok().put("data", page); // 返回成功结果
}
/**
*
* @param params
* @param config
* @return
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ConfigEntity config){
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>();
PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, ConfigEntity config) {
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); // 创建查询条件
PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params)); // 查询分页数据
return R.ok().put("data", page); // 返回成功结果
}
/**
* ID
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
ConfigEntity config = configService.selectById(id);
return R.ok().put("data", config);
public R info(@PathVariable("id") String id) {
ConfigEntity config = configService.selectById(id); // 根据ID查询配置
return R.ok().put("data", config); // 返回成功结果
}
/**
* ID
* @param id ID
* @return
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") String id){
ConfigEntity config = configService.selectById(id);
return R.ok().put("data", config);
public R detail(@PathVariable("id") String id) {
ConfigEntity config = configService.selectById(id); // 根据ID查询配置
return R.ok().put("data", config); // 返回成功结果
}
/**
*
* @param name
* @return
*/
@RequestMapping("/info")
public R infoByName(@RequestParam String name){
ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
return R.ok().put("data", config);
public R infoByName(@RequestParam String name) {
ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); // 根据名称查询配置
return R.ok().put("data", config); // 返回成功结果
}
/**
*
* @param config
* @return
*/
@PostMapping("/save")
public R save(@RequestBody ConfigEntity config){
// ValidatorUtils.validateEntity(config);
configService.insert(config);
return R.ok();
public R save(@RequestBody ConfigEntity config) {
// ValidatorUtils.validateEntity(config); // 验证配置对象
configService.insert(config); // 插入配置
return R.ok(); // 返回成功结果
}
/**
*
* @param config
* @return
*/
@RequestMapping("/update")
public R update(@RequestBody ConfigEntity config){
// ValidatorUtils.validateEntity(config);
configService.updateById(config);//全部更新
return R.ok();
public R update(@RequestBody ConfigEntity config) {
// ValidatorUtils.validateEntity(config); // 验证配置对象
configService.updateById(config); // 根据ID更新配置
return R.ok(); // 返回成功结果
}
/**
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
configService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
configService.deleteBatchIds(Arrays.asList(ids)); // 批量删除配置
return R.ok(); // 返回成功结果
}
}

@ -1,14 +1,7 @@
package com.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
@ -16,11 +9,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
@ -38,180 +28,192 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/discusshuodongxinde")
public class DiscusshuodongxindeController {
@Autowired
private DiscusshuodongxindeService discusshuodongxindeService;
private DiscusshuodongxindeService discusshuodongxindeService; // 注入服务类
/**
*
*
* @param params
* @param discusshuodongxinde
* @param request
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,DiscusshuodongxindeEntity discusshuodongxinde,
HttpServletRequest request){
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<DiscusshuodongxindeEntity>();
PageUtils page = discusshuodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discusshuodongxinde), params), params));
return R.ok().put("data", page);
public R page(@RequestParam Map<String, Object> params, DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = discusshuodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discusshuodongxinde), params), params)); // 查询分页数据
return R.ok().put("data", page); // 返回成功结果
}
/**
*
*
* @param params
* @param discusshuodongxinde
* @param request
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,DiscusshuodongxindeEntity discusshuodongxinde,
HttpServletRequest request){
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<DiscusshuodongxindeEntity>();
PageUtils page = discusshuodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discusshuodongxinde), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = discusshuodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discusshuodongxinde), params), params)); // 查询分页数据
return R.ok().put("data", page); // 返回成功结果
}
/**
*
/**
*
* @param discusshuodongxinde
* @return
*/
@RequestMapping("/lists")
public R list( DiscusshuodongxindeEntity discusshuodongxinde){
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<DiscusshuodongxindeEntity>();
ew.allEq(MPUtil.allEQMapPre( discusshuodongxinde, "discusshuodongxinde"));
return R.ok().put("data", discusshuodongxindeService.selectListView(ew));
public R list(DiscusshuodongxindeEntity discusshuodongxinde) {
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
ew.allEq(MPUtil.allEQMapPre(discusshuodongxinde, "discusshuodongxinde")); // 设置查询条件
return R.ok().put("data", discusshuodongxindeService.selectListView(ew)); // 返回查询结果
}
/**
*
/**
*
* @param discusshuodongxinde
* @return
*/
@RequestMapping("/query")
public R query(DiscusshuodongxindeEntity discusshuodongxinde){
EntityWrapper< DiscusshuodongxindeEntity> ew = new EntityWrapper< DiscusshuodongxindeEntity>();
ew.allEq(MPUtil.allEQMapPre( discusshuodongxinde, "discusshuodongxinde"));
DiscusshuodongxindeView discusshuodongxindeView = discusshuodongxindeService.selectView(ew);
return R.ok("查询活动心得评论表成功").put("data", discusshuodongxindeView);
public R query(DiscusshuodongxindeEntity discusshuodongxinde) {
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
ew.allEq(MPUtil.allEQMapPre(discusshuodongxinde, "discusshuodongxinde")); // 设置查询条件
DiscusshuodongxindeView discusshuodongxindeView = discusshuodongxindeService.selectView(ew); // 查询视图数据
return R.ok("查询活动心得评论表成功").put("data", discusshuodongxindeView); // 返回查询结果
}
/**
*
*
* @param id ID
* @return ID
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
DiscusshuodongxindeEntity discusshuodongxinde = discusshuodongxindeService.selectById(id);
return R.ok().put("data", discusshuodongxinde);
public R info(@PathVariable("id") Long id) {
DiscusshuodongxindeEntity discusshuodongxinde = discusshuodongxindeService.selectById(id); // 根据ID查询数据
return R.ok().put("data", discusshuodongxinde); // 返回查询结果
}
/**
*
*
* @param id ID
* @return ID
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
DiscusshuodongxindeEntity discusshuodongxinde = discusshuodongxindeService.selectById(id);
return R.ok().put("data", discusshuodongxinde);
public R detail(@PathVariable("id") Long id) {
DiscusshuodongxindeEntity discusshuodongxinde = discusshuodongxindeService.selectById(id); // 根据ID查询数据
return R.ok().put("data", discusshuodongxinde); // 返回查询结果
}
/**
*
*
* @param discusshuodongxinde
* @param request
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request){
discusshuodongxinde.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(discusshuodongxinde);
discusshuodongxindeService.insert(discusshuodongxinde);
return R.ok();
public R save(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
discusshuodongxinde.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(discusshuodongxinde); // 验证数据
discusshuodongxindeService.insert(discusshuodongxinde); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param discusshuodongxinde
* @param request
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request){
discusshuodongxinde.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(discusshuodongxinde);
discusshuodongxindeService.insert(discusshuodongxinde);
return R.ok();
public R add(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
discusshuodongxinde.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(discusshuodongxinde); // 验证数据
discusshuodongxindeService.insert(discusshuodongxinde); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param discusshuodongxinde
* @param request
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request){
//ValidatorUtils.validateEntity(discusshuodongxinde);
discusshuodongxindeService.updateById(discusshuodongxinde);//全部更新
return R.ok();
@Transactional // 开启事务
public R update(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
// ValidatorUtils.validateEntity(discusshuodongxinde); // 验证数据
discusshuodongxindeService.updateById(discusshuodongxinde); // 根据ID更新数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
discusshuodongxindeService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
discusshuodongxindeService.deleteBatchIds(Arrays.asList(ids)); // 批量删除数据
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<DiscusshuodongxindeEntity> wrapper = new EntityWrapper<DiscusshuodongxindeEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = discusshuodongxindeService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加类型到参数
if (type.equals("2")) { // 如果类型为2
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有开始日期
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并存入参数
}
if (map.get("remindend") != null) { // 如果有结束日期
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并存入参数
}
}
Wrapper<DiscusshuodongxindeEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
int count = discusshuodongxindeService.selectCount(wrapper); // 统计符合条件的记录数
return R.ok().put("count", count); // 返回统计结果
}
}

@ -19,11 +19,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.annotation.IgnoreAuth;
@ -34,83 +30,95 @@ import com.service.ConfigService;
import com.utils.R;
/**
*
*
*/
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
public class FileController {
@Autowired
private ConfigService configService;
private ConfigService configService; // 注入配置服务类
/**
*
*
* @param file
* @param type 1
* @return
* @throws Exception
*/
@RequestMapping("/upload")
public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
if (file.isEmpty()) {
throw new EIException("上传文件不能为空");
public R upload(@RequestParam("file") MultipartFile file, String type) throws Exception {
if (file.isEmpty()) { // 检查文件是否为空
throw new EIException("上传文件不能为空"); // 抛出异常
}
String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
File path = new File(ResourceUtils.getURL("classpath:static").getPath());
if(!path.exists()) {
path = new File("");
String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); // 获取文件扩展名
File path = new File(ResourceUtils.getURL("classpath:static").getPath()); // 获取静态资源路径
if (!path.exists()) { // 如果路径不存在
path = new File(""); // 设置默认路径
}
File upload = new File(path.getAbsolutePath(),"/upload/");
if(!upload.exists()) {
upload.mkdirs();
File upload = new File(path.getAbsolutePath(), "/upload/"); // 定义上传目录
if (!upload.exists()) { // 如果上传目录不存在
upload.mkdirs(); // 创建目录
}
String fileName = new Date().getTime()+"."+fileExt;
File dest = new File(upload.getAbsolutePath()+"/"+fileName);
file.transferTo(dest);
String fileName = new Date().getTime() + "." + fileExt; // 生成唯一的文件名
File dest = new File(upload.getAbsolutePath() + "/" + fileName); // 定义目标文件路径
file.transferTo(dest); // 将文件保存到目标位置
/**
* 使ideaeclipse
* "D:\\springbootq33sd\\src\\main\\resources\\static\\upload"upload
*
*/
// FileUtils.copyFile(dest, new File("D:\\springbootq33sd\\src\\main\\resources\\static\\upload"+"/"+fileName)); /**修改了路径以后请将该行最前面的//注释去掉**/
if(StringUtils.isNotBlank(type) && type.equals("1")) {
ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
if(configEntity==null) {
configEntity = new ConfigEntity();
configEntity.setName("faceFile");
configEntity.setValue(fileName);
* 使IDEIntelliJ IDEAEclipse
* 1.
* 2. "D:\\\\springbootq33sd\\\\src\\\\main\\\\resources\\\\static\\\\upload"
* 3.
*/
// FileUtils.copyFile(dest, new File("D:\\\\springbootq33sd\\\\src\\\\main\\\\resources\\\\static\\\\upload\\\\" + fileName)); // 复制文件到指定路径
if (StringUtils.isNotBlank(type) && type.equals("1")) { // 如果类型为1人脸文件
ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); // 查询配置项
if (configEntity == null) { // 如果配置项不存在
configEntity = new ConfigEntity(); // 创建新配置项
configEntity.setName("faceFile"); // 设置配置项名称
configEntity.setValue(fileName); // 设置文件名
} else {
configEntity.setValue(fileName);
configEntity.setValue(fileName); // 更新文件名
}
configService.insertOrUpdate(configEntity);
configService.insertOrUpdate(configEntity); // 插入或更新配置项
}
return R.ok().put("file", fileName);
return R.ok().put("file", fileName); // 返回成功结果
}
/**
*
*
* @param fileName
* @return
*/
@IgnoreAuth
@RequestMapping("/download")
public ResponseEntity<byte[]> download(@RequestParam String fileName) {
try {
File path = new File(ResourceUtils.getURL("classpath:static").getPath());
if(!path.exists()) {
path = new File("");
File path = new File(ResourceUtils.getURL("classpath:static").getPath()); // 获取静态资源路径
if (!path.exists()) { // 如果路径不存在
path = new File(""); // 设置默认路径
}
File upload = new File(path.getAbsolutePath(),"/upload/");
if(!upload.exists()) {
upload.mkdirs();
File upload = new File(path.getAbsolutePath(), "/upload/"); // 定义上传目录
if (!upload.exists()) { // 如果上传目录不存在
upload.mkdirs(); // 创建目录
}
File file = new File(upload.getAbsolutePath()+"/"+fileName);
if(file.exists()){
/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
getResponse().sendError(403);
}*/
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
headers.setContentDispositionFormData("attachment", fileName);
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
File file = new File(upload.getAbsolutePath() + "/" + fileName); // 定义目标文件路径
if (file.exists()) { // 如果文件存在
HttpHeaders headers = new HttpHeaders(); // 设置响应头
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); // 设置内容类型
headers.setContentDispositionFormData("attachment", fileName); // 设置附件下载
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file), headers, HttpStatus.OK); // 返回文件流
}
} catch (IOException e) {
e.printStackTrace();
e.printStackTrace(); // 打印异常日志
}
return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR); // 返回错误状态码
}
}

@ -38,188 +38,204 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/huodongbaoming")
public class HuodongbaomingController {
@Autowired
private HuodongbaomingService huodongbaomingService;
private HuodongbaomingService huodongbaomingService; // 注入活动报名服务
/**
*
* @param params
* @param huodongbaoming
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,HuodongbaomingEntity huodongbaoming,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("zhiyuanzhe")) {
huodongbaoming.setXuehao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<HuodongbaomingEntity>();
PageUtils page = huodongbaomingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongbaoming), params), params));
return R.ok().put("data", page);
public R page(@RequestParam Map<String, Object> params, HuodongbaomingEntity huodongbaoming,
HttpServletRequest request) {
String tableName = request.getSession().getAttribute("tableName").toString(); // 获取当前用户表名
if (tableName.equals("zhiyuanzhe")) { // 如果是志愿者表
huodongbaoming.setXuehao((String) request.getSession().getAttribute("username")); // 设置学号
}
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongbaomingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongbaoming), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param huodongbaoming
* @param request HTTP
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,HuodongbaomingEntity huodongbaoming,
HttpServletRequest request){
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<HuodongbaomingEntity>();
PageUtils page = huodongbaomingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongbaoming), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, HuodongbaomingEntity huodongbaoming,
HttpServletRequest request) {
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongbaomingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongbaoming), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param huodongbaoming
* @return
*/
@RequestMapping("/lists")
public R list( HuodongbaomingEntity huodongbaoming){
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<HuodongbaomingEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongbaoming, "huodongbaoming"));
return R.ok().put("data", huodongbaomingService.selectListView(ew));
public R list(HuodongbaomingEntity huodongbaoming) {
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongbaoming, "huodongbaoming")); // 设置查询条件
return R.ok().put("data", huodongbaomingService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param huodongbaoming
* @return
*/
@RequestMapping("/query")
public R query(HuodongbaomingEntity huodongbaoming){
EntityWrapper< HuodongbaomingEntity> ew = new EntityWrapper< HuodongbaomingEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongbaoming, "huodongbaoming"));
HuodongbaomingView huodongbaomingView = huodongbaomingService.selectView(ew);
return R.ok("查询活动报名成功").put("data", huodongbaomingView);
public R query(HuodongbaomingEntity huodongbaoming) {
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongbaoming, "huodongbaoming")); // 设置查询条件
HuodongbaomingView huodongbaomingView = huodongbaomingService.selectView(ew); // 查询视图
return R.ok("查询活动报名成功").put("data", huodongbaomingView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id);
return R.ok().put("data", huodongbaoming);
public R info(@PathVariable("id") Long id) {
HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongbaoming); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id);
return R.ok().put("data", huodongbaoming);
public R detail(@PathVariable("id") Long id) {
HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongbaoming); // 返回记录详情
}
/**
*
* @param huodongbaoming
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request){
huodongbaoming.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongbaoming);
huodongbaomingService.insert(huodongbaoming);
return R.ok();
public R save(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request) {
huodongbaoming.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
huodongbaomingService.insert(huodongbaoming); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param huodongbaoming
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request){
huodongbaoming.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongbaoming);
huodongbaomingService.insert(huodongbaoming);
return R.ok();
public R add(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request) {
huodongbaoming.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
huodongbaomingService.insert(huodongbaoming); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param huodongbaoming
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request){
//ValidatorUtils.validateEntity(huodongbaoming);
huodongbaomingService.updateById(huodongbaoming);//全部更新
return R.ok();
public R update(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request) {
huodongbaomingService.updateById(huodongbaoming); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
huodongbaomingService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
huodongbaomingService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<HuodongbaomingEntity> wrapper = new EntityWrapper<HuodongbaomingEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("zhiyuanzhe")) {
wrapper.eq("xuehao", (String)request.getSession().getAttribute("username"));
}
int count = huodongbaomingService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<HuodongbaomingEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
String tableName = request.getSession().getAttribute("tableName").toString(); // 获取当前用户表名
if (tableName.equals("zhiyuanzhe")) { // 如果是志愿者表
wrapper.eq("xuehao", (String) request.getSession().getAttribute("username")); // 设置学号条件
}
int count = huodongbaomingService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -38,180 +38,194 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/huodongleixing")
public class HuodongleixingController {
@Autowired
private HuodongleixingService huodongleixingService;
private HuodongleixingService huodongleixingService; // 注入活动类型服务
/**
*
* @param params
* @param huodongleixing
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,HuodongleixingEntity huodongleixing,
HttpServletRequest request){
EntityWrapper<HuodongleixingEntity> ew = new EntityWrapper<HuodongleixingEntity>();
PageUtils page = huodongleixingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongleixing), params), params));
public R page(@RequestParam Map<String, Object> params, HuodongleixingEntity huodongleixing,
HttpServletRequest request) {
EntityWrapper<HuodongleixingEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongleixingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongleixing), params), params));
return R.ok().put("data", page);
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param huodongleixing
* @param request HTTP
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,HuodongleixingEntity huodongleixing,
HttpServletRequest request){
EntityWrapper<HuodongleixingEntity> ew = new EntityWrapper<HuodongleixingEntity>();
PageUtils page = huodongleixingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongleixing), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, HuodongleixingEntity huodongleixing,
HttpServletRequest request) {
EntityWrapper<HuodongleixingEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongleixingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongleixing), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param huodongleixing
* @return
*/
@RequestMapping("/lists")
public R list( HuodongleixingEntity huodongleixing){
EntityWrapper<HuodongleixingEntity> ew = new EntityWrapper<HuodongleixingEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongleixing, "huodongleixing"));
return R.ok().put("data", huodongleixingService.selectListView(ew));
public R list(HuodongleixingEntity huodongleixing) {
EntityWrapper<HuodongleixingEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongleixing, "huodongleixing")); // 设置查询条件
return R.ok().put("data", huodongleixingService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param huodongleixing
* @return
*/
@RequestMapping("/query")
public R query(HuodongleixingEntity huodongleixing){
EntityWrapper< HuodongleixingEntity> ew = new EntityWrapper< HuodongleixingEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongleixing, "huodongleixing"));
HuodongleixingView huodongleixingView = huodongleixingService.selectView(ew);
return R.ok("查询活动类型成功").put("data", huodongleixingView);
public R query(HuodongleixingEntity huodongleixing) {
EntityWrapper<HuodongleixingEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongleixing, "huodongleixing")); // 设置查询条件
HuodongleixingView huodongleixingView = huodongleixingService.selectView(ew); // 查询视图
return R.ok("查询活动类型成功").put("data", huodongleixingView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
HuodongleixingEntity huodongleixing = huodongleixingService.selectById(id);
return R.ok().put("data", huodongleixing);
public R info(@PathVariable("id") Long id) {
HuodongleixingEntity huodongleixing = huodongleixingService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongleixing); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
HuodongleixingEntity huodongleixing = huodongleixingService.selectById(id);
return R.ok().put("data", huodongleixing);
public R detail(@PathVariable("id") Long id) {
HuodongleixingEntity huodongleixing = huodongleixingService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongleixing); // 返回记录详情
}
/**
*
* @param huodongleixing
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody HuodongleixingEntity huodongleixing, HttpServletRequest request){
huodongleixing.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongleixing);
huodongleixingService.insert(huodongleixing);
return R.ok();
public R save(@RequestBody HuodongleixingEntity huodongleixing, HttpServletRequest request) {
huodongleixing.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
huodongleixingService.insert(huodongleixing); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param huodongleixing
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody HuodongleixingEntity huodongleixing, HttpServletRequest request){
huodongleixing.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongleixing);
huodongleixingService.insert(huodongleixing);
return R.ok();
public R add(@RequestBody HuodongleixingEntity huodongleixing, HttpServletRequest request) {
huodongleixing.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
huodongleixingService.insert(huodongleixing); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param huodongleixing
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody HuodongleixingEntity huodongleixing, HttpServletRequest request){
//ValidatorUtils.validateEntity(huodongleixing);
huodongleixingService.updateById(huodongleixing);//全部更新
return R.ok();
public R update(@RequestBody HuodongleixingEntity huodongleixing, HttpServletRequest request) {
huodongleixingService.updateById(huodongleixing); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
huodongleixingService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
huodongleixingService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<HuodongleixingEntity> wrapper = new EntityWrapper<HuodongleixingEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = huodongleixingService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<HuodongleixingEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
int count = huodongleixingService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -38,188 +38,204 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/huodongtongzhi")
public class HuodongtongzhiController {
@Autowired
private HuodongtongzhiService huodongtongzhiService;
private HuodongtongzhiService huodongtongzhiService; // 注入活动通知服务
/**
*
* @param params
* @param huodongtongzhi
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,HuodongtongzhiEntity huodongtongzhi,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("zhiyuanzhe")) {
huodongtongzhi.setXuehao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<HuodongtongzhiEntity> ew = new EntityWrapper<HuodongtongzhiEntity>();
PageUtils page = huodongtongzhiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongtongzhi), params), params));
return R.ok().put("data", page);
public R page(@RequestParam Map<String, Object> params, HuodongtongzhiEntity huodongtongzhi,
HttpServletRequest request) {
String tableName = request.getSession().getAttribute("tableName").toString(); // 获取当前表名
if (tableName.equals("zhiyuanzhe")) { // 如果是志愿者表
huodongtongzhi.setXuehao((String) request.getSession().getAttribute("username")); // 设置学号
}
EntityWrapper<HuodongtongzhiEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongtongzhiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongtongzhi), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param huodongtongzhi
* @param request HTTP
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,HuodongtongzhiEntity huodongtongzhi,
HttpServletRequest request){
EntityWrapper<HuodongtongzhiEntity> ew = new EntityWrapper<HuodongtongzhiEntity>();
PageUtils page = huodongtongzhiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongtongzhi), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, HuodongtongzhiEntity huodongtongzhi,
HttpServletRequest request) {
EntityWrapper<HuodongtongzhiEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongtongzhiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongtongzhi), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param huodongtongzhi
* @return
*/
@RequestMapping("/lists")
public R list( HuodongtongzhiEntity huodongtongzhi){
EntityWrapper<HuodongtongzhiEntity> ew = new EntityWrapper<HuodongtongzhiEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongtongzhi, "huodongtongzhi"));
return R.ok().put("data", huodongtongzhiService.selectListView(ew));
public R list(HuodongtongzhiEntity huodongtongzhi) {
EntityWrapper<HuodongtongzhiEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongtongzhi, "huodongtongzhi")); // 设置查询条件
return R.ok().put("data", huodongtongzhiService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param huodongtongzhi
* @return
*/
@RequestMapping("/query")
public R query(HuodongtongzhiEntity huodongtongzhi){
EntityWrapper< HuodongtongzhiEntity> ew = new EntityWrapper< HuodongtongzhiEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongtongzhi, "huodongtongzhi"));
HuodongtongzhiView huodongtongzhiView = huodongtongzhiService.selectView(ew);
return R.ok("查询活动通知成功").put("data", huodongtongzhiView);
public R query(HuodongtongzhiEntity huodongtongzhi) {
EntityWrapper<HuodongtongzhiEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongtongzhi, "huodongtongzhi")); // 设置查询条件
HuodongtongzhiView huodongtongzhiView = huodongtongzhiService.selectView(ew); // 查询视图
return R.ok("查询活动通知成功").put("data", huodongtongzhiView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
HuodongtongzhiEntity huodongtongzhi = huodongtongzhiService.selectById(id);
return R.ok().put("data", huodongtongzhi);
public R info(@PathVariable("id") Long id) {
HuodongtongzhiEntity huodongtongzhi = huodongtongzhiService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongtongzhi); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
HuodongtongzhiEntity huodongtongzhi = huodongtongzhiService.selectById(id);
return R.ok().put("data", huodongtongzhi);
public R detail(@PathVariable("id") Long id) {
HuodongtongzhiEntity huodongtongzhi = huodongtongzhiService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongtongzhi); // 返回记录详情
}
/**
*
* @param huodongtongzhi
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody HuodongtongzhiEntity huodongtongzhi, HttpServletRequest request){
huodongtongzhi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongtongzhi);
huodongtongzhiService.insert(huodongtongzhi);
return R.ok();
public R save(@RequestBody HuodongtongzhiEntity huodongtongzhi, HttpServletRequest request) {
huodongtongzhi.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
huodongtongzhiService.insert(huodongtongzhi); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param huodongtongzhi
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody HuodongtongzhiEntity huodongtongzhi, HttpServletRequest request){
huodongtongzhi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongtongzhi);
huodongtongzhiService.insert(huodongtongzhi);
return R.ok();
public R add(@RequestBody HuodongtongzhiEntity huodongtongzhi, HttpServletRequest request) {
huodongtongzhi.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
huodongtongzhiService.insert(huodongtongzhi); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param huodongtongzhi
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody HuodongtongzhiEntity huodongtongzhi, HttpServletRequest request){
//ValidatorUtils.validateEntity(huodongtongzhi);
huodongtongzhiService.updateById(huodongtongzhi);//全部更新
return R.ok();
public R update(@RequestBody HuodongtongzhiEntity huodongtongzhi, HttpServletRequest request) {
huodongtongzhiService.updateById(huodongtongzhi); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
huodongtongzhiService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
huodongtongzhiService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<HuodongtongzhiEntity> wrapper = new EntityWrapper<HuodongtongzhiEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("zhiyuanzhe")) {
wrapper.eq("xuehao", (String)request.getSession().getAttribute("username"));
}
int count = huodongtongzhiService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<HuodongtongzhiEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
String tableName = request.getSession().getAttribute("tableName").toString(); // 获取当前表名
if (tableName.equals("zhiyuanzhe")) { // 如果是志愿者表
wrapper.eq("xuehao", (String) request.getSession().getAttribute("username")); // 设置学号过滤条件
}
int count = huodongtongzhiService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -40,189 +40,212 @@ import com.service.StoreupService;
import com.entity.StoreupEntity;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/huodongxinde")
public class HuodongxindeController {
@Autowired
private HuodongxindeService huodongxindeService;
private HuodongxindeService huodongxindeService; // 注入活动心得服务
@Autowired
private StoreupService storeupService;
private StoreupService storeupService; // 注入收藏服务
/**
*
* @param params
* @param huodongxinde
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,HuodongxindeEntity huodongxinde,
HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
huodongxinde.setUserid((Long)request.getSession().getAttribute("userId"));
}
EntityWrapper<HuodongxindeEntity> ew = new EntityWrapper<HuodongxindeEntity>();
PageUtils page = huodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinde), params), params));
return R.ok().put("data", page);
public R page(@RequestParam Map<String, Object> params, HuodongxindeEntity huodongxinde,
HttpServletRequest request) {
// 如果不是管理员设置用户ID
if (!request.getSession().getAttribute("role").toString().equals("管理员")) {
huodongxinde.setUserid((Long) request.getSession().getAttribute("userId"));
}
EntityWrapper<HuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinde), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param huodongxinde
* @param request HTTP
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,HuodongxindeEntity huodongxinde,
HttpServletRequest request){
EntityWrapper<HuodongxindeEntity> ew = new EntityWrapper<HuodongxindeEntity>();
PageUtils page = huodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinde), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, HuodongxindeEntity huodongxinde,
HttpServletRequest request) {
EntityWrapper<HuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinde), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param huodongxinde
* @return
*/
@RequestMapping("/lists")
public R list( HuodongxindeEntity huodongxinde){
EntityWrapper<HuodongxindeEntity> ew = new EntityWrapper<HuodongxindeEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongxinde, "huodongxinde"));
return R.ok().put("data", huodongxindeService.selectListView(ew));
public R list(HuodongxindeEntity huodongxinde) {
EntityWrapper<HuodongxindeEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongxinde, "huodongxinde")); // 设置查询条件
return R.ok().put("data", huodongxindeService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param huodongxinde
* @return
*/
@RequestMapping("/query")
public R query(HuodongxindeEntity huodongxinde){
EntityWrapper< HuodongxindeEntity> ew = new EntityWrapper< HuodongxindeEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongxinde, "huodongxinde"));
HuodongxindeView huodongxindeView = huodongxindeService.selectView(ew);
return R.ok("查询活动心得成功").put("data", huodongxindeView);
public R query(HuodongxindeEntity huodongxinde) {
EntityWrapper<HuodongxindeEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongxinde, "huodongxinde")); // 设置查询条件
HuodongxindeView huodongxindeView = huodongxindeService.selectView(ew); // 查询视图
return R.ok("查询活动心得成功").put("data", huodongxindeView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
HuodongxindeEntity huodongxinde = huodongxindeService.selectById(id);
return R.ok().put("data", huodongxinde);
public R info(@PathVariable("id") Long id) {
HuodongxindeEntity huodongxinde = huodongxindeService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongxinde); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
HuodongxindeEntity huodongxinde = huodongxindeService.selectById(id);
return R.ok().put("data", huodongxinde);
public R detail(@PathVariable("id") Long id) {
HuodongxindeEntity huodongxinde = huodongxindeService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongxinde); // 返回记录详情
}
/**
*
* @param huodongxinde
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody HuodongxindeEntity huodongxinde, HttpServletRequest request){
huodongxinde.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongxinde);
huodongxinde.setUserid((Long)request.getSession().getAttribute("userId"));
huodongxindeService.insert(huodongxinde);
return R.ok();
public R save(@RequestBody HuodongxindeEntity huodongxinde, HttpServletRequest request) {
huodongxinde.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(huodongxinde); // 验证实体(可选)
huodongxinde.setUserid((Long) request.getSession().getAttribute("userId")); // 设置用户ID
huodongxindeService.insert(huodongxinde); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param huodongxinde
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody HuodongxindeEntity huodongxinde, HttpServletRequest request){
huodongxinde.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongxinde);
huodongxindeService.insert(huodongxinde);
return R.ok();
public R add(@RequestBody HuodongxindeEntity huodongxinde, HttpServletRequest request) {
huodongxinde.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(huodongxinde); // 验证实体(可选)
huodongxinde.setUserid((Long) request.getSession().getAttribute("userId")); // 设置用户ID
huodongxindeService.insert(huodongxinde); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param huodongxinde
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody HuodongxindeEntity huodongxinde, HttpServletRequest request){
//ValidatorUtils.validateEntity(huodongxinde);
huodongxindeService.updateById(huodongxinde);//全部更新
return R.ok();
public R update(@RequestBody HuodongxindeEntity huodongxinde, HttpServletRequest request) {
// ValidatorUtils.validateEntity(huodongxinde); // 验证实体(可选)
huodongxindeService.updateById(huodongxinde); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
huodongxindeService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
huodongxindeService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<HuodongxindeEntity> wrapper = new EntityWrapper<HuodongxindeEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
wrapper.eq("userid", (Long)request.getSession().getAttribute("userId"));
}
int count = huodongxindeService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<HuodongxindeEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
// 如果不是管理员设置用户ID过滤条件
if (!request.getSession().getAttribute("role").toString().equals("管理员")) {
wrapper.eq("userid", (Long) request.getSession().getAttribute("userId"));
}
int count = huodongxindeService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -38,180 +38,197 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/huodongxinxi")
public class HuodongxinxiController {
@Autowired
private HuodongxinxiService huodongxinxiService;
private HuodongxinxiService huodongxinxiService; // 注入活动信息服务
/**
*
* @param params
* @param huodongxinxi
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,HuodongxinxiEntity huodongxinxi,
HttpServletRequest request){
EntityWrapper<HuodongxinxiEntity> ew = new EntityWrapper<HuodongxinxiEntity>();
PageUtils page = huodongxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinxi), params), params));
public R page(@RequestParam Map<String, Object> params, HuodongxinxiEntity huodongxinxi,
HttpServletRequest request) {
EntityWrapper<HuodongxinxiEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinxi), params), params));
return R.ok().put("data", page);
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param huodongxinxi
* @param request HTTP
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,HuodongxinxiEntity huodongxinxi,
HttpServletRequest request){
EntityWrapper<HuodongxinxiEntity> ew = new EntityWrapper<HuodongxinxiEntity>();
PageUtils page = huodongxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinxi), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, HuodongxinxiEntity huodongxinxi,
HttpServletRequest request) {
EntityWrapper<HuodongxinxiEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinxi), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param huodongxinxi
* @return
*/
@RequestMapping("/lists")
public R list( HuodongxinxiEntity huodongxinxi){
EntityWrapper<HuodongxinxiEntity> ew = new EntityWrapper<HuodongxinxiEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongxinxi, "huodongxinxi"));
return R.ok().put("data", huodongxinxiService.selectListView(ew));
public R list(HuodongxinxiEntity huodongxinxi) {
EntityWrapper<HuodongxinxiEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongxinxi, "huodongxinxi")); // 设置查询条件
return R.ok().put("data", huodongxinxiService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param huodongxinxi
* @return
*/
@RequestMapping("/query")
public R query(HuodongxinxiEntity huodongxinxi){
EntityWrapper< HuodongxinxiEntity> ew = new EntityWrapper< HuodongxinxiEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongxinxi, "huodongxinxi"));
HuodongxinxiView huodongxinxiView = huodongxinxiService.selectView(ew);
return R.ok("查询活动信息成功").put("data", huodongxinxiView);
public R query(HuodongxinxiEntity huodongxinxi) {
EntityWrapper<HuodongxinxiEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongxinxi, "huodongxinxi")); // 设置查询条件
HuodongxinxiView huodongxinxiView = huodongxinxiService.selectView(ew); // 查询视图
return R.ok("查询活动信息成功").put("data", huodongxinxiView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
HuodongxinxiEntity huodongxinxi = huodongxinxiService.selectById(id);
return R.ok().put("data", huodongxinxi);
public R info(@PathVariable("id") Long id) {
HuodongxinxiEntity huodongxinxi = huodongxinxiService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongxinxi); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
HuodongxinxiEntity huodongxinxi = huodongxinxiService.selectById(id);
return R.ok().put("data", huodongxinxi);
public R detail(@PathVariable("id") Long id) {
HuodongxinxiEntity huodongxinxi = huodongxinxiService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongxinxi); // 返回记录详情
}
/**
*
* @param huodongxinxi
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody HuodongxinxiEntity huodongxinxi, HttpServletRequest request){
huodongxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongxinxi);
huodongxinxiService.insert(huodongxinxi);
return R.ok();
public R save(@RequestBody HuodongxinxiEntity huodongxinxi, HttpServletRequest request) {
huodongxinxi.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(huodongxinxi); // 验证实体(可选)
huodongxinxiService.insert(huodongxinxi); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param huodongxinxi
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody HuodongxinxiEntity huodongxinxi, HttpServletRequest request){
huodongxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongxinxi);
huodongxinxiService.insert(huodongxinxi);
return R.ok();
public R add(@RequestBody HuodongxinxiEntity huodongxinxi, HttpServletRequest request) {
huodongxinxi.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(huodongxinxi); // 验证实体(可选)
huodongxinxiService.insert(huodongxinxi); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param huodongxinxi
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody HuodongxinxiEntity huodongxinxi, HttpServletRequest request){
//ValidatorUtils.validateEntity(huodongxinxi);
huodongxinxiService.updateById(huodongxinxi);//全部更新
return R.ok();
public R update(@RequestBody HuodongxinxiEntity huodongxinxi, HttpServletRequest request) {
// ValidatorUtils.validateEntity(huodongxinxi); // 验证实体(可选)
huodongxinxiService.updateById(huodongxinxi); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
huodongxinxiService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
huodongxinxiService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<HuodongxinxiEntity> wrapper = new EntityWrapper<HuodongxinxiEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = huodongxinxiService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<HuodongxinxiEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
int count = huodongxinxiService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -38,183 +38,200 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/messages")
public class MessagesController {
@Autowired
private MessagesService messagesService;
private MessagesService messagesService; // 注入消息服务
/**
*
* @param params
* @param messages
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,MessagesEntity messages,
HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
messages.setUserid((Long)request.getSession().getAttribute("userId"));
}
EntityWrapper<MessagesEntity> ew = new EntityWrapper<MessagesEntity>();
PageUtils page = messagesService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, messages), params), params));
return R.ok().put("data", page);
public R page(@RequestParam Map<String, Object> params, MessagesEntity messages,
HttpServletRequest request) {
if (!request.getSession().getAttribute("role").toString().equals("管理员")) {
messages.setUserid((Long) request.getSession().getAttribute("userId")); // 设置当前用户ID
}
EntityWrapper<MessagesEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = messagesService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, messages), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param messages
* @param request HTTP
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,MessagesEntity messages,
HttpServletRequest request){
EntityWrapper<MessagesEntity> ew = new EntityWrapper<MessagesEntity>();
PageUtils page = messagesService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, messages), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, MessagesEntity messages,
HttpServletRequest request) {
EntityWrapper<MessagesEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = messagesService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, messages), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param messages
* @return
*/
@RequestMapping("/lists")
public R list( MessagesEntity messages){
EntityWrapper<MessagesEntity> ew = new EntityWrapper<MessagesEntity>();
ew.allEq(MPUtil.allEQMapPre( messages, "messages"));
return R.ok().put("data", messagesService.selectListView(ew));
public R list(MessagesEntity messages) {
EntityWrapper<MessagesEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(messages, "messages")); // 设置查询条件
return R.ok().put("data", messagesService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param messages
* @return
*/
@RequestMapping("/query")
public R query(MessagesEntity messages){
EntityWrapper< MessagesEntity> ew = new EntityWrapper< MessagesEntity>();
ew.allEq(MPUtil.allEQMapPre( messages, "messages"));
MessagesView messagesView = messagesService.selectView(ew);
return R.ok("查询交流反馈成功").put("data", messagesView);
public R query(MessagesEntity messages) {
EntityWrapper<MessagesEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(messages, "messages")); // 设置查询条件
MessagesView messagesView = messagesService.selectView(ew); // 查询视图
return R.ok("查询交流反馈成功").put("data", messagesView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
MessagesEntity messages = messagesService.selectById(id);
return R.ok().put("data", messages);
public R info(@PathVariable("id") Long id) {
MessagesEntity messages = messagesService.selectById(id); // 查询单条记录
return R.ok().put("data", messages); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
MessagesEntity messages = messagesService.selectById(id);
return R.ok().put("data", messages);
public R detail(@PathVariable("id") Long id) {
MessagesEntity messages = messagesService.selectById(id); // 查询单条记录
return R.ok().put("data", messages); // 返回记录详情
}
/**
*
* @param messages
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody MessagesEntity messages, HttpServletRequest request){
messages.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(messages);
messagesService.insert(messages);
return R.ok();
public R save(@RequestBody MessagesEntity messages, HttpServletRequest request) {
messages.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(messages); // 验证实体(可选)
messagesService.insert(messages); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param messages
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody MessagesEntity messages, HttpServletRequest request){
messages.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(messages);
messagesService.insert(messages);
return R.ok();
public R add(@RequestBody MessagesEntity messages, HttpServletRequest request) {
messages.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(messages); // 验证实体(可选)
messagesService.insert(messages); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param messages
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody MessagesEntity messages, HttpServletRequest request){
//ValidatorUtils.validateEntity(messages);
messagesService.updateById(messages);//全部更新
return R.ok();
public R update(@RequestBody MessagesEntity messages, HttpServletRequest request) {
// ValidatorUtils.validateEntity(messages); // 验证实体(可选)
messagesService.updateById(messages); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
messagesService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
messagesService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<MessagesEntity> wrapper = new EntityWrapper<MessagesEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = messagesService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<MessagesEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
int count = messagesService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -38,180 +38,197 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/news")
public class NewsController {
@Autowired
private NewsService newsService;
private NewsService newsService; // 注入新闻服务
/**
*
* @param params
* @param news
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,NewsEntity news,
HttpServletRequest request){
EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>();
PageUtils page = newsService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, news), params), params));
public R page(@RequestParam Map<String, Object> params, NewsEntity news,
HttpServletRequest request) {
EntityWrapper<NewsEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = newsService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, news), params), params));
return R.ok().put("data", page);
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param news
* @param request HTTP
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,NewsEntity news,
HttpServletRequest request){
EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>();
PageUtils page = newsService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, news), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, NewsEntity news,
HttpServletRequest request) {
EntityWrapper<NewsEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = newsService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, news), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param news
* @return
*/
@RequestMapping("/lists")
public R list( NewsEntity news){
EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>();
ew.allEq(MPUtil.allEQMapPre( news, "news"));
return R.ok().put("data", newsService.selectListView(ew));
public R list(NewsEntity news) {
EntityWrapper<NewsEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(news, "news")); // 设置查询条件
return R.ok().put("data", newsService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param news
* @return
*/
@RequestMapping("/query")
public R query(NewsEntity news){
EntityWrapper< NewsEntity> ew = new EntityWrapper< NewsEntity>();
ew.allEq(MPUtil.allEQMapPre( news, "news"));
NewsView newsView = newsService.selectView(ew);
return R.ok("查询公告信息成功").put("data", newsView);
public R query(NewsEntity news) {
EntityWrapper<NewsEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(news, "news")); // 设置查询条件
NewsView newsView = newsService.selectView(ew); // 查询视图
return R.ok("查询公告信息成功").put("data", newsView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
NewsEntity news = newsService.selectById(id);
return R.ok().put("data", news);
public R info(@PathVariable("id") Long id) {
NewsEntity news = newsService.selectById(id); // 查询单条记录
return R.ok().put("data", news); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
NewsEntity news = newsService.selectById(id);
return R.ok().put("data", news);
public R detail(@PathVariable("id") Long id) {
NewsEntity news = newsService.selectById(id); // 查询单条记录
return R.ok().put("data", news); // 返回记录详情
}
/**
*
* @param news
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody NewsEntity news, HttpServletRequest request){
news.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(news);
newsService.insert(news);
return R.ok();
public R save(@RequestBody NewsEntity news, HttpServletRequest request) {
news.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(news); // 验证实体(可选)
newsService.insert(news); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param news
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody NewsEntity news, HttpServletRequest request){
news.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(news);
newsService.insert(news);
return R.ok();
public R add(@RequestBody NewsEntity news, HttpServletRequest request) {
news.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(news); // 验证实体(可选)
newsService.insert(news); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param news
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody NewsEntity news, HttpServletRequest request){
//ValidatorUtils.validateEntity(news);
newsService.updateById(news);//全部更新
return R.ok();
public R update(@RequestBody NewsEntity news, HttpServletRequest request) {
// ValidatorUtils.validateEntity(news); // 验证实体(可选)
newsService.updateById(news); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
newsService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
newsService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<NewsEntity> wrapper = new EntityWrapper<NewsEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = newsService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<NewsEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
int count = newsService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -38,190 +38,207 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/storeup")
public class StoreupController {
@Autowired
private StoreupService storeupService;
private StoreupService storeupService; // 注入收藏服务
/**
*
* @param params
* @param storeup
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,StoreupEntity storeup,
HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
storeup.setUserid((Long)request.getSession().getAttribute("userId"));
}
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));
return R.ok().put("data", page);
public R page(@RequestParam Map<String, Object> params, StoreupEntity storeup,
HttpServletRequest request) {
if (!request.getSession().getAttribute("role").toString().equals("管理员")) {
storeup.setUserid((Long) request.getSession().getAttribute("userId")); // 非管理员设置用户ID
}
EntityWrapper<StoreupEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param storeup
* @param request HTTP
* @return
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,StoreupEntity storeup,
HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
storeup.setUserid((Long)request.getSession().getAttribute("userId"));
}
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, StoreupEntity storeup,
HttpServletRequest request) {
if (!request.getSession().getAttribute("role").toString().equals("管理员")) {
storeup.setUserid((Long) request.getSession().getAttribute("userId")); // 非管理员设置用户ID
}
EntityWrapper<StoreupEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param storeup
* @return
*/
@RequestMapping("/lists")
public R list( StoreupEntity storeup){
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
ew.allEq(MPUtil.allEQMapPre( storeup, "storeup"));
return R.ok().put("data", storeupService.selectListView(ew));
public R list(StoreupEntity storeup) {
EntityWrapper<StoreupEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(storeup, "storeup")); // 设置查询条件
return R.ok().put("data", storeupService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param storeup
* @return
*/
@RequestMapping("/query")
public R query(StoreupEntity storeup){
EntityWrapper< StoreupEntity> ew = new EntityWrapper< StoreupEntity>();
ew.allEq(MPUtil.allEQMapPre( storeup, "storeup"));
StoreupView storeupView = storeupService.selectView(ew);
return R.ok("查询收藏表成功").put("data", storeupView);
public R query(StoreupEntity storeup) {
EntityWrapper<StoreupEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(storeup, "storeup")); // 设置查询条件
StoreupView storeupView = storeupService.selectView(ew); // 查询视图
return R.ok("查询收藏表成功").put("data", storeupView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
StoreupEntity storeup = storeupService.selectById(id);
return R.ok().put("data", storeup);
public R info(@PathVariable("id") Long id) {
StoreupEntity storeup = storeupService.selectById(id); // 查询单条记录
return R.ok().put("data", storeup); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
StoreupEntity storeup = storeupService.selectById(id);
return R.ok().put("data", storeup);
public R detail(@PathVariable("id") Long id) {
StoreupEntity storeup = storeupService.selectById(id); // 查询单条记录
return R.ok().put("data", storeup); // 返回记录详情
}
/**
*
* @param storeup
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody StoreupEntity storeup, HttpServletRequest request){
storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(storeup);
storeup.setUserid((Long)request.getSession().getAttribute("userId"));
storeupService.insert(storeup);
return R.ok();
public R save(@RequestBody StoreupEntity storeup, HttpServletRequest request) {
storeup.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(storeup); // 验证实体(可选)
storeup.setUserid((Long) request.getSession().getAttribute("userId")); // 设置用户ID
storeupService.insert(storeup); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param storeup
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody StoreupEntity storeup, HttpServletRequest request){
storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(storeup);
storeup.setUserid((Long)request.getSession().getAttribute("userId"));
storeupService.insert(storeup);
return R.ok();
public R add(@RequestBody StoreupEntity storeup, HttpServletRequest request) {
storeup.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(storeup); // 验证实体(可选)
storeup.setUserid((Long) request.getSession().getAttribute("userId")); // 设置用户ID
storeupService.insert(storeup); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param storeup
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody StoreupEntity storeup, HttpServletRequest request){
//ValidatorUtils.validateEntity(storeup);
storeupService.updateById(storeup);//全部更新
return R.ok();
public R update(@RequestBody StoreupEntity storeup, HttpServletRequest request) {
// ValidatorUtils.validateEntity(storeup); // 验证实体(可选)
storeupService.updateById(storeup); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
storeupService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
storeupService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<StoreupEntity> wrapper = new EntityWrapper<StoreupEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
wrapper.eq("userid", (Long)request.getSession().getAttribute("userId"));
}
int count = storeupService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<StoreupEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
if (!request.getSession().getAttribute("role").toString().equals("管理员")) {
wrapper.eq("userid", (Long) request.getSession().getAttribute("userId")); // 非管理员过滤数据
}
int count = storeupService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -1,7 +1,5 @@
package com.controller;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
@ -33,142 +31,169 @@ import com.utils.R;
import com.utils.ValidatorUtils;
/**
*
*
*/
@RequestMapping("users")
@RestController
public class UserController{
public class UserController {
@Autowired
private UserService userService;
private UserService userService; // 注入用户服务
@Autowired
private TokenService tokenService;
private TokenService tokenService; // 注入令牌服务
/**
*
*
* @param username
* @param password
* @param captcha 使
* @param request HTTP
* @return
*/
@IgnoreAuth
@PostMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
if(user==null || !user.getPassword().equals(password)) {
return R.error("账号或密码不正确");
UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username)); // 查询用户
if (user == null || !user.getPassword().equals(password)) { // 验证用户名和密码是否匹配
return R.error("账号或密码不正确"); // 返回错误信息
}
String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
return R.ok().put("token", token);
String token = tokenService.generateToken(user.getId(), username, "users", user.getRole()); // 生成令牌
return R.ok().put("token", token); // 返回成功结果及令牌
}
/**
*
*
* @param user
* @return
*/
@IgnoreAuth
@PostMapping(value = "/register")
public R register(@RequestBody UserEntity user){
// ValidatorUtils.validateEntity(user);
if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
return R.error("用户已存在");
}
userService.insert(user);
return R.ok();
}
public R register(@RequestBody UserEntity user) {
// ValidatorUtils.validateEntity(user); // 验证用户实体(可选)
if (userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) != null) { // 检查用户名是否已存在
return R.error("用户已存在"); // 返回错误信息
}
userService.insert(user); // 插入新用户
return R.ok(); // 返回成功结果
}
/**
* 退
* 退
* @param request HTTP
* @return 退
*/
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
request.getSession().invalidate(); // 清空Session
return R.ok("退出成功"); // 返回成功信息
}
/**
*
*/
@IgnoreAuth
*
* @param username
* @param request HTTP
* @return
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
if(user==null) {
return R.error("账号不存在");
}
user.setPassword("123456");
userService.update(user,null);
return R.ok("密码已重置为123456");
}
public R resetPass(String username, HttpServletRequest request) {
UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username)); // 查询用户
if (user == null) { // 如果用户不存在
return R.error("账号不存在"); // 返回错误信息
}
user.setPassword("123456"); // 设置默认密码
userService.update(user, null); // 更新用户密码
return R.ok("密码已重置为123456"); // 返回成功信息
}
/**
*
* @param params
* @param user
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, UserEntity user) {
EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>(); // 创建查询条件
PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params)); // 查询分页数据
return R.ok().put("data", page); // 返回分页数据
}
/**
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,UserEntity user){
EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
return R.ok().put("data", page);
}
*
* @param user
* @return
*/
@RequestMapping("/list")
public R list(UserEntity user) {
EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>(); // 创建查询条件
ew.allEq(MPUtil.allEQMapPre(user, "user")); // 设置查询条件
return R.ok().put("data", userService.selectListView(ew)); // 返回用户列表
}
/**
*
*/
@RequestMapping("/list")
public R list( UserEntity user){
EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
ew.allEq(MPUtil.allEQMapPre( user, "user"));
return R.ok().put("data", userService.selectListView(ew));
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
UserEntity user = userService.selectById(id);
return R.ok().put("data", user);
}
/**
* session
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
UserEntity user = userService.selectById(id);
return R.ok().put("data", user);
}
/**
*
*/
@PostMapping("/save")
public R save(@RequestBody UserEntity user){
// ValidatorUtils.validateEntity(user);
if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
return R.error("用户已存在");
}
userService.insert(user);
return R.ok();
}
/**
*
*/
@RequestMapping("/update")
public R update(@RequestBody UserEntity user){
// ValidatorUtils.validateEntity(user);
UserEntity u = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername()));
if(u!=null && u.getId()!=user.getId() && u.getUsername().equals(user.getUsername())) {
return R.error("用户名已存在。");
}
userService.updateById(user);//全部更新
return R.ok();
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
userService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id) {
UserEntity user = userService.selectById(id); // 查询用户信息
return R.ok().put("data", user); // 返回用户信息
}
/**
* Session
* @param request HTTP
* @return
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request) {
Long id = (Long) request.getSession().getAttribute("userId"); // 获取Session中的用户ID
UserEntity user = userService.selectById(id); // 查询用户信息
return R.ok().put("data", user); // 返回当前用户信息
}
/**
*
* @param user
* @return
*/
@PostMapping("/save")
public R save(@RequestBody UserEntity user) {
// ValidatorUtils.validateEntity(user); // 验证用户实体(可选)
if (userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) != null) { // 检查用户名是否已存在
return R.error("用户已存在"); // 返回错误信息
}
userService.insert(user); // 插入新用户
return R.ok(); // 返回成功结果
}
/**
*
* @param user
* @return
*/
@RequestMapping("/update")
public R update(@RequestBody UserEntity user) {
// ValidatorUtils.validateEntity(user); // 验证用户实体(可选)
UserEntity u = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())); // 查询用户名是否存在
if (u != null && u.getId() != user.getId() && u.getUsername().equals(user.getUsername())) { // 检查用户名是否重复
return R.error("用户名已存在。"); // 返回错误信息
}
userService.updateById(user); // 全量更新用户信息
return R.ok(); // 返回成功结果
}
/**
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids) {
userService.deleteBatchIds(Arrays.asList(ids)); // 批量删除用户
return R.ok(); // 返回成功结果
}
}

@ -4,294 +4,314 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.ZhiyuanzheEntity;
import com.entity.view.ZhiyuanzheView;
import com.service.ZhiyuanzheService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
import java.io.IOException;
import com.utils.PageUtils;
import com.utils.R;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/zhiyuanzhe")
public class ZhiyuanzheController {
@Autowired
private ZhiyuanzheService zhiyuanzheService;
@Autowired
private ZhiyuanzheService zhiyuanzheService; // 注入志愿者服务
@Autowired
private TokenService tokenService;
private TokenService tokenService; // 注入令牌服务
/**
*
*
* @param username
* @param password
* @param captcha 使
* @param request HTTP
* @return
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", username)); // 查询用户
if (user == null || !user.getMima().equals(password)) { // 验证用户名和密码是否匹配
return R.error("账号或密码不正确"); // 返回错误信息
}
if ("否".equals(user.getSfsh())) { // 检查账号是否被锁定
return R.error("账号已锁定,请联系管理员审核。");
}
if("否".equals(user.getSfsh())) return R.error("账号已锁定,请联系管理员审核。");
String token = tokenService.generateToken(user.getId(), username,"zhiyuanzhe", "志愿者" );
return R.ok().put("token", token);
String token = tokenService.generateToken(user.getId(), username, "zhiyuanzhe", "志愿者"); // 生成令牌
return R.ok().put("token", token); // 返回成功结果及令牌
}
/**
*
*/
*
* @param zhiyuanzhe
* @return
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody ZhiyuanzheEntity zhiyuanzhe){
//ValidatorUtils.validateEntity(zhiyuanzhe);
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", zhiyuanzhe.getXuehao()));
if(user!=null) {
return R.error("注册用户已存在");
@RequestMapping("/register")
public R register(@RequestBody ZhiyuanzheEntity zhiyuanzhe) {
// ValidatorUtils.validateEntity(zhiyuanzhe); // 验证用户实体(可选)
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", zhiyuanzhe.getXuehao())); // 检查用户名是否已存在
if (user != null) {
return R.error("注册用户已存在"); // 返回错误信息
}
Long uId = new Date().getTime();
zhiyuanzhe.setId(uId);
zhiyuanzheService.insert(zhiyuanzhe);
return R.ok();
}
Long uId = new Date().getTime(); // 生成唯一ID
zhiyuanzhe.setId(uId); // 设置用户ID
zhiyuanzheService.insert(zhiyuanzhe); // 插入新用户
return R.ok(); // 返回成功结果
}
/**
* 退
* 退
* @param request HTTP
* @return 退
*/
@RequestMapping("/logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
request.getSession().invalidate(); // 清空Session
return R.ok("退出成功"); // 返回成功信息
}
/**
* session
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
ZhiyuanzheEntity user = zhiyuanzheService.selectById(id);
return R.ok().put("data", user);
}
/**
*
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
zhiyuanzheService.updateById(user);
return R.ok("密码已重置为123456");
}
* Session
* @param request HTTP
* @return
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request) {
Long id = (Long) request.getSession().getAttribute("userId"); // 获取Session中的用户ID
ZhiyuanzheEntity user = zhiyuanzheService.selectById(id); // 查询用户信息
return R.ok().put("data", user); // 返回当前用户信息
}
/**
*
* @param username
* @param request HTTP
* @return
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request) {
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", username)); // 查询用户
if (user == null) { // 如果用户不存在
return R.error("账号不存在"); // 返回错误信息
}
user.setMima("123456"); // 设置默认密码
zhiyuanzheService.updateById(user); // 更新用户密码
return R.ok("密码已重置为123456"); // 返回成功信息
}
/**
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,ZhiyuanzheEntity zhiyuanzhe,
HttpServletRequest request){
EntityWrapper<ZhiyuanzheEntity> ew = new EntityWrapper<ZhiyuanzheEntity>();
PageUtils page = zhiyuanzheService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, zhiyuanzhe), params), params));
/**
*
* @param params
* @param zhiyuanzhe
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request) {
EntityWrapper<ZhiyuanzheEntity> ew = new EntityWrapper<ZhiyuanzheEntity>(); // 创建查询条件
PageUtils page = zhiyuanzheService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, zhiyuanzhe), params), params)); // 查询分页数据
return R.ok().put("data", page); // 返回分页数据
}
return R.ok().put("data", page);
}
/**
*
*/
/**
*
* @param params
* @param zhiyuanzhe
* @param request HTTP
* @return
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ZhiyuanzheEntity zhiyuanzhe,
HttpServletRequest request){
EntityWrapper<ZhiyuanzheEntity> ew = new EntityWrapper<ZhiyuanzheEntity>();
PageUtils page = zhiyuanzheService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, zhiyuanzhe), params), params));
return R.ok().put("data", page);
}
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request) {
EntityWrapper<ZhiyuanzheEntity> ew = new EntityWrapper<ZhiyuanzheEntity>(); // 创建查询条件
PageUtils page = zhiyuanzheService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, zhiyuanzhe), params), params)); // 查询分页数据
return R.ok().put("data", page); // 返回分页数据
}
/**
*
*/
@RequestMapping("/lists")
public R list( ZhiyuanzheEntity zhiyuanzhe){
EntityWrapper<ZhiyuanzheEntity> ew = new EntityWrapper<ZhiyuanzheEntity>();
ew.allEq(MPUtil.allEQMapPre( zhiyuanzhe, "zhiyuanzhe"));
return R.ok().put("data", zhiyuanzheService.selectListView(ew));
}
/**
*
*/
@RequestMapping("/query")
public R query(ZhiyuanzheEntity zhiyuanzhe){
EntityWrapper< ZhiyuanzheEntity> ew = new EntityWrapper< ZhiyuanzheEntity>();
ew.allEq(MPUtil.allEQMapPre( zhiyuanzhe, "zhiyuanzhe"));
ZhiyuanzheView zhiyuanzheView = zhiyuanzheService.selectView(ew);
return R.ok("查询志愿者成功").put("data", zhiyuanzheView);
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
ZhiyuanzheEntity zhiyuanzhe = zhiyuanzheService.selectById(id);
return R.ok().put("data", zhiyuanzhe);
}
*
* @param zhiyuanzhe
* @return
*/
@RequestMapping("/lists")
public R lists(ZhiyuanzheEntity zhiyuanzhe) {
EntityWrapper<ZhiyuanzheEntity> ew = new EntityWrapper<ZhiyuanzheEntity>(); // 创建查询条件
ew.allEq(MPUtil.allEQMapPre(zhiyuanzhe, "zhiyuanzhe")); // 设置查询条件
return R.ok().put("data", zhiyuanzheService.selectListView(ew)); // 返回用户列表
}
/**
*
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
ZhiyuanzheEntity zhiyuanzhe = zhiyuanzheService.selectById(id);
return R.ok().put("data", zhiyuanzhe);
}
/**
*
* @param zhiyuanzhe
* @return
*/
@RequestMapping("/query")
public R query(ZhiyuanzheEntity zhiyuanzhe) {
EntityWrapper<ZhiyuanzheEntity> ew = new EntityWrapper<ZhiyuanzheEntity>(); // 创建查询条件
ew.allEq(MPUtil.allEQMapPre(zhiyuanzhe, "zhiyuanzhe")); // 设置查询条件
ZhiyuanzheView zhiyuanzheView = zhiyuanzheService.selectView(ew); // 查询视图数据
return R.ok("查询志愿者成功").put("data", zhiyuanzheView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id) {
ZhiyuanzheEntity zhiyuanzhe = zhiyuanzheService.selectById(id); // 查询用户信息
return R.ok().put("data", zhiyuanzhe); // 返回用户详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id) {
ZhiyuanzheEntity zhiyuanzhe = zhiyuanzheService.selectById(id); // 查询用户信息
return R.ok().put("data", zhiyuanzhe); // 返回用户详情
}
/**
*
*/
@RequestMapping("/save")
public R save(@RequestBody ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request){
zhiyuanzhe.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(zhiyuanzhe);
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", zhiyuanzhe.getXuehao()));
if(user!=null) {
return R.error("用户已存在");
/**
*
* @param zhiyuanzhe
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request) {
zhiyuanzhe.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(zhiyuanzhe); // 验证用户实体(可选)
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", zhiyuanzhe.getXuehao())); // 检查用户名是否已存在
if (user != null) {
return R.error("用户已存在"); // 返回错误信息
}
zhiyuanzhe.setId(new Date().getTime());
zhiyuanzheService.insert(zhiyuanzhe);
return R.ok();
}
/**
*
*/
@RequestMapping("/add")
public R add(@RequestBody ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request){
zhiyuanzhe.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(zhiyuanzhe);
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", zhiyuanzhe.getXuehao()));
if(user!=null) {
return R.error("用户已存在");
zhiyuanzhe.setId(new Date().getTime()); // 设置用户ID
zhiyuanzheService.insert(zhiyuanzhe); // 插入新用户
return R.ok(); // 返回成功结果
}
/**
*
* @param zhiyuanzhe
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request) {
zhiyuanzhe.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(zhiyuanzhe); // 验证用户实体(可选)
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", zhiyuanzhe.getXuehao())); // 检查用户名是否已存在
if (user != null) {
return R.error("用户已存在"); // 返回错误信息
}
zhiyuanzhe.setId(new Date().getTime());
zhiyuanzheService.insert(zhiyuanzhe);
return R.ok();
}
zhiyuanzhe.setId(new Date().getTime()); // 设置用户ID
zhiyuanzheService.insert(zhiyuanzhe); // 插入新用户
return R.ok(); // 返回成功结果
}
/**
*
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request){
//ValidatorUtils.validateEntity(zhiyuanzhe);
zhiyuanzheService.updateById(zhiyuanzhe);//全部更新
return R.ok();
}
/**
*
* @param zhiyuanzhe
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request) {
// ValidatorUtils.validateEntity(zhiyuanzhe); // 验证用户实体(可选)
zhiyuanzheService.updateById(zhiyuanzhe); // 全量更新用户信息
return R.ok(); // 返回成功结果
}
/**
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids) {
zhiyuanzheService.deleteBatchIds(Arrays.asList(ids)); // 批量删除用户
return R.ok(); // 返回成功结果
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
zhiyuanzheService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
*
*/
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 设置查询字段
map.put("type", type); // 设置查询类型
if ("2".equals(type)) { // 如果类型为2
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有开始日期
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 添加天数
remindStartDate = c.getTime(); // 获取新的日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
if (map.get("remindend") != null) { // 如果有结束日期
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 添加天数
remindEndDate = c.getTime(); // 获取新的日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<ZhiyuanzheEntity> wrapper = new EntityWrapper<ZhiyuanzheEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
Wrapper<ZhiyuanzheEntity> wrapper = new EntityWrapper<ZhiyuanzheEntity>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
int count = zhiyuanzheService.selectCount(wrapper);
return R.ok().put("count", count);
int count = zhiyuanzheService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回查询结果
}
}

Loading…
Cancel
Save