18655803770 4 months ago
parent 3c19495e91
commit 686832b883

@ -9,27 +9,38 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupp
import com.interceptor.AuthorizationInterceptor; import com.interceptor.AuthorizationInterceptor;
@Configuration @Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport{ public class InterceptorConfig extends WebMvcConfigurationSupport {
@Bean // 定义一个 Bean 方法,返回 AuthorizationInterceptor 的实例
@Bean
public AuthorizationInterceptor getAuthorizationInterceptor() { public AuthorizationInterceptor getAuthorizationInterceptor() {
return new AuthorizationInterceptor(); return new AuthorizationInterceptor(); // 创建并返回一个新的 AuthorizationInterceptor 实例
} }
@Override // 重写 addInterceptors 方法,添加自定义拦截器
@Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(getAuthorizationInterceptor()).addPathPatterns("/**").excludePathPatterns("/static/**"); // 将 AuthorizationInterceptor 添加到拦截器链中
super.addInterceptors(registry); registry.addInterceptor(getAuthorizationInterceptor())
} .addPathPatterns("/**") // 匹配所有路径
.excludePathPatterns("/static/**"); // 排除对 /static/** 路径的拦截
super.addInterceptors(registry); // 调用父类方法继续处理其他拦截器
}
@Override /**
* 使 Spring Boot 2.0 WebMvcConfigurationSupport
* addResourceHandlers 访
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**") // 添加资源处理器,处理所有路径的静态资源请求
.addResourceLocations("classpath:/resources/") registry.addResourceHandler("/**")
.addResourceLocations("classpath:/static/") .addResourceLocations("classpath:/resources/") // 从 classpath:/resources/ 目录加载资源
.addResourceLocations("classpath:/admin/") .addResourceLocations("classpath:/static/") // 从 classpath:/static/ 目录加载资源
.addResourceLocations("classpath:/front/") .addResourceLocations("classpath:/admin/") // 从 classpath:/admin/ 目录加载资源
.addResourceLocations("classpath:/public/"); .addResourceLocations("classpath:/front/") // 从 classpath:/front/ 目录加载资源
super.addResourceHandlers(registry); .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.mapper.MetaObjectHandler;
import com.baomidou.mybatisplus.plugins.PaginationInterceptor; import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
/**
* mybatis-plus
*/
@Configuration @Configuration
public class MybatisPlusConfig { public class MybatisPlusConfig {
/**
*
*/
@Bean @Bean
public PaginationInterceptor paginationInterceptor() { 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.FileUtil;
import com.utils.R; import com.utils.R;
/**
*
*/
@RestController @RestController
public class CommonController{ public class CommonController {
@Autowired
private CommonService commonService; // 注入通用服务
private static AipFace client = null; // 百度人脸API客户端实例
@Autowired @Autowired
private CommonService commonService; private ConfigService configService; // 注入配置服务
private static AipFace client = null; /**
* tablecolumn()
@Autowired * @param tableName
private ConfigService configService; * @param columnName
* @param level
* @param parent
* @return
*/
@IgnoreAuth @IgnoreAuth
@RequestMapping("/option/{tableName}/{columnName}") @RequestMapping("/option/{tableName}/{columnName}")
public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,String level,String parent) { public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,
Map<String, Object> params = new HashMap<String, Object>(); String level, String parent) {
params.put("table", tableName); Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("column", columnName); params.put("table", tableName); // 添加表名
if(StringUtils.isNotBlank(level)) { params.put("column", columnName); // 添加列名
params.put("level", level); if (StringUtils.isNotBlank(level)) { // 如果层级不为空
params.put("level", level); // 添加层级
} }
if(StringUtils.isNotBlank(parent)) { if (StringUtils.isNotBlank(parent)) { // 如果父节点不为空
params.put("parent", parent); params.put("parent", parent); // 添加父节点
} }
List<String> data = commonService.getOption(params); List<String> data = commonService.getOption(params); // 调用服务获取数据
return R.ok().put("data", data); return R.ok().put("data", data); // 返回成功结果
} }
/**
* tablecolumn
* @param tableName
* @param columnName
* @param columnValue
* @return
*/
@IgnoreAuth @IgnoreAuth
@RequestMapping("/follow/{tableName}/{columnName}") @RequestMapping("/follow/{tableName}/{columnName}")
public R getFollowByOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, @RequestParam String columnValue) { public R getFollowByOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,
Map<String, Object> params = new HashMap<String, Object>(); @RequestParam String columnValue) {
params.put("table", tableName); Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("column", columnName); params.put("table", tableName); // 添加表名
params.put("columnValue", columnValue); params.put("column", columnName); // 添加列名
Map<String, Object> result = commonService.getFollowByOption(params); params.put("columnValue", columnValue); // 添加列值
return R.ok().put("data", result); Map<String, Object> result = commonService.getFollowByOption(params); // 调用服务获取结果
return R.ok().put("data", result); // 返回成功结果
} }
/**
* tablesfsh
* @param tableName
* @param map
* @return
*/
@RequestMapping("/sh/{tableName}") @RequestMapping("/sh/{tableName}")
public R sh(@PathVariable("tableName") String tableName, @RequestBody Map<String, Object> map) { public R sh(@PathVariable("tableName") String tableName, @RequestBody Map<String, Object> map) {
map.put("table", tableName); map.put("table", tableName); // 添加表名
commonService.sh(map); commonService.sh(map); // 调用服务修改状态
return R.ok(); return R.ok(); // 返回成功结果
} }
/**
*
* @param tableName
* @param columnName
* @param type 1:, 2:
* @param map
* @return
*/
@IgnoreAuth @IgnoreAuth
@RequestMapping("/remind/{tableName}/{columnName}/{type}") @RequestMapping("/remind/{tableName}/{columnName}/{type}")
public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) { @PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("table", tableName); map.put("table", tableName); // 添加表名
map.put("column", columnName); map.put("column", columnName); // 添加列名
map.put("type", type); map.put("type", type); // 添加提醒类型
if ("2".equals(type)) { // 如果类型为日期
if(type.equals("2")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 日期格式化工具
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); // 日历实例
Calendar c = Calendar.getInstance(); Date remindStartDate = null; // 提醒开始日期
Date remindStartDate = null; Date remindEndDate = null; // 提醒结束日期
Date remindEndDate = null; if (map.get("remindstart") != null) { // 如果有提醒开始时间
if(map.get("remindstart")!=null) { Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); c.setTime(new Date()); // 设置当前时间为基准
c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH, remindStart); // 增加天数
c.add(Calendar.DAY_OF_MONTH,remindStart); remindStartDate = c.getTime(); // 获取新的日期
remindStartDate = c.getTime(); map.put("remindstart", sdf.format(remindStartDate)); // 格式化并更新参数
map.put("remindstart", sdf.format(remindStartDate));
} }
if(map.get("remindend")!=null) { if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); c.setTime(new Date()); // 设置当前时间为基准
c.add(Calendar.DAY_OF_MONTH,remindEnd); c.add(Calendar.DAY_OF_MONTH, remindEnd); // 增加天数
remindEndDate = c.getTime(); remindEndDate = c.getTime(); // 获取新的日期
map.put("remindend", sdf.format(remindEndDate)); map.put("remindend", sdf.format(remindEndDate)); // 格式化并更新参数
} }
} }
int count = commonService.remindCount(map); // 调用服务获取提醒记录数
int count = commonService.remindCount(map); return R.ok().put("count", count); // 返回成功结果
return R.ok().put("count", count);
} }
/** /**
* *
* @param tableName
* @param columnName
* @return
*/ */
@IgnoreAuth @IgnoreAuth
@RequestMapping("/cal/{tableName}/{columnName}") @RequestMapping("/cal/{tableName}/{columnName}")
public R cal(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) { public R cal(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) {
Map<String, Object> params = new HashMap<String, Object>(); Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("table", tableName); params.put("table", tableName); // 添加表名
params.put("column", columnName); params.put("column", columnName); // 添加列名
Map<String, Object> result = commonService.selectCal(params); Map<String, Object> result = commonService.selectCal(params); // 调用服务获取求和结果
return R.ok().put("data", result); return R.ok().put("data", result); // 返回成功结果
} }
/** /**
* *
* @param tableName
* @param columnName
* @return
*/ */
@IgnoreAuth @IgnoreAuth
@RequestMapping("/group/{tableName}/{columnName}") @RequestMapping("/group/{tableName}/{columnName}")
public R group(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) { public R group(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) {
Map<String, Object> params = new HashMap<String, Object>(); Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("table", tableName); params.put("table", tableName); // 添加表名
params.put("column", columnName); params.put("column", columnName); // 添加列名
List<Map<String, Object>> result = commonService.selectGroup(params); List<Map<String, Object>> result = commonService.selectGroup(params); // 调用服务获取分组统计结果
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 日期格式化工具
for(Map<String, Object> m : result) { for (Map<String, Object> m : result) { // 遍历结果
for(String k : m.keySet()) { for (String k : m.keySet()) { // 遍历键
if(m.get(k) instanceof Date) { if (m.get(k) instanceof Date) { // 如果值是日期类型
m.put(k, sdf.format((Date)m.get(k))); 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 @IgnoreAuth
@RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}") @RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}")
public R value(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName) { public R value(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName,
Map<String, Object> params = new HashMap<String, Object>(); @PathVariable("xColumnName") String xColumnName) {
params.put("table", tableName); Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("xColumn", xColumnName); params.put("table", tableName); // 添加表名
params.put("yColumn", yColumnName); params.put("xColumn", xColumnName); // 添加X轴列名
List<Map<String, Object>> result = commonService.selectValue(params); params.put("yColumn", yColumnName); // 添加Y轴列名
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); List<Map<String, Object>> result = commonService.selectValue(params); // 调用服务获取按值统计结果
for(Map<String, Object> m : result) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 日期格式化工具
for(String k : m.keySet()) { for (Map<String, Object> m : result) { // 遍历结果
if(m.get(k) instanceof Date) { for (String k : m.keySet()) { // 遍历键
m.put(k, sdf.format((Date)m.get(k))); 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 @IgnoreAuth
@RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}/{timeStatType}") @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) { public R valueDay(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName,
Map<String, Object> params = new HashMap<String, Object>(); @PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType) {
params.put("table", tableName); Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("xColumn", xColumnName); params.put("table", tableName); // 添加表名
params.put("yColumn", yColumnName); params.put("xColumn", xColumnName); // 添加X轴列名
params.put("timeStatType", timeStatType); params.put("yColumn", yColumnName); // 添加Y轴列名
List<Map<String, Object>> result = commonService.selectTimeStatValue(params); params.put("timeStatType", timeStatType); // 添加时间统计类型
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); List<Map<String, Object>> result = commonService.selectTimeStatValue(params); // 调用服务获取按值统计结果
for(Map<String, Object> m : result) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 日期格式化工具
for(String k : m.keySet()) { for (Map<String, Object> m : result) { // 遍历结果
if(m.get(k) instanceof Date) { for (String k : m.keySet()) { // 遍历键
m.put(k, sdf.format((Date)m.get(k))); 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; package com.controller;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map; import java.util.Map;
@ -23,64 +21,108 @@ import com.utils.R;
import com.utils.ValidatorUtils; import com.utils.ValidatorUtils;
/** /**
* *
*/ */
@RequestMapping("config") @RequestMapping("config")
@RestController @RestController
public class ConfigController{ public class ConfigController {
@Autowired
private ConfigService configService;
@Autowired
private ConfigService configService; // 注入配置服务
/**
*
* @param params
* @param config
* @return
*/
@RequestMapping("/page") @RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,ConfigEntity config){ public R page(@RequestParam Map<String, Object> params, ConfigEntity config) {
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); // 创建查询条件
PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params)); PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params)); // 查询分页数据
return R.ok().put("data", page); return R.ok().put("data", page); // 返回成功结果
} }
/**
*
* @param params
* @param config
* @return
*/
@IgnoreAuth @IgnoreAuth
@RequestMapping("/list") @RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ConfigEntity config){ public R list(@RequestParam Map<String, Object> params, ConfigEntity config) {
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); // 创建查询条件
PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params)); PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params)); // 查询分页数据
return R.ok().put("data", page); return R.ok().put("data", page); // 返回成功结果
} }
/**
* ID
* @param id ID
* @return
*/
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){ public R info(@PathVariable("id") String id) {
ConfigEntity config = configService.selectById(id); ConfigEntity config = configService.selectById(id); // 根据ID查询配置
return R.ok().put("data", config); return R.ok().put("data", config); // 返回成功结果
} }
/**
* ID
* @param id ID
* @return
*/
@IgnoreAuth @IgnoreAuth
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") String id){ public R detail(@PathVariable("id") String id) {
ConfigEntity config = configService.selectById(id); ConfigEntity config = configService.selectById(id); // 根据ID查询配置
return R.ok().put("data", config); return R.ok().put("data", config); // 返回成功结果
} }
/**
*
* @param name
* @return
*/
@RequestMapping("/info") @RequestMapping("/info")
public R infoByName(@RequestParam String name){ public R infoByName(@RequestParam String name) {
ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); // 根据名称查询配置
return R.ok().put("data", config); return R.ok().put("data", config); // 返回成功结果
} }
/**
*
* @param config
* @return
*/
@PostMapping("/save") @PostMapping("/save")
public R save(@RequestBody ConfigEntity config){ public R save(@RequestBody ConfigEntity config) {
// ValidatorUtils.validateEntity(config); // ValidatorUtils.validateEntity(config); // 验证配置对象
configService.insert(config); configService.insert(config); // 插入配置
return R.ok(); return R.ok(); // 返回成功结果
} }
/**
*
* @param config
* @return
*/
@RequestMapping("/update") @RequestMapping("/update")
public R update(@RequestBody ConfigEntity config){ public R update(@RequestBody ConfigEntity config) {
// ValidatorUtils.validateEntity(config); // ValidatorUtils.validateEntity(config); // 验证配置对象
configService.updateById(config);//全部更新 configService.updateById(config); // 根据ID更新配置
return R.ok(); return R.ok(); // 返回成功结果
} }
/**
*
* @param ids ID
* @return
*/
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){ public R delete(@RequestBody Long[] ids) {
configService.deleteBatchIds(Arrays.asList(ids)); configService.deleteBatchIds(Arrays.asList(ids)); // 批量删除配置
return R.ok(); return R.ok(); // 返回成功结果
} }
} }

@ -1,14 +1,7 @@
package com.controller; package com.controller;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
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 javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils; import com.utils.ValidatorUtils;
@ -16,11 +9,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
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 com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth; import com.annotation.IgnoreAuth;
@ -38,180 +28,192 @@ import com.utils.CommonUtil;
import java.io.IOException; import java.io.IOException;
/** /**
* *
* * @author []
* @author * @email []
* @email
* @date 2022-05-06 08:33:49 * @date 2022-05-06 08:33:49
*/ */
@RestController @RestController
@RequestMapping("/discusshuodongxinde") @RequestMapping("/discusshuodongxinde")
public class DiscusshuodongxindeController { public class DiscusshuodongxindeController {
@Autowired @Autowired
private DiscusshuodongxindeService discusshuodongxindeService; private DiscusshuodongxindeService discusshuodongxindeService; // 注入服务类
/** /**
* *
* @param params
* @param discusshuodongxinde
* @param request
* @return
*/ */
@RequestMapping("/page") @RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,DiscusshuodongxindeEntity discusshuodongxinde, public R page(@RequestParam Map<String, Object> params, DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
HttpServletRequest request){ EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<DiscusshuodongxindeEntity>(); PageUtils page = discusshuodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discusshuodongxinde), params), params)); // 查询分页数据
PageUtils page = discusshuodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discusshuodongxinde), params), params)); return R.ok().put("data", page); // 返回成功结果
return R.ok().put("data", page);
} }
/** /**
* *
* @param params
* @param discusshuodongxinde
* @param request
* @return
*/ */
@IgnoreAuth @IgnoreAuth
@RequestMapping("/list") @RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,DiscusshuodongxindeEntity discusshuodongxinde, public R list(@RequestParam Map<String, Object> params, DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
HttpServletRequest request){ EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<DiscusshuodongxindeEntity>(); PageUtils page = discusshuodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discusshuodongxinde), params), params)); // 查询分页数据
PageUtils page = discusshuodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discusshuodongxinde), params), params)); return R.ok().put("data", page); // 返回成功结果
return R.ok().put("data", page);
} }
/** /**
* *
* @param discusshuodongxinde
* @return
*/ */
@RequestMapping("/lists") @RequestMapping("/lists")
public R list( DiscusshuodongxindeEntity discusshuodongxinde){ public R list(DiscusshuodongxindeEntity discusshuodongxinde) {
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<DiscusshuodongxindeEntity>(); EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
ew.allEq(MPUtil.allEQMapPre( discusshuodongxinde, "discusshuodongxinde")); ew.allEq(MPUtil.allEQMapPre(discusshuodongxinde, "discusshuodongxinde")); // 设置查询条件
return R.ok().put("data", discusshuodongxindeService.selectListView(ew)); return R.ok().put("data", discusshuodongxindeService.selectListView(ew)); // 返回查询结果
} }
/** /**
* *
* @param discusshuodongxinde
* @return
*/ */
@RequestMapping("/query") @RequestMapping("/query")
public R query(DiscusshuodongxindeEntity discusshuodongxinde){ public R query(DiscusshuodongxindeEntity discusshuodongxinde) {
EntityWrapper< DiscusshuodongxindeEntity> ew = new EntityWrapper< DiscusshuodongxindeEntity>(); EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
ew.allEq(MPUtil.allEQMapPre( discusshuodongxinde, "discusshuodongxinde")); ew.allEq(MPUtil.allEQMapPre(discusshuodongxinde, "discusshuodongxinde")); // 设置查询条件
DiscusshuodongxindeView discusshuodongxindeView = discusshuodongxindeService.selectView(ew); DiscusshuodongxindeView discusshuodongxindeView = discusshuodongxindeService.selectView(ew); // 查询视图数据
return R.ok("查询活动心得评论表成功").put("data", discusshuodongxindeView); return R.ok("查询活动心得评论表成功").put("data", discusshuodongxindeView); // 返回查询结果
} }
/** /**
* *
* @param id ID
* @return ID
*/ */
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){ public R info(@PathVariable("id") Long id) {
DiscusshuodongxindeEntity discusshuodongxinde = discusshuodongxindeService.selectById(id); DiscusshuodongxindeEntity discusshuodongxinde = discusshuodongxindeService.selectById(id); // 根据ID查询数据
return R.ok().put("data", discusshuodongxinde); return R.ok().put("data", discusshuodongxinde); // 返回查询结果
} }
/** /**
* *
* @param id ID
* @return ID
*/ */
@IgnoreAuth @IgnoreAuth
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){ public R detail(@PathVariable("id") Long id) {
DiscusshuodongxindeEntity discusshuodongxinde = discusshuodongxindeService.selectById(id); DiscusshuodongxindeEntity discusshuodongxinde = discusshuodongxindeService.selectById(id); // 根据ID查询数据
return R.ok().put("data", discusshuodongxinde); return R.ok().put("data", discusshuodongxinde); // 返回查询结果
} }
/** /**
* *
* @param discusshuodongxinde
* @param request
* @return
*/ */
@RequestMapping("/save") @RequestMapping("/save")
public R save(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request){ public R save(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
discusshuodongxinde.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); discusshuodongxinde.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
//ValidatorUtils.validateEntity(discusshuodongxinde); // ValidatorUtils.validateEntity(discusshuodongxinde); // 验证数据
discusshuodongxindeService.insert(discusshuodongxinde); discusshuodongxindeService.insert(discusshuodongxinde); // 插入数据
return R.ok(); return R.ok(); // 返回成功结果
} }
/** /**
* *
* @param discusshuodongxinde
* @param request
* @return
*/ */
@RequestMapping("/add") @RequestMapping("/add")
public R add(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request){ public R add(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
discusshuodongxinde.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); discusshuodongxinde.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
//ValidatorUtils.validateEntity(discusshuodongxinde); // ValidatorUtils.validateEntity(discusshuodongxinde); // 验证数据
discusshuodongxindeService.insert(discusshuodongxinde); discusshuodongxindeService.insert(discusshuodongxinde); // 插入数据
return R.ok(); return R.ok(); // 返回成功结果
} }
/** /**
* *
* @param discusshuodongxinde
* @param request
* @return
*/ */
@RequestMapping("/update") @RequestMapping("/update")
@Transactional @Transactional // 开启事务
public R update(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request){ public R update(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
//ValidatorUtils.validateEntity(discusshuodongxinde); // ValidatorUtils.validateEntity(discusshuodongxinde); // 验证数据
discusshuodongxindeService.updateById(discusshuodongxinde);//全部更新 discusshuodongxindeService.updateById(discusshuodongxinde); // 根据ID更新数据
return R.ok(); return R.ok(); // 返回成功结果
} }
/** /**
* *
* @param ids ID
* @return
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){ public R delete(@RequestBody Long[] ids) {
discusshuodongxindeService.deleteBatchIds(Arrays.asList(ids)); discusshuodongxindeService.deleteBatchIds(Arrays.asList(ids)); // 批量删除数据
return R.ok(); return R.ok(); // 返回成功结果
} }
/** /**
* *
* @param columnName
* @param type
* @param map
* @return
*/ */
@RequestMapping("/remind/{columnName}/{type}") @RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) { @PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); map.put("column", columnName); // 添加字段名到参数
map.put("type", type); map.put("type", type); // 添加类型到参数
if(type.equals("2")) { if (type.equals("2")) { // 如果类型为2
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; Date remindEndDate = null; // 初始化结束日期
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); if (map.get("remindstart") != null) { // 如果有开始日期
c.setTime(new Date()); Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.add(Calendar.DAY_OF_MONTH,remindStart); c.setTime(new Date()); // 设置当前日期
remindStartDate = c.getTime(); c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
map.put("remindstart", sdf.format(remindStartDate)); 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()); if (map.get("remindend") != null) { // 如果有结束日期
c.add(Calendar.DAY_OF_MONTH,remindEnd); Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
remindEndDate = c.getTime(); c.setTime(new Date()); // 设置当前日期
map.put("remindend", sdf.format(remindEndDate)); 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")); Wrapper<DiscusshuodongxindeEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
} if (map.get("remindstart") != null) { // 如果有开始日期
if(map.get("remindend")!=null) { wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
wrapper.le(columnName, map.get("remindend")); }
} if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
int count = discusshuodongxindeService.selectCount(wrapper);
return R.ok().put("count", count); 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.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils; import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
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.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.annotation.IgnoreAuth; import com.annotation.IgnoreAuth;
@ -34,83 +30,95 @@ import com.service.ConfigService;
import com.utils.R; import com.utils.R;
/** /**
* *
*/ */
@RestController @RestController
@RequestMapping("file") @RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"}) @SuppressWarnings({"unchecked","rawtypes"})
public class FileController{ public class FileController {
@Autowired @Autowired
private ConfigService configService; private ConfigService configService; // 注入配置服务类
/** /**
* *
* @param file
* @param type 1
* @return
* @throws Exception
*/ */
@RequestMapping("/upload") @RequestMapping("/upload")
public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception { public R upload(@RequestParam("file") MultipartFile file, String type) throws Exception {
if (file.isEmpty()) { if (file.isEmpty()) { // 检查文件是否为空
throw new EIException("上传文件不能为空"); throw new EIException("上传文件不能为空"); // 抛出异常
} }
String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
File path = new File(ResourceUtils.getURL("classpath:static").getPath()); String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); // 获取文件扩展名
if(!path.exists()) { File path = new File(ResourceUtils.getURL("classpath:static").getPath()); // 获取静态资源路径
path = new File(""); if (!path.exists()) { // 如果路径不存在
path = new File(""); // 设置默认路径
} }
File upload = new File(path.getAbsolutePath(),"/upload/");
if(!upload.exists()) { File upload = new File(path.getAbsolutePath(), "/upload/"); // 定义上传目录
upload.mkdirs(); if (!upload.exists()) { // 如果上传目录不存在
upload.mkdirs(); // 创建目录
} }
String fileName = new Date().getTime()+"."+fileExt;
File dest = new File(upload.getAbsolutePath()+"/"+fileName); String fileName = new Date().getTime() + "." + fileExt; // 生成唯一的文件名
file.transferTo(dest); File dest = new File(upload.getAbsolutePath() + "/" + fileName); // 定义目标文件路径
file.transferTo(dest); // 将文件保存到目标位置
/** /**
* 使ideaeclipse * 使IDEIntelliJ IDEAEclipse
* "D:\\springbootq33sd\\src\\main\\resources\\static\\upload"upload * 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")) { // FileUtils.copyFile(dest, new File("D:\\\\springbootq33sd\\\\src\\\\main\\\\resources\\\\static\\\\upload\\\\" + fileName)); // 复制文件到指定路径
ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
if(configEntity==null) { if (StringUtils.isNotBlank(type) && type.equals("1")) { // 如果类型为1人脸文件
configEntity = new ConfigEntity(); ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); // 查询配置项
configEntity.setName("faceFile"); if (configEntity == null) { // 如果配置项不存在
configEntity.setValue(fileName); configEntity = new ConfigEntity(); // 创建新配置项
configEntity.setName("faceFile"); // 设置配置项名称
configEntity.setValue(fileName); // 设置文件名
} else { } 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 @IgnoreAuth
@RequestMapping("/download") @RequestMapping("/download")
public ResponseEntity<byte[]> download(@RequestParam String fileName) { public ResponseEntity<byte[]> download(@RequestParam String fileName) {
try { try {
File path = new File(ResourceUtils.getURL("classpath:static").getPath()); File path = new File(ResourceUtils.getURL("classpath:static").getPath()); // 获取静态资源路径
if(!path.exists()) { if (!path.exists()) { // 如果路径不存在
path = new File(""); path = new File(""); // 设置默认路径
} }
File upload = new File(path.getAbsolutePath(),"/upload/");
if(!upload.exists()) { File upload = new File(path.getAbsolutePath(), "/upload/"); // 定义上传目录
upload.mkdirs(); if (!upload.exists()) { // 如果上传目录不存在
upload.mkdirs(); // 创建目录
} }
File file = new File(upload.getAbsolutePath()+"/"+fileName);
if(file.exists()){ File file = new File(upload.getAbsolutePath() + "/" + fileName); // 定义目标文件路径
/*if(!fileService.canRead(file, SessionManager.getSessionUser())){ if (file.exists()) { // 如果文件存在
getResponse().sendError(403); HttpHeaders headers = new HttpHeaders(); // 设置响应头
}*/ headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); // 设置内容类型
HttpHeaders headers = new HttpHeaders(); headers.setContentDispositionFormData("attachment", fileName); // 设置附件下载
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file), headers, HttpStatus.OK); // 返回文件流
headers.setContentDispositionFormData("attachment", fileName);
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
} }
} catch (IOException e) { } 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; import java.io.IOException;
/** /**
* *
* * @author []
* @author * @email []
* @email
* @date 2022-05-06 08:33:49 * @date 2022-05-06 08:33:49
*/ */
@RestController @RestController
@RequestMapping("/huodongbaoming") @RequestMapping("/huodongbaoming")
public class HuodongbaomingController { public class HuodongbaomingController {
@Autowired @Autowired
private HuodongbaomingService huodongbaomingService; private HuodongbaomingService huodongbaomingService; // 注入活动报名服务
/** /**
* *
* @param params
* @param huodongbaoming
* @param request HTTP
* @return
*/ */
@RequestMapping("/page") @RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,HuodongbaomingEntity huodongbaoming, public R page(@RequestParam Map<String, Object> params, HuodongbaomingEntity huodongbaoming,
HttpServletRequest request){ HttpServletRequest request) {
String tableName = request.getSession().getAttribute("tableName").toString(); String tableName = request.getSession().getAttribute("tableName").toString(); // 获取当前用户表名
if(tableName.equals("zhiyuanzhe")) { if (tableName.equals("zhiyuanzhe")) { // 如果是志愿者表
huodongbaoming.setXuehao((String)request.getSession().getAttribute("username")); 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)); 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);
return R.ok().put("data", page); // 返回分页数据
} }
/** /**
* *
* @param params
* @param huodongbaoming
* @param request HTTP
* @return
*/ */
@IgnoreAuth @IgnoreAuth
@RequestMapping("/list") @RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,HuodongbaomingEntity huodongbaoming, public R list(@RequestParam Map<String, Object> params, HuodongbaomingEntity huodongbaoming,
HttpServletRequest request){ HttpServletRequest request) {
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<HuodongbaomingEntity>(); EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongbaomingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongbaoming), params), params)); PageUtils page = huodongbaomingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongbaoming), params), params));
return R.ok().put("data", page);
return R.ok().put("data", page); // 返回分页数据
} }
/** /**
* *
* @param huodongbaoming
* @return
*/ */
@RequestMapping("/lists") @RequestMapping("/lists")
public R list( HuodongbaomingEntity huodongbaoming){ public R list(HuodongbaomingEntity huodongbaoming) {
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<HuodongbaomingEntity>(); EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre( huodongbaoming, "huodongbaoming")); ew.allEq(MPUtil.allEQMapPre(huodongbaoming, "huodongbaoming")); // 设置查询条件
return R.ok().put("data", huodongbaomingService.selectListView(ew)); return R.ok().put("data", huodongbaomingService.selectListView(ew)); // 返回数据列表
} }
/** /**
* *
* @param huodongbaoming
* @return
*/ */
@RequestMapping("/query") @RequestMapping("/query")
public R query(HuodongbaomingEntity huodongbaoming){ public R query(HuodongbaomingEntity huodongbaoming) {
EntityWrapper< HuodongbaomingEntity> ew = new EntityWrapper< HuodongbaomingEntity>(); EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre( huodongbaoming, "huodongbaoming")); ew.allEq(MPUtil.allEQMapPre(huodongbaoming, "huodongbaoming")); // 设置查询条件
HuodongbaomingView huodongbaomingView = huodongbaomingService.selectView(ew); HuodongbaomingView huodongbaomingView = huodongbaomingService.selectView(ew); // 查询视图
return R.ok("查询活动报名成功").put("data", huodongbaomingView); return R.ok("查询活动报名成功").put("data", huodongbaomingView); // 返回查询结果
} }
/** /**
* *
* @param id ID
* @return
*/ */
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){ public R info(@PathVariable("id") Long id) {
HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id); HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongbaoming); return R.ok().put("data", huodongbaoming); // 返回记录详情
} }
/** /**
* *
* @param id ID
* @return
*/ */
@IgnoreAuth @IgnoreAuth
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){ public R detail(@PathVariable("id") Long id) {
HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id); HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongbaoming); return R.ok().put("data", huodongbaoming); // 返回记录详情
} }
/** /**
* *
* @param huodongbaoming
* @param request HTTP
* @return
*/ */
@RequestMapping("/save") @RequestMapping("/save")
public R save(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request){ public R save(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request) {
huodongbaoming.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); huodongbaoming.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
//ValidatorUtils.validateEntity(huodongbaoming); huodongbaomingService.insert(huodongbaoming); // 插入数据
huodongbaomingService.insert(huodongbaoming); return R.ok(); // 返回成功结果
return R.ok();
} }
/** /**
* *
* @param huodongbaoming
* @param request HTTP
* @return
*/ */
@RequestMapping("/add") @RequestMapping("/add")
public R add(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request){ public R add(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request) {
huodongbaoming.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); huodongbaoming.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
//ValidatorUtils.validateEntity(huodongbaoming); huodongbaomingService.insert(huodongbaoming); // 插入数据
huodongbaomingService.insert(huodongbaoming); return R.ok(); // 返回成功结果
return R.ok();
} }
/** /**
* *
* @param huodongbaoming
* @param request HTTP
* @return
*/ */
@RequestMapping("/update") @RequestMapping("/update")
@Transactional @Transactional
public R update(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request){ public R update(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request) {
//ValidatorUtils.validateEntity(huodongbaoming); huodongbaomingService.updateById(huodongbaoming); // 全量更新
huodongbaomingService.updateById(huodongbaoming);//全部更新 return R.ok(); // 返回成功结果
return R.ok();
} }
/** /**
* *
* @param ids ID
* @return
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){ public R delete(@RequestBody Long[] ids) {
huodongbaomingService.deleteBatchIds(Arrays.asList(ids)); huodongbaomingService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); return R.ok(); // 返回成功结果
} }
/** /**
* *
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/ */
@RequestMapping("/remind/{columnName}/{type}") @RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) { @PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); map.put("column", columnName); // 添加字段名到参数
map.put("type", type); map.put("type", type); // 添加提醒类型到参数
if(type.equals("2")) { if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; Date remindEndDate = null; // 初始化结束日期
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); if (map.get("remindstart") != null) { // 如果有提醒开始时间
c.setTime(new Date()); Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.add(Calendar.DAY_OF_MONTH,remindStart); c.setTime(new Date()); // 设置当前日期
remindStartDate = c.getTime(); c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
map.put("remindstart", sdf.format(remindStartDate)); 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()); if (map.get("remindend") != null) { // 如果有提醒结束时间
c.add(Calendar.DAY_OF_MONTH,remindEnd); Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
remindEndDate = c.getTime(); c.setTime(new Date()); // 设置当前日期
map.put("remindend", sdf.format(remindEndDate)); 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")); Wrapper<HuodongbaomingEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
} if (map.get("remindstart") != null) { // 如果有开始日期
if(map.get("remindend")!=null) { wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
wrapper.le(columnName, map.get("remindend")); }
} 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")); 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);
} int count = huodongbaomingService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
} }

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save