add new columns

This commit is contained in:
sunflower2014 2025-09-25 19:51:27 +08:00
parent 0330592c7c
commit 1be38d2d80
10 changed files with 242 additions and 11 deletions

View File

@ -215,6 +215,46 @@ public class AdminUserController {
return ResultObject.failed(500, "服务端错误,请联系系统管理员!"); return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
} }
return adminUserService.create(name, phone); return adminUserService.create(name, phone, adminUserCreateDTO.getUserType());
}
/**
* 管理后台创建用户接口
*
* @param token 登陆Token
* @param adminUserCreateDTO 要创建的用户昵称及手机号
* @return 创建结果
*/
@PostMapping("/h5")
public ResultObject<Void> createH5User(@RequestHeader("auth-token") String token,
@RequestParam(value = "phone", required = true) String phone) {
if (!StringUtils.hasText(token)) {
return ResultObject.failed("登陆Token为空!");
}
if (!StringUtils.hasText(phone)) {
return ResultObject.failed("手机号不可为空!");
}
try {
AdminUser adminUser = AdminJwtService.parseToken(token);
if (adminUser == null) {
log.warn("解析token {}拿不到AdminUser对象!", token);
return ResultObject.failed("登陆Token有误请联系系统管理员!");
}
if (!adminUser.isActive()) {
log.warn("当前用户已被封禁! id = {}", adminUser.getId());
return ResultObject.failed("当前用户已被封禁!请联系系统管理员!");
}
log.info("path: /admin/user/h5, method: POST, request user id: {}, name: {}, phone: {}",
adminUser.getId(), adminUser.getName(), phone);
} catch (Exception e) {
log.error("解析登陆Token出错!", e);
return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
}
return adminUserService.createH5User(phone);
} }
} }

View File

@ -59,15 +59,22 @@ public interface AdminUserMapper {
void delete(@Param("id") long id); void delete(@Param("id") long id);
@Insert("<script>" + @Insert("<script>" +
"insert into admin_user(phone, create_time, update_time" + "insert into admin_user(phone, password, userType, create_time, update_time" +
"<if test=\"name != null and !name.isEmpty()\">" + "<if test=\"name != null and !name.isEmpty()\">" +
", name" + ", name" +
"</if>" + "</if>" +
") values (#{phone}, now(), now()" + ") values (#{phone}, #{password},#{userType}, now(), now()" +
"<if test=\"name != null and !name.isEmpty()\">" + "<if test=\"name != null and !name.isEmpty()\">" +
", #{name}" + ", #{name}" +
"</if>" + "</if>" +
")" + ")" +
"</script>") "</script>")
void create(@Param("name") String name, @Param("phone") String phone); void create(@Param("name") String name, @Param("phone") String phone, @Param("password") String password, @Param("userType") String userType);
@Insert("<script>" +
"insert into allowlist_detail(mobile, create_time, update_time" +
") values (#{phone}, now(), now()" +
")" +
"</script>")
void createH5User(@Param("phone") String phone);
} }

View File

@ -15,6 +15,8 @@ public class AdminUserCreateDTO {
*/ */
private String phone; private String phone;
private String userType;
public String getName() { public String getName() {
return name; return name;
} }
@ -30,4 +32,12 @@ public class AdminUserCreateDTO {
public void setPhone(String phone) { public void setPhone(String phone) {
this.phone = phone; this.phone = phone;
} }
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
} }

View File

@ -9,6 +9,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
@ -245,7 +246,7 @@ public class AdminUserService {
return ResultObject.success(); return ResultObject.success();
} }
public ResultObject<Void> create(String name, String phone) { public ResultObject<Void> create(String name, String phone, String userType) {
try { try {
AdminUser adminUser = adminUserMapper.getAdminUserByPhone(phone); AdminUser adminUser = adminUserMapper.getAdminUserByPhone(phone);
if (adminUser != null) { if (adminUser != null) {
@ -256,9 +257,11 @@ public class AdminUserService {
log.error("根据手机号查询用户出错!", e); log.error("根据手机号查询用户出错!", e);
return ResultObject.failed(500, "服务端错误!请联系系统管理员!"); return ResultObject.failed(500, "服务端错误!请联系系统管理员!");
} }
if (ObjectUtils.isEmpty(userType)) {
userType = "00";
}
try { try {
adminUserMapper.create(name, phone); adminUserMapper.create(name, phone, "111111", userType);
} catch (Exception e) { } catch (Exception e) {
log.error("注册用户报错!", e); log.error("注册用户报错!", e);
return ResultObject.failed(500, "服务端错误!请联系系统管理员!"); return ResultObject.failed(500, "服务端错误!请联系系统管理员!");
@ -293,4 +296,14 @@ public class AdminUserService {
private static String getLoginLockKey(String phone) { private static String getLoginLockKey(String phone) {
return REDIS_LOGIN_LOCK_KEY + phone; return REDIS_LOGIN_LOCK_KEY + phone;
} }
public ResultObject<Void> createH5User(String phone) {
try {
adminUserMapper.createH5User(phone);
} catch (Exception e) {
log.error("注册用户报错!", e);
return ResultObject.failed(500, "服务端错误!请联系系统管理员!");
}
return ResultObject.success();
}
} }

View File

@ -72,8 +72,8 @@ public interface NewsMapper {
void saveDraft(NewsDraft newsDraft); void saveDraft(NewsDraft newsDraft);
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
@Insert("insert into news(draft_id, title, summary, picture, type, content, create_time, update_time, status, publish_time, content_text, newsinfo_id, llm_title, llm_content, rating)" + @Insert("insert into news(draft_id, title, summary, picture, type, content, create_time, update_time, status, publish_time, content_text, newsinfo_id, llm_title, llm_content, rating, overseas_event, overseas_macro, china_macro, industry_news, company_news, reprint_source, company_name)" +
"values (#{draftId}, #{title}, #{summary}, #{picture}, #{type}, #{content}, now(), now(), #{status}, #{publishTime}, #{contentText}, #{newsinfoId}, #{llmTitle}, #{llmContent}, #{rating})") "values (#{draftId}, #{title}, #{summary}, #{picture}, #{type}, #{content}, now(), now(), #{status}, #{publishTime}, #{contentText}, #{newsinfoId}, #{llmTitle}, #{llmContent}, #{rating}, #{overseasEvent}, #{overseasMacro}, #{chinaMacro}, #{industryNews}, #{companyNews}, #{reprintSource}, #{companyName})")
void saveNews(News news); void saveNews(News news);
@Select("<script>" + @Select("<script>" +

View File

@ -6,7 +6,6 @@ import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results; import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import com.jinrui.reference.core.model.entity.News;
import com.jinrui.reference.core.model.entity.NewsTags; import com.jinrui.reference.core.model.entity.NewsTags;
import com.jinrui.reference.core.typehandler.JsonArrayTypeHandler; import com.jinrui.reference.core.typehandler.JsonArrayTypeHandler;
@ -31,6 +30,13 @@ public interface NewsTagsMapper {
@Result(column = "deleted", property = "deleted"), @Result(column = "deleted", property = "deleted"),
@Result(column = "create_time", property = "createTime"), @Result(column = "create_time", property = "createTime"),
@Result(column = "update_time", property = "updateTime"), @Result(column = "update_time", property = "updateTime"),
@Result(column = "overseas_event", property = "overseasEvent"),
@Result(column = "overseas_macro", property = "overseasMacro"),
@Result(column = "china_macro", property = "chinaMacro"),
@Result(column = "industry_news", property = "industryNews"),
@Result(column = "company_news", property = "companyNews"),
@Result(column = "reprint_source", property = "reprintSource"),
@Result(column = "company_name", property = "companyName"),
}) })
@Select("select * from news_tags where newsinfo_id = #{newsId}") @Select("select * from news_tags where newsinfo_id = #{newsId}")
NewsTags getNewsTagsByNewsId(@Param("newsId") String newsId); NewsTags getNewsTagsByNewsId(@Param("newsId") String newsId);

View File

@ -1,5 +1,6 @@
package com.jinrui.reference.core.model.entity; package com.jinrui.reference.core.model.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.jinrui.reference.core.model.dto.news.SaveNewsDTO; import com.jinrui.reference.core.model.dto.news.SaveNewsDTO;
import java.util.Date; import java.util.Date;
@ -88,6 +89,20 @@ public class News {
private String revision; private String revision;
private Boolean overseasEvent;
private Boolean overseasMacro;
private Boolean chinaMacro;
private Boolean industryNews;
private Boolean companyNews;
private String reprintSource;
private String companyName;
public News() {} public News() {}
public News(SaveNewsDTO saveNewsDTO) { public News(SaveNewsDTO saveNewsDTO) {
@ -267,4 +282,60 @@ public class News {
public String getRevision() { public String getRevision() {
return revision; return revision;
} }
public Boolean getOverseasEvent() {
return overseasEvent;
}
public void setOverseasEvent(Boolean overseasEvent) {
this.overseasEvent = overseasEvent;
}
public Boolean getOverseasMacro() {
return overseasMacro;
}
public void setOverseasMacro(Boolean overseasMacro) {
this.overseasMacro = overseasMacro;
}
public Boolean getChinaMacro() {
return chinaMacro;
}
public void setChinaMacro(Boolean chinaMacro) {
this.chinaMacro = chinaMacro;
}
public Boolean getIndustryNews() {
return industryNews;
}
public void setIndustryNews(Boolean industryNews) {
this.industryNews = industryNews;
}
public Boolean getCompanyNews() {
return companyNews;
}
public void setCompanyNews(Boolean companyNews) {
this.companyNews = companyNews;
}
public String getReprintSource() {
return reprintSource;
}
public void setReprintSource(String reprintSource) {
this.reprintSource = reprintSource;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
} }

View File

@ -66,6 +66,27 @@ public class NewsTags {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "Asia/Shanghai") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "Asia/Shanghai")
private Date updateTime; private Date updateTime;
@JsonProperty("overseas_event")
private Boolean overseasEvent;
@JsonProperty("overseas_macro")
private Boolean overseasMacro;
@JsonProperty("china_macro")
private Boolean chinaMacro;
@JsonProperty("industry_news")
private Boolean industryNews;
@JsonProperty("company_news")
private Boolean companyNews;
@JsonProperty("reprint_source")
private String reprintSource;
@JsonProperty("company_name")
private String companyName;
public List<Double> getIndustryScore() { public List<Double> getIndustryScore() {
return industryScore; return industryScore;
} }
@ -217,4 +238,60 @@ public class NewsTags {
public void setUpdateTime(Date updateTime) { public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime; this.updateTime = updateTime;
} }
public Boolean getOverseasEvent() {
return overseasEvent;
}
public void setOverseasEvent(Boolean overseasEvent) {
this.overseasEvent = overseasEvent;
}
public Boolean getOverseasMacro() {
return overseasMacro;
}
public void setOverseasMacro(Boolean overseasMacro) {
this.overseasMacro = overseasMacro;
}
public Boolean getChinaMacro() {
return chinaMacro;
}
public void setChinaMacro(Boolean chinaMacro) {
this.chinaMacro = chinaMacro;
}
public Boolean getIndustryNews() {
return industryNews;
}
public void setIndustryNews(Boolean industryNews) {
this.industryNews = industryNews;
}
public Boolean getCompanyNews() {
return companyNews;
}
public void setCompanyNews(Boolean companyNews) {
this.companyNews = companyNews;
}
public String getReprintSource() {
return reprintSource;
}
public void setReprintSource(String reprintSource) {
this.reprintSource = reprintSource;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
} }

View File

@ -116,6 +116,13 @@ public class NewsInfoService {
relNews.setLlmTitle(llmTitle); relNews.setLlmTitle(llmTitle);
String llmContent = Optional.ofNullable(newsTags.getRewriteContent()).filter(s -> !s.isEmpty()).orElse(relNews.getContent()); String llmContent = Optional.ofNullable(newsTags.getRewriteContent()).filter(s -> !s.isEmpty()).orElse(relNews.getContent());
relNews.setLlmContent(llmContent); relNews.setLlmContent(llmContent);
relNews.setOverseasEvent(newsTags.getOverseasEvent());
relNews.setOverseasMacro(newsTags.getOverseasMacro());
relNews.setChinaMacro(newsTags.getChinaMacro());
relNews.setIndustryNews(newsTags.getIndustryNews());
relNews.setCompanyNews(newsTags.getCompanyNews());
relNews.setReprintSource(newsTags.getReprintSource());
relNews.setCompanyName(newsTags.getCompanyName());
} }
newsMapper.saveNews(relNews); newsMapper.saveNews(relNews);
saveNewsRel(id, relNews.getId()); saveNewsRel(id, relNews.getId());