diff --git a/src/main/java/com/controller/WenjuandiaochaController.java b/src/main/java/com/controller/WenjuandiaochaController.java index 6151049..8dbfe6f 100644 --- a/src/main/java/com/controller/WenjuandiaochaController.java +++ b/src/main/java/com/controller/WenjuandiaochaController.java @@ -52,331 +52,240 @@ import com.entity.StoreupEntity; @RequestMapping("/wenjuandiaocha") public class WenjuandiaochaController { @Autowired - private WenjuandiaochaService wenjuandiaochaService; - + private WenjuandiaochaService wenjuandiaochaService; // 注入问卷调查服务 @Autowired - private StoreupService storeupService; - - - + private StoreupService storeupService; // 注入收藏服务 /** - * 后端列表 - */ - @RequestMapping("/page") - public R page(@RequestParam Map params,WenjuandiaochaEntity wenjuandiaocha, - HttpServletRequest request){ - - EntityWrapper ew = new EntityWrapper(); - - PageUtils page = wenjuandiaochaService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandiaocha), params), params)); - request.setAttribute("data", page); - return R.ok().put("data", page); - } - - /** - * 前端列表 - */ - @IgnoreAuth - @RequestMapping("/list") - public R list(@RequestParam Map params,WenjuandiaochaEntity wenjuandiaocha, - HttpServletRequest request){ - EntityWrapper ew = new EntityWrapper(); - - PageUtils page = wenjuandiaochaService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandiaocha), params), params)); - request.setAttribute("data", page); - return R.ok().put("data", page); - } - - /** - * 列表 + * 提醒接口 */ - @RequestMapping("/lists") - public R list( WenjuandiaochaEntity wenjuandiaocha){ - EntityWrapper ew = new EntityWrapper(); - ew.allEq(MPUtil.allEQMapPre( wenjuandiaocha, "wenjuandiaocha")); - return R.ok().put("data", wenjuandiaochaService.selectListView(ew)); - } + @RequestMapping("/remind/{columnName}/{type}") + public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, + @PathVariable("type") String type, @RequestParam Map map) { + // 将列名和类型添加到 map 中 + map.put("column", columnName); + map.put("type", type); + + // 如果类型为 "2",处理日期范围 + if (type.equals("2")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 定义日期格式 + Calendar c = Calendar.getInstance(); // 获取当前日期时间 + Date remindStartDate = null; + Date remindEndDate = null; + + // 处理 remindstart 参数 + if (map.get("remindstart") != null) { + Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 将 remindstart 转换为整数 + c.setTime(new Date()); // 设置当前时间 + c.add(Calendar.DAY_OF_MONTH, remindStart); // 添加 remindStart 天 + remindStartDate = c.getTime(); // 获取新的开始日期 + map.put("remindstart", sdf.format(remindStartDate)); // 格式化并添加到 map 中 + } + + // 处理 remindend 参数 + if (map.get("remindend") != null) { + Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 将 remindend 转换为整数 + c.setTime(new Date()); // 设置当前时间 + c.add(Calendar.DAY_OF_MONTH, remindEnd); // 添加 remindEnd 天 + remindEndDate = c.getTime(); // 获取新的结束日期 + map.put("remindend", sdf.format(remindEndDate)); // 格式化并添加到 map 中 + } + } + + // 创建 EntityWrapper 对象,用于构建查询条件 + Wrapper wrapper = new EntityWrapper(); + if (map.get("remindstart") != null) { + wrapper.ge(columnName, map.get("remindstart")); // 大于等于 remindstart + } + if (map.get("remindend") != null) { + wrapper.le(columnName, map.get("remindend")); // 小于等于 remindend + } - /** - * 查询 - */ - @RequestMapping("/query") - public R query(WenjuandiaochaEntity wenjuandiaocha){ - EntityWrapper< WenjuandiaochaEntity> ew = new EntityWrapper< WenjuandiaochaEntity>(); - ew.allEq(MPUtil.allEQMapPre( wenjuandiaocha, "wenjuandiaocha")); - WenjuandiaochaView wenjuandiaochaView = wenjuandiaochaService.selectView(ew); - return R.ok("查询问卷调查成功").put("data", wenjuandiaochaView); + // 查询符合条件的记录数 + int count = wenjuandiaochaService.selectCount(wrapper); + return R.ok().put("count", count); // 返回记录数 } /** - * 后端详情 - */ - @RequestMapping("/info/{id}") - public R info(@PathVariable("id") Long id){ - WenjuandiaochaEntity wenjuandiaocha = wenjuandiaochaService.selectById(id); - wenjuandiaocha.setClicktime(new Date()); - wenjuandiaochaService.updateById(wenjuandiaocha); - return R.ok().put("data", wenjuandiaocha); - } - - /** - * 前端详情 - */ - @IgnoreAuth - @RequestMapping("/detail/{id}") - public R detail(@PathVariable("id") Long id){ - WenjuandiaochaEntity wenjuandiaocha = wenjuandiaochaService.selectById(id); - wenjuandiaocha.setClicktime(new Date()); - wenjuandiaochaService.updateById(wenjuandiaocha); - return R.ok().put("data", wenjuandiaocha); - } - - - - - /** - * 后端保存 - */ - @RequestMapping("/save") - public R save(@RequestBody WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request){ - wenjuandiaocha.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); - //ValidatorUtils.validateEntity(wenjuandiaocha); - - wenjuandiaochaService.insert(wenjuandiaocha); - return R.ok(); - } - - /** - * 前端保存 - */ - @RequestMapping("/add") - public R add(@RequestBody WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request){ - wenjuandiaocha.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); - //ValidatorUtils.validateEntity(wenjuandiaocha); - - wenjuandiaochaService.insert(wenjuandiaocha); - return R.ok(); - } - - - /** - * 修改 - */ - @RequestMapping("/update") - @Transactional - public R update(@RequestBody WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request){ - //ValidatorUtils.validateEntity(wenjuandiaocha); - wenjuandiaochaService.updateById(wenjuandiaocha);//全部更新 - return R.ok(); - } - - - - /** - * 删除 - */ - @RequestMapping("/delete") - public R delete(@RequestBody Long[] ids){ - wenjuandiaochaService.deleteBatchIds(Arrays.asList(ids)); - return R.ok(); - } - - /** - * 提醒接口 - */ - @RequestMapping("/remind/{columnName}/{type}") - public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, - @PathVariable("type") String type,@RequestParam Map map) { - map.put("column", columnName); - map.put("type", type); - - if(type.equals("2")) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Calendar c = Calendar.getInstance(); - Date remindStartDate = null; - Date remindEndDate = null; - if(map.get("remindstart")!=null) { - Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); - c.setTime(new Date()); - c.add(Calendar.DAY_OF_MONTH,remindStart); - remindStartDate = c.getTime(); - map.put("remindstart", sdf.format(remindStartDate)); - } - if(map.get("remindend")!=null) { - Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); - c.setTime(new Date()); - c.add(Calendar.DAY_OF_MONTH,remindEnd); - remindEndDate = c.getTime(); - map.put("remindend", sdf.format(remindEndDate)); - } - } - - Wrapper wrapper = new EntityWrapper(); - if(map.get("remindstart")!=null) { - wrapper.ge(columnName, map.get("remindstart")); - } - if(map.get("remindend")!=null) { - wrapper.le(columnName, map.get("remindend")); - } - - - int count = wenjuandiaochaService.selectCount(wrapper); - return R.ok().put("count", count); - } - - - /** * 前端智能排序 */ - @IgnoreAuth + @IgnoreAuth // 忽略认证 @RequestMapping("/autoSort") - public R autoSort(@RequestParam Map params,WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request,String pre){ + public R autoSort(@RequestParam Map params, WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request, String pre) { + // 创建 EntityWrapper 对象,用于构建查询条件 EntityWrapper ew = new EntityWrapper(); Map newMap = new HashMap(); Map param = new HashMap(); - Iterator> it = param.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry entry = it.next(); - String key = entry.getKey(); - String newKey = entry.getKey(); - if (pre.endsWith(".")) { - newMap.put(pre + newKey, entry.getValue()); - } else if (StringUtils.isEmpty(pre)) { - newMap.put(newKey, entry.getValue()); - } else { - newMap.put(pre + "." + newKey, entry.getValue()); - } - } - params.put("sort", "clicktime"); + Iterator> it = param.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + String key = entry.getKey(); + String newKey = entry.getKey(); + + // 处理 pre 参数 + if (pre.endsWith(".")) { + newMap.put(pre + newKey, entry.getValue()); + } else if (StringUtils.isEmpty(pre)) { + newMap.put(newKey, entry.getValue()); + } else { + newMap.put(pre + "." + newKey, entry.getValue()); + } + } + + // 设置排序条件 + params.put("sort", "clicktime"); params.put("order", "desc"); - PageUtils page = wenjuandiaochaService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandiaocha), params), params)); - return R.ok().put("data", page); + + // 查询分页数据 + PageUtils page = wenjuandiaochaService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandiaocha), params), params)); + return R.ok().put("data", page); // 返回分页数据 } /** * 协同算法(按收藏推荐) */ @RequestMapping("/autoSort2") - public R autoSort2(@RequestParam Map params,WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request){ + public R autoSort2(@RequestParam Map params, WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request) { + // 获取用户 ID String userId = request.getSession().getAttribute("userId").toString(); - String inteltypeColumn = "leixing"; + String inteltypeColumn = "leixing"; // 定义智能类型列名 List storeups = storeupService.selectList(new EntityWrapper().eq("type", 1).eq("userid", userId).eq("tablename", "wenjuandiaocha").orderBy("addtime", false)); List inteltypes = new ArrayList(); - Integer limit = params.get("limit")==null?10:Integer.parseInt(params.get("limit").toString()); + Integer limit = params.get("limit") == null ? 10 : Integer.parseInt(params.get("limit").toString()); // 设置限制数量,默认为 10 List wenjuandiaochaList = new ArrayList(); - //去重 - if(storeups!=null && storeups.size()>0) { - for(StoreupEntity s : storeups) { + + // 去重 + if (storeups != null && storeups.size() > 0) { + for (StoreupEntity s : storeups) { wenjuandiaochaList.addAll(wenjuandiaochaService.selectList(new EntityWrapper().eq(inteltypeColumn, s.getInteltype()))); } } + + // 创建 EntityWrapper 对象,用于构建查询条件 EntityWrapper ew = new EntityWrapper(); params.put("sort", "id"); params.put("order", "desc"); + + // 查询分页数据 PageUtils page = wenjuandiaochaService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandiaocha), params), params)); - List pageList = (List)page.getList(); - if(wenjuandiaochaList.size() pageList = (List) page.getList(); + + // 如果结果数量小于限制数量,则从分页数据中添加 + if (wenjuandiaochaList.size() < limit) { + int toAddNum = (limit - wenjuandiaochaList.size()) <= pageList.size() ? (limit - wenjuandiaochaList.size()) : pageList.size(); + for (WenjuandiaochaEntity o1 : pageList) { boolean addFlag = true; - for(WenjuandiaochaEntity o2 : wenjuandiaochaList) { - if(o1.getId().intValue()==o2.getId().intValue()) { + for (WenjuandiaochaEntity o2 : wenjuandiaochaList) { + if (o1.getId().intValue() == o2.getId().intValue()) { addFlag = false; break; } } - if(addFlag) { + if (addFlag) { wenjuandiaochaList.add(o1); - if(--toAddNum==0) break; + if (--toAddNum == 0) break; } } - } else if(wenjuandiaochaList.size()>limit) { - wenjuandiaochaList = wenjuandiaochaList.subList(0, limit); + } else if (wenjuandiaochaList.size() > limit) { + wenjuandiaochaList = wenjuandiaochaList.subList(0, limit); // 如果结果数量大于限制数量,则截取前 limit 个 } - page.setList(wenjuandiaochaList); - return R.ok().put("data", page); + + page.setList(wenjuandiaochaList); // 设置新的列表 + return R.ok().put("data", page); // 返回分页数据 } - - - /** * (按值统计) */ @RequestMapping("/value/{xColumnName}/{yColumnName}") - public R value(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName,HttpServletRequest request) { + public R value(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName, HttpServletRequest request) { Map params = new HashMap(); params.put("xColumn", xColumnName); params.put("yColumn", yColumnName); + + // 创建 EntityWrapper 对象,用于构建查询条件 EntityWrapper ew = new EntityWrapper(); + + // 查询统计结果 List> result = wenjuandiaochaService.selectValue(params, ew); + + // 处理日期格式 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - for(Map m : result) { - for(String k : m.keySet()) { - if(m.get(k) instanceof Date) { - m.put(k, sdf.format((Date)m.get(k))); + for (Map m : result) { + for (String k : m.keySet()) { + if (m.get(k) instanceof Date) { + m.put(k, sdf.format((Date) m.get(k))); } } } - return R.ok().put("data", result); + return R.ok().put("data", result); // 返回统计结果 } /** * (按值统计)时间统计类型 */ @RequestMapping("/value/{xColumnName}/{yColumnName}/{timeStatType}") - public R valueDay(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType,HttpServletRequest request) { + public R valueDay(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType, HttpServletRequest request) { Map params = new HashMap(); params.put("xColumn", xColumnName); params.put("yColumn", yColumnName); params.put("timeStatType", timeStatType); + + // 创建 EntityWrapper 对象,用于构建查询条件 EntityWrapper ew = new EntityWrapper(); + + // 查询时间统计结果 List> result = wenjuandiaochaService.selectTimeStatValue(params, ew); + + // 处理日期格式 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - for(Map m : result) { - for(String k : m.keySet()) { - if(m.get(k) instanceof Date) { - m.put(k, sdf.format((Date)m.get(k))); + for (Map m : result) { + for (String k : m.keySet()) { + if (m.get(k) instanceof Date) { + m.put(k, sdf.format((Date) m.get(k))); } } } - return R.ok().put("data", result); + return R.ok().put("data", result); // 返回时间统计结果 } /** * 分组统计 */ @RequestMapping("/group/{columnName}") - public R group(@PathVariable("columnName") String columnName,HttpServletRequest request) { + public R group(@PathVariable("columnName") String columnName, HttpServletRequest request) { Map params = new HashMap(); params.put("column", columnName); + + // 创建 EntityWrapper 对象,用于构建查询条件 EntityWrapper ew = new EntityWrapper(); + + // 查询分组统计结果 List> result = wenjuandiaochaService.selectGroup(params, ew); + + // 处理日期格式 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - for(Map m : result) { - for(String k : m.keySet()) { - if(m.get(k) instanceof Date) { - m.put(k, sdf.format((Date)m.get(k))); + for (Map m : result) { + for (String k : m.keySet()) { + if (m.get(k) instanceof Date) { + m.put(k, sdf.format((Date) m.get(k))); } } } - return R.ok().put("data", result); + return R.ok().put("data", result); // 返回分组统计结果 } - - - /** * 总数量 */ @RequestMapping("/count") - public R count(@RequestParam Map params,WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request){ + public R count(@RequestParam Map params, WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request) { + // 创建 EntityWrapper 对象,用于构建查询条件 EntityWrapper ew = new EntityWrapper(); + + // 查询符合条件的记录数 int count = wenjuandiaochaService.selectCount(MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandiaocha), params), params)); - return R.ok().put("data", count); + return R.ok().put("data", count); // 返回记录数 } - - } diff --git a/src/main/java/com/dao/WenjuandiaochaDao.java b/src/main/java/com/dao/WenjuandiaochaDao.java index 2367e7a..c472bf7 100644 --- a/src/main/java/com/dao/WenjuandiaochaDao.java +++ b/src/main/java/com/dao/WenjuandiaochaDao.java @@ -13,31 +13,73 @@ import com.entity.view.WenjuandiaochaView; /** - * 问卷调查 - * - * @author - * @email + * 问卷调查数据访问对象接口 + * 该接口继承自BaseMapper,提供了基本的CRUD操作方法 + * @author 未填写具体作者 + * @email 未填写具体邮箱 * @date 2023-02-21 09:46:06 */ public interface WenjuandiaochaDao extends BaseMapper { - - List selectListVO(@Param("ew") Wrapper wrapper); - - WenjuandiaochaVO selectVO(@Param("ew") Wrapper wrapper); - - List selectListView(@Param("ew") Wrapper wrapper); - List selectListView(Pagination page,@Param("ew") Wrapper wrapper); - - WenjuandiaochaView selectView(@Param("ew") Wrapper wrapper); - + /** + * 根据条件查询问卷调查列表,并将结果转换为WenjuandiaochaVO对象列表 + * @param ew 查询条件封装对象 + * @return 符合条件的问卷调查VO对象列表 + */ + List selectListVO(@Param("ew") Wrapper ew); - List> selectValue(@Param("params") Map params,@Param("ew") Wrapper wrapper); + /** + * 根据条件查询单个问卷调查记录,并将其转换为WenjuandiaochaVO对象 + * @param ew 查询条件封装对象 + * @return 符合条件的问卷调查VO对象 + */ + WenjuandiaochaVO selectVO(@Param("ew") Wrapper ew); - List> selectTimeStatValue(@Param("params") Map params,@Param("ew") Wrapper wrapper); - - List> selectGroup(@Param("params") Map params,@Param("ew") Wrapper wrapper); + /** + * 根据条件查询问卷调查列表,并将结果转换为WenjuandiaochaView对象列表 + * @param ew 查询条件封装对象 + * @return 符合条件的问卷调查View对象列表 + */ + List selectListView(@Param("ew") Wrapper ew); + /** + * 根据条件和分页参数查询问卷调查列表,并将结果转换为WenjuandiaochaView对象列表 + * @param page 分页参数对象 + * @param ew 查询条件封装对象 + * @return 分页后的符合条件的问卷调查View对象列表 + */ + List selectListView(Pagination page, @Param("ew") Wrapper ew); + /** + * 根据条件查询单个问卷调查记录,并将其转换为WenjuandiaochaView对象 + * @param ew 查询条件封装对象 + * @return 符合条件的问卷调查View对象 + */ + WenjuandiaochaView selectView(@Param("ew") Wrapper ew); + + /** + * 根据自定义参数和条件查询数据库,并返回Map对象列表 + * @param params 自定义查询参数 + * @param ew 查询条件封装对象 + * @return 符合条件的数据结果集,返回值为Map对象列表 + */ + List> selectValue(@Param("params") Map params, @Param("ew") Wrapper ew); + + /** + * 根据时间统计自定义参数和条件查询数据库,并返回Map对象列表 + * @param params 自定义查询参数,可能包含时间范围等信息 + * @param ew 查询条件封装对象 + * @return 符合条件的时间统计数据结果集,返回值为Map对象列表 + */ + List> selectTimeStatValue(@Param("params") Map params, @Param("ew") Wrapper ew); + + /** + * 根据分组查询自定义参数和条件查询数据库,并返回Map对象列表 + * @param params 自定义查询参数,可能包含分组依据等信息 + * @param ew 查询条件封装对象 + * @return 符合条件的分组数据结果集,返回值为Map对象列表 + */ + List> selectGroup(@Param("params") Map params, @Param("ew") Wrapper ew); } + diff --git a/src/main/java/com/entity/WenjuandiaochaEntity.java b/src/main/java/com/entity/WenjuandiaochaEntity.java index d826017..2d33f1f 100644 --- a/src/main/java/com/entity/WenjuandiaochaEntity.java +++ b/src/main/java/com/entity/WenjuandiaochaEntity.java @@ -3,7 +3,6 @@ package com.entity; import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotations.TableName; import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -11,37 +10,39 @@ import java.lang.reflect.InvocationTargetException; import java.io.Serializable; import java.util.Date; -import java.util.List; import org.springframework.format.annotation.DateTimeFormat; import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.commons.beanutils.BeanUtils; -import com.baomidou.mybatisplus.annotations.TableField; -import com.baomidou.mybatisplus.enums.FieldFill; -import com.baomidou.mybatisplus.enums.IdType; - /** * 问卷调查 * 数据库通用操作实体类(普通增删改查) - * @author - * @email + * @author 作者名 + * @email 邮箱地址 * @date 2023-02-21 09:46:06 */ -@TableName("wenjuandiaocha") -public class WenjuandiaochaEntity implements Serializable { - private static final long serialVersionUID = 1L; - +@TableName("wenjuandiaocha") // 指定该实体类对应的数据库表名为“wenjuandiaocha” +@JsonIgnoreProperties(ignoreUnknown = true) // 忽略未知属性,防止反序列化时出现错误 +public class WenjuandiaochaEntity implements Serializable { // 实现Serializable接口以支持序列化 + private static final long serialVersionUID = 1L; // 序列化版本号 + /** + * 无参构造函数 + */ public WenjuandiaochaEntity() { } + /** + * 带泛型参数的构造函数,用于从传入的对象t中复制属性值 + * @param t 传入的对象,其属性将被复制到当前实体对象中 + */ public WenjuandiaochaEntity(T t) { try { - BeanUtils.copyProperties(this, t); + BeanUtils.copyProperties(this, t); // 使用BeanUtils工具类复制属性 } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 打印堆栈跟踪信息以便调试 e.printStackTrace(); } } @@ -49,210 +50,274 @@ public class WenjuandiaochaEntity implements Serializable { /** * 主键id */ - @TableId + @TableId // 指定该字段为主键 private Long id; + /** * 问卷标题 + * 使用NotBlank注解确保问卷标题不为空字符串 */ - + @NotBlank(message = "问卷标题不能为空") private String wenjuanbiaoti; /** * 封面图片 + * 使用NotBlank注解确保封面图片路径不为空字符串 */ - + @NotBlank(message = "封面图片路径不能为空") private String fengmiantupian; /** * 类型 + * 使用NotBlank注解确保类型不为空字符串 */ - + @NotBlank(message = "类型不能为空") private String leixing; /** * 问题一 + * 使用NotBlank注解确保问题一不为空字符串 */ - + @NotBlank(message = "问题一不能为空") private String wentiyi; /** * 问题二 + * 使用NotBlank注解确保问题二不为空字符串 */ - + @NotBlank(message = "问题二不能为空") private String wentier; /** * 问题三 + * 使用NotBlank注解确保问题三不为空字符串 */ - + @NotBlank(message = "问题三不能为空") private String wentisan; /** * 问题四 + * 使用NotBlank注解确保问题四不为空字符串 */ - + @NotBlank(message = "问题四不能为空") private String wentisi; /** * 问题五 + * 使用NotBlank注解确保问题五不为空字符串 */ - + @NotBlank(message = "问题五不能为空") private String wentiwu; /** * 发布日期 + * 使用JsonFormat注解指定日期格式为“yyyy-MM-dd HH:mm:ss”,时区为东八区 + * 使用DateTimeFormat注解指定日期格式为“yyyy-MM-dd HH:mm:ss”,用于处理请求参数中的日期格式 + * 使用NotNull注解确保发布日期不为null */ - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd") - @DateTimeFormat + @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @NotNull(message = "发布日期不能为空") private Date faburiqi; - + /** * 最近点击时间 + * 使用JsonFormat注解指定日期格式为“yyyy-MM-dd HH:mm:ss”,时区为东八区 + * 使用DateTimeFormat注解指定日期格式为“yyyy-MM-dd HH:mm:ss”,用于处理请求参数中的日期格式 */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") private Date clicktime; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat - private Date addtime; - public Date getAddtime() { - return addtime; - } + /** + * 设置:添加时间 + * @param addtime 问卷的添加时间 + */ public void setAddtime(Date addtime) { this.addtime = addtime; } - public Long getId() { - return id; + /** + * 获取:添加时间 + * @return 问卷的添加时间 + */ + public Date getAddtime() { + return addtime; } + /** + * 设置:主键id + * @param id 主键id + */ public void setId(Long id) { this.id = id; } - /** - * 设置:问卷标题 - */ + + /** + * 获取:主键id + * @return 主键id + */ + public Long getId() { + return id; + } + + /** + * 设置:问卷标题 + * @param wenjuanbiaoti 问卷标题 + */ public void setWenjuanbiaoti(String wenjuanbiaoti) { this.wenjuanbiaoti = wenjuanbiaoti; } - /** - * 获取:问卷标题 - */ + + /** + * 获取:问卷标题 + * @return 问卷标题 + */ public String getWenjuanbiaoti() { return wenjuanbiaoti; } - /** - * 设置:封面图片 - */ + + /** + * 设置:封面图片 + * @param fengmiantupian 封面图片路径 + */ public void setFengmiantupian(String fengmiantupian) { this.fengmiantupian = fengmiantupian; } - /** - * 获取:封面图片 - */ + + /** + * 获取:封面图片 + * @return 封面图片路径 + */ public String getFengmiantupian() { return fengmiantupian; } - /** - * 设置:类型 - */ + + /** + * 设置:类型 + * @param leixing 问卷类型 + */ public void setLeixing(String leixing) { this.leixing = leixing; } - /** - * 获取:类型 - */ + + /** + * 获取:类型 + * @return 问卷类型 + */ public String getLeixing() { return leixing; } - /** - * 设置:问题一 - */ + + /** + * 设置:问题一 + * @param wentiyi 问题一的内容 + */ public void setWentiyi(String wentiyi) { this.wentiyi = wentiyi; } - /** - * 获取:问题一 - */ + + /** + * 获取:问题一 + * @return 问题一的内容 + */ public String getWentiyi() { return wentiyi; } - /** - * 设置:问题二 - */ + + /** + * 设置:问题二 + * @param wentier 问题二的内容 + */ public void setWentier(String wentier) { this.wentier = wentier; } - /** - * 获取:问题二 - */ + + /** + * 获取:问题二 + * @return 问题二的内容 + */ public String getWentier() { return wentier; } - /** - * 设置:问题三 - */ + + /** + * 设置:问题三 + * @param wentisan 问题三的内容 + */ public void setWentisan(String wentisan) { this.wentisan = wentisan; } - /** - * 获取:问题三 - */ + + /** + * 获取:问题三 + * @return 问题三的内容 + */ public String getWentisan() { return wentisan; } - /** - * 设置:问题四 - */ + + /** + * 设置:问题四 + * @param wentisi 问题四的内容 + */ public void setWentisi(String wentisi) { this.wentisi = wentisi; } - /** - * 获取:问题四 - */ + + /** + * 获取:问题四 + * @return 问题四的内容 + */ public String getWentisi() { return wentisi; } - /** - * 设置:问题五 - */ + + /** + * 设置:问题五 + * @param wentiwu 问题五的内容 + */ public void setWentiwu(String wentiwu) { this.wentiwu = wentiwu; } - /** - * 获取:问题五 - */ + + /** + * 获取:问题五 + * @return 问题五的内容 + */ public String getWentiwu() { return wentiwu; } - /** - * 设置:发布日期 - */ + + /** + * 设置:发布日期 + * @param faburiqi 问卷的发布日期 + */ public void setFaburiqi(Date faburiqi) { this.faburiqi = faburiqi; } - /** - * 获取:发布日期 - */ + + /** + * 获取:发布日期 + * @return 问卷的发布日期 + */ public Date getFaburiqi() { return faburiqi; } - /** - * 设置:最近点击时间 - */ + + /** + * 设置:最近点击时间 + * @param clicktime 最近点击该问卷的时间 + */ public void setClicktime(Date clicktime) { this.clicktime = clicktime; } - /** - * 获取:最近点击时间 - */ + + /** + * 获取:最近点击时间 + * @return 最近点击该问卷的时间 + */ public Date getClicktime() { return clicktime; } - } diff --git a/src/main/java/com/entity/model/WenjuandiaochaModel.java b/src/main/java/com/entity/model/WenjuandiaochaModel.java index 2370a3f..3473064 100644 --- a/src/main/java/com/entity/model/WenjuandiaochaModel.java +++ b/src/main/java/com/entity/model/WenjuandiaochaModel.java @@ -1,227 +1,195 @@ package com.entity.model; import com.entity.WenjuandiaochaEntity; - import com.baomidou.mybatisplus.annotations.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; - /** - * 问卷调查 - * 接收传参的实体类 - *(实际开发中配合移动端接口开发手动去掉些没用的字段, 后端一般用entity就够用了) - * 取自ModelAndView 的model名称 - * @author - * @email + * 问卷调查模型类 + * 该类用于接收传参,通常在实际开发中配合移动端接口开发时手动去掉一些不需要的字段 + * 取自ModelAndView的model名称 + * @author 未填写具体作者 + * @email 未填写具体邮箱 * @date 2023-02-21 09:46:06 */ -public class WenjuandiaochaModel implements Serializable { +public class WenjuandiaochaModel implements Serializable { private static final long serialVersionUID = 1L; - /** * 封面图片 */ - private String fengmiantupian; - + /** * 类型 */ - private String leixing; - + /** * 问题一 */ - private String wentiyi; - + /** * 问题二 */ - private String wentier; - + /** * 问题三 */ - private String wentisan; - + /** * 问题四 */ - private String wentisi; - + /** * 问题五 */ - private String wentiwu; - + /** * 发布日期 */ - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat private Date faburiqi; - + /** * 最近点击时间 */ - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat private Date clicktime; - - + /** * 设置:封面图片 */ - public void setFengmiantupian(String fengmiantupian) { this.fengmiantupian = fengmiantupian; } - + /** * 获取:封面图片 */ public String getFengmiantupian() { return fengmiantupian; } - - + /** * 设置:类型 */ - public void setLeixing(String leixing) { this.leixing = leixing; } - + /** * 获取:类型 */ public String getLeixing() { return leixing; } - - + /** * 设置:问题一 */ - public void setWentiyi(String wentiyi) { this.wentiyi = wentiyi; } - + /** * 获取:问题一 */ public String getWentiyi() { return wentiyi; } - - + /** * 设置:问题二 */ - public void setWentier(String wentier) { this.wentier = wentier; } - + /** * 获取:问题二 */ public String getWentier() { return wentier; } - - + /** * 设置:问题三 */ - public void setWentisan(String wentisan) { this.wentisan = wentisan; } - + /** * 获取:问题三 */ public String getWentisan() { return wentisan; } - - + /** * 设置:问题四 */ - public void setWentisi(String wentisi) { this.wentisi = wentisi; } - + /** * 获取:问题四 */ public String getWentisi() { return wentisi; } - - + /** * 设置:问题五 */ - public void setWentiwu(String wentiwu) { this.wentiwu = wentiwu; } - + /** * 获取:问题五 */ public String getWentiwu() { return wentiwu; } - - + /** * 设置:发布日期 */ - public void setFaburiqi(Date faburiqi) { this.faburiqi = faburiqi; } - + /** * 获取:发布日期 */ public Date getFaburiqi() { return faburiqi; } - - + /** * 设置:最近点击时间 */ - public void setClicktime(Date clicktime) { this.clicktime = clicktime; } - + /** * 获取:最近点击时间 */ public Date getClicktime() { return clicktime; } - } diff --git a/src/main/java/com/entity/view/WenjuandiaochaView.java b/src/main/java/com/entity/view/WenjuandiaochaView.java index e176a43..e7f6427 100644 --- a/src/main/java/com/entity/view/WenjuandiaochaView.java +++ b/src/main/java/com/entity/view/WenjuandiaochaView.java @@ -1,36 +1,40 @@ package com.entity.view; import com.entity.WenjuandiaochaEntity; - import com.baomidou.mybatisplus.annotations.TableName; import org.apache.commons.beanutils.BeanUtils; import java.lang.reflect.InvocationTargetException; import java.io.Serializable; - /** - * 问卷调查 - * 后端返回视图实体辅助类 - * (通常后端关联的表或者自定义的字段需要返回使用) - * @author - * @email + * 问卷调查视图实体类 + * 该类用于在后端返回视图时使用的辅助实体类。 + * 通常在后端需要关联其他表或自定义字段时,会使用此类来封装返回的数据。 + * @author 未填写具体作者 + * @email 未填写具体邮箱 * @date 2023-02-21 09:46:06 */ @TableName("wenjuandiaocha") -public class WenjuandiaochaView extends WenjuandiaochaEntity implements Serializable { - private static final long serialVersionUID = 1L; +public class WenjuandiaochaView extends WenjuandiaochaEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 无参构造函数 + */ + public WenjuandiaochaView() { + } - public WenjuandiaochaView(){ - } - - public WenjuandiaochaView(WenjuandiaochaEntity wenjuandiaochaEntity){ - try { - BeanUtils.copyProperties(this, wenjuandiaochaEntity); - } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } + /** + * 带参数的构造函数,用于将WenjuandiaochaEntity对象的属性复制到WenjuandiaochaView对象中 + * @param wenjuandiaochaEntity 问卷调查实体对象 + */ + public WenjuandiaochaView(WenjuandiaochaEntity wenjuandiaochaEntity) { + try { + BeanUtils.copyProperties(this, wenjuandiaochaEntity); + } catch (IllegalAccessException | InvocationTargetException e) { + // 打印堆栈跟踪信息以便调试 + e.printStackTrace(); + } + } } diff --git a/src/main/java/com/service/WenjuandiaochaService.java b/src/main/java/com/service/WenjuandiaochaService.java index 8035f61..64f4643 100644 --- a/src/main/java/com/service/WenjuandiaochaService.java +++ b/src/main/java/com/service/WenjuandiaochaService.java @@ -10,36 +10,80 @@ import com.entity.vo.WenjuandiaochaVO; import org.apache.ibatis.annotations.Param; import com.entity.view.WenjuandiaochaView; - /** - * 问卷调查 + * 问卷调查服务接口 * - * @author - * @email + * @author 作者名 + * @email 邮箱地址 * @date 2023-02-21 09:46:06 */ public interface WenjuandiaochaService extends IService { + /** + * 分页查询问卷调查数据 + * @param params 查询参数 + * @return 分页结果 + */ PageUtils queryPage(Map params); - List selectListVO(Wrapper wrapper); + /** + * 查询问卷调查列表(带条件) + * @param wrapper 查询条件包装器 + * @return 问卷调查列表 + */ + List selectListVO(Wrapper wrapper); - WenjuandiaochaVO selectVO(@Param("ew") Wrapper wrapper); + /** + * 查询单个问卷调查(带条件) + * @param wrapper 查询条件包装器 + * @return 单个问卷调查 + */ + WenjuandiaochaVO selectVO(@Param("ew") Wrapper wrapper); - List selectListView(Wrapper wrapper); + /** + * 查询问卷调查视图列表(带条件) + * @param wrapper 查询条件包装器 + * @return 问卷调查视图列表 + */ + List selectListView(Wrapper wrapper); - WenjuandiaochaView selectView(@Param("ew") Wrapper wrapper); + /** + * 查询单个问卷调查视图(带条件) + * @param wrapper 查询条件包装器 + * @return 单个问卷调查视图 + */ + WenjuandiaochaView selectView(@Param("ew") Wrapper wrapper); - PageUtils queryPage(Map params,Wrapper wrapper); + /** + * 分页查询问卷调查数据(带条件) + * @param params 查询参数 + * @param wrapper 查询条件包装器 + * @return 分页结果 + */ + PageUtils queryPage(Map params, Wrapper wrapper); - List> selectValue(Map params,Wrapper wrapper); + /** + * 查询问卷调查的统计值(带条件) + * @param params 查询参数 + * @param wrapper 查询条件包装器 + * @return 统计值列表 + */ + List> selectValue(Map params, Wrapper wrapper); - List> selectTimeStatValue(Map params,Wrapper wrapper); + /** + * 查询问卷调查的时间统计值(带条件) + * @param params 查询参数 + * @param wrapper 查询条件包装器 + * @return 时间统计值列表 + */ + List> selectTimeStatValue(Map params, Wrapper wrapper); - List> selectGroup(Map params,Wrapper wrapper); - - - + /** + * 查询问卷调查的分组统计值(带条件) + * @param params 查询参数 + * @param wrapper 查询条件包装器 + * @return 分组统计值列表 + */ + List> selectGroup(Map params, Wrapper wrapper); } - diff --git a/src/main/java/com/service/impl/WenjuandiaochaServiceImpl.java b/src/main/java/com/service/impl/WenjuandiaochaServiceImpl.java index deb91f4..7063a05 100644 --- a/src/main/java/com/service/impl/WenjuandiaochaServiceImpl.java +++ b/src/main/java/com/service/impl/WenjuandiaochaServiceImpl.java @@ -11,19 +11,27 @@ import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.utils.PageUtils; import com.utils.Query; - import com.dao.WenjuandiaochaDao; import com.entity.WenjuandiaochaEntity; import com.service.WenjuandiaochaService; import com.entity.vo.WenjuandiaochaVO; -import com.entity.view.WenjuandiaochaView; +import com.entity.view.Wenjuandiaocha; +/** + * 问卷调查服务实现类 + * 继承自MyBatis-Plus的ServiceImpl,并实现WenjuandiaochaService接口 + */ @Service("wenjuandiaochaService") public class WenjuandiaochaServiceImpl extends ServiceImpl implements WenjuandiaochaService { - + /** + * 分页查询问卷调查数据 + * @param params 查询参数 + * @return 分页结果 + */ @Override public PageUtils queryPage(Map params) { + // 使用MyBatis-Plus的分页插件进行分页查询 Page page = this.selectPage( new Query(params).getPage(), new EntityWrapper() @@ -31,50 +39,93 @@ public class WenjuandiaochaServiceImpl extends ServiceImpl params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; + // 创建分页对象 + Page page = new Query(params).getPage(); + // 设置分页记录 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; } + /** + * 查询问卷调查列表(带条件) + * @param wrapper 查询条件包装器 + * @return 问卷调查列表 + */ @Override public List selectListVO(Wrapper wrapper) { return baseMapper.selectListVO(wrapper); } + /** + * 查询单个问卷调查(带条件) + * @param wrapper 查询条件包装器 + * @return 单个问卷调查 + */ @Override public WenjuandiaochaVO selectVO(Wrapper wrapper) { return baseMapper.selectVO(wrapper); } + /** + * 查询问卷调查视图列表(带条件) + * @param wrapper 查询条件包装器 + * @return 问卷调查视图列表 + */ @Override public List selectListView(Wrapper wrapper) { return baseMapper.selectListView(wrapper); } + /** + * 查询单个问卷调查视图(带条件) + * @param wrapper 查询条件包装器 + * @return 单个问卷调查视图 + */ @Override public WenjuandiaochaView selectView(Wrapper wrapper) { return baseMapper.selectView(wrapper); } + /** + * 查询问卷调查的统计值(带条件) + * @param params 查询参数 + * @param wrapper 查询条件包装器 + * @return 统计值列表 + */ @Override public List> selectValue(Map params, Wrapper wrapper) { return baseMapper.selectValue(params, wrapper); } + /** + * 查询问卷调查的时间统计值(带条件) + * @param params 查询参数 + * @param wrapper 查询条件包装器 + * @return 时间统计值列表 + */ @Override public List> selectTimeStatValue(Map params, Wrapper wrapper) { return baseMapper.selectTimeStatValue(params, wrapper); } + /** + * 查询问卷调查的分组统计值(带条件) + * @param params 查询参数 + * @param wrapper 查询条件包装器 + * @return 分组统计值列表 + */ @Override public List> selectGroup(Map params, Wrapper wrapper) { return baseMapper.selectGroup(params, wrapper); } - - - - } diff --git a/src/main/resources/mapper/ChatDao.xml b/src/main/resources/mapper/ChatDao.xml index ca1c919..799b879 100644 --- a/src/main/resources/mapper/ChatDao.xml +++ b/src/main/resources/mapper/ChatDao.xml @@ -3,38 +3,109 @@ - + - - - - - + + + + + - + SELECT * FROM chat chat + 1=1 ${ew.sqlSegment} - - - + + + + + + + + - SELECT chat.* FROM chat chat + + + + + + + + - - - + GROUP BY isreply + diff --git a/src/main/resources/mapper/CommonDao.xml b/src/main/resources/mapper/CommonDao.xml index bbbd3e8..2700bbd 100644 --- a/src/main/resources/mapper/CommonDao.xml +++ b/src/main/resources/mapper/CommonDao.xml @@ -2,70 +2,158 @@ - + SELECT DISTINCT ${column} FROM ${table} + WHERE ${column} IS NOT NULL AND ${column} != '' + + + AND ${conditionColumn} = #{conditionValue} + + + + AND level = #{level} + + + + AND parent = #{parent} + + + + + + + + + UPDATE ${table} + SET sfsh = #{sfsh} + WHERE id = #{id} + + + + - - - - - UPDATE ${table} set sfsh=#{sfsh} where id=#{id} - - - - - - - - - + + + + + + + + + + + - + + diff --git a/src/main/resources/mapper/ConfigDao.xml b/src/main/resources/mapper/ConfigDao.xml index 21e8863..db89bf5 100644 --- a/src/main/resources/mapper/ConfigDao.xml +++ b/src/main/resources/mapper/ConfigDao.xml @@ -1,5 +1,8 @@ + + - \ No newline at end of file + + diff --git a/src/main/resources/mapper/ForumDao.xml b/src/main/resources/mapper/ForumDao.xml index fa17907..6c6e700 100644 --- a/src/main/resources/mapper/ForumDao.xml +++ b/src/main/resources/mapper/ForumDao.xml @@ -1,42 +1,71 @@ + + + - + - - - - - - - + + + + + + + - + SELECT * FROM forum forum + 1=1 ${ew.sqlSegment} - - - + + + + + + + + - - - + diff --git a/src/main/resources/mapper/LeixingDao.xml b/src/main/resources/mapper/LeixingDao.xml index 4365bf8..dd88cf5 100644 --- a/src/main/resources/mapper/LeixingDao.xml +++ b/src/main/resources/mapper/LeixingDao.xml @@ -1,36 +1,108 @@ + + + - + - + - + SELECT * FROM leixing leixing + 1=1 ${ew.sqlSegment} - - - + + + + +当然,我会在你的代码中添加详细的注释,以确保每个部分的功能和参数都能被详细理解。以下是添加了注释的代码: + +```xml + + + + + + + - SELECT leixing.* FROM leixing leixing + + + + + + + + + + + + + + + + - - - + diff --git a/src/main/resources/mapper/NewsDao.xml b/src/main/resources/mapper/NewsDao.xml index 88ae12d..0f1794b 100644 --- a/src/main/resources/mapper/NewsDao.xml +++ b/src/main/resources/mapper/NewsDao.xml @@ -1,39 +1,68 @@ + + + - + - - - - + + + + - + SELECT * FROM news news + 1=1 ${ew.sqlSegment} - - - + + + + + + + + - - - + diff --git a/src/main/resources/mapper/StoreupDao.xml b/src/main/resources/mapper/StoreupDao.xml index 3d3965d..37be3e1 100644 --- a/src/main/resources/mapper/StoreupDao.xml +++ b/src/main/resources/mapper/StoreupDao.xml @@ -1,43 +1,72 @@ + + + - + - - - - - - - - + + + + + + + + - + SELECT * FROM storeup storeup + 1=1 ${ew.sqlSegment} - - - + + + + + + + + - - - + diff --git a/src/main/resources/mapper/SystemintroDao.xml b/src/main/resources/mapper/SystemintroDao.xml index 5301805..3a42909 100644 --- a/src/main/resources/mapper/SystemintroDao.xml +++ b/src/main/resources/mapper/SystemintroDao.xml @@ -1,41 +1,70 @@ + + + - + - - - - - - + + + + + + - + SELECT * FROM systemintro systemintro + 1=1 ${ew.sqlSegment} - - - + + + + + + + + - - - + diff --git a/src/main/resources/mapper/TokenDao.xml b/src/main/resources/mapper/TokenDao.xml index 7dc0e2e..5ad296f 100644 --- a/src/main/resources/mapper/TokenDao.xml +++ b/src/main/resources/mapper/TokenDao.xml @@ -1,13 +1,21 @@ + + + + + - \ No newline at end of file + diff --git a/src/main/resources/mapper/UsersDao.xml b/src/main/resources/mapper/UsersDao.xml index 7a6c222..31bd3ce 100644 --- a/src/main/resources/mapper/UsersDao.xml +++ b/src/main/resources/mapper/UsersDao.xml @@ -1,13 +1,21 @@ + + + + + diff --git a/src/main/resources/mapper/WenjuandafuDao.xml b/src/main/resources/mapper/WenjuandafuDao.xml index a346f1a..1fbf730 100644 --- a/src/main/resources/mapper/WenjuandafuDao.xml +++ b/src/main/resources/mapper/WenjuandafuDao.xml @@ -1,84 +1,138 @@ + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + SELECT * FROM wenjuandafu wenjuandafu + 1=1 ${ew.sqlSegment} - - - + + + + + - - - + + + + - + SELECT ${params.xColumn}, sum(${params.yColumn}) AS total FROM wenjuandafu + 1=1 ${ew.sqlSegment} - group by ${params.xColumn} - limit 10 + GROUP BY ${params.xColumn} + LIMIT 10 - + + + SELECT DATE_FORMAT(${params.xColumn}, '%Y-%m-%d') AS ${params.xColumn}, sum(${params.yColumn}) AS total FROM wenjuandafu + + 1=1 ${ew.sqlSegment} + GROUP BY DATE_FORMAT(${params.xColumn}, '%Y-%m-%d') - - SELECT DATE_FORMAT(${params.xColumn},'%Y-%m') ${params.xColumn}, sum(${params.yColumn}) total FROM wenjuandafu - 1=1 ${ew.sqlSegment} - group by DATE_FORMAT(${params.xColumn},'%Y-%m') + + SELECT DATE_FORMAT(${params.xColumn}, '%Y-%m') AS ${params.xColumn}, sum(${params.yColumn}) AS total FROM wenjuandafu + + 1=1 ${ew.sqlSegment} + GROUP BY DATE_FORMAT(${params.xColumn}, '%Y-%m') - - SELECT DATE_FORMAT(${params.xColumn},'%Y') ${params.xColumn}, sum(${params.yColumn}) total FROM wenjuandafu - 1=1 ${ew.sqlSegment} - group by DATE_FORMAT(${params.xColumn},'%Y') + + SELECT DATE_FORMAT(${params.xColumn}, '%Y') AS ${params.xColumn}, sum(${params.yColumn}) AS total FROM wenjuandafu + + 1=1 ${ew.sqlSegment} + GROUP BY DATE_FORMAT(${params.xColumn}, '%Y') - + SELECT ${params.column}, count(1) AS total FROM wenjuandafu + 1=1 ${ew.sqlSegment} - group by ${params.column} - limit 10 + GROUP BY ${params.column} + LIMIT 10 - - diff --git a/src/main/resources/mapper/WenjuandiaochaDao.xml b/src/main/resources/mapper/WenjuandiaochaDao.xml index 8da3de7..dbfa60f 100644 --- a/src/main/resources/mapper/WenjuandiaochaDao.xml +++ b/src/main/resources/mapper/WenjuandiaochaDao.xml @@ -1,79 +1,133 @@ + + + - + - - - - - - - - - - + + + + + + + + + + - + SELECT * FROM wenjuandiaocha wenjuandiaocha + 1=1 ${ew.sqlSegment} - - - + + + + + - - - + + + + - + SELECT ${params.xColumn}, sum(${params.yColumn}) AS total FROM wenjuandiaocha + 1=1 ${ew.sqlSegment} - group by ${params.xColumn} - limit 10 + GROUP BY ${params.xColumn} + LIMIT 10 - + + + SELECT DATE_FORMAT(${params.xColumn}, '%Y-%m-%d') AS ${params.xColumn}, sum(${params.yColumn}) AS total FROM wenjuandiaocha + + 1=1 ${ew.sqlSegment} + GROUP BY DATE_FORMAT(${params.xColumn}, '%Y-%m-%d') - - SELECT DATE_FORMAT(${params.xColumn},'%Y-%m') ${params.xColumn}, sum(${params.yColumn}) total FROM wenjuandiaocha - 1=1 ${ew.sqlSegment} - group by DATE_FORMAT(${params.xColumn},'%Y-%m') + + SELECT DATE_FORMAT(${params.xColumn}, '%Y-%m') AS ${params.xColumn}, sum(${params.yColumn}) AS total FROM wenjuandiaocha + + 1=1 ${ew.sqlSegment} + GROUP BY DATE_FORMAT(${params.xColumn}, '%Y-%m') - - SELECT DATE_FORMAT(${params.xColumn},'%Y') ${params.xColumn}, sum(${params.yColumn}) total FROM wenjuandiaocha - 1=1 ${ew.sqlSegment} - group by DATE_FORMAT(${params.xColumn},'%Y') + + SELECT DATE_FORMAT(${params.xColumn}, '%Y') AS ${params.xColumn}, sum(${params.yColumn}) AS total FROM wenjuandiaocha + + 1=1 ${ew.sqlSegment} + GROUP BY DATE_FORMAT(${params.xColumn}, '%Y') - + SELECT ${params.column}, count(1) AS total FROM wenjuandiaocha + 1=1 ${ew.sqlSegment} - group by ${params.column} - limit 10 + GROUP BY ${params.column} + LIMIT 10 - - diff --git a/src/main/resources/mapper/YonghuDao.xml b/src/main/resources/mapper/YonghuDao.xml index 9e1a806..738405f 100644 --- a/src/main/resources/mapper/YonghuDao.xml +++ b/src/main/resources/mapper/YonghuDao.xml @@ -1,76 +1,130 @@ + + + - + - - - - - - - + + + + + + + - + SELECT * FROM yonghu yonghu + 1=1 ${ew.sqlSegment} - - - + + + + + - - - + + + + - + SELECT ${params.xColumn}, sum(${params.yColumn}) AS total FROM yonghu + 1=1 ${ew.sqlSegment} - group by ${params.xColumn} - limit 10 + GROUP BY ${params.xColumn} + LIMIT 10 - + + + SELECT DATE_FORMAT(${params.xColumn}, '%Y-%m-%d') AS ${params.xColumn}, sum(${params.yColumn}) AS total FROM yonghu + + 1=1 ${ew.sqlSegment} + GROUP BY DATE_FORMAT(${params.xColumn}, '%Y-%m-%d') - - SELECT DATE_FORMAT(${params.xColumn},'%Y-%m') ${params.xColumn}, sum(${params.yColumn}) total FROM yonghu - 1=1 ${ew.sqlSegment} - group by DATE_FORMAT(${params.xColumn},'%Y-%m') + + SELECT DATE_FORMAT(${params.xColumn}, '%Y-%m') AS ${params.xColumn}, sum(${params.yColumn}) AS total FROM yonghu + + 1=1 ${ew.sqlSegment} + GROUP BY DATE_FORMAT(${params.xColumn}, '%Y-%m') - - SELECT DATE_FORMAT(${params.xColumn},'%Y') ${params.xColumn}, sum(${params.yColumn}) total FROM yonghu - 1=1 ${ew.sqlSegment} - group by DATE_FORMAT(${params.xColumn},'%Y') + + SELECT DATE_FORMAT(${params.xColumn}, '%Y') AS ${params.xColumn}, sum(${params.yColumn}) AS total FROM yonghu + + 1=1 ${ew.sqlSegment} + GROUP BY DATE_FORMAT(${params.xColumn}, '%Y') - + SELECT ${params.column}, count(1) AS total FROM yonghu + 1=1 ${ew.sqlSegment} - group by ${params.column} - limit 10 + GROUP BY ${params.column} + LIMIT 10 - -