记得上下班打卡 | git大法好,push需谨慎

Commit 71b0d06e authored by 姜秀龙's avatar 姜秀龙

草莓徽章管理增加副标题

parent eef61ce4
......@@ -75,4 +75,7 @@ CREATE TABLE `adam_caomei_badge_apply_record` (
ALTER TABLE `adam_caomei_badge` ADD COLUMN `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序值,数值越大越靠前' AFTER `display_status`;
-- 2026-04-16 新增分享文案字段
ALTER TABLE `adam_caomei_badge` ADD COLUMN `share_text` varchar(255) NOT NULL DEFAULT '' COMMENT '徽章分享文案' AFTER `sort`;
\ No newline at end of file
ALTER TABLE `adam_caomei_badge` ADD COLUMN `share_text` varchar(255) NOT NULL DEFAULT '' COMMENT '徽章分享文案' AFTER `sort`;
-- 2026-04-23 新增徽章副标题字段
ALTER TABLE `adam_caomei_badge` ADD COLUMN `sub_title` varchar(32) NOT NULL DEFAULT '' COMMENT '徽章副标题(最多20字)' AFTER `name`;
\ No newline at end of file
......@@ -20,6 +20,9 @@ public class AdamCaomeiBadgeParam {
@ApiModelProperty(value = "徽章名称")
private String name;
@ApiModelProperty(value = "徽章副标题")
private String subTitle;
@ApiModelProperty(value = "徽章图标 (Emoji字符或图片URL)")
private String icon;
......
......@@ -22,6 +22,9 @@ public class AdamCaomeiBadgeVo {
@ApiModelProperty(value = "徽章名称")
private String name;
@ApiModelProperty(value = "徽章副标题")
private String subTitle;
@ApiModelProperty(value = "徽章图标 (Emoji字符或图片URL)")
private String icon;
......
......@@ -18,6 +18,9 @@ public class AdamCaomeiPassportBadgeShelfItemVo {
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("副标题")
private String subTitle;
@ApiModelProperty("图标")
private String icon;
......
......@@ -18,6 +18,9 @@ public class AdamCaomeiPassportUserClaimedBadgeVo {
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("副标题")
private String subTitle;
@ApiModelProperty("图标")
private String icon;
......
......@@ -33,6 +33,7 @@ public class AdamCaomeiBadgeController extends BaseController {
private final String prefix = "zhengzai/adam/caomei/badge";
private static final int BADGE_NAME_MAX_CHARS = 20;
private static final int BADGE_SUBTITLE_MAX_CHARS = 20;
@Autowired
private IAdamCaomeiBadgeAdminService adamCaomeiBadgeAdminService;
......@@ -74,6 +75,10 @@ public class AdamCaomeiBadgeController extends BaseController {
if (nameCheck != null) {
return nameCheck;
}
AjaxResult subTitleCheck = validateBadgeSubTitle(param.getSubTitle());
if (subTitleCheck != null) {
return subTitleCheck;
}
String trimmedName = StringUtils.trimToEmpty(param.getName());
if (adamCaomeiBadgeAdminService.existsOtherBadgeWithSameName(trimmedName, null)) {
return error("徽章名称已存在,请勿重复");
......@@ -82,6 +87,7 @@ public class AdamCaomeiBadgeController extends BaseController {
AdamCaomeiBadge badge = new AdamCaomeiBadge();
BeanUtils.copyProperties(param, badge);
badge.setName(trimmedName);
badge.setSubTitle(StringUtils.trimToEmpty(param.getSubTitle()));
badge.setShareText(StringUtils.defaultString(badge.getShareText()));
badge.setBadgeId(IDGenerator.nextSnowId());
badge.setDisplayStatus(0); // 默认下架
......@@ -163,6 +169,10 @@ public class AdamCaomeiBadgeController extends BaseController {
if (nameCheck != null) {
return nameCheck;
}
AjaxResult subTitleCheck = validateBadgeSubTitle(param.getSubTitle());
if (subTitleCheck != null) {
return subTitleCheck;
}
String trimmedName = StringUtils.trimToEmpty(param.getName());
if (adamCaomeiBadgeAdminService.existsOtherBadgeWithSameName(trimmedName, param.getBadgeId())) {
return error("徽章名称已存在,请勿重复");
......@@ -174,6 +184,7 @@ public class AdamCaomeiBadgeController extends BaseController {
AdamCaomeiBadge badge = new AdamCaomeiBadge();
BeanUtils.copyProperties(param, badge);
badge.setName(trimmedName);
badge.setSubTitle(StringUtils.trimToEmpty(param.getSubTitle()));
badge.setShareText(StringUtils.defaultString(badge.getShareText()));
badge.setMid(oldBadge.getMid());
badge.setUpdatedAt(new java.util.Date());
......@@ -226,4 +237,16 @@ public class AdamCaomeiBadgeController extends BaseController {
}
return null;
}
private AjaxResult validateBadgeSubTitle(String subTitle) {
String s = StringUtils.trimToEmpty(subTitle);
if (StringUtils.isBlank(s)) {
return null;
}
int len = s.codePointCount(0, s.length());
if (len > BADGE_SUBTITLE_MAX_CHARS) {
return error("徽章副标题不能超过" + BADGE_SUBTITLE_MAX_CHARS + "个字");
}
return null;
}
}
......@@ -13,6 +13,12 @@
<input name="name" class="form-control" type="text" maxlength="20" required placeholder="最多20个字">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">徽章副标题:</label>
<div class="col-sm-8">
<input name="subTitle" class="form-control" type="text" maxlength="20" placeholder="最多20个字">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">徽章图标:</label>
<div class="col-sm-8">
......
......@@ -12,6 +12,12 @@
<div class="form-control-static" th:text="*{name}"></div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">徽章副标题:</label>
<div class="col-sm-8">
<div class="form-control-static" th:text="*{subTitle != null and subTitle != '' ? subTitle : '-'}"></div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">徽章图标:</label>
<div class="col-sm-8">
......
......@@ -14,6 +14,12 @@
<input name="name" th:field="*{name}" class="form-control" type="text" maxlength="20" required placeholder="最多20个字">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">徽章副标题:</label>
<div class="col-sm-8">
<input name="subTitle" th:field="*{subTitle}" class="form-control" type="text" maxlength="20" placeholder="最多20个字">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">徽章图标:</label>
<div class="col-sm-8">
......
......@@ -92,6 +92,13 @@
field: 'name',
title: '名称'
},
{
field: 'subTitle',
title: '副标题',
formatter: function(value) {
return value ? value : '-';
}
},
{
field: 'type',
title: '类型',
......
......@@ -8,6 +8,7 @@ import java.util.Date;
public class AdamCaomeiPassportUserBadgeDto {
private String badgeId;
private String badgeName;
private String subTitle;
private String icon;
private String shareText;
private Integer type;
......
......@@ -33,6 +33,11 @@ public class AdamCaomeiBadge implements Serializable {
*/
private String name;
/**
* 徽章副标题(最多20字)
*/
private String subTitle;
/**
* 徽章图标 (Emoji字符或图片URL)
*/
......
......@@ -63,6 +63,7 @@
SELECT
ub.badge_id AS badgeId,
IFNULL(b.name, '') AS badgeName,
IFNULL(b.sub_title, '') AS subTitle,
IFNULL(b.icon, '') AS icon,
IFNULL(b.share_text, '') AS shareText,
IFNULL(b.type, 0) AS type,
......
......@@ -285,6 +285,7 @@ public class AdamCaomeiPassportUserServiceImpl implements IAdamCaomeiPassportUse
AdamCaomeiPassportUserClaimedBadgeVo v = new AdamCaomeiPassportUserClaimedBadgeVo();
v.setBadgeId(r.getBadgeId());
v.setName(StringUtils.defaultString(r.getBadgeName()));
v.setSubTitle(StringUtils.defaultString(r.getSubTitle()));
v.setIcon(StringUtils.defaultString(r.getIcon()));
v.setShareText(StringUtils.defaultString(r.getShareText()));
v.setType(r.getType());
......@@ -376,6 +377,7 @@ public class AdamCaomeiPassportUserServiceImpl implements IAdamCaomeiPassportUse
AdamCaomeiPassportBadgeShelfItemVo v = new AdamCaomeiPassportBadgeShelfItemVo();
v.setBadgeId(b.getBadgeId());
v.setName(StringUtils.defaultString(b.getName()));
v.setSubTitle(StringUtils.defaultString(b.getSubTitle()));
v.setIcon(StringUtils.defaultString(b.getIcon()));
v.setShareText(StringUtils.defaultString(b.getShareText()));
v.setType(b.getType());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment