智慧厨房
This commit is contained in:
parent
4bc462feb9
commit
f410994c76
|
|
@ -36,7 +36,7 @@ public class KitchenStaffInfoController extends BaseController {
|
|||
@ApiOperation(value = "查询厨房员工资料列表")
|
||||
//@RequiresPermissions("kitchen:info:list")
|
||||
@PostMapping("/list")
|
||||
public TableDataInfo list(@RequestBody @Valid KitchenStaffInfo kitchenStaffInfo) {
|
||||
public TableDataInfo list(@RequestBody KitchenStaffInfo kitchenStaffInfo) {
|
||||
startPage();
|
||||
List<KitchenStaffInfo> list = kitchenStaffInfoService.selectKitchenStaffInfoList(kitchenStaffInfo);
|
||||
return getDataTable(list);
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ import com.bonus.canteen.core.kitchen.domain.KitchenStaffDevicePrivilege;
|
|||
|
||||
/**
|
||||
* 厨房员工设备权限Mapper接口
|
||||
*
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-06-17
|
||||
*/
|
||||
public interface KitchenStaffDevicePrivilegeMapper {
|
||||
/**
|
||||
* 查询厨房员工设备权限
|
||||
*
|
||||
*
|
||||
* @param id 厨房员工设备权限主键
|
||||
* @return 厨房员工设备权限
|
||||
*/
|
||||
|
|
@ -28,7 +28,7 @@ public interface KitchenStaffDevicePrivilegeMapper {
|
|||
|
||||
/**
|
||||
* 查询厨房员工设备权限列表
|
||||
*
|
||||
*
|
||||
* @param kitchenStaffDevicePrivilege 厨房员工设备权限
|
||||
* @return 厨房员工设备权限集合
|
||||
*/
|
||||
|
|
@ -36,7 +36,7 @@ public interface KitchenStaffDevicePrivilegeMapper {
|
|||
|
||||
/**
|
||||
* 新增厨房员工设备权限
|
||||
*
|
||||
*
|
||||
* @param kitchenStaffDevicePrivilege 厨房员工设备权限
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -44,7 +44,7 @@ public interface KitchenStaffDevicePrivilegeMapper {
|
|||
|
||||
/**
|
||||
* 修改厨房员工设备权限
|
||||
*
|
||||
*
|
||||
* @param kitchenStaffDevicePrivilege 厨房员工设备权限
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -52,7 +52,7 @@ public interface KitchenStaffDevicePrivilegeMapper {
|
|||
|
||||
/**
|
||||
* 删除厨房员工设备权限
|
||||
*
|
||||
*
|
||||
* @param id 厨房员工设备权限主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -60,11 +60,13 @@ public interface KitchenStaffDevicePrivilegeMapper {
|
|||
|
||||
/**
|
||||
* 批量删除厨房员工设备权限
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteKitchenStaffDevicePrivilegeByIds(Long[] ids);
|
||||
|
||||
public int deleteKitchenStaffDevicePrivilegeByStaffId(Long staffId);
|
||||
|
||||
public int deleteKitchenStaffDevicePrivilegeByStaffIds(Long[] staffIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,12 +56,11 @@ public class KitchenStaffDevicePrivilegeServiceImpl implements IKitchenStaffDevi
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertKitchenStaffDevicePrivilege(List<KitchenStaffDevicePrivilege> kitchenStaffDevicePrivilege) {
|
||||
if(CollUtil.isNotEmpty(kitchenStaffDevicePrivilege)) {
|
||||
kitchenStaffDevicePrivilegeMapper.deleteKitchenStaffDevicePrivilegeByStaffId(kitchenStaffDevicePrivilege.get(0).getStaffId());
|
||||
for (KitchenStaffDevicePrivilege privilege : kitchenStaffDevicePrivilege) {
|
||||
privilege.setCreateTime(DateUtils.getNowDate());
|
||||
privilege.setCreateBy(SecurityUtils.getUsername());
|
||||
try {
|
||||
return kitchenStaffDevicePrivilegeMapper.insertKitchenStaffDevicePrivilege(privilege);
|
||||
kitchenStaffDevicePrivilegeMapper.insertKitchenStaffDevicePrivilege(privilege);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
package com.bonus.canteen.core.kitchen.service.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.bonus.canteen.core.kitchen.domain.AccessAuthority;
|
||||
|
|
@ -61,6 +58,7 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
|
|||
List<KitchenStaffDevicePrivilege> kitchenStaffDevicePrivilegeList = kitchenStaffDevicePrivilegeMapper
|
||||
.selectKitchenStaffDevicePrivilegeByStaffId(staffId);
|
||||
if(CollUtil.isNotEmpty(kitchenStaffDevicePrivilegeList)) {
|
||||
List<AccessAuthority> accessAuthorityList = Lists.newArrayList();
|
||||
AccessAuthority accessAuthority = new AccessAuthority();
|
||||
for (KitchenStaffDevicePrivilege kitchenStaffDevicePrivilege : kitchenStaffDevicePrivilegeList) {
|
||||
KitchenDeviceListVO deviceInfo = kitchenDeviceInfoMapper.selectKitchenDeviceInfoByDeviceId(kitchenStaffDevicePrivilege.getDeviceId());
|
||||
|
|
@ -71,7 +69,9 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
|
|||
accessAuthority.setDeviceId(kitchenStaffDevicePrivilege.getDeviceId());
|
||||
accessAuthority.setDeviceType(kitchenStaffDevicePrivilege.getDeviceType());
|
||||
accessAuthority.setPrivilegeValue(kitchenStaffDevicePrivilege.getPrivilegeValue());
|
||||
accessAuthorityList.add(accessAuthority);
|
||||
}
|
||||
kitchenStaffInfo.setAccessAuthorityList(accessAuthorityList);
|
||||
}
|
||||
}
|
||||
return kitchenStaffInfo;
|
||||
|
|
@ -108,7 +108,9 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
|
|||
public int insertKitchenStaffInfo(KitchenStaffInfo kitchenStaffInfo) {
|
||||
kitchenStaffInfo.setCreateTime(DateUtils.getNowDate());
|
||||
kitchenStaffInfo.setCreateBy(SecurityUtils.getUsername());
|
||||
kitchenStaffInfo.setStaffId(null);
|
||||
try {
|
||||
checkUser(kitchenStaffInfo);
|
||||
int result = kitchenStaffInfoMapper.insertKitchenStaffInfo(kitchenStaffInfo);
|
||||
addPrivileges(kitchenStaffInfo);
|
||||
return result;
|
||||
|
|
@ -127,7 +129,11 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
|
|||
public int updateKitchenStaffInfo(KitchenStaffInfo kitchenStaffInfo) {
|
||||
kitchenStaffInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
kitchenStaffInfo.setUpdateBy(SecurityUtils.getUsername());
|
||||
if(Objects.isNull(kitchenStaffInfo.getStaffId())) {
|
||||
throw new ServiceException("员工编号不能为空");
|
||||
}
|
||||
try {
|
||||
checkUser(kitchenStaffInfo);
|
||||
kitchenStaffInfoMapper.updateKitchenStaffInfo(kitchenStaffInfo);
|
||||
kitchenStaffDevicePrivilegeMapper.deleteKitchenStaffDevicePrivilegeByStaffId(kitchenStaffInfo.getStaffId());
|
||||
addPrivileges(kitchenStaffInfo);
|
||||
|
|
@ -137,8 +143,24 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
|
|||
return 1;
|
||||
}
|
||||
|
||||
private void checkUser(KitchenStaffInfo kitchenStaffInfo) {
|
||||
KitchenStaffInfo kitchenStaffInfoByPhone = new KitchenStaffInfo();
|
||||
kitchenStaffInfoByPhone.setUserId(kitchenStaffInfo.getUserId());
|
||||
List<KitchenStaffInfo> staffInfoList = kitchenStaffInfoMapper.selectKitchenStaffInfoList(kitchenStaffInfoByPhone);
|
||||
if(CollUtil.isNotEmpty(staffInfoList) && !Objects.equals(staffInfoList.get(0).getStaffId(), kitchenStaffInfo.getStaffId())) {
|
||||
throw new ServiceException("该用户已存在");
|
||||
}
|
||||
kitchenStaffInfoByPhone = new KitchenStaffInfo();
|
||||
kitchenStaffInfoByPhone.setStaffNo(kitchenStaffInfo.getStaffNo());
|
||||
staffInfoList = kitchenStaffInfoMapper.selectKitchenStaffInfoList(kitchenStaffInfoByPhone);
|
||||
if(CollUtil.isNotEmpty(staffInfoList) && !Objects.equals(staffInfoList.get(0).getStaffId(), kitchenStaffInfo.getStaffId())) {
|
||||
throw new ServiceException("该用户编号已存在");
|
||||
}
|
||||
}
|
||||
|
||||
private void addPrivileges(KitchenStaffInfo kitchenStaffInfo) {
|
||||
if(CollUtil.isNotEmpty(kitchenStaffInfo.getAccessAuthorityList())) {
|
||||
List<KitchenStaffDevicePrivilege> kitchenStaffDevicePrivilegeList = new ArrayList<>();
|
||||
for(AccessAuthority access : kitchenStaffInfo.getAccessAuthorityList()) {
|
||||
KitchenStaffDevicePrivilege kitchenStaffDevicePrivilege = new KitchenStaffDevicePrivilege();
|
||||
kitchenStaffDevicePrivilege.setStaffId(kitchenStaffInfo.getStaffId());
|
||||
|
|
@ -146,8 +168,9 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
|
|||
kitchenStaffDevicePrivilege.setDeviceType(access.getDeviceType());
|
||||
kitchenStaffDevicePrivilege.setPrivilegeName("is_enable");
|
||||
kitchenStaffDevicePrivilege.setPrivilegeValue(access.getPrivilegeValue());
|
||||
kitchenStaffDevicePrivilegeService.insertKitchenStaffDevicePrivilege(Collections.singletonList(kitchenStaffDevicePrivilege));
|
||||
kitchenStaffDevicePrivilegeList.add(kitchenStaffDevicePrivilege);
|
||||
}
|
||||
kitchenStaffDevicePrivilegeService.insertKitchenStaffDevicePrivilege(kitchenStaffDevicePrivilegeList);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -159,6 +182,7 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
|
|||
*/
|
||||
@Override
|
||||
public int deleteKitchenStaffInfoByStaffIds(Long[] staffIds) {
|
||||
kitchenStaffDevicePrivilegeMapper.deleteKitchenStaffDevicePrivilegeByStaffIds(staffIds);
|
||||
return kitchenStaffInfoMapper.deleteKitchenStaffInfoByStaffIds(staffIds);
|
||||
}
|
||||
|
||||
|
|
@ -170,6 +194,7 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
|
|||
*/
|
||||
@Override
|
||||
public int deleteKitchenStaffInfoByStaffId(Long staffId) {
|
||||
kitchenStaffDevicePrivilegeMapper.deleteKitchenStaffDevicePrivilegeByStaffId(staffId);
|
||||
return kitchenStaffInfoMapper.deleteKitchenStaffInfoByStaffId(staffId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,4 +96,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<delete id="deleteKitchenStaffDevicePrivilegeByStaffId" parameterType="Long">
|
||||
delete from kitchen_staff_device_privilege where staff_id = #{staffId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteKitchenStaffDevicePrivilegeByStaffIds">
|
||||
delete from kitchen_staff_device_privilege where staff_id in
|
||||
<foreach item="staffId" collection="array" open="(" separator="," close=")">
|
||||
#{staffId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -42,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="nutrityCertExpire != null "> and nutrity_cert_expire = #{nutrityCertExpire}</if>
|
||||
<if test="safetyCertExpire != null "> and safety_cert_expire = #{safetyCertExpire}</if>
|
||||
<if test="sex != null "> and su.sex = #{sex}</if>
|
||||
<if test="postIds != null and postIds.length() > 0">
|
||||
<if test="postIds != null and postIds.length > 0">
|
||||
and sup.post_id in
|
||||
<foreach item="postId" collection="postIds" open="(" separator="," close=")">
|
||||
#{postId}
|
||||
|
|
|
|||
Loading…
Reference in New Issue