This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
package com.xiaowang.jayucloud.salon.core.modules.artist.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 美甲师专属颜色更新请求。
|
||||
*/
|
||||
@Data
|
||||
public class ArtistColorUpdateDTO {
|
||||
/**
|
||||
* 十六进制颜色值,格式 #RRGGBB;空值表示恢复默认色。
|
||||
*/
|
||||
private String color;
|
||||
}
|
||||
+8
@@ -48,6 +48,14 @@ public interface NailArtistInfoService extends IService<NailArtistInfoDO> {
|
||||
/** 保存运营字段,并将美甲师对外展示资料提交审核。 */
|
||||
NailArtistInfoDTO submitNailArtistInfo(NailArtistInfoDTO nailArtistInfoDTO, Long authorUserId);
|
||||
|
||||
/**
|
||||
* 更新美甲师在日程规划中使用的专属颜色。
|
||||
* @param userId 美甲师用户ID
|
||||
* @param color 颜色值,空值表示恢复默认色
|
||||
* @return 更新后的美甲师信息
|
||||
*/
|
||||
NailArtistInfoDTO updateArtistColor(Long userId, String color);
|
||||
|
||||
/**
|
||||
* 获取所有可用的美甲师信息(前台使用)
|
||||
* @return 美甲师信息列表
|
||||
|
||||
+46
@@ -24,6 +24,7 @@ import com.xiaowang.jayucloud.salon.core.modules.order.mapper.OrderMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.product.mapper.ProductMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.user.mapper.UserMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.common.BusinessException;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.artist.service.NailArtistInfoService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.file.service.ObjectStorageFileService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.file.support.ObjectStorageUrlSupport;
|
||||
@@ -256,6 +257,51 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
return saveNailArtistInfo(dto, authorUserId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class)
|
||||
public NailArtistInfoDTO updateArtistColor(Long userId, String color) {
|
||||
if (userId == null || userId <= 0) {
|
||||
throw new BusinessException(400, "美甲师用户ID不能为空");
|
||||
}
|
||||
UserDO user = userMapper.selectById(userId);
|
||||
if (user == null || isDeleted(user.getIsDelete())) {
|
||||
throw new BusinessException(404, "美甲师信息不存在");
|
||||
}
|
||||
if (!Integer.valueOf(3).equals(user.getType())) {
|
||||
throw new BusinessException(400, "仅支持修改美甲师专属颜色");
|
||||
}
|
||||
String normalizedColor = normalizeArtistColor(color);
|
||||
NailArtistInfoDO entity = getOne(new LambdaQueryWrapper<NailArtistInfoDO>()
|
||||
.eq(NailArtistInfoDO::getUserId, userId)
|
||||
.eq(NailArtistInfoDO::getIsDelete, 0)
|
||||
.last("LIMIT 1"));
|
||||
if (entity == null) {
|
||||
entity = new NailArtistInfoDO();
|
||||
entity.setUserId(userId);
|
||||
entity.setIdentity("");
|
||||
entity.setExperience(0);
|
||||
entity.setSkills("");
|
||||
entity.setPortfolio("");
|
||||
entity.setStatus(1);
|
||||
entity.setParticipateProduction(1);
|
||||
entity.setModerationStatus("APPROVED");
|
||||
}
|
||||
entity.setColor(normalizedColor);
|
||||
saveOrUpdate(entity);
|
||||
return convertToDTO(entity);
|
||||
}
|
||||
|
||||
private String normalizeArtistColor(String color) {
|
||||
if (!StringUtils.hasText(color)) {
|
||||
return null;
|
||||
}
|
||||
String value = color.trim().toUpperCase(java.util.Locale.ROOT);
|
||||
if (!value.matches("#[0-9A-F]{6}")) {
|
||||
throw new BusinessException(400, "美甲师专属颜色格式不正确,应为 #RRGGBB");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private NailArtistInfoDTO saveNailArtistInfo(NailArtistInfoDTO dto, Long authorUserId, boolean moderatePublicProfile) {
|
||||
if (dto == null || dto.getUserId() == null) {
|
||||
throw new IllegalArgumentException("美甲师用户信息不能为空");
|
||||
|
||||
+14
@@ -4,6 +4,7 @@ import com.xiaowang.jayucloud.salon.core.annotation.OperationGuard;
|
||||
import com.xiaowang.jayucloud.salon.core.annotation.RequirePermission;
|
||||
import com.xiaowang.jayucloud.salon.core.common.Result;
|
||||
import com.xiaowang.jayucloud.salon.core.common.vo.PageResultVO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.artist.dto.ArtistColorUpdateDTO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.artist.dto.ArtistScheduleDTO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.artist.dto.ArtistScheduleExceptionDTO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.artist.dto.ArtistScheduleRuleDTO;
|
||||
@@ -263,6 +264,19 @@ public class AdminManagerController {
|
||||
return Result.success(nailArtistInfoService.submitNailArtistInfo(dto, currentUser.getId()));
|
||||
}
|
||||
|
||||
@PutMapping("/employees/{userId}/color")
|
||||
@RequirePermission("nail_artist:edit")
|
||||
@OperationGuard(action = "manager-nail-artist-color", ttlSeconds = 10, message = "美甲师颜色保存处理中,请勿重复提交")
|
||||
public Result<NailArtistInfoDTO> updateEmployeeColor(HttpServletRequest request,
|
||||
@PathVariable Long userId,
|
||||
@RequestBody(required = false) ArtistColorUpdateDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
if (!adminScopeHelper.isPlatformAdmin(currentUser)) {
|
||||
adminScopeHelper.ensureUserAccessibleInCurrentShop(currentUser, userId, "无权编辑其他店铺员工");
|
||||
}
|
||||
return Result.success(nailArtistInfoService.updateArtistColor(userId, dto == null ? null : dto.getColor()));
|
||||
}
|
||||
|
||||
@PostMapping("/employees/users")
|
||||
@RequirePermission("user:create")
|
||||
@OperationGuard(action = "manager-user-create", ttlSeconds = 10, message = "员工账号创建处理中,请勿重复提交")
|
||||
|
||||
Reference in New Issue
Block a user