作者 dong

按钮管理界面code字段修改

... ... @@ -86,6 +86,11 @@ public class AiragButtonController extends JeecgController<AiragButton, IAiragBu
@RequiresPermissions("airagbutton:airag_button:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody AiragButton airagButton) {
// 唯一性校验
if (!airagButtonService.isCodeUnique(airagButton.getCode(), null)) {
return Result.error("按钮编码已存在,请重新输入!");
}
// 检查按钮开关是否为开启状态
if ("Y".equals(airagButton.getButtonSwitch())) {
// 查询当前已开启的按钮数量
... ... @@ -113,6 +118,11 @@ public class AiragButtonController extends JeecgController<AiragButton, IAiragBu
@RequiresPermissions("airagbutton:airag_button:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody AiragButton airagButton) {
// 唯一性校验
if (!airagButtonService.isCodeUnique(airagButton.getCode(), null)) {
return Result.error("按钮编码已存在,请重新输入!");
}
// 检查按钮开关是否为开启状态
if ("Y".equals(airagButton.getButtonSwitch())) {
// 查询当前已开启的按钮数量(排除自身)
... ...
... ... @@ -49,21 +49,37 @@
<select id="getMonthlyCount" resultType="java.util.Map">
SELECT
DATE_FORMAT(create_time, '%Y-%m') AS month,
COUNT(*) AS count
FROM airag_log
WHERE create_time >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH)
GROUP BY DATE_FORMAT(create_time, '%Y-%m')
ORDER BY month ASC
DATE_FORMAT(date_range.month, '%Y-%m') AS month,
IFNULL(log_counts.count, 0) AS count
FROM (
SELECT DATE_SUB(DATE_FORMAT(CURDATE(), '%Y-%m-01'), INTERVAL n MONTH) AS month
FROM (
SELECT 0 AS n UNION SELECT 1 UNION SELECT 2 UNION SELECT 3
UNION SELECT 4 UNION SELECT 5 UNION SELECT 6
UNION SELECT 7 UNION SELECT 8 UNION SELECT 9
UNION SELECT 10 UNION SELECT 11
) months
) date_range
LEFT JOIN (
SELECT
DATE_FORMAT(create_time, '%Y-%m-01') AS month,
COUNT(*) AS count
FROM airag_log
WHERE create_time >= DATE_SUB(DATE_FORMAT(CURDATE(), '%Y-%m-01'), INTERVAL 12 MONTH)
GROUP BY DATE_FORMAT(create_time, '%Y-%m-01')
) log_counts ON date_range.month = log_counts.month
WHERE date_range.month >= DATE_SUB(DATE_FORMAT(CURDATE(), '%Y-%m-01'), INTERVAL 12 MONTH)
ORDER BY date_range.month ASC
</select>
<select id="getButtonRankList" resultType="java.util.Map">
SELECT
question, COUNT(*) as count
FROM airag_log
WHERE code IS NOT NULL AND code != ''
GROUP BY question
ORDER BY count DESC
b.button_name AS name,
COUNT(l.id) AS total
FROM airag_button b
LEFT JOIN airag_log l ON b.code = l.code
GROUP BY b.id, b.button_name
ORDER BY total DESC
LIMIT 7
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -14,4 +14,6 @@ import java.util.List;
*/
public interface IAiragButtonService extends IService<AiragButton> {
boolean isCodeUnique(String code, String excludeId);
}
... ...
package org.jeecg.modules.airag.app.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.airag.app.entity.AiragButton;
import org.jeecg.modules.airag.app.entity.Embeddings;
import org.jeecg.modules.airag.app.mapper.AiragButtonMapper;
... ... @@ -8,6 +9,7 @@ import org.jeecg.modules.airag.app.mapper.PgVectorMapper;
import org.jeecg.modules.airag.app.service.IAiragButtonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.List;
... ... @@ -20,5 +22,18 @@ import java.util.List;
@Service
public class AiragButtonServiceImpl extends ServiceImpl<AiragButtonMapper, AiragButton> implements IAiragButtonService {
@Autowired
private AiragButtonMapper airagButtonMapper;
@Override
public boolean isCodeUnique(String code, String excludeId) {
QueryWrapper<AiragButton> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("code", code);
// 编辑时排除当前记录
if (StringUtils.isNotBlank(excludeId)) {
queryWrapper.ne("id", excludeId);
}
return airagButtonMapper.selectCount(queryWrapper) == 0;
}
}
... ...