pull/2/head
2593162056@qq.com 9 months ago
parent 1e85e38192
commit 0ecf6a84c1

@ -2,6 +2,9 @@ package com.controller;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URLDecoder;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Date; import java.util.Date;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -40,17 +43,23 @@ public class FileController{
public R upload(@RequestParam("file") MultipartFile file, String type,HttpServletRequest request) throws Exception { public R upload(@RequestParam("file") MultipartFile file, String type,HttpServletRequest request) throws Exception {
if (file.isEmpty()) { if (file.isEmpty()) {
throw new EIException("上传文件不能为空"); throw new EIException("上传文件不能为空");
}String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
String path = URLDecoder.decode(request.getSession().getServletContext().getRealPath("/upload"),"UTF-8");
File dest = new File(path);
if (!dest.getParentFile().exists()) {
dest.getParentFile().mkdirs();
}String path2 = path.replace("target\\jspm0c59i\\upload", "src\\main\\webapp\\upload\\");
File upload2 = new File(path2);
if (!upload2.exists()) {
upload2.mkdirs();
} }
String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
String fileName = new Date().getTime() + "." + fileExt; String fileName = new Date().getTime() + "." + fileExt;
File dest = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+fileName); File dest1 = new File(dest.getAbsolutePath() + "/" + fileName);
file.transferTo(dest); File dest2 = new File(upload2.getAbsolutePath() + "/" + fileName);
/**
* 使ideaeclipse file.transferTo(dest1);
* "D:\\ssmpiv99\\src\\main\\webapp\\upload"upload Files.copy(dest1.toPath(), dest2.toPath(), StandardCopyOption.REPLACE_EXISTING);
*
*/
//FileUtils.copyFile(dest, new File("D:\\ssmpiv99\\src\\main\\webapp\\upload"+"/"+fileName)); /**修改了路径以后请将该行最前面的//注释去掉**/
if(StringUtils.isNotBlank(type) && type.equals("1")) { if(StringUtils.isNotBlank(type) && type.equals("1")) {
ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
if(configEntity==null) { if(configEntity==null) {
@ -59,10 +68,8 @@ public class FileController{
configEntity.setValue(fileName); 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);
} }
/** /**

@ -1,43 +1,46 @@
package com.controller; package com.controller;
// 定义控制器所在的包名
import java.math.BigDecimal; // 导入BigDecimal类用于进行高精度的数学运算
import java.text.SimpleDateFormat; // 导入SimpleDateFormat类用于格式化和解析日期
import java.text.ParseException; // 导入ParseException类用于处理日期解析异常
import java.util.ArrayList; // 导入ArrayList类用于创建动态数组
import java.util.Arrays; // 导入Arrays类提供了对数组操作的工具方法
import java.util.Calendar; // 导入Calendar类用于日期时间的操作
import java.util.Map; // 导入Map接口用于键值对集合
import java.util.HashMap; // 导入HashMap类基于哈希表的Map实现
import java.util.Iterator; // 导入Iterator接口用于遍历集合
import java.util.Date; // 导入Date类用于日期时间的表示
import java.util.List; // 导入List接口用于列表集合
import javax.servlet.http.HttpServletRequest; // 导入HttpServletRequest接口用于访问HTTP请求信息
import java.io.IOException; // 导入IOException类用于处理IO异常
import com.utils.ValidatorUtils; // 导入自定义的ValidatorUtils工具类用于数据验证
import org.apache.commons.lang3.StringUtils; // 导入Apache Commons Lang库的StringUtils类用于字符串操作
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring的Autowired注解用于自动注入依赖
import org.springframework.transaction.annotation.Transactional; // 导入Spring的Transactional注解用于声明事务
import org.springframework.format.annotation.DateTimeFormat; // 导入Spring的DateTimeFormat注解用于日期格式注解
import org.springframework.web.bind.annotation.PathVariable; // 导入Spring的PathVariable注解用于将URL中的参数绑定到控制器方法的参数上
import org.springframework.web.bind.annotation.RequestBody; // 导入Spring的RequestBody注解用于将HTTP请求的body部分绑定到控制器方法的参数上
import org.springframework.web.bind.annotation.RequestMapping; // 导入Spring的RequestMapping注解用于定义请求映射
import org.springframework.web.bind.annotation.RequestParam; // 导入Spring的RequestParam注解用于将请求参数绑定到控制器方法的参数上
import org.springframework.web.bind.annotation.RestController; // 导入Spring的RestController注解用于定义REST风格的控制器
import com.baomidou.mybatisplus.mapper.EntityWrapper; // 导入MyBatis Plus的EntityWrapper类用于构建查询条件
import com.baomidou.mybatisplus.mapper.Wrapper; // 导入MyBatis Plus的Wrapper接口EntityWrapper实现该接口
import com.annotation.IgnoreAuth; // 导入自定义的IgnoreAuth注解用于忽略权限验证
import com.entity.NewsEntity; // 导入新闻实体类
import com.entity.view.NewsView; // 导入新闻视图类
import com.service.NewsService; // 导入新闻服务类
import com.service.TokenService; // 导入Token服务类
import com.utils.PageUtils; // 导入自定义的PageUtils工具类用于分页处理
import com.utils.R; // 导入自定义的R类用于封装响应结果
import com.utils.MD5Util; // 导入自定义的MD5Util工具类用于MD5加密
import com.utils.MPUtil; // 导入自定义的MPUtil工具类提供MyBatis Plus工具方法
import com.utils.CommonUtil; // 导入自定义的CommonUtil工具类提供常用方法
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.NewsEntity;
import com.entity.view.NewsView;
import com.service.NewsService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/** /**
* *
@ -50,24 +53,23 @@ import com.utils.CommonUtil;
@RequestMapping("/news") @RequestMapping("/news")
public class NewsController { public class NewsController {
@Autowired @Autowired
private NewsService newsService; private NewsService newsService;//注入新闻服务类
/** /**
* *
*/ */
@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对象用于构建查询条件
EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>(); EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>();
// 使用MPUtil工具类对查询条件进行排序和分页处理
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));
// 将分页结果设置到request对象中
request.setAttribute("data", page); request.setAttribute("data", page);
// 返回成功响应,包含分页结果
return R.ok().put("data", page); return R.ok().put("data", page);
} }
@ -76,12 +78,17 @@ public class NewsController {
*/ */
@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对象用于构建查询条件
EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>(); EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>();
// 使用MPUtil工具类对查询条件进行排序和分页处理
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));
// 将分页结果设置到request对象中
request.setAttribute("data", page); request.setAttribute("data", page);
// 返回成功响应,包含分页结果
return R.ok().put("data", page); return R.ok().put("data", page);
} }
@ -89,10 +96,19 @@ public class NewsController {
* *
*/ */
@RequestMapping("/lists") @RequestMapping("/lists")
public R list( NewsEntity news){ //一个Spring MVC的注解用于将HTTP请求映射到 list 方法。当客户端发送一个HTTP请求到 /lists 路径时Spring MVC会调用 list 方法来处理这个请求
public R list(NewsEntity news) //NewsEntity news 参数表示要查询的 NewsEntity 对象
{
// 创建一个EntityWrapper对象用于构建查询条件
EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>(); EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>();
// 使用MPUtil工具类对查询条件进行排序和分页处理
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));
//这行代码返回一个表示请求成功的响应对象,并将 newsService.selectListView(ew) 的结果添加到响应对象中,键为 "data"。
//newsService.selectListView(ew) 方法用于查询满足 ew 对象的查询条件的记录,并返回一个包含查询结果的列表。
} }
/** /**
@ -100,8 +116,13 @@ public class NewsController {
*/ */
@RequestMapping("/query") @RequestMapping("/query")
public R query(NewsEntity news) { public R query(NewsEntity news) {
// 创建一个EntityWrapper对象用于构建查询条件
EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>(); EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>();
// 使用MPUtil工具类对查询条件进行排序和分页处理
ew.allEq(MPUtil.allEQMapPre(news, "news")); ew.allEq(MPUtil.allEQMapPre(news, "news"));
// 调用 newsService 对象的 selectView 方法,查询满足 ew 对象的查询条件的记录,并返回一个 NewsView 对象
NewsView newsView = newsService.selectView(ew); NewsView newsView = newsService.selectView(ew);
return R.ok("查询公告信息成功").put("data", newsView); return R.ok("查询公告信息成功").put("data", newsView);
} }
@ -109,34 +130,40 @@ public class NewsController {
/** /**
* *
*/ */
//一个Spring MVC的注解用于将HTTP请求映射到 info 方法。
//当客户端发送一个HTTP请求到 /info/{id} 路径时Spring MVC会调用 info 方法来处理这个请求
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id) { public R info(@PathVariable("id") Long id) {
// 根据ID查询并返回结果
NewsEntity news = newsService.selectById(id); NewsEntity news = newsService.selectById(id);
return R.ok().put("data", news); //调用 newsService 对象的 selectById 方法,根据 id 参数的值查询数据库中的记录,并返回一个 NewsEntity 对象。
return R.ok().put("data", news); //将 news 对象添加到响应对象中,键为 "data"
} }
/** /**
* *
*/ */
@IgnoreAuth @IgnoreAuth
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id) { public R detail(@PathVariable("id") Long id) {
// 根据ID查询并返回结果
NewsEntity news = newsService.selectById(id); NewsEntity news = newsService.selectById(id);
return R.ok().put("data", news); return R.ok().put("data", news);
} }
/** /**
* *
*/ */
@RequestMapping("/save") @RequestMapping("/save")
public R save(@RequestBody NewsEntity news, HttpServletRequest request) { public R save(@RequestBody NewsEntity news, HttpServletRequest request) {
// 设置ID为当前时间戳加上一个随机数
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());
// 验证实体对象,如果需要验证,可以取消注释
// ValidatorUtils.validateEntity(news); // ValidatorUtils.validateEntity(news);
// 插入数据,将 news 对象插入到数据库中
newsService.insert(news); newsService.insert(news);
//返回一个表示请求成功的响应对象
return R.ok(); return R.ok();
} }
@ -145,86 +172,95 @@ public class NewsController {
*/ */
@RequestMapping("/add") @RequestMapping("/add")
public R add(@RequestBody NewsEntity news, HttpServletRequest request) { public R add(@RequestBody NewsEntity news, HttpServletRequest request) {
// 设置ID为当前时间戳加上一个随机数
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());
// 验证实体对象,如果需要验证,可以取消注释
// ValidatorUtils.validateEntity(news); // ValidatorUtils.validateEntity(news);
// 插入数据
newsService.insert(news); newsService.insert(news);
return R.ok(); return R.ok();
} }
/** /**
* *
*/ */
@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();
} }
/** /**
* *
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")//这是一个Spring MVC的注解用于将HTTP请求映射到 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();//R.ok() 方法通常表示请求成功,并返回一个默认的成功响应。
} }
/** /**
* *
*/ */
@RequestMapping("/remind/{columnName}/{type}") @RequestMapping("/remind/{columnName}/{type}")
//这是一个Spring MVC的注解用于将HTTP请求映射到 remindCount 方法。当客户端发送一个HTTP请求到 /remind/{columnName}/{type} 路径时Spring MVC会调用 remindCount 方法来处理这个请求。
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中,@PathVariable 注解表示 columnName 和 type 参数的值将从URL路径中获取
map.put("column", columnName);//将 columnName 参数的值添加到 map 中,键为 "column"。
map.put("type", type); map.put("type", type);
if(type.equals("2")) { if (type.equals("2")) //如果 type 参数的值为 "2"
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//创建一个 SimpleDateFormat 对象sdf用于将日期格式化为 "yyyy-MM-dd" 格式。
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
Date remindStartDate = null; //创建一个 Calendar 对象用于处理日期和时间。Calendar.getInstance() 方法返回一个表示当前日期和时间的 Calendar 对象。
Date remindStartDate = null;//声明一个变量 remindStartDate,初始化为 null,这个变量将用于存储提醒开始日期。
Date remindEndDate = null; Date remindEndDate = null;
if(map.get("remindstart")!=null) {
if (map.get("remindstart") != null)//如果 map 中存在键为 "remindstart" 的元素
{
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date()); //将 map 中键为 "remindstart" 的元素的值转换为 Integer 类型,并赋值给 remindStart
c.add(Calendar.DAY_OF_MONTH,remindStart); c.setTime(new Date());//setTime(new Date()) 方法将 Calendar 对象c的时间设置为当前时间。
remindStartDate = c.getTime(); c.add(Calendar.DAY_OF_MONTH, remindStart);//将 Calendar 对象的时间增加 remindStart 天。
map.put("remindstart", sdf.format(remindStartDate)); remindStartDate = c.getTime();//返回一个表示 Calendar 对象当前时间的 Date 对象,并将其赋值给 remindStartDate。
map.put("remindstart", sdf.format(remindStartDate));//将 remindStartDate 格式化为 "yyyy-MM-dd" 格式,并将其作为 map 中键为 "remindstart" 的元素的值。
} }
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 的时间设置为当前时间
c.add(Calendar.DAY_OF_MONTH,remindEnd); c.add(Calendar.DAY_OF_MONTH, remindEnd);//c 的时间增加 remindStart 天
remindEndDate = c.getTime(); remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate)); map.put("remindend", sdf.format(remindEndDate));
} }
} }
Wrapper<NewsEntity> wrapper = new EntityWrapper<NewsEntity>(); // 创建一个EntityWrapper对象用于构建查询条件
if(map.get("remindstart")!=null) { Wrapper<NewsEntity> wrapper = new EntityWrapper<NewsEntity>();//创建一个EntityWrapper对象用于构建查询条件
wrapper.ge(columnName, map.get("remindstart"));
if (map.get("remindstart") != null)//如果map中存在键为"remindstart"的元素
{
wrapper.ge(columnName, map.get("remindstart"));//将 wrapper 对象的查询条件设置为 columnName>=map 中键为 "remindend" 的元素的值
} }
if (map.get("remindend") != null) { if (map.get("remindend") != null) {
wrapper.le(columnName, map.get("remindend")); wrapper.le(columnName, map.get("remindend"));//将 wrapper 对象的查询条件设置为 columnName<=map 中键为 "remindend" 的元素的值
} }
// 查询并返回结果
int count = newsService.selectCount(wrapper); int count = newsService.selectCount(wrapper);//查询满足wrapper对象的查询条件的记录数并赋值给 count 变量
return R.ok().put("count", count); return R.ok().put("count", count);//返回一个包含 count 变量的 R 对象(请求成功的响应对象)
} }
} }

@ -1,43 +1,44 @@
package com.controller; package com.controller;
import java.math.BigDecimal; // 导入BigDecimal类用于高精度的数学计算
import java.math.BigDecimal; import java.text.SimpleDateFormat; // 导入SimpleDateFormat类用于日期格式化
import java.text.SimpleDateFormat; import java.text.ParseException; // 导入ParseException类用于处理日期解析异常
import java.text.ParseException; import java.util.ArrayList; // 导入ArrayList类用于创建动态数组
import java.util.ArrayList; import java.util.Arrays; // 导入Arrays类提供对数组操作的工具方法
import java.util.Arrays; import java.util.Calendar; // 导入Calendar类用于日期时间操作
import java.util.Calendar; import java.util.Map; // 导入Map接口用于键值对集合
import java.util.Map; import java.util.HashMap; // 导入HashMap类基于哈希表的Map实现
import java.util.HashMap; import java.util.Iterator; // 导入Iterator接口用于遍历集合
import java.util.Iterator; import java.util.Date; // 导入Date类用于日期时间表示
import java.util.Date; import java.util.List; // 导入List接口用于列表集合
import java.util.List; import javax.servlet.http.HttpServletRequest; // 导入HttpServletRequest接口用于访问HTTP请求信息
import javax.servlet.http.HttpServletRequest; import java.io.IOException; // 导入IOException类用于处理输入输出异常
import java.io.IOException;
import com.utils.ValidatorUtils; // 导入ValidatorUtils工具类用于实体验证
import com.utils.ValidatorUtils; import org.apache.commons.lang3.StringUtils; // 导入StringUtils类提供字符串操作的工具方法
import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; // 导入Autowired注解用于自动注入依赖
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; // 导入Transactional注解用于声明事务管理
import org.springframework.transaction.annotation.Transactional; import org.springframework.format.annotation.DateTimeFormat; // 导入DateTimeFormat注解用于日期时间格式化
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.web.bind.annotation.PathVariable; // 导入PathVariable注解用于将URL中的参数绑定到控制器方法的参数上
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; // 导入RequestBody注解用于将HTTP请求体绑定到控制器方法的参数上
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; // 导入RequestMapping注解用于映射HTTP请求到控制器方法
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; // 导入RequestParam注解用于将请求参数绑定到控制器方法的参数上
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; // 导入RestController注解用于声明一个REST风格的控制器
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.EntityWrapper; // 导入EntityWrapper类用于构建查询条件
import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.mapper.Wrapper; // 导入Wrapper接口用于封装查询条件
import com.annotation.IgnoreAuth;
import com.annotation.IgnoreAuth; // 导入IgnoreAuth注解用于标记不需要认证的接口
import com.entity.StoreupEntity;
import com.entity.view.StoreupView; import com.entity.StoreupEntity; // 导入StoreupEntity实体类代表存储数据
import com.entity.view.StoreupView; // 导入StoreupView视图类用于展示存储数据
import com.service.StoreupService;
import com.service.TokenService; import com.service.StoreupService; // 导入StoreupService接口用于存储业务操作
import com.utils.PageUtils; import com.service.TokenService; // 导入TokenService接口用于令牌操作未使用
import com.utils.R; import com.utils.PageUtils; // 导入PageUtils工具类用于分页处理
import com.utils.MD5Util; import com.utils.R; // 导入R工具类用于构建统一的响应格式
import com.utils.MPUtil; import com.utils.MD5Util; // 导入MD5Util工具类用于MD5加密未使用
import com.utils.CommonUtil; import com.utils.MPUtil; // 导入MPUtil工具类提供MyBatis Plus操作的工具方法
import com.utils.CommonUtil; // 导入CommonUtil工具类提供通用的工具方法
/** /**
* *
@ -52,186 +53,170 @@ public class StoreupController {
@Autowired @Autowired
private StoreupService storeupService; private StoreupService storeupService;
/** /**
* *
*/ */
@RequestMapping("/page") @RequestMapping("/page")//定义了一个处理HTTP请求的映射当请求路径为/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){ {//定义了一个公共方法接收请求参数、实体对象和HTTP请求对象
if(!request.getSession().getAttribute("role").toString().equals("管理员")) { if(!request.getSession().getAttribute("role").toString().equals("管理员"))
storeup.setUserid((Long)request.getSession().getAttribute("userId")); {//检查当前用户的角色是否为管理员如果不是管理员则设置用户ID
} storeup.setUserid((Long)request.getSession().getAttribute("userId"));//设置用户ID
}
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>(); EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();//创建一个实体包装器对象,用于构建查询条件
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));//调用storeupService的queryPage方法根据查询条件和分页参数进行分页查询并返回分页结果
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params)); request.setAttribute("data", page);//将分页结果设置到HTTP请求对象中
request.setAttribute("data", page); return R.ok().put("data", page);//返回一个包含分页结果的响应对象
return R.ok().put("data", page);
} }
/** /**
* *
*/ */
@IgnoreAuth @IgnoreAuth//定义了一个注解,用于标记不需要权限认证的接口
@RequestMapping("/list") @RequestMapping("/list")//定义了一个处理HTTP请求的映射当请求路径为/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){ {
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>(); EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();//创建一个实体包装器对象,用于构建查询条件
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));//调用storeupService的queryPage方法根据查询条件和分页参数进行分页查询并返回分页结果
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params)); request.setAttribute("data", page);//将分页查询结果设置到HTTP请求对象中
request.setAttribute("data", page); return R.ok().put("data", page);//返回一个包含分页查询结果的响应对象
return R.ok().put("data", page);
} }
/** /**
* *
*/ */
@RequestMapping("/lists") @RequestMapping("/lists")
public R list( StoreupEntity storeup){ public R list( StoreupEntity storeup)//定义了一个公共方法,接收实体对象
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>(); {
ew.allEq(MPUtil.allEQMapPre( storeup, "storeup")); EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();//创建一个实体包装器对象,用于构建查询条件
return R.ok().put("data", storeupService.selectListView(ew)); ew.allEq(MPUtil.allEQMapPre( storeup, "storeup")); //使用allEq方法设置查询条件MPUtil.allEQMapPre方法将实体对象的属性转换为Map,并添加前缀"storeup",allEq方法将Map中的键值对作为查询条件查询出符合条件的实体对象
return R.ok().put("data", storeupService.selectListView(ew));//根据查询条件查询出符合条件的实体对象列表,并返回一个包含实体对象列表的响应对象
} }
/** /**
* *
*/ */
@RequestMapping("/query") @RequestMapping("/query")//定义了一个处理HTTP请求的映射当请求路径为/query时会调用这个方法。
public R query(StoreupEntity storeup){ public R query(StoreupEntity storeup)
{
EntityWrapper< StoreupEntity> ew = new EntityWrapper< StoreupEntity>(); EntityWrapper< StoreupEntity> ew = new EntityWrapper< StoreupEntity>();
//创建一个实体包装器,用于构建查询条件
ew.allEq(MPUtil.allEQMapPre( storeup, "storeup")); ew.allEq(MPUtil.allEQMapPre( storeup, "storeup"));
//使用allEq方法设置查询条件,MPUtil.allEQMapPre方法将实体对象的属性转换为Map,并添加前缀"storeup",allEq方法将Map中的键值对作为查询条件查询出符合条件的实体对象。
StoreupView storeupView = storeupService.selectView(ew); StoreupView storeupView = storeupService.selectView(ew);
//调用服务层的方法查询单个数据,并返回视图对象
return R.ok("查询收藏表成功").put("data", storeupView); return R.ok("查询收藏表成功").put("data", storeupView);
//返回一个包含查询结果的响应对象,并附带成功消息
} }
/** /**
* *
*/ */
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")// 定义一个请求映射,当访问 /info/{id} 路径时,会调用这个方法
public R info(@PathVariable("id") Long id){ public R info(@PathVariable("id") Long id)// 定义一个方法,接收一个路径变量 id类型为 Long
StoreupEntity storeup = storeupService.selectById(id); {
return R.ok().put("data", storeup); StoreupEntity storeup = storeupService.selectById(id);//调用服务层的方法根据ID查询数据并返回实体对象
return R.ok().put("data", storeup);//返回一个包含查询结果的 R 对象,其中包含键 "data" 和对应的 storeup 实体对象
} }
/** /**
* *
*/ */
@IgnoreAuth @IgnoreAuth//定义了一个注解,用于标记不需要权限认证的接口
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}")//定义了一个处理HTTP请求的映射当请求路径为/detail/{id}时,会调用这个方法
public R detail(@PathVariable("id") Long id){ public R detail(@PathVariable("id") Long id)//定义了一个方法,接收一个路径变量 id类型为 Long
StoreupEntity storeup = storeupService.selectById(id); {
return R.ok().put("data", storeup); StoreupEntity storeup = storeupService.selectById(id);//调用服务层的方法根据ID查询数据并返回实体对象
return R.ok().put("data", storeup);//返回一个包含查询结果的响应对象,并附带成功消息
} }
/** /**
* *
*/ */
@RequestMapping("/save") @RequestMapping("/save")//定义了一个处理HTTP请求的映射当请求路径为/save时会调用这个方法
public R save(@RequestBody StoreupEntity storeup, HttpServletRequest request){ public R save(@RequestBody StoreupEntity storeup, HttpServletRequest request)//定义了一个方法接收一个JSON格式的请求体类型为 StoreupEntity并接收一个 HttpServletRequest 对象
{
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());
//ValidatorUtils.validateEntity(storeup); //ValidatorUtils.validateEntity(storeup);
storeup.setUserid((Long)request.getSession().getAttribute("userId")); storeup.setUserid((Long)request.getSession().getAttribute("userId"));//从请求的 session 中获取用户ID并设置到 storeup 实体对象中
storeupService.insert(storeup);//调用服务层的方法将 storeup 实体对象插入数据库
storeupService.insert(storeup); return R.ok();//返回一个包含成功信息的 R 对象
return R.ok();
} }
/** /**
* *
*/ */
@RequestMapping("/add") @RequestMapping("/add")//定义了一个处理HTTP请求的映射当请求路径为/add时会调用这个方法
public R add(@RequestBody StoreupEntity storeup, HttpServletRequest request){ public R add(@RequestBody StoreupEntity storeup, HttpServletRequest request) //定义一个方法,接收一个请求体中的 StoreupEntity 对象和 HttpServletRequest 对象
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);
storeupService.insert(storeup);//调用服务层的方法将 storeup 实体对象插入数据库
storeupService.insert(storeup);
return R.ok(); return R.ok();
} }
/** /**
* *
*/ */
@RequestMapping("/update") @RequestMapping("/update")
@Transactional @Transactional//定义了一个事务注解,表示该方法中的数据库操作应该在一个事务中执行
public R update(@RequestBody StoreupEntity storeup, HttpServletRequest request){ public R update(@RequestBody StoreupEntity storeup, HttpServletRequest request)//定义了一个方法,接收一个请求体中的 StoreupEntity 对象和 HttpServletRequest 对象
{
//ValidatorUtils.validateEntity(storeup); //ValidatorUtils.validateEntity(storeup);
storeupService.updateById(storeup);//全部更新 storeupService.updateById(storeup);//调用服务层的方法根据 ID 更新 storeup 实体对象的所有字段
return R.ok(); return R.ok();//返回一个包含成功信息的 R 对象
} }
/** /**
* *
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){ public R delete(@RequestBody Long[] ids)// 定义一个方法,接收一个请求体中的 Long 数组,类型为 Long[]
storeupService.deleteBatchIds(Arrays.asList(ids)); {
return R.ok(); storeupService.deleteBatchIds(Arrays.asList(ids));//调用服务层的方法,根据传入的 ID 数组批量删除数据
return R.ok();//返回一个包含成功信息的 R 对象 R.ok()函数是R工具类中的一个静态方法用于创建一个包含成功信息的响应对象
} }
/** /**
* *
*/ */
@RequestMapping("/remind/{columnName}/{type}") @RequestMapping("/remind/{columnName}/{type}") // 定义一个请求映射,当访问 /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) { // 定义一个方法,接收一个路径变量 columnName 和 type类型为 String以及一个请求参数 map类型为 Map<String, Object>
map.put("column", columnName); map.put("column", columnName); // 将 columnName 添加到 map 中,键为 "column"
map.put("type", type); map.put("type", type); // 将 type 添加到 map 中,键为 "type"
if(type.equals("2")) { if(type.equals("2")) { // 如果 type 等于 "2"
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 创建一个日期格式化对象,格式为 "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) { // 如果 map 中存在 "remindstart" 键
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 将 "remindstart" 键对应的值转换为整数
c.setTime(new Date()); c.setTime(new Date()); // 设置日历对象的时间为当前时间
c.add(Calendar.DAY_OF_MONTH,remindStart); c.add(Calendar.DAY_OF_MONTH,remindStart); // 将日历对象的时间增加 remindStart 天
remindStartDate = c.getTime(); remindStartDate = c.getTime(); // 获取增加后的时间,并赋值给 remindStartDate
map.put("remindstart", sdf.format(remindStartDate)); map.put("remindstart", sdf.format(remindStartDate)); // 将 remindStartDate 格式化为 "yyyy-MM-dd" 格式,并添加到 map 中,键为 "remindstart"
} }
if(map.get("remindend")!=null) { if(map.get("remindend")!=null) { // 如果 map 中存在 "remindend" 键
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 将 "remindend" 键对应的值转换为整数
c.setTime(new Date()); c.setTime(new Date()); // 设置日历对象的时间为当前时间
c.add(Calendar.DAY_OF_MONTH,remindEnd); c.add(Calendar.DAY_OF_MONTH,remindEnd); // 将日历对象的时间增加 remindEnd 天
remindEndDate = c.getTime(); remindEndDate = c.getTime(); // 获取增加后的时间,并赋值给 remindEndDate
map.put("remindend", sdf.format(remindEndDate)); map.put("remindend", sdf.format(remindEndDate)); // 将 remindEndDate 格式化为 "yyyy-MM-dd" 格式,并添加到 map 中,键为 "remindend"
} }
} }
Wrapper<StoreupEntity> wrapper = new EntityWrapper<StoreupEntity>(); Wrapper<StoreupEntity> wrapper = new EntityWrapper<StoreupEntity>(); // 创建一个实体包装器对象,用于构建查询条件
if(map.get("remindstart")!=null) { if(map.get("remindstart")!=null) { // 如果 map 中存在 "remindstart" 键
wrapper.ge(columnName, map.get("remindstart")); wrapper.ge(columnName, map.get("remindstart")); // 设置查询条件,查询 columnName 字段大于等于 "remindstart" 键对应的值
} }
if(map.get("remindend")!=null) { if(map.get("remindend")!=null) { // 如果 map 中存在 "remindend" 键
wrapper.le(columnName, map.get("remindend")); wrapper.le(columnName, map.get("remindend")); // 设置查询条件,查询 columnName 字段小于等于 "remindend" 键对应的值
} }
if(!request.getSession().getAttribute("role").toString().equals("管理员")) { if(!request.getSession().getAttribute("role").toString().equals("管理员")) { // 如果当前用户的角色不是管理员
wrapper.eq("userid", (Long)request.getSession().getAttribute("userId")); wrapper.eq("userid", (Long)request.getSession().getAttribute("userId")); // 设置查询条件,查询 userid 字段等于当前用户的 ID
} }
int count = storeupService.selectCount(wrapper); // 调用服务层的方法,根据查询条件查询符合条件的记录数,并赋值给 count
int count = storeupService.selectCount(wrapper); return R.ok().put("count", count); // 返回一个包含查询结果的响应对象,其中包含键 "count" 和对应的 count 值
return R.ok().put("count", count);
} }
} }

@ -1,43 +1,45 @@
package com.controller; package com.controller; // 定义一个包,用于组织和管理类
import java.math.BigDecimal; import java.math.BigDecimal; // 导入BigDecimal类用于高精度的数学计算
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat; // 导入SimpleDateFormat类用于日期格式化
import java.text.ParseException; import java.text.ParseException; // 导入ParseException类用于处理日期解析异常
import java.util.ArrayList; import java.util.ArrayList; // 导入ArrayList类用于创建动态数组
import java.util.Arrays; import java.util.Arrays; // 导入Arrays类提供对数组操作的工具方法
import java.util.Calendar; import java.util.Calendar; // 导入Calendar类用于日期时间操作
import java.util.Map; import java.util.Map; // 导入Map接口用于键值对集合
import java.util.HashMap; import java.util.HashMap; // 导入HashMap类基于哈希表的Map实现
import java.util.Iterator; import java.util.Iterator; // 导入Iterator接口用于遍历集合
import java.util.Date; import java.util.Date; // 导入Date类用于日期时间表示
import java.util.List; import java.util.List; // 导入List接口用于列表集合
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest; // 导入HttpServletRequest接口用于访问HTTP请求信息
import java.io.IOException; import java.io.IOException; // 导入IOException类用于处理输入输出异常
import com.utils.ValidatorUtils; import com.utils.ValidatorUtils; // 导入ValidatorUtils工具类用于实体验证
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils; // 导入StringUtils类提供字符串操作的工具方法
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired; // 导入Autowired注解用于自动注入依赖
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional; // 导入Transactional注解用于声明事务管理
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat; // 导入DateTimeFormat注解用于日期时间格式化
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable; // 导入PathVariable注解用于将URL中的参数绑定到控制器方法的参数上
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody; // 导入RequestBody注解用于将HTTP请求体绑定到控制器方法的参数上
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping; // 导入RequestMapping注解用于映射HTTP请求到控制器方法
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam; // 导入RequestParam注解用于将请求参数绑定到控制器方法的参数上
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController; // 导入RestController注解用于声明一个REST风格的控制器
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.mapper.EntityWrapper; // 导入EntityWrapper类用于构建查询条件
import com.annotation.IgnoreAuth; import com.baomidou.mybatisplus.mapper.Wrapper; // 导入Wrapper接口用于封装查询条件
import com.entity.SystemintroEntity; import com.annotation.IgnoreAuth; // 导入IgnoreAuth注解用于标记不需要认证的接口
import com.entity.view.SystemintroView;
import com.entity.SystemintroEntity; // 导入SystemintroEntity实体类代表存储数据
import com.service.SystemintroService; import com.entity.view.SystemintroView; // 导入SystemintroView视图类用于展示存储数据
import com.service.TokenService;
import com.utils.PageUtils; import com.service.SystemintroService; // 导入SystemintroService接口用于存储业务操作
import com.utils.R; import com.service.TokenService; // 导入TokenService接口用于令牌操作未使用
import com.utils.MD5Util; import com.utils.PageUtils; // 导入PageUtils工具类用于分页处理
import com.utils.MPUtil; import com.utils.R; // 导入R工具类用于构建统一的响应格式
import com.utils.CommonUtil; import com.utils.MD5Util; // 导入MD5Util工具类用于MD5加密未使用
import com.utils.MPUtil; // 导入MPUtil工具类提供MyBatis Plus操作的工具方法
import com.utils.CommonUtil; // 导入CommonUtil工具类提供通用的工具方法
/** /**
* *
@ -46,83 +48,75 @@ import com.utils.CommonUtil;
* @email * @email
* @date 2023-02-21 09:46:06 * @date 2023-02-21 09:46:06
*/ */
@RestController @RestController // 声明一个REST风格的控制器
@RequestMapping("/systemintro") @RequestMapping("/systemintro") // 定义一个请求映射,当访问 /systemintro 路径时,会调用这个控制器
public class SystemintroController { public class SystemintroController {
@Autowired @Autowired // 自动注入依赖
private SystemintroService systemintroService; private SystemintroService systemintroService; // 声明一个SystemintroService对象用于存储业务操作
/** /**
* *
*/ */
@RequestMapping("/page") @RequestMapping("/page") // 定义一个请求映射,当访问 /page 路径时,会调用这个方法
public R page(@RequestParam Map<String, Object> params,SystemintroEntity systemintro, public R page(@RequestParam Map<String, Object> params,SystemintroEntity systemintro,
HttpServletRequest request){ HttpServletRequest request){ // 定义一个方法接收请求参数、实体对象和HTTP请求对象
EntityWrapper<SystemintroEntity> ew = new EntityWrapper<SystemintroEntity>(); // 创建一个实体包装器对象,用于构建查询条件
EntityWrapper<SystemintroEntity> ew = new EntityWrapper<SystemintroEntity>(); PageUtils page = systemintroService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, systemintro), params), params)); // 调用服务层的方法,根据查询条件和分页参数进行分页查询,并返回分页结果
request.setAttribute("data", page); // 将分页结果设置到HTTP请求对象中
PageUtils page = systemintroService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, systemintro), params), params)); return R.ok().put("data", page); // 返回一个包含分页结果的响应对象
request.setAttribute("data", page);
return R.ok().put("data", page);
} }
/** /**
* *
*/ */
@IgnoreAuth @IgnoreAuth // 定义了一个注解,用于标记不需要权限认证的接口
@RequestMapping("/list") @RequestMapping("/list") // 定义一个请求映射,当访问 /list 路径时,会调用这个方法
public R list(@RequestParam Map<String, Object> params,SystemintroEntity systemintro, public R list(@RequestParam Map<String, Object> params,SystemintroEntity systemintro,
HttpServletRequest request){ HttpServletRequest request){ // 定义一个方法接收请求参数、实体对象和HTTP请求对象
EntityWrapper<SystemintroEntity> ew = new EntityWrapper<SystemintroEntity>(); EntityWrapper<SystemintroEntity> ew = new EntityWrapper<SystemintroEntity>(); // 创建一个实体包装器对象,用于构建查询条件
PageUtils page = systemintroService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, systemintro), params), params)); // 调用服务层的方法,根据查询条件和分页参数进行分页查询,并返回分页结果
PageUtils page = systemintroService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, systemintro), params), params)); request.setAttribute("data", page); // 将分页结果设置到HTTP请求对象中
request.setAttribute("data", page); return R.ok().put("data", page); // 返回一个包含分页结果的响应对象
return R.ok().put("data", page);
} }
/** /**
* *
*/ */
@RequestMapping("/lists") @RequestMapping("/lists") // 定义一个请求映射,当访问 /lists 路径时,会调用这个方法
public R list( SystemintroEntity systemintro){ public R list( SystemintroEntity systemintro){ // 定义一个方法,接收实体对象
EntityWrapper<SystemintroEntity> ew = new EntityWrapper<SystemintroEntity>(); EntityWrapper<SystemintroEntity> ew = new EntityWrapper<SystemintroEntity>(); // 创建一个实体包装器对象,用于构建查询条件
ew.allEq(MPUtil.allEQMapPre( systemintro, "systemintro")); ew.allEq(MPUtil.allEQMapPre( systemintro, "systemintro")); // 使用allEq方法设置查询条件MPUtil.allEQMapPre方法将实体对象的属性转换为Map,并添加前缀"systemintro",allEq方法将Map中的键值对作为查询条件查询出符合条件的实体对象
return R.ok().put("data", systemintroService.selectListView(ew)); return R.ok().put("data", systemintroService.selectListView(ew)); // 根据查询条件查询出符合条件的实体对象列表,并返回一个包含实体对象列表的响应对象
} }
/** /**
* *
*/ */
@RequestMapping("/query") @RequestMapping("/query") // 定义一个请求映射,当访问 /query 路径时,会调用这个方法
public R query(SystemintroEntity systemintro){ public R query(SystemintroEntity systemintro){ // 定义一个方法,接收实体对象
EntityWrapper< SystemintroEntity> ew = new EntityWrapper< SystemintroEntity>(); EntityWrapper< SystemintroEntity> ew = new EntityWrapper< SystemintroEntity>(); // 创建一个实体包装器对象,用于构建查询条件
ew.allEq(MPUtil.allEQMapPre( systemintro, "systemintro")); ew.allEq(MPUtil.allEQMapPre( systemintro, "systemintro")); // 使用allEq方法设置查询条件MPUtil.allEQMapPre方法将实体对象的属性转换为Map,并添加前缀"systemintro",allEq方法将Map中的键值对作为查询条件查询出符合条件的实体对象
SystemintroView systemintroView = systemintroService.selectView(ew); SystemintroView systemintroView = systemintroService.selectView(ew); // 调用服务层的方法查询单个数据,并返回视图对象
return R.ok("查询关于我们成功").put("data", systemintroView); return R.ok("查询关于我们成功").put("data", systemintroView); // 返回一个包含查询结果的响应对象,并附带成功消息
} }
/** /**
* *
*/ */
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}") // 定义一个请求映射,当访问 /info/{id} 路径时,会调用这个方法
public R info(@PathVariable("id") Long id){ public R info(@PathVariable("id") Long id){ // 定义一个方法,接收一个路径变量 id类型为 Long
SystemintroEntity systemintro = systemintroService.selectById(id); SystemintroEntity systemintro = systemintroService.selectById(id); // 调用服务层的方法根据ID查询数据并返回实体对象
return R.ok().put("data", systemintro); return R.ok().put("data", systemintro); // 返回一个包含查询结果的 R 对象,其中包含键 "data" 和对应的 systemintro 实体对象
} }
/** /**
* *
*/ */
@IgnoreAuth @IgnoreAuth // 定义了一个注解,用于标记不需要权限认证的接口
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}") // 定义一个请求映射,当访问 /detail/{id} 路径时,会调用这个方法
public R detail(@PathVariable("id") Long id){ public R detail(@PathVariable("id") Long id){ // 定义一个方法,接收一个路径变量 id类型为 Long
SystemintroEntity systemintro = systemintroService.selectById(id); SystemintroEntity systemintro = systemintroService.selectById(id); // 调用服务层的方法根据ID查询数据并返回实体对象
return R.ok().put("data", systemintro); return R.ok().put("data", systemintro); // 返回一个包含查询结果的响应对象,并附带成功消息
} }
@ -131,37 +125,35 @@ public class SystemintroController {
/** /**
* *
*/ */
@RequestMapping("/save") @RequestMapping("/save") // 定义一个请求映射,当访问 /save 路径时,会调用这个方法
public R save(@RequestBody SystemintroEntity systemintro, HttpServletRequest request){ public R save(@RequestBody SystemintroEntity systemintro, HttpServletRequest request){ // 定义一个方法接收一个JSON格式的请求体类型为 SystemintroEntity并接收一个 HttpServletRequest 对象
systemintro.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); systemintro.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); // 生成一个新的唯一ID由当前时间戳加上一个随机数
//ValidatorUtils.validateEntity(systemintro); //ValidatorUtils.validateEntity(systemintro); // 注释掉的代码,用于验证 systemintro 实体对象是否符合要求
systemintroService.insert(systemintro); // 调用服务层的方法将 systemintro 实体对象插入数据库
systemintroService.insert(systemintro); return R.ok(); // 返回一个包含成功信息的 R 对象
return R.ok();
} }
/** /**
* *
*/ */
@RequestMapping("/add") @RequestMapping("/add") // 定义一个请求映射,当访问 /add 路径时,会调用这个方法
public R add(@RequestBody SystemintroEntity systemintro, HttpServletRequest request){ public R add(@RequestBody SystemintroEntity systemintro, HttpServletRequest request){ // 定义一个方法,接收一个请求体中的 SystemintroEntity 对象和 HttpServletRequest 对象
systemintro.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); systemintro.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); // 生成一个新的唯一ID由当前时间戳加上一个随机数
//ValidatorUtils.validateEntity(systemintro); //ValidatorUtils.validateEntity(systemintro); // 注释掉的代码,用于验证 systemintro 实体对象是否符合要求
systemintroService.insert(systemintro); // 调用服务层的方法将 systemintro 实体对象插入数据库
systemintroService.insert(systemintro); return R.ok(); // 返回一个包含成功信息的 R 对象
return R.ok();
} }
/** /**
* *
*/ */
@RequestMapping("/update") @RequestMapping("/update") // 定义一个请求映射,当访问 /update 路径时,会调用这个方法
@Transactional @Transactional // 定义了一个事务注解,表示该方法中的数据库操作应该在一个事务中执行
public R update(@RequestBody SystemintroEntity systemintro, HttpServletRequest request){ public R update(@RequestBody SystemintroEntity systemintro, HttpServletRequest request){ // 定义一个方法,接收一个请求体中的 SystemintroEntity 对象和 HttpServletRequest 对象
//ValidatorUtils.validateEntity(systemintro); //ValidatorUtils.validateEntity(systemintro); // 注释掉的代码,用于验证 systemintro 实体对象是否符合要求
systemintroService.updateById(systemintro);//全部更新 systemintroService.updateById(systemintro); // 调用服务层的方法根据 ID 更新 systemintro 实体对象的所有字段
return R.ok(); return R.ok(); // 返回一个包含成功信息的 R 对象
} }
@ -169,62 +161,52 @@ public class SystemintroController {
/** /**
* *
*/ */
@RequestMapping("/delete") @RequestMapping("/delete") // 定义一个请求映射,当访问 /delete 路径时,会调用这个方法
public R delete(@RequestBody Long[] ids){ public R delete(@RequestBody Long[] ids){ // 定义一个方法,接收一个请求体中的 Long 数组,类型为 Long[]
systemintroService.deleteBatchIds(Arrays.asList(ids)); systemintroService.deleteBatchIds(Arrays.asList(ids)); // 调用服务层的方法,根据传入的 ID 数组批量删除数据
return R.ok(); return R.ok(); // 返回一个包含成功信息的 R 对象
} }
/** /**
* *
*/ */
@RequestMapping("/remind/{columnName}/{type}") @RequestMapping("/remind/{columnName}/{type}") // 定义一个请求映射,当访问 /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) { // 定义一个方法,接收一个路径变量 columnName 和 type类型为 String以及一个请求参数 map类型为 Map<String, Object>
map.put("column", columnName); map.put("column", columnName); // 将 columnName 添加到 map 中,键为 "column"
map.put("type", type); map.put("type", type); // 将 type 添加到 map 中,键为 "type"
if(type.equals("2")) { if(type.equals("2")) { // 如果 type 等于 "2"
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 创建一个日期格式化对象,格式为 "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) { // 如果 map 中存在 "remindstart" 键
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 将 "remindstart" 键对应的值转换为整数
c.setTime(new Date()); c.setTime(new Date()); // 设置日历对象的时间为当前时间
c.add(Calendar.DAY_OF_MONTH,remindStart); c.add(Calendar.DAY_OF_MONTH,remindStart); // 将日历对象的时间增加 remindStart 天
remindStartDate = c.getTime(); remindStartDate = c.getTime(); // 获取增加后的时间,并赋值给 remindStartDate
map.put("remindstart", sdf.format(remindStartDate)); map.put("remindstart", sdf.format(remindStartDate)); // 将 remindStartDate 格式化为 "yyyy-MM-dd" 格式,并添加到 map 中,键为 "remindstart"
} }
if(map.get("remindend")!=null) { if(map.get("remindend")!=null) { // 如果 map 中存在 "remindend" 键
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 将 "remindend" 键对应的值转换为整数
c.setTime(new Date()); c.setTime(new Date()); // 设置日历对象的时间为当前时间
c.add(Calendar.DAY_OF_MONTH,remindEnd); c.add(Calendar.DAY_OF_MONTH,remindEnd); // 将日历对象的时间增加 remindEnd 天
remindEndDate = c.getTime(); remindEndDate = c.getTime(); // 获取增加后的时间,并赋值给 remindEndDate
map.put("remindend", sdf.format(remindEndDate)); map.put("remindend", sdf.format(remindEndDate)); // 将 remindEndDate 格式化为 "yyyy-MM-dd" 格式,并添加到 map 中,键为 "remindend"
} }
} }
Wrapper<SystemintroEntity> wrapper = new EntityWrapper<SystemintroEntity>(); Wrapper<SystemintroEntity> wrapper = new EntityWrapper<SystemintroEntity>(); // 创建一个实体包装器对象,用于构建查询条件
if(map.get("remindstart")!=null) { if(map.get("remindstart")!=null) { // 如果 map 中存在 "remindstart" 键
wrapper.ge(columnName, map.get("remindstart")); wrapper.ge(columnName, map.get("remindstart")); // 设置查询条件,查询 columnName 字段大于等于 "remindstart" 键对应的值
} }
if(map.get("remindend")!=null) { if(map.get("remindend")!=null) { // 如果 map 中存在 "remindend" 键
wrapper.le(columnName, map.get("remindend")); wrapper.le(columnName, map.get("remindend")); // 设置查询条件,查询 columnName 字段小于等于 "remindend" 键对应的值
} }
int count = systemintroService.selectCount(wrapper); int count = systemintroService.selectCount(wrapper); // 调用服务层的方法,根据查询条件查询符合条件的记录数,并赋值给 count
return R.ok().put("count", count); return R.ok().put("count", count); // 返回一个包含查询结果的响应对象,其中包含键 "count" 和对应的 count 值
} }
} }

@ -35,140 +35,145 @@ import com.utils.ValidatorUtils;
/** /**
* *
*/ */
@RequestMapping("users") @RequestMapping("users") // 定义请求路径的基础 URL 为 "users"
@RestController @RestController // 标明该类是一个控制器,返回的对象直接作为 JSON 响应
public class UsersController { public class UsersController {
@Autowired @Autowired // 自动注入 UsersService 依赖
private UsersService userService; private UsersService userService;
@Autowired @Autowired // 自动注入 TokenService 依赖
private TokenService tokenService; private TokenService tokenService;
/** /**
* *
*/ */
@IgnoreAuth @IgnoreAuth // 忽略认证,允许未登录用户访问
@PostMapping(value = "/login") @PostMapping(value = "/login") // 处理 POST 请求,路径为 "users/login"
public R login(String username, String password, String captcha, HttpServletRequest request) { public R login(String username, String password, String captcha, HttpServletRequest request) {
// 根据用户名查询用户
UsersEntity user = userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username)); UsersEntity user = userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username));
// 检查用户是否存在且密码是否匹配
if(user == null || !user.getPassword().equals(password)) { if(user == null || !user.getPassword().equals(password)) {
return R.error("账号或密码不正确"); return R.error("账号或密码不正确"); // 返回错误信息
} }
// 生成用户的 token
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); // 返回成功信息和 token
} }
/** /**
* *
*/ */
@IgnoreAuth @IgnoreAuth // 忽略认证,允许未登录用户访问
@PostMapping(value = "/register") @PostMapping(value = "/register") // 处理 POST 请求,路径为 "users/register"
public R register(@RequestBody UsersEntity user) { public R register(@RequestBody UsersEntity user) {
// ValidatorUtils.validateEntity(user); // 校验用户是否已存在
if(userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) != null) { if(userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) != null) {
return R.error("用户已存在"); return R.error("用户已存在"); // 返回用户已存在的错误信息
} }
userService.insert(user); userService.insert(user); // 插入新用户
return R.ok(); return R.ok(); // 返回成功信息
} }
/** /**
* 退 * 退
*/ */
@GetMapping(value = "logout") @GetMapping(value = "logout") // 处理 GET 请求,路径为 "users/logout"
public R logout(HttpServletRequest request) { public R logout(HttpServletRequest request) {
request.getSession().invalidate(); request.getSession().invalidate(); // 使 session 失效,用户登出
return R.ok("退出成功"); return R.ok("退出成功"); // 返回成功信息
} }
/** /**
* *
*/ */
@IgnoreAuth @IgnoreAuth // 忽略认证,允许未登录用户访问
@RequestMapping(value = "/resetPass") @RequestMapping(value = "/resetPass") // 处理请求,路径为 "users/resetPass"
public R resetPass(String username, HttpServletRequest request){ public R resetPass(String username, HttpServletRequest request){
// 根据用户名查询用户
UsersEntity user = userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username)); UsersEntity user = userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username));
if(user == null) { if(user == null) {
return R.error("账号不存在"); return R.error("账号不存在"); // 返回账号不存在的错误信息
} }
user.setPassword("123456"); user.setPassword("123456"); // 将用户密码重置为 "123456"
userService.update(user,null); userService.update(user, null); // 更新用户信息
return R.ok("密码已重置为123456"); return R.ok("密码已重置为123456"); // 返回成功信息
} }
/** /**
* *
*/ */
@RequestMapping("/page") @RequestMapping("/page") // 处理请求,路径为 "users/page"
public R page(@RequestParam Map<String, Object> params, UsersEntity user) { public R page(@RequestParam Map<String, Object> params, UsersEntity user) {
EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>(); EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>(); // 创建查询条件
// 调用服务层方法查询分页数据
PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params)); PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
return R.ok().put("data", page); return R.ok().put("data", page); // 返回查询结果
} }
/** /**
* *
*/ */
@RequestMapping("/list") @RequestMapping("/list") // 处理请求,路径为 "users/list"
public R list(UsersEntity user) { public R list(UsersEntity user) {
EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>(); EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>(); // 创建查询条件
ew.allEq(MPUtil.allEQMapPre( user, "user")); ew.allEq(MPUtil.allEQMapPre(user, "user")); // 添加所有相等条件
return R.ok().put("data", userService.selectListView(ew)); return R.ok().put("data", userService.selectListView(ew)); // 返回查询结果
} }
/** /**
* *
*/ */
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}") // 处理请求,路径为 "users/info/{id}"
public R info(@PathVariable("id") String id) { public R info(@PathVariable("id") String id) {
UsersEntity user = userService.selectById(id); UsersEntity user = userService.selectById(id); // 根据 ID 查找用户
return R.ok().put("data", user); return R.ok().put("data", user); // 返回用户信息
} }
/** /**
* session * session
*/ */
@RequestMapping("/session") @RequestMapping("/session") // 处理请求,路径为 "users/session"
public R getCurrUser(HttpServletRequest request) { public R getCurrUser(HttpServletRequest request) {
Long id = (Long)request.getSession().getAttribute("userId"); Long id = (Long) request.getSession().getAttribute("userId"); // 从 session 中获取用户 ID
UsersEntity user = userService.selectById(id); UsersEntity user = userService.selectById(id); // 根据 ID 查找用户
return R.ok().put("data", user); return R.ok().put("data", user); // 返回用户信息
} }
/** /**
* *
*/ */
@PostMapping("/save") @PostMapping("/save") // 处理 POST 请求,路径为 "users/save"
public R save(@RequestBody UsersEntity user) { public R save(@RequestBody UsersEntity user) {
// ValidatorUtils.validateEntity(user); // 校验用户是否已存在
if(userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) != null) { if(userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) != null) {
return R.error("用户已存在"); return R.error("用户已存在"); // 返回用户已存在的错误信息
} }
userService.insert(user); userService.insert(user); // 插入新用户
return R.ok(); return R.ok(); // 返回成功信息
} }
/** /**
* *
*/ */
@RequestMapping("/update") @RequestMapping("/update") // 处理请求,路径为 "users/update"
public R update(@RequestBody UsersEntity user) { public R update(@RequestBody UsersEntity user) {
// ValidatorUtils.validateEntity(user); // 校验用户是否已存在
UsersEntity u = userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())); UsersEntity u = userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername()));
if(u != null && u.getId() != user.getId() && u.getUsername().equals(user.getUsername())) { if(u != null && u.getId() != user.getId() && u.getUsername().equals(user.getUsername())) {
return R.error("用户名已存在。"); return R.error("用户名已存在。"); // 返回用户名已存在的错误信息
} }
userService.updateById(user);//全部更新 userService.updateById(user); // 更新用户信息
return R.ok(); return R.ok(); // 返回成功信息
} }
/** /**
* *
*/ */
@RequestMapping("/delete") @RequestMapping("/delete") // 处理请求,路径为 "users/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(); // 返回成功信息
} }
} }

@ -11,9 +11,9 @@ import org.apache.ibatis.annotations.Param;
import com.entity.vo.NewsVO; import com.entity.vo.NewsVO;
import com.entity.view.NewsView; import com.entity.view.NewsView;
/** /**
* *
* 访
* *
* @author * @author
* @email * @email
@ -21,15 +21,18 @@ import com.entity.view.NewsView;
*/ */
public interface NewsDao extends BaseMapper<NewsEntity> { public interface NewsDao extends BaseMapper<NewsEntity> {
// 根据查询条件Wrapper选择公告的信息列表并返回一个 NewsVO 对象的列表
List<NewsVO> selectListVO(@Param("ew") Wrapper<NewsEntity> wrapper); List<NewsVO> selectListVO(@Param("ew") Wrapper<NewsEntity> wrapper);
// 根据查询条件Wrapper选择单个公告的信息并返回一个 NewsVO 对象
NewsVO selectVO(@Param("ew") Wrapper<NewsEntity> wrapper); NewsVO selectVO(@Param("ew") Wrapper<NewsEntity> wrapper);
// 根据查询条件Wrapper选择公告的信息视图列表并返回一个 NewsView 对象的列表
List<NewsView> selectListView(@Param("ew") Wrapper<NewsEntity> wrapper); List<NewsView> selectListView(@Param("ew") Wrapper<NewsEntity> wrapper);
// 根据查询条件Wrapper与分页信息选择公告的信息视图列表并返回一个 NewsView 对象的列表
List<NewsView> selectListView(Pagination page, @Param("ew") Wrapper<NewsEntity> wrapper); List<NewsView> selectListView(Pagination page, @Param("ew") Wrapper<NewsEntity> wrapper);
// 根据查询条件Wrapper选择单个公告的信息视图并返回一个 NewsView 对象
NewsView selectView(@Param("ew") Wrapper<NewsEntity> wrapper); NewsView selectView(@Param("ew") Wrapper<NewsEntity> wrapper);
} }

@ -1,35 +1,37 @@
package com.dao; package com.dao; // 声明该接口所在的包为com.dao
import com.entity.StoreupEntity; import com.entity.StoreupEntity; // 导入StoreupEntity类代表收藏表的实体类
import com.baomidou.mybatisplus.mapper.BaseMapper; import com.baomidou.mybatisplus.mapper.BaseMapper; // 导入MyBatis-Plus框架的BaseMapper接口提供基础的CRUD操作
import java.util.List; import java.util.List; // 导入List接口用于返回列表结果
import java.util.Map; import java.util.Map; // 导入Map接口虽然在此代码中未使用
import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.mapper.Wrapper; // 导入Wrapper接口用于构造查询条件
import com.baomidou.mybatisplus.plugins.pagination.Pagination; import com.baomidou.mybatisplus.plugins.pagination.Pagination; // 导入Pagination类用于支持分页查询
import org.apache.ibatis.annotations.Param;
import com.entity.vo.StoreupVO;
import com.entity.view.StoreupView;
import org.apache.ibatis.annotations.Param; // 导入Param注解用于在Mapper方法中定义参数
import com.entity.vo.StoreupVO; // 导入StoreupVO类代表用于展示的视图对象
import com.entity.view.StoreupView; // 导入StoreupView类代表用于视图展示的另一个对象
/** /**
* *
* *
* @author * @author // 作者信息(未填写)
* @email * @email // 邮箱信息(未填写)
* @date 2023-02-21 09:46:06 * @date 2023-02-21 09:46:06 // 该接口的创建日期
*/ */
public interface StoreupDao extends BaseMapper<StoreupEntity> { public interface StoreupDao extends BaseMapper<StoreupEntity> { // 定义StoreupDao接口继承BaseMapper以获得基本的数据库操作
// 根据条件查询返回StoreupVO类型的列表
List<StoreupVO> selectListVO(@Param("ew") Wrapper<StoreupEntity> wrapper); List<StoreupVO> selectListVO(@Param("ew") Wrapper<StoreupEntity> wrapper);
// 根据条件查询返回单个StoreupVO对象
StoreupVO selectVO(@Param("ew") Wrapper<StoreupEntity> wrapper); StoreupVO selectVO(@Param("ew") Wrapper<StoreupEntity> wrapper);
// 根据条件查询返回StoreupView类型的列表
List<StoreupView> selectListView(@Param("ew") Wrapper<StoreupEntity> wrapper); List<StoreupView> selectListView(@Param("ew") Wrapper<StoreupEntity> wrapper);
// 根据条件及分页信息查询返回StoreupView类型的列表
List<StoreupView> selectListView(Pagination page, @Param("ew") Wrapper<StoreupEntity> wrapper); List<StoreupView> selectListView(Pagination page, @Param("ew") Wrapper<StoreupEntity> wrapper);
// 根据条件查询返回单个StoreupView对象
StoreupView selectView(@Param("ew") Wrapper<StoreupEntity> wrapper); StoreupView selectView(@Param("ew") Wrapper<StoreupEntity> wrapper);
} }

@ -11,9 +11,9 @@ import org.apache.ibatis.annotations.Param;
import com.entity.vo.SystemintroVO; import com.entity.vo.SystemintroVO;
import com.entity.view.SystemintroView; import com.entity.view.SystemintroView;
/** /**
* *
* "关于我们"访
* *
* @author * @author
* @email * @email
@ -21,15 +21,18 @@ import com.entity.view.SystemintroView;
*/ */
public interface SystemintroDao extends BaseMapper<SystemintroEntity> { public interface SystemintroDao extends BaseMapper<SystemintroEntity> {
// 根据查询条件Wrapper选择系统介绍的信息列表并返回一个 SystemintroVO 对象的列表
List<SystemintroVO> selectListVO(@Param("ew") Wrapper<SystemintroEntity> wrapper); List<SystemintroVO> selectListVO(@Param("ew") Wrapper<SystemintroEntity> wrapper);
// 根据查询条件Wrapper选择单个系统介绍的信息并返回一个 SystemintroVO 对象
SystemintroVO selectVO(@Param("ew") Wrapper<SystemintroEntity> wrapper); SystemintroVO selectVO(@Param("ew") Wrapper<SystemintroEntity> wrapper);
// 根据查询条件Wrapper选择系统介绍信息视图的列表并返回一个 SystemintroView 对象的列表
List<SystemintroView> selectListView(@Param("ew") Wrapper<SystemintroEntity> wrapper); List<SystemintroView> selectListView(@Param("ew") Wrapper<SystemintroEntity> wrapper);
// 根据查询条件Wrapper和分页信息选择系统介绍信息视图的列表并返回一个 SystemintroView 对象的列表
List<SystemintroView> selectListView(Pagination page, @Param("ew") Wrapper<SystemintroEntity> wrapper); List<SystemintroView> selectListView(Pagination page, @Param("ew") Wrapper<SystemintroEntity> wrapper);
// 根据查询条件Wrapper选择单个平台介绍的信息视图并返回一个 SystemintroView 对象
SystemintroView selectView(@Param("ew") Wrapper<SystemintroEntity> wrapper); SystemintroView selectView(@Param("ew") Wrapper<SystemintroEntity> wrapper);
} }

@ -9,14 +9,17 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.pagination.Pagination; import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.entity.UsersEntity; import com.entity.UsersEntity;
/** /**
* *
* 访
*/ */
public interface UsersDao extends BaseMapper<UsersEntity> { public interface UsersDao extends BaseMapper<UsersEntity> {
// 根据查询条件Wrapper选择用户列表并返回一个 UsersEntity 对象的列表
List<UsersEntity> selectListView(@Param("ew") Wrapper<UsersEntity> wrapper); List<UsersEntity> selectListView(@Param("ew") Wrapper<UsersEntity> wrapper);
// 根据查询条件Wrapper和分页信息选择用户列表并返回一个 UsersEntity 对象的列表
List<UsersEntity> selectListView(Pagination page, @Param("ew") Wrapper<UsersEntity> wrapper); List<UsersEntity> selectListView(Pagination page, @Param("ew") Wrapper<UsersEntity> wrapper);
} }

@ -5,14 +5,11 @@ import com.baomidou.mybatisplus.annotations.TableName;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
@ -32,16 +29,13 @@ import com.baomidou.mybatisplus.enums.IdType;
public class StoreupEntity<T> implements Serializable { public class StoreupEntity<T> implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public StoreupEntity() { public StoreupEntity() {
} }
public StoreupEntity(T t) { public StoreupEntity(T t) {
try { try {
BeanUtils.copyProperties(this, t); BeanUtils.copyProperties(this, t);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -54,52 +48,43 @@ public class StoreupEntity<T> implements Serializable {
/** /**
* id * id
*/ */
private Long userid; private Long userid;
/** /**
* id * id
*/ */
private Long refid; private Long refid;
/** /**
* *
*/ */
private String tablename; private String tablename;
/** /**
* *
*/ */
private String name; private String name;
/** /**
* *
*/ */
private String picture; private String picture;
/** /**
* (1:,21:,22:,31:,41:) * (1:,21:,22:,31:,41:)
*/ */
private String type; private String type;
/** /**
* *
*/ */
private String inteltype; private String inteltype;
/** /**
* *
*/ */
private String remark; private String remark;
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat @DateTimeFormat
private Date addtime; private Date addtime;
@ -214,5 +199,4 @@ public class StoreupEntity<T> implements Serializable {
public String getRemark() { public String getRemark() {
return remark; return remark;
} }
} }

@ -7,71 +7,72 @@ import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType; import com.baomidou.mybatisplus.enums.IdType;
/** /**
* *
*/ */
@TableName("users") @TableName("users") // 指定实体类对应的数据库表为users
public class UsersEntity implements Serializable { public class UsersEntity implements Serializable { // 定义UsersEntity类实现Serializable接口
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L; // 定义序列化ID
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO) // 标识为主键,并设置主键自增
private Long id; private Long id; // 主键id
/** /**
* *
*/ */
private String username; private String username; // 用户名
/** /**
* *
*/ */
private String password; private String password; // 用户密码
/** /**
* *
*/ */
private String role; private String role; // 用户角色
private Date addtime; private Date addtime; // 添加时间
public String getUsername() { public String getUsername() { // 获取用户名
return username; return username; // 返回username
} }
public void setUsername(String username) { public void setUsername(String username) { // 设置用户名
this.username = username; this.username = username; // 赋值username
} }
public String getPassword() { public String getPassword() { // 获取密码
return password; return password; // 返回password
} }
public void setPassword(String password) { public void setPassword(String password) { // 设置密码
this.password = password; this.password = password; // 赋值password
} }
public String getRole() { public String getRole() { // 获取用户角色
return role; return role; // 返回role
} }
public void setRole(String role) { public void setRole(String role) { // 设置用户角色
this.role = role; this.role = role; // 赋值role
} }
public Date getAddtime() { public Date getAddtime() { // 获取添加时间
return addtime; return addtime; // 返回addtime
} }
public void setAddtime(Date addtime) { public void setAddtime(Date addtime) { // 设置添加时间
this.addtime = addtime; this.addtime = addtime; // 赋值addtime
} }
public Long getId() { public Long getId() { // 获取主键id
return id; return id; // 返回id
} }
public void setId(Long id) { public void setId(Long id) { // 设置主键id
this.id = id; this.id = id; // 赋值id
} }
} }

@ -28,6 +28,7 @@ import com.baomidou.mybatisplus.enums.IdType;
* @email * @email
* @date 2023-02-21 09:46:06 * @date 2023-02-21 09:46:06
*/ */
//
@TableName("wenjuandiaocha") @TableName("wenjuandiaocha")
public class WenjuandiaochaEntity<T> implements Serializable { public class WenjuandiaochaEntity<T> implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

@ -19,73 +19,62 @@ import java.io.Serializable;
* @date 2023-02-21 09:46:06 * @date 2023-02-21 09:46:06
*/ */
public class NewsModel implements Serializable { public class NewsModel implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L; // 序列化版本号
/** /**
* *
*/ */
private String introduction; // 存放公告的简介
private String introduction;
/** /**
* *
*/ */
private String picture; // 存放公告相关的图片
private String picture;
/** /**
* *
*/ */
private String content; // 存放公告的详细内容
private String content;
/** /**
* *
*/ */
public void setIntroduction(String introduction) { public void setIntroduction(String introduction) {
this.introduction = introduction; this.introduction = introduction; // 设置简介字段
} }
/** /**
* *
*/ */
public String getIntroduction() { public String getIntroduction() {
return introduction; return introduction; // 返回简介字段的值
} }
/** /**
* *
*/ */
public void setPicture(String picture) { public void setPicture(String picture) {
this.picture = picture; this.picture = picture; // 设置图片字段
} }
/** /**
* *
*/ */
public String getPicture() { public String getPicture() {
return picture; return picture; // 返回图片字段的值
} }
/** /**
* *
*/ */
public void setContent(String content) { public void setContent(String content) {
this.content = content; this.content = content; // 设置内容字段
} }
/** /**
* *
*/ */
public String getContent() { public String getContent() {
return content; return content; // 返回内容字段的值
} }
} }

@ -9,6 +9,10 @@ import java.lang.reflect.InvocationTargetException;
import java.io.Serializable; import java.io.Serializable;
/**
*
*
* 使
/** /**
* *
* *
@ -17,20 +21,22 @@ import java.io.Serializable;
* @email * @email
* @date 2023-02-21 09:46:06 * @date 2023-02-21 09:46:06
*/ */
@TableName("news") @TableName("news") // 指定该类对应的数据库表名为 "news"
public class NewsView extends NewsEntity implements Serializable { public class NewsView extends NewsEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L; // 序列化版本号
// 默认构造函数
public NewsView() { public NewsView() {
} }
// 构造函数,接受一个 NewsEntity 对象并复制其属性
public NewsView(NewsEntity newsEntity) { public NewsView(NewsEntity newsEntity) {
try { try {
BeanUtils.copyProperties(this, newsEntity); BeanUtils.copyProperties(this, newsEntity); // 使用 BeanUtils 复制属性
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
// TODO Auto-generated catch block // 捕获并处理属性复制过程中的异常
e.printStackTrace(); e.printStackTrace(); // 打印异常堆栈跟踪
} }
} }
} }

@ -17,20 +17,21 @@ import java.io.Serializable;
* @email * @email
* @date 2023-02-21 09:46:06 * @date 2023-02-21 09:46:06
*/ */
@TableName("storeup") @TableName("storeup") // 指定该类对应的数据库表名为 "storeup"
public class StoreupView extends StoreupEntity implements Serializable { public class StoreupView extends StoreupEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L; // 序列化版本号
// 默认构造函数
public StoreupView() { public StoreupView() {
} }
// 构造函数,接受一个 StoreupEntity 对象并复制其属性
public StoreupView(StoreupEntity storeupEntity) { public StoreupView(StoreupEntity storeupEntity) {
try { try {
BeanUtils.copyProperties(this, storeupEntity); BeanUtils.copyProperties(this, storeupEntity); // 使用 BeanUtils 复制属性
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
// TODO Auto-generated catch block // 捕获并处理属性复制过程中的异常
e.printStackTrace(); e.printStackTrace(); // 打印异常堆栈跟踪
} }
} }
} }

@ -1,14 +1,18 @@
package com.entity.view; package com.entity.view;
// 导入系统介绍实体类
import com.entity.SystemintroEntity; import com.entity.SystemintroEntity;
// 导入MyBatis-Plus的注解库
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 导入Apache Commons BeanUtils类
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
// 导入反射异常处理类
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
// 导入序列化接口
import java.io.Serializable; import java.io.Serializable;
/** /**
* *
* *
@ -17,20 +21,24 @@ import java.io.Serializable;
* @email * @email
* @date 2023-02-21 09:46:06 * @date 2023-02-21 09:46:06
*/ */
// 指定表名为"systemintro"的实体类
@TableName("systemintro") @TableName("systemintro")
public class SystemintroView extends SystemintroEntity implements Serializable { public class SystemintroView extends SystemintroEntity implements Serializable {
// 版本控制
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// 默认构造函数
public SystemintroView() { public SystemintroView() {
} }
// 带参构造函数用于根据SystemintroEntity对象初始化SystemintroView
public SystemintroView(SystemintroEntity systemintroEntity) { public SystemintroView(SystemintroEntity systemintroEntity) {
try { try {
// 复制systemintroEntity的属性到当前对象
BeanUtils.copyProperties(this, systemintroEntity); BeanUtils.copyProperties(this, systemintroEntity);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
// TODO Auto-generated catch block // 捕获反射过程中的异常并打印堆栈信息
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

@ -14,24 +14,24 @@ import com.entity.view.NewsView;
/** /**
* *
* *
* @author * @author // 作者信息
* @email * @email // 邮箱信息
* @date 2023-02-21 09:46:06 * @date 2023-02-21 09:46:06 // 创建日期
*/ */
public interface NewsService extends IService<NewsEntity> { public interface NewsService extends IService<NewsEntity> { // 声明一个接口,扩展 IService 用于基本的 CRUD 操作
PageUtils queryPage(Map<String, Object> params); PageUtils queryPage(Map<String, Object> params); // 根据传入的参数进行分页查询,并返回分页结果
List<NewsVO> selectListVO(Wrapper<NewsEntity> wrapper); List<NewsVO> selectListVO(Wrapper<NewsEntity> wrapper); // 根据条件包装器查询并返回 NewsVO 列表
NewsVO selectVO(@Param("ew") Wrapper<NewsEntity> wrapper); NewsVO selectVO(@Param("ew") Wrapper<NewsEntity> wrapper); // 根据条件包装器查询并返回单个 NewsVO 对象
List<NewsView> selectListView(Wrapper<NewsEntity> wrapper); List<NewsView> selectListView(Wrapper<NewsEntity> wrapper); // 根据条件包装器查询并返回 NewsView 列表
NewsView selectView(@Param("ew") Wrapper<NewsEntity> wrapper); NewsView selectView(@Param("ew") Wrapper<NewsEntity> wrapper); // 根据条件包装器查询并返回单个 NewsView 对象
PageUtils queryPage(Map<String, Object> params,Wrapper<NewsEntity> wrapper);
PageUtils queryPage(Map<String, Object> params, Wrapper<NewsEntity> wrapper); // 根据参数和条件包装器进行分页查询,并返回分页结果
} }

@ -10,28 +10,27 @@ import com.entity.vo.StoreupVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import com.entity.view.StoreupView; import com.entity.view.StoreupView;
/** /**
* *
* *
* @author * @author // 作者信息
* @email * @email // 邮箱信息
* @date 2023-02-21 09:46:06 * @date 2023-02-21 09:46:06 // 创建日期
*/ */
public interface StoreupService extends IService<StoreupEntity> { public interface StoreupService extends IService<StoreupEntity> { // 声明一个接口,扩展 IService 用于基本的 CRUD 操作
PageUtils queryPage(Map<String, Object> params);
List<StoreupVO> selectListVO(Wrapper<StoreupEntity> wrapper); PageUtils queryPage(Map<String, Object> params); // 根据传入的参数进行分页查询,并返回分页结果
StoreupVO selectVO(@Param("ew") Wrapper<StoreupEntity> wrapper); List<StoreupVO> selectListVO(Wrapper<StoreupEntity> wrapper); // 根据条件包装器查询并返回 StoreupVO 列表
List<StoreupView> selectListView(Wrapper<StoreupEntity> wrapper); StoreupVO selectVO(@Param("ew") Wrapper<StoreupEntity> wrapper); // 根据条件包装器查询并返回单个 StoreupVO 对象
StoreupView selectView(@Param("ew") Wrapper<StoreupEntity> wrapper); List<StoreupView> selectListView(Wrapper<StoreupEntity> wrapper); // 根据条件包装器查询并返回 StoreupView 列表
PageUtils queryPage(Map<String, Object> params,Wrapper<StoreupEntity> wrapper); StoreupView selectView(@Param("ew") Wrapper<StoreupEntity> wrapper); // 根据条件包装器查询并返回单个 StoreupView 对象
PageUtils queryPage(Map<String, Object> params, Wrapper<StoreupEntity> wrapper); // 根据参数和条件包装器进行分页查询,并返回分页结果
} }

@ -9,29 +9,27 @@ import java.util.Map;
import com.entity.vo.SystemintroVO; import com.entity.vo.SystemintroVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import com.entity.view.SystemintroView; import com.entity.view.SystemintroView;
/** /**
* *
* *
* @author * @author // 作者信息
* @email * @email // 邮箱信息
* @date 2023-02-21 09:46:06 * @date 2023-02-21 09:46:06 // 创建日期
*/ */
public interface SystemintroService extends IService<SystemintroEntity> { public interface SystemintroService extends IService<SystemintroEntity> { // 声明一个接口,扩展 IService 用于基本的 CRUD 操作
PageUtils queryPage(Map<String, Object> params); PageUtils queryPage(Map<String, Object> params); // 根据传入的参数进行分页查询,并返回分页结果
List<SystemintroVO> selectListVO(Wrapper<SystemintroEntity> wrapper); List<SystemintroVO> selectListVO(Wrapper<SystemintroEntity> wrapper); // 根据条件包装器查询并返回 SystemintroVO 列表
SystemintroVO selectVO(@Param("ew") Wrapper<SystemintroEntity> wrapper); SystemintroVO selectVO(@Param("ew") Wrapper<SystemintroEntity> wrapper); // 根据条件包装器查询并返回单个 SystemintroVO 对象
List<SystemintroView> selectListView(Wrapper<SystemintroEntity> wrapper); List<SystemintroView> selectListView(Wrapper<SystemintroEntity> wrapper); // 根据条件包装器查询并返回 SystemintroView 列表
SystemintroView selectView(@Param("ew") Wrapper<SystemintroEntity> wrapper); SystemintroView selectView(@Param("ew") Wrapper<SystemintroEntity> wrapper); // 根据条件包装器查询并返回单个 SystemintroView 对象
PageUtils queryPage(Map<String, Object> params,Wrapper<SystemintroEntity> wrapper);
PageUtils queryPage(Map<String, Object> params, Wrapper<SystemintroEntity> wrapper); // 根据参数和条件包装器进行分页查询,并返回分页结果
} }

@ -11,15 +11,15 @@ import com.baomidou.mybatisplus.service.IService;
import com.entity.UsersEntity; import com.entity.UsersEntity;
import com.utils.PageUtils; import com.utils.PageUtils;
/** /**
* *
*/ */
public interface UsersService extends IService<UsersEntity> { public interface UsersService extends IService<UsersEntity> { // 声明一个接口,扩展 IService用于基本的 CRUD 操作
PageUtils queryPage(Map<String, Object> params);
List<UsersEntity> selectListView(Wrapper<UsersEntity> wrapper); PageUtils queryPage(Map<String, Object> params); // 根据传入的参数进行分页查询,并返回分页结果
PageUtils queryPage(Map<String, Object> params,Wrapper<UsersEntity> wrapper); List<UsersEntity> selectListView(Wrapper<UsersEntity> wrapper); // 根据条件包装器查询并返回 UsersEntity 列表
PageUtils queryPage(Map<String, Object> params, Wrapper<UsersEntity> wrapper); // 根据参数和条件包装器进行分页查询,并返回分页结果
} }

@ -18,46 +18,52 @@ import com.service.NewsService;
import com.entity.vo.NewsVO; import com.entity.vo.NewsVO;
import com.entity.view.NewsView; import com.entity.view.NewsView;
@Service("newsService") @Service("newsService") // 声明该类为服务层组件,并指定服务名称为 "newsService"
public class NewsServiceImpl extends ServiceImpl<NewsDao, NewsEntity> implements NewsService { public class NewsServiceImpl extends ServiceImpl<NewsDao, NewsEntity> implements NewsService {
// 实现分页查询
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
// 创建一个分页对象,使用传入的参数获取页面信息
Page<NewsEntity> page = this.selectPage( Page<NewsEntity> page = this.selectPage(
new Query<NewsEntity>(params).getPage(), new Query<NewsEntity>(params).getPage(), // 获取分页对象
new EntityWrapper<NewsEntity>() new EntityWrapper<NewsEntity>() // 构建查询条件的包装器
); );
return new PageUtils(page); return new PageUtils(page); // 返回分页结果包装
} }
// 实现带条件的分页查询
@Override @Override
public PageUtils queryPage(Map<String, Object> params, Wrapper<NewsEntity> wrapper) { public PageUtils queryPage(Map<String, Object> params, Wrapper<NewsEntity> wrapper) {
// 创建分页对象
Page<NewsView> page = new Query<NewsView>(params).getPage(); Page<NewsView> page = new Query<NewsView>(params).getPage();
// 设置页面记录
page.setRecords(baseMapper.selectListView(page, wrapper)); page.setRecords(baseMapper.selectListView(page, wrapper));
PageUtils pageUtil = new PageUtils(page); PageUtils pageUtil = new PageUtils(page); // 包装分页结果
return pageUtil; return pageUtil; // 返回分页结果
} }
// 查询符合条件的所有 NewsVO 对象
@Override @Override
public List<NewsVO> selectListVO(Wrapper<NewsEntity> wrapper) { public List<NewsVO> selectListVO(Wrapper<NewsEntity> wrapper) {
return baseMapper.selectListVO(wrapper); return baseMapper.selectListVO(wrapper); // 调用 DAO 层方法执行查询
} }
// 查询单个 NewsVO 对象
@Override @Override
public NewsVO selectVO(Wrapper<NewsEntity> wrapper) { public NewsVO selectVO(Wrapper<NewsEntity> wrapper) {
return baseMapper.selectVO(wrapper); return baseMapper.selectVO(wrapper); // 调用 DAO 层方法执行查询
} }
// 查询符合条件的所有 NewsView 对象
@Override @Override
public List<NewsView> selectListView(Wrapper<NewsEntity> wrapper) { public List<NewsView> selectListView(Wrapper<NewsEntity> wrapper) {
return baseMapper.selectListView(wrapper); return baseMapper.selectListView(wrapper); // 调用 DAO 层方法执行查询
} }
// 查询单个 NewsView 对象
@Override @Override
public NewsView selectView(Wrapper<NewsEntity> wrapper) { public NewsView selectView(Wrapper<NewsEntity> wrapper) {
return baseMapper.selectView(wrapper); return baseMapper.selectView(wrapper); // 调用 DAO 层方法执行查询
} }
} }

@ -18,46 +18,51 @@ import com.service.StoreupService;
import com.entity.vo.StoreupVO; import com.entity.vo.StoreupVO;
import com.entity.view.StoreupView; import com.entity.view.StoreupView;
@Service("storeupService") @Service("storeupService") // 将该类标记为服务,并指定 bean 的名称为 "storeupService"
public class StoreupServiceImpl extends ServiceImpl<StoreupDao, StoreupEntity> implements StoreupService { public class StoreupServiceImpl extends ServiceImpl<StoreupDao, StoreupEntity> implements StoreupService {
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
// 根据传入的参数创建分页对象,并调用 selectPage 方法获取数据
Page<StoreupEntity> page = this.selectPage( Page<StoreupEntity> page = this.selectPage(
new Query<StoreupEntity>(params).getPage(), new Query<StoreupEntity>(params).getPage(), // 构造分页信息
new EntityWrapper<StoreupEntity>() new EntityWrapper<StoreupEntity>() // 创建 EntityWrapper 用于封装查询条件
); );
// 返回封装好的分页结果
return new PageUtils(page); return new PageUtils(page);
} }
@Override @Override
public PageUtils queryPage(Map<String, Object> params, Wrapper<StoreupEntity> wrapper) { public PageUtils queryPage(Map<String, Object> params, Wrapper<StoreupEntity> wrapper) {
// 创建分页对象
Page<StoreupView> page = new Query<StoreupView>(params).getPage(); Page<StoreupView> page = new Query<StoreupView>(params).getPage();
page.setRecords(baseMapper.selectListView(page,wrapper)); // 设置分页记录
page.setRecords(baseMapper.selectListView(page, wrapper)); // 根据分页信息和条件查询数据
// 返回封装好的分页结果
PageUtils pageUtil = new PageUtils(page); PageUtils pageUtil = new PageUtils(page);
return pageUtil; return pageUtil;
} }
@Override @Override
public List<StoreupVO> selectListVO(Wrapper<StoreupEntity> wrapper) { public List<StoreupVO> selectListVO(Wrapper<StoreupEntity> wrapper) {
// 根据 Wrapper 条件查询并返回 StoreupVO 列表
return baseMapper.selectListVO(wrapper); return baseMapper.selectListVO(wrapper);
} }
@Override @Override
public StoreupVO selectVO(Wrapper<StoreupEntity> wrapper) { public StoreupVO selectVO(Wrapper<StoreupEntity> wrapper) {
// 根据 Wrapper 条件查询并返回单个 StoreupVO 对象
return baseMapper.selectVO(wrapper); return baseMapper.selectVO(wrapper);
} }
@Override @Override
public List<StoreupView> selectListView(Wrapper<StoreupEntity> wrapper) { public List<StoreupView> selectListView(Wrapper<StoreupEntity> wrapper) {
// 根据 Wrapper 条件查询并返回 StoreupView 列表
return baseMapper.selectListView(wrapper); return baseMapper.selectListView(wrapper);
} }
@Override @Override
public StoreupView selectView(Wrapper<StoreupEntity> wrapper) { public StoreupView selectView(Wrapper<StoreupEntity> wrapper) {
// 根据 Wrapper 条件查询并返回单个 StoreupView 对象
return baseMapper.selectView(wrapper); return baseMapper.selectView(wrapper);
} }
} }

@ -18,46 +18,51 @@ import com.service.SystemintroService;
import com.entity.vo.SystemintroVO; import com.entity.vo.SystemintroVO;
import com.entity.view.SystemintroView; import com.entity.view.SystemintroView;
@Service("systemintroService") @Service("systemintroService") // 将该类标记为服务,并指定 bean 的名称为 "systemintroService"
public class SystemintroServiceImpl extends ServiceImpl<SystemintroDao, SystemintroEntity> implements SystemintroService { public class SystemintroServiceImpl extends ServiceImpl<SystemintroDao, SystemintroEntity> implements SystemintroService {
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
// 根据传入的参数创建分页对象,并调用 selectPage 方法获取数据
Page<SystemintroEntity> page = this.selectPage( Page<SystemintroEntity> page = this.selectPage(
new Query<SystemintroEntity>(params).getPage(), new Query<SystemintroEntity>(params).getPage(), // 构造分页信息
new EntityWrapper<SystemintroEntity>() new EntityWrapper<SystemintroEntity>() // 创建 EntityWrapper 用于封装查询条件
); );
// 返回封装好的分页结果
return new PageUtils(page); return new PageUtils(page);
} }
@Override @Override
public PageUtils queryPage(Map<String, Object> params, Wrapper<SystemintroEntity> wrapper) { public PageUtils queryPage(Map<String, Object> params, Wrapper<SystemintroEntity> wrapper) {
// 创建分页对象
Page<SystemintroView> page = new Query<SystemintroView>(params).getPage(); Page<SystemintroView> page = new Query<SystemintroView>(params).getPage();
page.setRecords(baseMapper.selectListView(page,wrapper)); // 设置分页记录
page.setRecords(baseMapper.selectListView(page, wrapper)); // 根据分页信息和条件查询数据
// 返回封装好的分页结果
PageUtils pageUtil = new PageUtils(page); PageUtils pageUtil = new PageUtils(page);
return pageUtil; return pageUtil;
} }
@Override @Override
public List<SystemintroVO> selectListVO(Wrapper<SystemintroEntity> wrapper) { public List<SystemintroVO> selectListVO(Wrapper<SystemintroEntity> wrapper) {
// 根据 Wrapper 条件查询并返回 SystemintroVO 列表
return baseMapper.selectListVO(wrapper); return baseMapper.selectListVO(wrapper);
} }
@Override @Override
public SystemintroVO selectVO(Wrapper<SystemintroEntity> wrapper) { public SystemintroVO selectVO(Wrapper<SystemintroEntity> wrapper) {
// 根据 Wrapper 条件查询并返回单个 SystemintroVO 对象
return baseMapper.selectVO(wrapper); return baseMapper.selectVO(wrapper);
} }
@Override @Override
public List<SystemintroView> selectListView(Wrapper<SystemintroEntity> wrapper) { public List<SystemintroView> selectListView(Wrapper<SystemintroEntity> wrapper) {
// 根据 Wrapper 条件查询并返回 SystemintroView 列表
return baseMapper.selectListView(wrapper); return baseMapper.selectListView(wrapper);
} }
@Override @Override
public SystemintroView selectView(Wrapper<SystemintroEntity> wrapper) { public SystemintroView selectView(Wrapper<SystemintroEntity> wrapper) {
// 根据 Wrapper 条件查询并返回单个 SystemintroView 对象
return baseMapper.selectView(wrapper); return baseMapper.selectView(wrapper);
} }
} }

@ -21,28 +21,33 @@ import com.utils.Query;
/** /**
* *
*/ */
@Service("usersService") @Service("usersService") // 将该类标记为服务,并指定 bean 的名称为 "usersService"
public class UsersServiceImpl extends ServiceImpl<UsersDao, UsersEntity> implements UsersService { public class UsersServiceImpl extends ServiceImpl<UsersDao, UsersEntity> implements UsersService {
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
// 根据传入的参数创建分页对象,并调用 selectPage 方法获取用户数据
Page<UsersEntity> page = this.selectPage( Page<UsersEntity> page = this.selectPage(
new Query<UsersEntity>(params).getPage(), new Query<UsersEntity>(params).getPage(), // 构造分页信息
new EntityWrapper<UsersEntity>() new EntityWrapper<UsersEntity>() // 创建 EntityWrapper 用于封装查询条件
); );
// 返回封装好的分页结果
return new PageUtils(page); return new PageUtils(page);
} }
@Override @Override
public List<UsersEntity> selectListView(Wrapper<UsersEntity> wrapper) { public List<UsersEntity> selectListView(Wrapper<UsersEntity> wrapper) {
// 根据 Wrapper 条件查询并返回 UsersEntity 列表
return baseMapper.selectListView(wrapper); return baseMapper.selectListView(wrapper);
} }
@Override @Override
public PageUtils queryPage(Map<String, Object> params, public PageUtils queryPage(Map<String, Object> params, Wrapper<UsersEntity> wrapper) {
Wrapper<UsersEntity> wrapper) { // 创建分页对象
Page<UsersEntity> page = new Query<UsersEntity>(params).getPage(); Page<UsersEntity> page = new Query<UsersEntity>(params).getPage();
page.setRecords(baseMapper.selectListView(page,wrapper)); // 设置分页记录
page.setRecords(baseMapper.selectListView(page, wrapper)); // 根据分页信息和条件查询数据
// 返回封装好的分页结果
PageUtils pageUtil = new PageUtils(page); PageUtils pageUtil = new PageUtils(page);
return pageUtil; return pageUtil;
} }

Loading…
Cancel
Save