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);
|
NailArtistInfoDTO submitNailArtistInfo(NailArtistInfoDTO nailArtistInfoDTO, Long authorUserId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新美甲师在日程规划中使用的专属颜色。
|
||||||
|
* @param userId 美甲师用户ID
|
||||||
|
* @param color 颜色值,空值表示恢复默认色
|
||||||
|
* @return 更新后的美甲师信息
|
||||||
|
*/
|
||||||
|
NailArtistInfoDTO updateArtistColor(Long userId, String color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有可用的美甲师信息(前台使用)
|
* 获取所有可用的美甲师信息(前台使用)
|
||||||
* @return 美甲师信息列表
|
* @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.product.mapper.ProductMapper;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.shop.mapper.ShopMapper;
|
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.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.artist.service.NailArtistInfoService;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.file.service.ObjectStorageFileService;
|
import com.xiaowang.jayucloud.salon.core.modules.file.service.ObjectStorageFileService;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.file.support.ObjectStorageUrlSupport;
|
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);
|
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) {
|
private NailArtistInfoDTO saveNailArtistInfo(NailArtistInfoDTO dto, Long authorUserId, boolean moderatePublicProfile) {
|
||||||
if (dto == null || dto.getUserId() == null) {
|
if (dto == null || dto.getUserId() == null) {
|
||||||
throw new IllegalArgumentException("美甲师用户信息不能为空");
|
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.annotation.RequirePermission;
|
||||||
import com.xiaowang.jayucloud.salon.core.common.Result;
|
import com.xiaowang.jayucloud.salon.core.common.Result;
|
||||||
import com.xiaowang.jayucloud.salon.core.common.vo.PageResultVO;
|
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.ArtistScheduleDTO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.artist.dto.ArtistScheduleExceptionDTO;
|
import com.xiaowang.jayucloud.salon.core.modules.artist.dto.ArtistScheduleExceptionDTO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.artist.dto.ArtistScheduleRuleDTO;
|
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()));
|
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")
|
@PostMapping("/employees/users")
|
||||||
@RequirePermission("user:create")
|
@RequirePermission("user:create")
|
||||||
@OperationGuard(action = "manager-user-create", ttlSeconds = 10, message = "员工账号创建处理中,请勿重复提交")
|
@OperationGuard(action = "manager-user-create", ttlSeconds = 10, message = "员工账号创建处理中,请勿重复提交")
|
||||||
|
|||||||
@@ -22,6 +22,14 @@ module.exports = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateColor(userId, color) {
|
||||||
|
return request({
|
||||||
|
url: `/manager/employees/${userId}/color`,
|
||||||
|
method: 'PUT',
|
||||||
|
data: { color }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
createUser(data) {
|
createUser(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/manager/employees/users/unlinked',
|
url: '/manager/employees/users/unlinked',
|
||||||
|
|||||||
@@ -1,7 +1,22 @@
|
|||||||
|
const employeesApi = require('../../api/employees')
|
||||||
|
const { showErrorToast } = require('../../utils/toast')
|
||||||
|
const { markPlanningRefresh } = require('../../utils/planning-refresh')
|
||||||
|
|
||||||
|
const DEFAULT_COLOR = '#247B63'
|
||||||
|
|
||||||
|
function normalizeColor(value) {
|
||||||
|
const raw = String(value || '').trim()
|
||||||
|
if (!raw) return ''
|
||||||
|
const color = raw[0] === '#' ? raw : `#${raw}`
|
||||||
|
return color.toUpperCase()
|
||||||
|
}
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
selected: '#247B63',
|
id: '',
|
||||||
customColor: '#247B63',
|
saving: false,
|
||||||
|
selected: DEFAULT_COLOR,
|
||||||
|
customColor: DEFAULT_COLOR,
|
||||||
wheelColors: [
|
wheelColors: [
|
||||||
'#E0627A', '#E7785B', '#E2A64B', '#D8C85C', '#9EBB63', '#63B77B',
|
'#E0627A', '#E7785B', '#E2A64B', '#D8C85C', '#9EBB63', '#63B77B',
|
||||||
'#4CB7A6', '#56A7D6', '#5F82D7', '#7C70D4', '#A66BC8', '#CF72A8'
|
'#4CB7A6', '#56A7D6', '#5F82D7', '#7C70D4', '#A66BC8', '#CF72A8'
|
||||||
@@ -15,6 +30,21 @@ Page({
|
|||||||
'#6D8491', '#829A9A', '#A9B3A2', '#C6B7D1', '#E0C2B6', '#F0D6A8'
|
'#6D8491', '#829A9A', '#A9B3A2', '#C6B7D1', '#E0C2B6', '#F0D6A8'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
onLoad(options) {
|
||||||
|
this.setData({ id: options && options.id ? options.id : '' })
|
||||||
|
if (this.data.id) {
|
||||||
|
this.loadColor()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async loadColor() {
|
||||||
|
try {
|
||||||
|
const detail = await employeesApi.detail(this.data.id)
|
||||||
|
const color = normalizeColor(detail && detail.color) || DEFAULT_COLOR
|
||||||
|
this.setData({ selected: color, customColor: color })
|
||||||
|
} catch (error) {
|
||||||
|
showErrorToast(error, '美甲师颜色加载失败')
|
||||||
|
}
|
||||||
|
},
|
||||||
select(event) {
|
select(event) {
|
||||||
const color = event.currentTarget.dataset.color
|
const color = event.currentTarget.dataset.color
|
||||||
this.setData({ selected: color, customColor: color })
|
this.setData({ selected: color, customColor: color })
|
||||||
@@ -27,14 +57,39 @@ Page({
|
|||||||
this.setData({ customColor: event.detail.value })
|
this.setData({ customColor: event.detail.value })
|
||||||
},
|
},
|
||||||
applyCustomColor() {
|
applyCustomColor() {
|
||||||
let color = (this.data.customColor || '').trim()
|
const color = normalizeColor(this.data.customColor)
|
||||||
if (color && color[0] !== '#') color = `#${color}`
|
if (!/^#[0-9A-F]{6}$/.test(color)) {
|
||||||
if (!/^#[0-9a-fA-F]{6}$/.test(color)) {
|
|
||||||
wx.showToast({ title: '请输入6位色值', icon: 'none' })
|
wx.showToast({ title: '请输入6位色值', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.setData({ selected: color.toUpperCase(), customColor: color.toUpperCase() })
|
this.setData({ selected: color, customColor: color })
|
||||||
},
|
},
|
||||||
save() { wx.showToast({ title: '已保存到本地' }) },
|
async save() {
|
||||||
back() { wx.navigateBack() }
|
if (this.data.saving) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!this.data.id) {
|
||||||
|
wx.showToast({ title: '缺少美甲师信息', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const color = normalizeColor(this.data.selected)
|
||||||
|
if (!/^#[0-9A-F]{6}$/.test(color)) {
|
||||||
|
wx.showToast({ title: '请选择颜色', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.setData({ saving: true })
|
||||||
|
try {
|
||||||
|
const saved = await employeesApi.updateColor(this.data.id, color)
|
||||||
|
const savedColor = normalizeColor(saved && saved.color) || color
|
||||||
|
this.setData({ selected: savedColor, customColor: savedColor, saving: false })
|
||||||
|
markPlanningRefresh()
|
||||||
|
wx.showToast({ title: '颜色已保存', icon: 'success' })
|
||||||
|
} catch (error) {
|
||||||
|
this.setData({ saving: false })
|
||||||
|
showErrorToast(error, '颜色保存失败')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
back() {
|
||||||
|
wx.navigateBack()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
const assert = require('assert')
|
||||||
|
const employeesApi = require('../../api/employees')
|
||||||
|
|
||||||
|
const storage = {}
|
||||||
|
const app = { globalData: {} }
|
||||||
|
const toasts = []
|
||||||
|
global.wx = {
|
||||||
|
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||||
|
getDeviceInfo: () => ({ platform: 'devtools' }),
|
||||||
|
showToast: options => toasts.push(options),
|
||||||
|
navigateBack: () => {},
|
||||||
|
setStorageSync: (key, value) => { storage[key] = value },
|
||||||
|
getStorageSync: key => storage[key]
|
||||||
|
}
|
||||||
|
global.getApp = () => app
|
||||||
|
global.getCurrentPages = () => []
|
||||||
|
|
||||||
|
let definition
|
||||||
|
global.Page = value => { definition = value }
|
||||||
|
require('./index')
|
||||||
|
|
||||||
|
const page = {
|
||||||
|
...definition,
|
||||||
|
data: JSON.parse(JSON.stringify(definition.data)),
|
||||||
|
setData(values) {
|
||||||
|
Object.entries(values).forEach(([key, value]) => {
|
||||||
|
const parts = key.split('.')
|
||||||
|
let target = this.data
|
||||||
|
for (let index = 0; index < parts.length - 1; index += 1) target = target[parts[index]]
|
||||||
|
target[parts[parts.length - 1]] = value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
page.setData({ id: '88' })
|
||||||
|
employeesApi.detail = async () => ({ color: '#8fb89a' })
|
||||||
|
await page.loadColor()
|
||||||
|
assert.strictEqual(page.data.selected, '#8FB89A')
|
||||||
|
assert.strictEqual(page.data.customColor, '#8FB89A')
|
||||||
|
|
||||||
|
page.setData({ selected: '#aabbcc', customColor: '#aabbcc' })
|
||||||
|
let saved
|
||||||
|
employeesApi.updateColor = async (id, color) => {
|
||||||
|
saved = { id, color }
|
||||||
|
return { color: '#AABBCC' }
|
||||||
|
}
|
||||||
|
await page.save()
|
||||||
|
assert.deepStrictEqual(saved, { id: '88', color: '#AABBCC' })
|
||||||
|
assert.strictEqual(page.data.selected, '#AABBCC')
|
||||||
|
assert.strictEqual(page.data.saving, false)
|
||||||
|
assert.strictEqual(app.globalData.planningNeedRefresh, true)
|
||||||
|
assert.strictEqual(storage.planningNeedRefresh, '1')
|
||||||
|
assert.strictEqual(toasts[toasts.length - 1].title, '颜色已保存')
|
||||||
|
|
||||||
|
app.globalData.planningNeedRefresh = false
|
||||||
|
storage.planningNeedRefresh = ''
|
||||||
|
employeesApi.updateColor = async () => {
|
||||||
|
throw new Error('颜色保存失败,请稍后重试')
|
||||||
|
}
|
||||||
|
await page.save()
|
||||||
|
assert.strictEqual(page.data.saving, false)
|
||||||
|
assert.strictEqual(app.globalData.planningNeedRefresh, false)
|
||||||
|
assert.strictEqual(toasts[toasts.length - 1].title, '颜色保存失败,请稍后重试')
|
||||||
|
}
|
||||||
|
|
||||||
|
run().catch(error => {
|
||||||
|
console.error(error)
|
||||||
|
process.exitCode = 1
|
||||||
|
})
|
||||||
@@ -18,7 +18,12 @@ Page({
|
|||||||
|
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
this.setData({ id: options.id || '' })
|
this.setData({ id: options.id || '' })
|
||||||
this.loadDetail()
|
},
|
||||||
|
|
||||||
|
onShow() {
|
||||||
|
if (this.data.id) {
|
||||||
|
this.loadDetail()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadDetail() {
|
async loadDetail() {
|
||||||
|
|||||||
Reference in New Issue
Block a user