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

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

草莓徽章管理增加副标题

parent eef61ce4
...@@ -76,3 +76,6 @@ ALTER TABLE `adam_caomei_badge` ADD COLUMN `sort` int(11) NOT NULL DEFAULT 0 COM ...@@ -76,3 +76,6 @@ ALTER TABLE `adam_caomei_badge` ADD COLUMN `sort` int(11) NOT NULL DEFAULT 0 COM
-- 2026-04-16 新增分享文案字段 -- 2026-04-16 新增分享文案字段
ALTER TABLE `adam_caomei_badge` ADD COLUMN `share_text` varchar(255) NOT NULL DEFAULT '' COMMENT '徽章分享文案' AFTER `sort`; 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 { ...@@ -20,6 +20,9 @@ public class AdamCaomeiBadgeParam {
@ApiModelProperty(value = "徽章名称") @ApiModelProperty(value = "徽章名称")
private String name; private String name;
@ApiModelProperty(value = "徽章副标题")
private String subTitle;
@ApiModelProperty(value = "徽章图标 (Emoji字符或图片URL)") @ApiModelProperty(value = "徽章图标 (Emoji字符或图片URL)")
private String icon; private String icon;
......
...@@ -22,6 +22,9 @@ public class AdamCaomeiBadgeVo { ...@@ -22,6 +22,9 @@ public class AdamCaomeiBadgeVo {
@ApiModelProperty(value = "徽章名称") @ApiModelProperty(value = "徽章名称")
private String name; private String name;
@ApiModelProperty(value = "徽章副标题")
private String subTitle;
@ApiModelProperty(value = "徽章图标 (Emoji字符或图片URL)") @ApiModelProperty(value = "徽章图标 (Emoji字符或图片URL)")
private String icon; private String icon;
......
...@@ -18,6 +18,9 @@ public class AdamCaomeiPassportBadgeShelfItemVo { ...@@ -18,6 +18,9 @@ public class AdamCaomeiPassportBadgeShelfItemVo {
@ApiModelProperty("名称") @ApiModelProperty("名称")
private String name; private String name;
@ApiModelProperty("副标题")
private String subTitle;
@ApiModelProperty("图标") @ApiModelProperty("图标")
private String icon; private String icon;
......
...@@ -18,6 +18,9 @@ public class AdamCaomeiPassportUserClaimedBadgeVo { ...@@ -18,6 +18,9 @@ public class AdamCaomeiPassportUserClaimedBadgeVo {
@ApiModelProperty("名称") @ApiModelProperty("名称")
private String name; private String name;
@ApiModelProperty("副标题")
private String subTitle;
@ApiModelProperty("图标") @ApiModelProperty("图标")
private String icon; private String icon;
......
...@@ -33,6 +33,7 @@ public class AdamCaomeiBadgeController extends BaseController { ...@@ -33,6 +33,7 @@ public class AdamCaomeiBadgeController extends BaseController {
private final String prefix = "zhengzai/adam/caomei/badge"; private final String prefix = "zhengzai/adam/caomei/badge";
private static final int BADGE_NAME_MAX_CHARS = 20; private static final int BADGE_NAME_MAX_CHARS = 20;
private static final int BADGE_SUBTITLE_MAX_CHARS = 20;
@Autowired @Autowired
private IAdamCaomeiBadgeAdminService adamCaomeiBadgeAdminService; private IAdamCaomeiBadgeAdminService adamCaomeiBadgeAdminService;
...@@ -74,6 +75,10 @@ public class AdamCaomeiBadgeController extends BaseController { ...@@ -74,6 +75,10 @@ public class AdamCaomeiBadgeController extends BaseController {
if (nameCheck != null) { if (nameCheck != null) {
return nameCheck; return nameCheck;
} }
AjaxResult subTitleCheck = validateBadgeSubTitle(param.getSubTitle());
if (subTitleCheck != null) {
return subTitleCheck;
}
String trimmedName = StringUtils.trimToEmpty(param.getName()); String trimmedName = StringUtils.trimToEmpty(param.getName());
if (adamCaomeiBadgeAdminService.existsOtherBadgeWithSameName(trimmedName, null)) { if (adamCaomeiBadgeAdminService.existsOtherBadgeWithSameName(trimmedName, null)) {
return error("徽章名称已存在,请勿重复"); return error("徽章名称已存在,请勿重复");
...@@ -82,6 +87,7 @@ public class AdamCaomeiBadgeController extends BaseController { ...@@ -82,6 +87,7 @@ public class AdamCaomeiBadgeController extends BaseController {
AdamCaomeiBadge badge = new AdamCaomeiBadge(); AdamCaomeiBadge badge = new AdamCaomeiBadge();
BeanUtils.copyProperties(param, badge); BeanUtils.copyProperties(param, badge);
badge.setName(trimmedName); badge.setName(trimmedName);
badge.setSubTitle(StringUtils.trimToEmpty(param.getSubTitle()));
badge.setShareText(StringUtils.defaultString(badge.getShareText())); badge.setShareText(StringUtils.defaultString(badge.getShareText()));
badge.setBadgeId(IDGenerator.nextSnowId()); badge.setBadgeId(IDGenerator.nextSnowId());
badge.setDisplayStatus(0); // 默认下架 badge.setDisplayStatus(0); // 默认下架
...@@ -163,6 +169,10 @@ public class AdamCaomeiBadgeController extends BaseController { ...@@ -163,6 +169,10 @@ public class AdamCaomeiBadgeController extends BaseController {
if (nameCheck != null) { if (nameCheck != null) {
return nameCheck; return nameCheck;
} }
AjaxResult subTitleCheck = validateBadgeSubTitle(param.getSubTitle());
if (subTitleCheck != null) {
return subTitleCheck;
}
String trimmedName = StringUtils.trimToEmpty(param.getName()); String trimmedName = StringUtils.trimToEmpty(param.getName());
if (adamCaomeiBadgeAdminService.existsOtherBadgeWithSameName(trimmedName, param.getBadgeId())) { if (adamCaomeiBadgeAdminService.existsOtherBadgeWithSameName(trimmedName, param.getBadgeId())) {
return error("徽章名称已存在,请勿重复"); return error("徽章名称已存在,请勿重复");
...@@ -174,6 +184,7 @@ public class AdamCaomeiBadgeController extends BaseController { ...@@ -174,6 +184,7 @@ public class AdamCaomeiBadgeController extends BaseController {
AdamCaomeiBadge badge = new AdamCaomeiBadge(); AdamCaomeiBadge badge = new AdamCaomeiBadge();
BeanUtils.copyProperties(param, badge); BeanUtils.copyProperties(param, badge);
badge.setName(trimmedName); badge.setName(trimmedName);
badge.setSubTitle(StringUtils.trimToEmpty(param.getSubTitle()));
badge.setShareText(StringUtils.defaultString(badge.getShareText())); badge.setShareText(StringUtils.defaultString(badge.getShareText()));
badge.setMid(oldBadge.getMid()); badge.setMid(oldBadge.getMid());
badge.setUpdatedAt(new java.util.Date()); badge.setUpdatedAt(new java.util.Date());
...@@ -226,4 +237,16 @@ public class AdamCaomeiBadgeController extends BaseController { ...@@ -226,4 +237,16 @@ public class AdamCaomeiBadgeController extends BaseController {
} }
return null; 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 @@ ...@@ -13,6 +13,12 @@
<input name="name" class="form-control" type="text" maxlength="20" required placeholder="最多20个字"> <input name="name" class="form-control" type="text" maxlength="20" required placeholder="最多20个字">
</div> </div>
</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"> <div class="form-group">
<label class="col-sm-3 control-label is-required">徽章图标:</label> <label class="col-sm-3 control-label is-required">徽章图标:</label>
<div class="col-sm-8"> <div class="col-sm-8">
......
...@@ -12,6 +12,12 @@ ...@@ -12,6 +12,12 @@
<div class="form-control-static" th:text="*{name}"></div> <div class="form-control-static" th:text="*{name}"></div>
</div> </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"> <div class="form-group">
<label class="col-sm-3 control-label">徽章图标:</label> <label class="col-sm-3 control-label">徽章图标:</label>
<div class="col-sm-8"> <div class="col-sm-8">
......
...@@ -14,6 +14,12 @@ ...@@ -14,6 +14,12 @@
<input name="name" th:field="*{name}" class="form-control" type="text" maxlength="20" required placeholder="最多20个字"> <input name="name" th:field="*{name}" class="form-control" type="text" maxlength="20" required placeholder="最多20个字">
</div> </div>
</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"> <div class="form-group">
<label class="col-sm-3 control-label is-required">徽章图标:</label> <label class="col-sm-3 control-label is-required">徽章图标:</label>
<div class="col-sm-8"> <div class="col-sm-8">
......
...@@ -92,6 +92,13 @@ ...@@ -92,6 +92,13 @@
field: 'name', field: 'name',
title: '名称' title: '名称'
}, },
{
field: 'subTitle',
title: '副标题',
formatter: function(value) {
return value ? value : '-';
}
},
{ {
field: 'type', field: 'type',
title: '类型', title: '类型',
......
...@@ -8,6 +8,7 @@ import java.util.Date; ...@@ -8,6 +8,7 @@ import java.util.Date;
public class AdamCaomeiPassportUserBadgeDto { public class AdamCaomeiPassportUserBadgeDto {
private String badgeId; private String badgeId;
private String badgeName; private String badgeName;
private String subTitle;
private String icon; private String icon;
private String shareText; private String shareText;
private Integer type; private Integer type;
......
...@@ -33,6 +33,11 @@ public class AdamCaomeiBadge implements Serializable { ...@@ -33,6 +33,11 @@ public class AdamCaomeiBadge implements Serializable {
*/ */
private String name; private String name;
/**
* 徽章副标题(最多20字)
*/
private String subTitle;
/** /**
* 徽章图标 (Emoji字符或图片URL) * 徽章图标 (Emoji字符或图片URL)
*/ */
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
SELECT SELECT
ub.badge_id AS badgeId, ub.badge_id AS badgeId,
IFNULL(b.name, '') AS badgeName, IFNULL(b.name, '') AS badgeName,
IFNULL(b.sub_title, '') AS subTitle,
IFNULL(b.icon, '') AS icon, IFNULL(b.icon, '') AS icon,
IFNULL(b.share_text, '') AS shareText, IFNULL(b.share_text, '') AS shareText,
IFNULL(b.type, 0) AS type, IFNULL(b.type, 0) AS type,
......
...@@ -285,6 +285,7 @@ public class AdamCaomeiPassportUserServiceImpl implements IAdamCaomeiPassportUse ...@@ -285,6 +285,7 @@ public class AdamCaomeiPassportUserServiceImpl implements IAdamCaomeiPassportUse
AdamCaomeiPassportUserClaimedBadgeVo v = new AdamCaomeiPassportUserClaimedBadgeVo(); AdamCaomeiPassportUserClaimedBadgeVo v = new AdamCaomeiPassportUserClaimedBadgeVo();
v.setBadgeId(r.getBadgeId()); v.setBadgeId(r.getBadgeId());
v.setName(StringUtils.defaultString(r.getBadgeName())); v.setName(StringUtils.defaultString(r.getBadgeName()));
v.setSubTitle(StringUtils.defaultString(r.getSubTitle()));
v.setIcon(StringUtils.defaultString(r.getIcon())); v.setIcon(StringUtils.defaultString(r.getIcon()));
v.setShareText(StringUtils.defaultString(r.getShareText())); v.setShareText(StringUtils.defaultString(r.getShareText()));
v.setType(r.getType()); v.setType(r.getType());
...@@ -376,6 +377,7 @@ public class AdamCaomeiPassportUserServiceImpl implements IAdamCaomeiPassportUse ...@@ -376,6 +377,7 @@ public class AdamCaomeiPassportUserServiceImpl implements IAdamCaomeiPassportUse
AdamCaomeiPassportBadgeShelfItemVo v = new AdamCaomeiPassportBadgeShelfItemVo(); AdamCaomeiPassportBadgeShelfItemVo v = new AdamCaomeiPassportBadgeShelfItemVo();
v.setBadgeId(b.getBadgeId()); v.setBadgeId(b.getBadgeId());
v.setName(StringUtils.defaultString(b.getName())); v.setName(StringUtils.defaultString(b.getName()));
v.setSubTitle(StringUtils.defaultString(b.getSubTitle()));
v.setIcon(StringUtils.defaultString(b.getIcon())); v.setIcon(StringUtils.defaultString(b.getIcon()));
v.setShareText(StringUtils.defaultString(b.getShareText())); v.setShareText(StringUtils.defaultString(b.getShareText()));
v.setType(b.getType()); 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