-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9910f4
commit 0ceed51
Showing
8 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/com/swpu/uchain/blog/controller/IndexController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.swpu.uchain.blog.controller; | ||
|
||
import com.swpu.uchain.blog.accessctro.RoleContro; | ||
import com.swpu.uchain.blog.enums.RoleEnum; | ||
import com.swpu.uchain.blog.service.VisitorService; | ||
import com.swpu.uchain.blog.util.ResultVOUtil; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.CrossOrigin; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* @author hobo | ||
* @description | ||
*/ | ||
@RestController | ||
@CrossOrigin | ||
@Api(tags = "首页显示") | ||
public class IndexController { | ||
|
||
@Autowired | ||
private VisitorService visitorService; | ||
|
||
@ApiOperation("获取首页底部信息") | ||
@PostMapping("/getMsg") | ||
public Object getMsg() { | ||
return visitorService.getIndexMsg(); | ||
} | ||
|
||
@RoleContro(role = RoleEnum.ADMIN) | ||
@ApiOperation("/更新底部网站更新时间") | ||
@PostMapping("/updateTime") | ||
public Object updateTime(String date) { | ||
return ResultVOUtil.success(date); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
package com.swpu.uchain.blog.dao; | ||
|
||
import com.swpu.uchain.blog.entity.Visitor; | ||
import com.swpu.uchain.blog.vo.IndexMsgVO; | ||
|
||
import java.util.List; | ||
|
||
public interface VisitorMapper { | ||
|
||
int updateByPrimaryKey(Visitor record); | ||
|
||
Visitor selectByPage(String page); | ||
|
||
int getArticleTotal(); | ||
|
||
int getTagsTotal(); | ||
|
||
int getCommentTotal(); | ||
|
||
int getLeaveMsgTotal(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.swpu.uchain.blog.vo; | ||
|
||
import lombok.Data; | ||
|
||
/** | ||
* @author hobo | ||
* @description | ||
*/ | ||
@Data | ||
public class IndexMsgVO { | ||
|
||
private int articleTotal; | ||
|
||
private int tagTotal; | ||
|
||
private int leaveMessageTotal; | ||
|
||
private int commentTotal; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
<mapper namespace="com.swpu.uchain.blog.dao.VisitorMapper" > | ||
<resultMap id="BaseResultMap" type="com.swpu.uchain.blog.entity.Visitor" > | ||
<id column="id" property="id" jdbcType="INTEGER" /> | ||
<result column="page" property="page" jdbcType="VARCHAR" /> | ||
<result column="total_num" property="totalNum" jdbcType="BIGINT" /> | ||
</resultMap> | ||
<update id="updateByPrimaryKey" parameterType="com.swpu.uchain.blog.entity.Visitor" > | ||
update visitor | ||
set page = #{page,jdbcType=VARCHAR}, | ||
total_num = #{totalNum,jdbcType=BIGINT} | ||
where id = #{id,jdbcType=INTEGER} | ||
</update> | ||
<select id="selectByPage" resultType="com.swpu.uchain.blog.entity.Visitor"> | ||
select id, page, total_num | ||
from visitor | ||
where page=#{page} | ||
</select> | ||
<select id="getArticleTotal" resultType="java.lang.Integer"> | ||
select COUNT(*) from article | ||
</select> | ||
<select id="getTagsTotal" resultType="java.lang.Integer"> | ||
select COUNT(*) from tags | ||
</select> | ||
<select id="getCommentTotal" resultType="java.lang.Integer"> | ||
select COUNT(*) from comment | ||
</select> | ||
<select id="getLeaveMsgTotal" resultType="java.lang.Integer"> | ||
select COUNT(*) from leave_message | ||
</select> | ||
</mapper> |