苍穹外卖--公共字段自动填充功能实现

This commit is contained in:
2025-11-10 15:48:13 +08:00
parent 5d81997761
commit 3257ae9b43
6 changed files with 112 additions and 14 deletions

View File

@@ -48,10 +48,10 @@ public class CategoryServiceImpl implements CategoryService {
category.setStatus(StatusConstant.DISABLE);
//设置创建时间、修改时间、创建人、修改人
category.setCreateTime(LocalDateTime.now());
category.setUpdateTime(LocalDateTime.now());
category.setCreateUser(BaseContext.getCurrentId());
category.setUpdateUser(BaseContext.getCurrentId());
// category.setCreateTime(LocalDateTime.now());
// category.setUpdateTime(LocalDateTime.now());
// category.setCreateUser(BaseContext.getCurrentId());
// category.setUpdateUser(BaseContext.getCurrentId());
categoryMapper.insert(category);
}
@@ -83,7 +83,7 @@ public class CategoryServiceImpl implements CategoryService {
//查询当前分类是否关联了套餐,如果关联了就抛出业务异常
count = setmealMapper.countByCategoryId(id);
if(count > 0){
//当前分类下有菜品,不能删除
//当前分类下有套餐,不能删除
throw new DeletionNotAllowedException(MessageConstant.CATEGORY_BE_RELATED_BY_SETMEAL);
}
@@ -100,8 +100,8 @@ public class CategoryServiceImpl implements CategoryService {
BeanUtils.copyProperties(categoryDTO,category);
//设置修改时间、修改人
category.setUpdateTime(LocalDateTime.now());
category.setUpdateUser(BaseContext.getCurrentId());
// category.setUpdateTime(LocalDateTime.now());
// category.setUpdateUser(BaseContext.getCurrentId());
categoryMapper.update(category);
}

View File

@@ -80,14 +80,14 @@ public class EmployeeServiceImpl implements EmployeeService {
//2.设置账号的状态默认正常状态1,0表示禁用
employee.setStatus(StatusConstant.ENABLE);
//3.设置创建时间和更新时间
employee.setCreateTime(LocalDateTime.now());
employee.setUpdateTime(LocalDateTime.now());
// employee.setCreateTime(LocalDateTime.now());
// employee.setUpdateTime(LocalDateTime.now());
//4.设置当前记录创建人和修改人的id
//todo 后期要修改为当前登录用户的id
//后期要修改为当前登录用户的id
//取出拦截器中保存的登录员工ID作为创建者和更新者ID数据
Long empId = BaseContext.getCurrentId();
employee.setCreateUser(empId);
employee.setUpdateUser(empId);
// employee.setCreateUser(empId);
// employee.setUpdateUser(empId);
//添加默认密码
employee.setPassword(DigestUtils.md5DigestAsHex(PasswordConstant.DEFAULT_PASSWORD.getBytes()));
@@ -145,8 +145,8 @@ public class EmployeeServiceImpl implements EmployeeService {
//属性拷贝
BeanUtils.copyProperties(employeeDTO,employee);
//补充属性
employee.setUpdateUser(BaseContext.getCurrentId());
employee.setUpdateTime(LocalDateTime.now());
// employee.setUpdateUser(BaseContext.getCurrentId());
// employee.setUpdateTime(LocalDateTime.now());
employeeMapper.update(employee);
}