说明:1、前端apilog文件名修改

2、前端实现每日一句页面,添加图片及音频标签
pull/254/head
xjs 4 years ago
parent 9872f67cf6
commit 3fc23fd59e

@ -0,0 +1,27 @@
import request from '@/utils/request'
// 查询每日一句列表
export function listAword(query) {
return request({
url: '/openapi/aword/list',
method: 'get',
params: query
})
}
// 查询每日一句详细
export function getAword(id) {
return request({
url: '/openapi/aword/' + id,
method: 'get'
})
}
// 删除每日一句
export function delAword(id) {
return request({
url: '/openapi/aword/' + id,
method: 'delete'
})
}

@ -59,7 +59,7 @@
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-tooltip class="item" effect="dark" content="点击查看详情" placement="top-start">
<el-tooltip class="item" effect="dark" content="点击查看json格式" placement="top-start">
<el-button circle
type=""
icon="el-icon-view"
@ -119,7 +119,7 @@
</template>
<script>
import {listLog, getLog, delLog} from "@/api/business/openapi/log";
import {listLog, getLog, delLog} from "@/api/business/openapi/apilog";
export default {
name: "Log",

@ -0,0 +1,236 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="句子内容" prop="content">
<el-input
v-model="queryParams.content"
placeholder="请输入句子内容"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="来源" prop="source">
<el-input
v-model="queryParams.source"
placeholder="请输入来源"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="释义" prop="note">
<el-input
v-model="queryParams.note"
placeholder="请输入释义"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['openapi:aword:remove']"
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['openapi:aword:export']"
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="awordList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="数据ID" align="center" prop="dataId" width="100px"/>
<el-table-column label="句子内容" align="center" prop="content"/>
<el-table-column label="来源" align="center" prop="source" width="150px"/>
<el-table-column label="释义" align="center" prop="note"/>
<el-table-column label="音频地址" align="center" prop="tts"width="350px">
<template slot-scope="scope">
<audio :src="scope.row.tts" controls="controls">
您的浏览器不支持 audio 标签
</audio>
</template>
</el-table-column>
<el-table-column label="图片地址" align="center" prop="imgurl">
<template slot-scope="scope">
<el-image
style="width: 108px; height: 141px"
:src="scope.row.imgurl"
:preview-src-list="[scope.row.imgurl]">
</el-image>
</template>
</el-table-column>
<el-table-column label="句子产生时间" align="center" prop="date" width="150px">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.date, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100px">
<template slot-scope="scope">
<el-button
circle
type="danger"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['openapi:aword:remove']"
>
</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改每日一句对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {listAword, getAword, delAword} from "@/api/business/openapi/aword";
export default {
name: "Aword",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
awordList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
content: null,
source: null,
note: null,
},
//
form: {},
//
rules: {}
};
},
created() {
this.getList();
},
methods: {
/** 查询每日一句列表 */
getList() {
this.loading = true;
listAword(this.queryParams).then(response => {
this.awordList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
dataId: null,
content: null,
source: null,
note: null,
tts: null,
imgurl: null,
date: null,
createTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除每日一句编号为"' + ids + '"的数据项?').then(function () {
return delAword(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
});
},
/** 导出按钮操作 */
handleExport() {
this.download('openapi/aword/export', {
...this.queryParams
}, `aword_${new Date().getTime()}.xlsx`)
}
}
}
</script>

@ -1,27 +1,32 @@
package com.xjs.aword.controller;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresLogin;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.xjs.aword.domain.ApiAWord;
import com.xjs.aword.domain.RequestBody;
import com.xjs.aword.factory.AWordFactory;
import com.xjs.aword.service.ApiAWordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Optional;
/**
* api
*
* @author xiejs
* @since 2022-01-08
*
*/
@RequestMapping("aword")
@RestController
@ -29,6 +34,8 @@ import java.util.Optional;
public class ApiAWordController extends BaseController {
@Autowired
private AWordFactory tianXingAWordFactory;
@Autowired
private ApiAWordService apiAWordService;
@GetMapping
@ApiOperation("每日一句接口")
@ -39,4 +46,49 @@ public class ApiAWordController extends BaseController {
ApiAWord apiAWord = tianXingAWordFactory.productApiAWord(requestBody);
return AjaxResult.success(apiAWord);
}
//--------------------------代码生成---------------------------------
/**
*
*/
@RequiresPermissions("openapi:aword:list")
@GetMapping("/list")
public TableDataInfo list(ApiAWord apiAWord) {
startPage();
List<ApiAWord> list = apiAWordService.selectApiAWordList(apiAWord);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("openapi:aword:export")
@Log(title = "每日一句", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ApiAWord apiAWord) {
List<ApiAWord> list = apiAWordService.selectApiAWordList(apiAWord);
ExcelUtil<ApiAWord> util = new ExcelUtil<ApiAWord>(ApiAWord.class);
util.exportExcel(response, list, "每日一句数据");
}
/**
*
*/
@RequiresPermissions("openapi:aword:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(apiAWordService.selectApiAWordById(id));
}
/**
*
*/
@RequiresPermissions("openapi:aword:remove")
@Log(title = "每日一句", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(apiAWordService.deleteApiAWordByIds(ids));
}
}

@ -15,7 +15,7 @@ public class RequestBody {
private String key;
/**
*
* 01
*/
private Integer rand;

@ -1,8 +1,10 @@
package com.xjs.aword.factory.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.http.HttpStatus;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xjs.aword.domain.ApiAWord;
import com.xjs.aword.domain.RequestBody;
import com.xjs.aword.factory.AWordFactory;
@ -14,9 +16,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
*
*
* @author xiejs
* @since 2022-01-08
*/
@ -47,10 +51,16 @@ public class TianXingAWordFactory implements AWordFactory {
.setImgurl(newslistJSONObject.getString("imgurl"))
.setNote(newslistJSONObject.getString("note"))
.setTts(newslistJSONObject.getString("tts"));
apiAWordMapper.insert(apiAWord);
List<ApiAWord> apiAWordList = apiAWordMapper.selectList(new QueryWrapper<ApiAWord>()
.eq("data_id", apiAWord.getDataId()));
if (CollUtil.isEmpty(apiAWordList)) {
apiAWordMapper.insert(apiAWord);
}
return apiAWord;
}else {
return new ApiAWord();
} else {
return apiAWordMapper.selectOne(new QueryWrapper<ApiAWord>()
.orderByDesc("date")
.last("limit 1"));
}
}
}

@ -3,11 +3,48 @@ package com.xjs.aword.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xjs.aword.domain.ApiAWord;
import java.util.List;
/**
* mapper
*
* @author xiejs
* @since 2022-01-08
*/
public interface ApiAWordMapper extends BaseMapper<ApiAWord> {
//---------------------代码生成-------------------------------
/**
*
*
* @param id
* @return
*/
public ApiAWord selectApiAWordById(Long id);
/**
*
*
* @param apiAWord
* @return
*/
public List<ApiAWord> selectApiAWordList(ApiAWord apiAWord);
/**
*
*
* @param id
* @return
*/
public int deleteApiAWordById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteApiAWordByIds(Long[] ids);
}

@ -0,0 +1,49 @@
package com.xjs.aword.service;
import com.xjs.aword.domain.ApiAWord;
import java.util.List;
/**
* service
* @author xiejs
* @since 2022-01-08
*/
public interface ApiAWordService {
//------------------代码生成--------------------------------
/**
*
*
* @param id
* @return
*/
public ApiAWord selectApiAWordById(Long id);
/**
*
*
* @param apiAWord
* @return
*/
public List<ApiAWord> selectApiAWordList(ApiAWord apiAWord);
/**
*
*
* @param ids
* @return
*/
public int deleteApiAWordByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteApiAWordById(Long id);
}

@ -0,0 +1,72 @@
package com.xjs.aword.service.impl;
import com.xjs.aword.domain.ApiAWord;
import com.xjs.aword.mapper.ApiAWordMapper;
import com.xjs.aword.service.ApiAWordService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* service
* @author xiejs
* @since 2022-01-08
*/
@Service
public class ApiAWordServiceImpl implements ApiAWordService {
@Resource
private ApiAWordMapper apiAWordMapper;
//---------------------------代码生成-----------------------------
/**
*
*
* @param id
* @return
*/
@Override
public ApiAWord selectApiAWordById(Long id)
{
return apiAWordMapper.selectApiAWordById(id);
}
/**
*
*
* @param apiAWord
* @return
*/
@Override
public List<ApiAWord> selectApiAWordList(ApiAWord apiAWord)
{
return apiAWordMapper.selectApiAWordList(apiAWord);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteApiAWordByIds(Long[] ids)
{
return apiAWordMapper.deleteApiAWordByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteApiAWordById(Long id)
{
return apiAWordMapper.deleteApiAWordById(id);
}
}

@ -0,0 +1,51 @@
<?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.xjs.aword.mapper.ApiAWordMapper">
<resultMap type="com.xjs.aword.domain.ApiAWord" id="ApiAWordResult">
<result property="id" column="id"/>
<result property="dataId" column="data_id"/>
<result property="content" column="content"/>
<result property="source" column="source"/>
<result property="note" column="note"/>
<result property="tts" column="tts"/>
<result property="imgurl" column="imgurl"/>
<result property="date" column="date"/>
<result property="createTime" column="create_time"/>
</resultMap>
<sql id="selectApiAWordVo">
select id, data_id, content, source, note, tts, imgurl, date, create_time
from api_a_word
</sql>
<select id="selectApiAWordList" parameterType="com.xjs.aword.domain.ApiAWord" resultMap="ApiAWordResult">
<include refid="selectApiAWordVo"/>
<where>
<if test="content != null and content != ''">and content like "%"#{content}"%"</if>
<if test="source != null and source != ''">and source like "%"#{source}"%"</if>
<if test="note != null and note != ''">and note like "%"#{note}"%"</if>
</where>
order by date desc
</select>
<select id="selectApiAWordById" parameterType="Long" resultMap="ApiAWordResult">
<include refid="selectApiAWordVo"/>
where id = #{id}
</select>
<delete id="deleteApiAWordById" parameterType="Long">
delete
from api_a_word
where id = #{id}
</delete>
<delete id="deleteApiAWordByIds" parameterType="String">
delete from api_a_word where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save