删除无用代码 开发后台作者和笔记接口
This commit is contained in:
@@ -18,6 +18,7 @@ import com.dd.admin.business.upNotes.service.UpNotesService;
|
||||
import com.dd.admin.business.upReplys.service.UpReplysService;
|
||||
import com.dd.admin.common.aop.operationLog.aop.OperLog;
|
||||
import com.dd.admin.common.aop.operationLog.aop.OperType;
|
||||
import com.dd.admin.common.exception.ApiException;
|
||||
import com.dd.admin.common.model.result.ResultBean;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@@ -51,6 +52,9 @@ public class AuthAuthorApi {
|
||||
public ResultBean<Author> getMine() {
|
||||
String authorId = String.valueOf(request.getAttribute("authorId"));
|
||||
Author author = authorService.getById(authorId);
|
||||
if(author==null){
|
||||
throw new ApiException(700,"当前用户信息不存在~");
|
||||
}
|
||||
if(author.getBirth()!=null){
|
||||
author.setAge(DateUtil.ageOfNow(author.getBirth()));
|
||||
}
|
||||
|
@@ -282,7 +282,6 @@ public class AuthNoteApi {
|
||||
Note note = BeanUtil.copyProperties(noteDto, Note.class);
|
||||
note.setAuthorId(author.getAuthorId());
|
||||
note.setAuthorName(author.getAuthorName());
|
||||
note.setAuthorAvatar(author.getAvatarUrl());
|
||||
note.setIpAddress(IPUtils.getIpAddr(request)); // 请求IP
|
||||
note.setIpRealAddress(AddressUtils.getRealAddress(note.getIpAddress()));
|
||||
noteService.save(note);
|
||||
@@ -321,7 +320,6 @@ public class AuthNoteApi {
|
||||
Note note = BeanUtil.copyProperties(noteDto, Note.class);
|
||||
note.setAuthorId(author.getAuthorId());
|
||||
note.setAuthorName(author.getAuthorName());
|
||||
note.setAuthorAvatar(author.getAvatarUrl());
|
||||
note.setIpAddress(IPUtils.getIpAddr(request)); // 请求IP
|
||||
note.setIpRealAddress(AddressUtils.getRealAddress(note.getIpAddress()));
|
||||
noteService.updateById(note);
|
||||
|
@@ -58,8 +58,13 @@ public class LoginApi {
|
||||
//验证后登陆
|
||||
Author author = authorService.selectAuthorByPhoneNumber(phoneLoginDto.getPhoneNumber());
|
||||
if(author==null){
|
||||
author = authorService.createNewAuthor(phoneLoginDto.getPhoneNumber());
|
||||
author = authorService.createNewAuthor(phoneLoginDto.getPhoneNumber());
|
||||
}else if(author.getDeleted().equals(1)){
|
||||
throw new ApiException("当前用户状态异常~");
|
||||
}
|
||||
// else if(author.getAuthorStatus().equals(1)){
|
||||
// throw new ApiException("当前用户已冻结~");
|
||||
// }
|
||||
//根据用户id生成token
|
||||
final String token = jwtTokenUtil.generateTokenByUserId(author.getAuthorId());
|
||||
author.setToken(token);
|
||||
|
@@ -112,5 +112,6 @@ public class AuthorDto {
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String phoneNumber;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "关键字搜索")
|
||||
private String keyword;
|
||||
}
|
||||
|
@@ -26,5 +26,7 @@ public interface AuthorMapper extends BaseMapper<Author> {
|
||||
|
||||
List<AuthorVo> selectAuthorList(@Param("authorDto") AuthorDto authorDto);
|
||||
|
||||
Author selectAuthorByPhoneNumber(@Param("phoneNumber") String phoneNumber);
|
||||
|
||||
Long selectAuthorUpAndStarTotalCount(@Param("authorId") String authorId);
|
||||
}
|
||||
|
@@ -39,9 +39,26 @@
|
||||
</sql>
|
||||
|
||||
<select id="selectAuthorPage" resultType="com.dd.admin.business.author.domain.AuthorVo">
|
||||
select
|
||||
*
|
||||
from business_author where 1 = 1
|
||||
SELECT
|
||||
(
|
||||
select count(1) from business_follow where follow_id = a.author_id
|
||||
) as follow,
|
||||
(
|
||||
select count(1) from business_follow where author_id = a.author_id
|
||||
) as fans,
|
||||
(
|
||||
select count(1) from business_up_notes where author_id = a.author_id
|
||||
) as upCount,
|
||||
(
|
||||
select count(1) from business_star_notes where author_id = a.author_id
|
||||
) as starCount,a.*
|
||||
FROM
|
||||
business_author a where 1=1
|
||||
<if test="authorDto.keyword != null and authorDto.keyword != ''">
|
||||
and (a.AUTHOR_NAME like CONCAT('%', #{authorDto.keyword}, '%')
|
||||
or a.PHONE_NUMBER like CONCAT('%', #{authorDto.keyword}, '%'))
|
||||
</if>
|
||||
ORDER BY a.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectAuthorList" resultType="com.dd.admin.business.author.domain.AuthorVo">
|
||||
@@ -60,4 +77,8 @@
|
||||
SELECT COUNT(*) AS count_value FROM business_up_replys WHERE AUTHOR_ID = #{authorId}
|
||||
) AS subquery_counts;
|
||||
</select>
|
||||
<select id="selectAuthorByPhoneNumber" resultType="com.dd.admin.business.author.entity.Author"
|
||||
parameterType="java.lang.String">
|
||||
select * from business_author where phone_number = #{phoneNumber}
|
||||
</select>
|
||||
</mapper>
|
||||
|
@@ -47,10 +47,7 @@ public class AuthorServiceImpl extends ServiceImpl<AuthorMapper, Author> impleme
|
||||
|
||||
@Override
|
||||
public Author selectAuthorByPhoneNumber(String phoneNumber) {
|
||||
LambdaQueryWrapper<Author> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Author::getPhoneNumber,phoneNumber);
|
||||
Author author = baseMapper.selectOne(queryWrapper);
|
||||
return author;
|
||||
return baseMapper.selectAuthorByPhoneNumber(phoneNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -11,12 +11,14 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import com.dd.admin.common.model.UpdateGroup;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
|
||||
/**
|
||||
@@ -100,5 +102,8 @@ public class NoteDto {
|
||||
//传入此参数 如果你点赞了会显示相应状态
|
||||
private String followId;
|
||||
|
||||
@ApiModelProperty(value = "关键字搜索")
|
||||
private String keyword;
|
||||
|
||||
private Integer noteStatus;
|
||||
}
|
||||
|
@@ -95,4 +95,5 @@ public class NoteVo {
|
||||
@ApiModelProperty(value = "图片集合")
|
||||
private List<String> imgList;
|
||||
|
||||
private Integer noteStatus;
|
||||
}
|
||||
|
@@ -58,10 +58,6 @@ public class Note implements Serializable {
|
||||
@TableField("AUTHOR_ID")
|
||||
private String authorId;
|
||||
|
||||
@ApiModelProperty(value = "作者头像")
|
||||
@TableField("AUTHOR_AVATAR")
|
||||
private String authorAvatar;
|
||||
|
||||
@ApiModelProperty(value = "作者名字")
|
||||
@TableField("AUTHOR_NAME")
|
||||
private String authorName;
|
||||
@@ -96,13 +92,7 @@ public class Note implements Serializable {
|
||||
@TableField("IP_REAL_ADDRESS")
|
||||
private String ipRealAddress;
|
||||
|
||||
@ApiModelProperty(value = "点赞数")
|
||||
@TableField("UP_COUNT")
|
||||
private Long upCount;
|
||||
|
||||
@ApiModelProperty(value = "收藏数")
|
||||
@TableField("STAR_COUNT")
|
||||
private Long starCount;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "0正常")
|
||||
@TableField("NOTE_STATUS")
|
||||
private Integer noteStatus;
|
||||
}
|
||||
|
@@ -11,7 +11,6 @@
|
||||
<result column="NOTE_CATEGORY_NAME" property="noteCategoryName" />
|
||||
<result column="NOTE_TYPE" property="noteType" />
|
||||
<result column="AUTHOR_ID" property="authorId" />
|
||||
<result column="AUTHOR_AVATAR" property="authorAvatar" />
|
||||
<result column="AUTHOR_NAME" property="authorName" />
|
||||
<result column="FIRST_PICTURE" property="firstPicture" />
|
||||
<result column="VERSION" property="version" />
|
||||
@@ -20,8 +19,6 @@
|
||||
<result column="UPDATE_TIME" property="updateTime" />
|
||||
<result column="IP_ADDRESS" property="ipAddress" />
|
||||
<result column="IP_REAL_ADDRESS" property="ipRealAddress" />
|
||||
<result column="UP_COUNT" property="upCount" />
|
||||
<result column="STAR_COUNT" property="starCount" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
@@ -31,26 +28,25 @@
|
||||
|
||||
<select id="selectNotePage" resultType="com.dd.admin.business.note.domain.NoteVo">
|
||||
SELECT
|
||||
a.*,
|
||||
(SELECT
|
||||
COALESCE (COUNT(e.note_id), 0)
|
||||
(
|
||||
SELECT
|
||||
IFNULL(COUNT(e.note_id), 0)
|
||||
FROM
|
||||
business_star_notes e
|
||||
WHERE
|
||||
e.note_id = a.note_id
|
||||
GROUP BY
|
||||
e.note_id
|
||||
) AS starCount,
|
||||
(
|
||||
SELECT
|
||||
COALESCE (COUNT(d.note_id), 0)
|
||||
IFNULL(COUNT(d.note_id), 0)
|
||||
FROM
|
||||
business_up_notes d
|
||||
WHERE
|
||||
d.note_id = a.note_id
|
||||
GROUP BY
|
||||
d.note_id
|
||||
) AS upCount
|
||||
) AS upCount,
|
||||
d.AVATAR_URL AS authorAvatar,
|
||||
a.*,
|
||||
d.AUTHOR_NAME AS authorName
|
||||
<if test="noteDto.followId!= null and noteDto.followId!= ''">
|
||||
,CASE WHEN EXISTS (
|
||||
SELECT 1
|
||||
@@ -71,8 +67,15 @@
|
||||
business_star_notes b ON a.note_id = b.note_id
|
||||
LEFT JOIN
|
||||
business_up_notes c ON a.note_id = c.note_id
|
||||
LEFT JOIN
|
||||
business_author d ON a.author_id = d.author_id
|
||||
WHERE
|
||||
a.deleted = 0
|
||||
<if test="noteDto.keyword != null and noteDto.keyword != ''">
|
||||
and (a.NOTE_TITLE like CONCAT('%', #{noteDto.keyword}, '%')
|
||||
or a.NOTE_CONTENT like CONCAT('%', #{noteDto.keyword}, '%'))
|
||||
</if>
|
||||
|
||||
<if test="noteDto.authorId!= null and noteDto.authorId!= ''">
|
||||
AND a.AUTHOR_ID = #{noteDto.authorId}
|
||||
</if>
|
||||
|
@@ -54,8 +54,11 @@ public class ApiInterceptor implements HandlerInterceptor {
|
||||
|
||||
request.setAttribute("authorId",authorId);
|
||||
|
||||
// Author author = authorService.getById(authorId);
|
||||
// request.setAttribute("author",author);
|
||||
Author author = authorService.getById(authorId);
|
||||
request.setAttribute("author",author);
|
||||
if(author.getAuthorStatus().equals(1)){
|
||||
throw new ApiException(700,"当前用户已冻结~");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user