|
|
|
@ -0,0 +1,340 @@
|
|
|
|
|
package com.controller; // 声明包路径,表示该文件位于com.controller包下
|
|
|
|
|
|
|
|
|
|
import java.io.File; // 导入文件操作类,用于处理文件上传
|
|
|
|
|
import java.math.BigDecimal; // 导入高精度数学计算类,用于处理金额计算
|
|
|
|
|
import java.net.URL; // 导入网络URL处理类,用于获取资源路径
|
|
|
|
|
import java.text.SimpleDateFormat; // 导入日期格式化类,用于日期格式转换
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; // 导入FastJSON的JSON对象类,用于JSON处理
|
|
|
|
|
import java.util.*; // 导入Java常用工具类(集合、日期等)
|
|
|
|
|
import org.springframework.beans.BeanUtils; // 导入Spring Bean属性复制工具类
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; // 导入HTTP请求处理类
|
|
|
|
|
import org.springframework.web.context.ContextLoader; // 导入Spring上下文加载器
|
|
|
|
|
import javax.servlet.ServletContext; // 导入Servlet上下文接口
|
|
|
|
|
import com.service.TokenService; // 导入自定义的Token服务类
|
|
|
|
|
import com.utils.*; // 导入自定义工具类
|
|
|
|
|
import java.lang.reflect.InvocationTargetException; // 导入反射异常类
|
|
|
|
|
|
|
|
|
|
import com.service.DictionaryService; // 导入自定义的字典服务类
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; // 导入Apache字符串工具类
|
|
|
|
|
import com.annotation.IgnoreAuth; // 导入自定义的忽略认证注解
|
|
|
|
|
import org.slf4j.Logger; // 导入日志接口
|
|
|
|
|
import org.slf4j.LoggerFactory; // 导入日志工厂类
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring自动注入注解
|
|
|
|
|
import org.springframework.stereotype.Controller; // 导入Spring控制器注解
|
|
|
|
|
import org.springframework.web.bind.annotation.*; // 导入Spring Web注解
|
|
|
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper; // 导入MyBatis Plus查询条件构造器
|
|
|
|
|
import com.baomidou.mybatisplus.mapper.Wrapper; // 导入MyBatis Plus包装器接口
|
|
|
|
|
import com.entity.*; // 导入实体类
|
|
|
|
|
import com.entity.view.*; // 导入视图实体类
|
|
|
|
|
import com.service.*; // 导入服务类
|
|
|
|
|
import com.utils.PageUtils; // 导入分页工具类
|
|
|
|
|
import com.utils.R; // 导入统一返回结果类
|
|
|
|
|
import com.alibaba.fastjson.*; // 导入FastJSON相关类
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//教练预约申请
|
|
|
|
|
//后端接口
|
|
|
|
|
//@author
|
|
|
|
|
// @email
|
|
|
|
|
|
|
|
|
|
@RestController // 标识为RESTful控制器,用于处理HTTP请求
|
|
|
|
|
@Controller // 标识为Spring控制器
|
|
|
|
|
@RequestMapping("/jiaolianYuyue") // 定义请求映射路径
|
|
|
|
|
public class JiaolianYuyueController {
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(JiaolianYuyueController.class); // 日志记录器,用于记录日志信息
|
|
|
|
|
|
|
|
|
|
private static final String TABLE_NAME = "jiaolianYuyue"; // 数据库表名常量
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private JiaolianYuyueService jiaolianYuyueService; // 自动注入教练预约服务
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private TokenService tokenService; // 自动注入Token服务
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private DictionaryService dictionaryService; // 自动注入字典服务
|
|
|
|
|
@Autowired
|
|
|
|
|
private ForumService forumService; // 自动注入健身论坛服务
|
|
|
|
|
@Autowired
|
|
|
|
|
private JianshenkechengService jianshenkechengService; // 自动注入健身课程服务
|
|
|
|
|
@Autowired
|
|
|
|
|
private JianshenkechengCollectionService jianshenkechengCollectionService; // 自动注入课程收藏服务
|
|
|
|
|
@Autowired
|
|
|
|
|
private JianshenkechengLiuyanService jianshenkechengLiuyanService; // 自动注入课程留言服务
|
|
|
|
|
@Autowired
|
|
|
|
|
private JiaolianService jiaolianService; // 自动注入教练服务
|
|
|
|
|
@Autowired
|
|
|
|
|
private NewsService newsService; // 自动注入健身资讯服务
|
|
|
|
|
@Autowired
|
|
|
|
|
private SingleSeachService singleSeachService; // 自动注入单页数据服务
|
|
|
|
|
@Autowired
|
|
|
|
|
private YonghuService yonghuService; // 自动注入用户服务
|
|
|
|
|
@Autowired
|
|
|
|
|
private UsersService usersService; // 自动注入管理员服务
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//后端列表
|
|
|
|
|
//处理分页查询请求
|
|
|
|
|
@RequestMapping("/page") // 映射分页查询请求
|
|
|
|
|
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
|
|
|
|
|
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); // 记录请求日志
|
|
|
|
|
String role = String.valueOf(request.getSession().getAttribute("role")); // 从session中获取用户角色
|
|
|
|
|
if(false) // 永远不会执行的代码块
|
|
|
|
|
return R.error(511,"永不会进入"); // 返回错误信息
|
|
|
|
|
else if("用户".equals(role)) // 如果是用户角色
|
|
|
|
|
params.put("yonghuId",request.getSession().getAttribute("userId")); // 将用户ID添加到查询参数
|
|
|
|
|
else if("教练".equals(role)) // 如果是教练角色
|
|
|
|
|
params.put("jiaolianId",request.getSession().getAttribute("userId")); // 将教练ID添加到查询参数
|
|
|
|
|
CommonUtil.checkMap(params); // 检查参数有效性
|
|
|
|
|
PageUtils page = jiaolianYuyueService.queryPage(params); // 调用服务层查询分页数据
|
|
|
|
|
|
|
|
|
|
// 字典表数据转换
|
|
|
|
|
List<JiaolianYuyueView> list =(List<JiaolianYuyueView>)page.getList(); // 获取分页数据列表
|
|
|
|
|
for(JiaolianYuyueView c:list){ // 遍历列表
|
|
|
|
|
dictionaryService.dictionaryConvert(c, request); // 转换字典字段
|
|
|
|
|
}
|
|
|
|
|
return R.ok().put("data", page); // 返回分页数据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//后端详情
|
|
|
|
|
//根据ID查询单条预约详情
|
|
|
|
|
@RequestMapping("/info/{id}") // 映射详情查询请求
|
|
|
|
|
public R info(@PathVariable("id") Long id, HttpServletRequest request){
|
|
|
|
|
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录请求日志
|
|
|
|
|
JiaolianYuyueEntity jiaolianYuyue = jiaolianYuyueService.selectById(id); // 根据ID查询预约
|
|
|
|
|
if(jiaolianYuyue !=null){ // 如果查询到数据
|
|
|
|
|
JiaolianYuyueView view = new JiaolianYuyueView(); // 创建视图对象
|
|
|
|
|
BeanUtils.copyProperties(jiaolianYuyue, view); // 复制属性到视图对象
|
|
|
|
|
|
|
|
|
|
// 查询关联的用户信息
|
|
|
|
|
YonghuEntity yonghu = yonghuService.selectById(jiaolianYuyue.getYonghuId());
|
|
|
|
|
if(yonghu != null){
|
|
|
|
|
BeanUtils.copyProperties(yonghu, view, new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});
|
|
|
|
|
view.setYonghuId(yonghu.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dictionaryService.dictionaryConvert(view, request); // 转换字典字段
|
|
|
|
|
return R.ok().put("data", view); // 返回详情数据
|
|
|
|
|
}else {
|
|
|
|
|
return R.error(511,"查不到数据"); // 返回错误信息
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//后端保存
|
|
|
|
|
//处理新增预约请求
|
|
|
|
|
@RequestMapping("/save") // 映射保存请求
|
|
|
|
|
public R save(@RequestBody JiaolianYuyueEntity jiaolianYuyue, HttpServletRequest request){
|
|
|
|
|
logger.debug("save方法:,,Controller:{},,jiaolianYuyue:{}",this.getClass().getName(),jiaolianYuyue.toString()); // 记录请求日志
|
|
|
|
|
|
|
|
|
|
String role = String.valueOf(request.getSession().getAttribute("role")); // 获取用户角色
|
|
|
|
|
if(false) // 永远不会执行的代码块
|
|
|
|
|
return R.error(511,"永远不会进入"); // 返回错误信息
|
|
|
|
|
else if("用户".equals(role)) // 如果是用户角色
|
|
|
|
|
jiaolianYuyue.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")))); // 设置用户ID
|
|
|
|
|
|
|
|
|
|
// 构建查询条件,检查是否存在相同用户的待审核或已通过的预约
|
|
|
|
|
Wrapper<JiaolianYuyueEntity> queryWrapper = new EntityWrapper<JiaolianYuyueEntity>()
|
|
|
|
|
.eq("yonghu_id", jiaolianYuyue.getYonghuId())
|
|
|
|
|
.in("jiaolian_yuyue_yesno_types", new Integer[]{1,2});
|
|
|
|
|
|
|
|
|
|
logger.info("sql语句:"+queryWrapper.getSqlSegment()); // 记录SQL语句
|
|
|
|
|
JiaolianYuyueEntity jiaolianYuyueEntity = jiaolianYuyueService.selectOne(queryWrapper); // 查询是否存在重复数据
|
|
|
|
|
if(jiaolianYuyueEntity==null){ // 如果没有重复数据
|
|
|
|
|
jiaolianYuyue.setJiaolianYuyueYesnoTypes(1); // 设置状态为待审核
|
|
|
|
|
jiaolianYuyue.setInsertTime(new Date()); // 设置插入时间
|
|
|
|
|
jiaolianYuyue.setCreateTime(new Date()); // 设置创建时间
|
|
|
|
|
jiaolianYuyueService.insert(jiaolianYuyue); // 调用服务层保存数据
|
|
|
|
|
return R.ok(); // 返回成功信息
|
|
|
|
|
}else { // 如果存在重复数据
|
|
|
|
|
if(jiaolianYuyueEntity.getJiaolianYuyueYesnoTypes()==1) // 如果是待审核状态
|
|
|
|
|
return R.error(511,"有相同的待审核的数据"); // 返回错误信息
|
|
|
|
|
else if(jiaolianYuyueEntity.getJiaolianYuyueYesnoTypes()==2) // 如果是已通过状态
|
|
|
|
|
return R.error(511,"有相同的审核通过的数据"); // 返回错误信息
|
|
|
|
|
else
|
|
|
|
|
return R.error(511,"表中有相同数据"); // 返回错误信息
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//后端修改
|
|
|
|
|
//处理更新预约请求
|
|
|
|
|
@RequestMapping("/update") // 映射更新请求
|
|
|
|
|
public R update(@RequestBody JiaolianYuyueEntity jiaolianYuyue, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
|
|
|
|
|
logger.debug("update方法:,,Controller:{},,jiaolianYuyue:{}",this.getClass().getName(),jiaolianYuyue.toString()); // 记录请求日志
|
|
|
|
|
JiaolianYuyueEntity oldJiaolianYuyueEntity = jiaolianYuyueService.selectById(jiaolianYuyue.getId()); // 查询原有数据
|
|
|
|
|
|
|
|
|
|
// 处理空值情况
|
|
|
|
|
if("".equals(jiaolianYuyue.getJiaolianYuyueText()) || "null".equals(jiaolianYuyue.getJiaolianYuyueText())){
|
|
|
|
|
jiaolianYuyue.setJiaolianYuyueText(null);
|
|
|
|
|
}
|
|
|
|
|
if("".equals(jiaolianYuyue.getJiaolianYuyueYesnoText()) || "null".equals(jiaolianYuyue.getJiaolianYuyueYesnoText())){
|
|
|
|
|
jiaolianYuyue.setJiaolianYuyueYesnoText(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jiaolianYuyueService.updateById(jiaolianYuyue); // 调用服务层更新数据
|
|
|
|
|
return R.ok(); // 返回成功信息
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//审核
|
|
|
|
|
//处理预约审核请求
|
|
|
|
|
@RequestMapping("/shenhe") // 映射审核请求
|
|
|
|
|
public R shenhe(@RequestBody JiaolianYuyueEntity jiaolianYuyueEntity, HttpServletRequest request){
|
|
|
|
|
logger.debug("shenhe方法:,,Controller:{},,jiaolianYuyueEntity:{}",this.getClass().getName(),jiaolianYuyueEntity.toString()); // 记录请求日志
|
|
|
|
|
|
|
|
|
|
JiaolianYuyueEntity oldJiaolianYuyue = jiaolianYuyueService.selectById(jiaolianYuyueEntity.getId()); // 查询原有数据
|
|
|
|
|
|
|
|
|
|
jiaolianYuyueService.updateById(jiaolianYuyueEntity); // 调用服务层更新审核状态
|
|
|
|
|
return R.ok(); // 返回成功信息
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//删除
|
|
|
|
|
//处理删除预约请求
|
|
|
|
|
@RequestMapping("/delete") // 映射删除请求
|
|
|
|
|
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
|
|
|
|
|
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); // 记录请求日志
|
|
|
|
|
List<JiaolianYuyueEntity> oldJiaolianYuyueList = jiaolianYuyueService.selectBatchIds(Arrays.asList(ids)); // 查询要删除的数据
|
|
|
|
|
jiaolianYuyueService.deleteBatchIds(Arrays.asList(ids)); // 调用服务层批量删除
|
|
|
|
|
return R.ok(); // 返回成功信息
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//批量上传
|
|
|
|
|
//处理批量导入数据请求
|
|
|
|
|
@RequestMapping("/batchInsert") // 映射批量导入请求
|
|
|
|
|
public R save(String fileName, HttpServletRequest request){
|
|
|
|
|
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); // 记录请求日志
|
|
|
|
|
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))); // 获取用户ID
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 创建日期格式化对象
|
|
|
|
|
try {
|
|
|
|
|
List<JiaolianYuyueEntity> jiaolianYuyueList = new ArrayList<>(); // 创建数据列表
|
|
|
|
|
Map<String, List<String>> seachFields = new HashMap<>(); // 创建查询字段映射
|
|
|
|
|
Date date = new Date(); // 当前时间
|
|
|
|
|
int lastIndexOf = fileName.lastIndexOf("."); // 获取文件后缀位置
|
|
|
|
|
if(lastIndexOf == -1){ // 如果没有后缀
|
|
|
|
|
return R.error(511,"该文件没有后缀"); // 返回错误信息
|
|
|
|
|
}else{
|
|
|
|
|
String suffix = fileName.substring(lastIndexOf); // 获取文件后缀
|
|
|
|
|
if(!".xls".equals(suffix)){ // 如果不是xls文件
|
|
|
|
|
return R.error(511,"只支持后缀为xls的excel文件"); // 返回错误信息
|
|
|
|
|
}else{
|
|
|
|
|
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName); // 获取文件路径
|
|
|
|
|
File file = new File(resource.getFile()); // 创建文件对象
|
|
|
|
|
if(!file.exists()){ // 如果文件不存在
|
|
|
|
|
return R.error(511,"找不到上传文件,请联系管理员"); // 返回错误信息
|
|
|
|
|
}else{
|
|
|
|
|
List<List<String>> dataList = PoiUtil.poiImport(file.getPath()); // 读取Excel文件
|
|
|
|
|
dataList.remove(0); // 删除标题行
|
|
|
|
|
for(List<String> data:dataList){ // 遍历数据行
|
|
|
|
|
JiaolianYuyueEntity jiaolianYuyueEntity = new JiaolianYuyueEntity(); // 创建实体对象
|
|
|
|
|
jiaolianYuyueList.add(jiaolianYuyueEntity); // 添加到列表
|
|
|
|
|
|
|
|
|
|
// 检查预约编号是否重复
|
|
|
|
|
if(seachFields.containsKey("jiaolianYuyueUuidNumber")){
|
|
|
|
|
List<String> jiaolianYuyueUuidNumber = seachFields.get("jiaolianYuyueUuidNumber");
|
|
|
|
|
jiaolianYuyueUuidNumber.add(data.get(0));
|
|
|
|
|
}else{
|
|
|
|
|
List<String> jiaolianYuyueUuidNumber = new ArrayList<>();
|
|
|
|
|
jiaolianYuyueUuidNumber.add(data.get(0));
|
|
|
|
|
seachFields.put("jiaolianYuyueUuidNumber",jiaolianYuyueUuidNumber);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查预约编号是否已存在
|
|
|
|
|
List<JiaolianYuyueEntity> jiaolianYuyueEntities_jiaolianYuyueUuidNumber = jiaolianYuyueService.selectList(new EntityWrapper<JiaolianYuyueEntity>().in("jiaolian_yuyue_uuid_number", seachFields.get("jiaolianYuyueUuidNumber")));
|
|
|
|
|
if(jiaolianYuyueEntities_jiaolianYuyueUuidNumber.size() >0 ){
|
|
|
|
|
ArrayList<String> repeatFields = new ArrayList<>();
|
|
|
|
|
for(JiaolianYuyueEntity s:jiaolianYuyueEntities_jiaolianYuyueUuidNumber){
|
|
|
|
|
repeatFields.add(s.getJiaolianYuyueUuidNumber());
|
|
|
|
|
}
|
|
|
|
|
return R.error(511,"数据库的该表中的 [预约编号] 字段已经存在 存在数据为:"+repeatFields.toString());
|
|
|
|
|
}
|
|
|
|
|
jiaolianYuyueService.insertBatch(jiaolianYuyueList); // 批量插入数据
|
|
|
|
|
return R.ok(); // 返回成功信息
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
e.printStackTrace(); // 打印异常堆栈
|
|
|
|
|
return R.error(511,"批量插入数据异常,请联系管理员"); // 返回错误信息
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//前端列表
|
|
|
|
|
//处理前端分页查询请求
|
|
|
|
|
@IgnoreAuth // 忽略认证
|
|
|
|
|
@RequestMapping("/list") // 映射列表查询请求
|
|
|
|
|
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
|
|
|
|
|
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); // 记录请求日志
|
|
|
|
|
CommonUtil.checkMap(params); // 检查参数有效性
|
|
|
|
|
PageUtils page = jiaolianYuyueService.queryPage(params); // 调用服务层查询分页数据
|
|
|
|
|
|
|
|
|
|
// 字典表数据转换
|
|
|
|
|
List<JiaolianYuyueView> list =(List<JiaolianYuyueView>)page.getList(); // 获取分页数据列表
|
|
|
|
|
for(JiaolianYuyueView c:list){ // 遍历列表
|
|
|
|
|
dictionaryService.dictionaryConvert(c, request); // 转换字典字段
|
|
|
|
|
}
|
|
|
|
|
return R.ok().put("data", page); // 返回分页数据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//前端详情
|
|
|
|
|
//处理前端详情查询请求
|
|
|
|
|
@RequestMapping("/detail/{id}") // 映射详情查询请求
|
|
|
|
|
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
|
|
|
|
|
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录请求日志
|
|
|
|
|
JiaolianYuyueEntity jiaolianYuyue = jiaolianYuyueService.selectById(id); // 根据ID查询预约
|
|
|
|
|
if(jiaolianYuyue !=null){ // 如果查询到数据
|
|
|
|
|
JiaolianYuyueView view = new JiaolianYuyueView(); // 创建视图对象
|
|
|
|
|
BeanUtils.copyProperties(jiaolianYuyue, view); // 复制属性到视图对象
|
|
|
|
|
|
|
|
|
|
// 查询关联的用户信息
|
|
|
|
|
YonghuEntity yonghu = yonghuService.selectById(jiaolianYuyue.getYonghuId());
|
|
|
|
|
if(yonghu != null){
|
|
|
|
|
BeanUtils.copyProperties(yonghu, view, new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});
|
|
|
|
|
view.setYonghuId(yonghu.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dictionaryService.dictionaryConvert(view, request); // 转换字典字段
|
|
|
|
|
return R.ok().put("data", view); // 返回详情数据
|
|
|
|
|
}else {
|
|
|
|
|
return R.error(511,"查不到数据"); // 返回错误信息
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//前端保存
|
|
|
|
|
//处理前端新增预约请求
|
|
|
|
|
@RequestMapping("/add") // 映射新增请求
|
|
|
|
|
public R add(@RequestBody JiaolianYuyueEntity jiaolianYuyue, HttpServletRequest request){
|
|
|
|
|
logger.debug("add方法:,,Controller:{},,jiaolianYuyue:{}",this.getClass().getName(),jiaolianYuyue.toString()); // 记录请求日志
|
|
|
|
|
// 构建查询条件,检查是否存在相同用户的待审核或已通过的预约
|
|
|
|
|
Wrapper<JiaolianYuyueEntity> queryWrapper = new EntityWrapper<JiaolianYuyueEntity>()
|
|
|
|
|
.eq("jiaolian_yuyue_uuid_number", jiaolianYuyue.getJiaolianYuyueUuidNumber())
|
|
|
|
|
.eq("yonghu_id", jiaolianYuyue.getYonghuId())
|
|
|
|
|
.eq("jiaolian_yuyue_text", jiaolianYuyue.getJiaolianYuyueText())
|
|
|
|
|
.in("jiaolian_yuyue_yesno_types", new Integer[]{1,2})
|
|
|
|
|
.eq("jiaolian_yuyue_yesno_text", jiaolianYuyue.getJiaolianYuyueYesnoText());
|
|
|
|
|
|
|
|
|
|
logger.info("sql语句:"+queryWrapper.getSqlSegment()); // 记录SQL语句
|
|
|
|
|
JiaolianYuyueEntity jiaolianYuyueEntity = jiaolianYuyueService.selectOne(queryWrapper); // 查询是否存在重复数据
|
|
|
|
|
if(jiaolianYuyueEntity==null){ // 如果没有重复数据
|
|
|
|
|
jiaolianYuyue.setJiaolianYuyueYesnoTypes(1); // 设置状态为待审核
|
|
|
|
|
jiaolianYuyue.setInsertTime(new Date()); // 设置插入时间
|
|
|
|
|
jiaolianYuyue.setCreateTime(new Date()); // 设置创建时间
|
|
|
|
|
jiaolianYuyueService.insert(jiaolianYuyue); // 调用服务层保存数据
|
|
|
|
|
return R.ok(); // 返回成功信息
|
|
|
|
|
}else { // 如果存在重复数据
|
|
|
|
|
if(jiaolianYuyueEntity.getJiaolianYuyueYesnoTypes()==1) // 如果是待审核状态
|
|
|
|
|
return R.error(511,"有相同的待审核的数据"); // 返回错误信息
|
|
|
|
|
else if(jiaolianYuyueEntity.getJiaolianYuyueYesnoTypes()==2) // 如果是已通过状态
|
|
|
|
|
return R.error(511,"有相同的审核通过的数据"); // 返回错误信息
|
|
|
|
|
else
|
|
|
|
|
return R.error(511,"表中有相同数据"); // 返回错误信息
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|