提交 024d5074 authored 作者: zgy's avatar zgy

完成社区:文章管理功能

上级 033b04b5
...@@ -64,7 +64,9 @@ public class TbCfStationItemController extends ApiBaseAction { ...@@ -64,7 +64,9 @@ public class TbCfStationItemController extends ApiBaseAction {
@RequiresPermissions("tbcfstationitem:list") @RequiresPermissions("tbcfstationitem:list")
@ResponseBody @ResponseBody
public R list(@RequestParam Map<String, Object> params) { public R list(@RequestParam Map<String, Object> params) {
if (!Constant.SUPER_ADMIN.equals(ShiroUtils.getUserId())) { if (!Constant.SUPER_ADMIN.equals(ShiroUtils.getUserId()) &&
!Constant.SUPER_ITEM.equals(ShiroUtils.getUserId()) &&
!Constant.SUPER_USER.equals(ShiroUtils.getUserId())) {
params.put("creator", ShiroUtils.getUserId()); params.put("creator", ShiroUtils.getUserId());
} }
String userId = ShiroUtils.getUserId(); String userId = ShiroUtils.getUserId();
......
...@@ -105,7 +105,7 @@ public class TbCfUserInfoController { ...@@ -105,7 +105,7 @@ public class TbCfUserInfoController {
@ResponseBody @ResponseBody
@GetMapping("/queryByAccount") @GetMapping("/queryByAccount")
public R queryByAccount(@RequestParam("account") String account) { public R queryByAccount(@RequestParam("account") String account) {
String userId = tbCfUserInfoService.queryById(account);
return R.ok(); return R.ok().put("userId", userId);
} }
} }
...@@ -58,6 +58,16 @@ public class TbCfArticleEntity implements Serializable { ...@@ -58,6 +58,16 @@ public class TbCfArticleEntity implements Serializable {
*/ */
private Date updatetime; private Date updatetime;
private String account;
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
/** /**
* 设置:文章ID * 设置:文章ID
*/ */
......
...@@ -73,5 +73,5 @@ public interface TbCfUserInfoService { ...@@ -73,5 +73,5 @@ public interface TbCfUserInfoService {
long queryUserTotal(); long queryUserTotal();
boolean queryByAccount(String account); String queryByAccount(String account);
} }
...@@ -68,8 +68,8 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService { ...@@ -68,8 +68,8 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
} }
@Override @Override
public boolean queryByAccount(String account) { public String queryByAccount(String account) {
return tbCfUserInfoDao.queryById(account) == null ? true : false; return tbCfUserInfoDao.queryById(account) ;
} }
} }
...@@ -46,18 +46,20 @@ ...@@ -46,18 +46,20 @@
`del_flag`, `del_flag`,
`top`, `top`,
`createTime`, `createTime`,
`updateTime` `updateTime`,
from tb_cf_article u.account account
from tb_cf_article a left join tb_cf_user_info u
on a.author=u.user_id
WHERE 1=1 WHERE 1=1
<if test="name != null and name.trim() != ''"> <if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%') AND title LIKE concat('%',#{name},'%')
</if> </if>
<choose> <choose>
<when test="sidx != null and sidx.trim() != ''"> <when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order} order by ${sidx} ${order}
</when> </when>
<otherwise> <otherwise>
order by id desc order by createTime desc
</otherwise> </otherwise>
</choose> </choose>
<if test="offset != null and limit != null"> <if test="offset != null and limit != null">
...@@ -69,7 +71,7 @@ ...@@ -69,7 +71,7 @@
select count(*) from tb_cf_article select count(*) from tb_cf_article
WHERE 1=1 WHERE 1=1
<if test="name != null and name.trim() != ''"> <if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%') AND title LIKE concat('%',#{name},'%')
</if> </if>
</select> </select>
...@@ -103,15 +105,15 @@ ...@@ -103,15 +105,15 @@
<update id="update" parameterType="com.platform.entity.TbCfArticleEntity"> <update id="update" parameterType="com.platform.entity.TbCfArticleEntity">
update tb_cf_article update tb_cf_article
<set> <set>
<if test="title != null">`title` = #{title}, </if> <if test="title != null">`title` = #{title},</if>
<if test="content != null">`content` = #{content}, </if> <if test="content != null">`content` = #{content},</if>
<if test="picture != null">`picture` = #{picture}, </if> <if test="picture != null">`picture` = #{picture},</if>
<if test="authorType != null">`author_type` = #{authorType}, </if> <if test="authorType != null">`author_type` = #{authorType},</if>
<if test="author != null">`author` = #{author}, </if> <if test="author != null">`author` = #{author},</if>
<if test="likeNum != null">`like_num` = #{likeNum}, </if> <if test="likeNum != null">`like_num` = #{likeNum},</if>
<if test="delFlag != null">`del_flag` = #{delFlag}, </if> <if test="delFlag != null">`del_flag` = #{delFlag},</if>
<if test="top != null">`top` = #{top}, </if> <if test="top != null">`top` = #{top},</if>
<if test="createtime != null">`createTime` = #{createtime}, </if> <if test="createtime != null">`createTime` = #{createtime},</if>
<if test="updatetime != null">`updateTime` = #{updatetime}</if> <if test="updatetime != null">`updateTime` = #{updatetime}</if>
</set> </set>
where id = #{id} where id = #{id}
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<Row :gutter="16"> <Row :gutter="16">
<div class="search-group"> <div class="search-group">
<i-col span="4"> <i-col span="4">
<i-input v-model="q.name" @on-enter="query" placeholder="名称"/> <i-input v-model="q.name" @on-enter="query" placeholder="文章标题"/>
</i-col> </i-col>
<i-button @click="query">查询</i-button> <i-button @click="query">查询</i-button>
<i-button @click="reloadSearch">重置</i-button> <i-button @click="reloadSearch">重置</i-button>
...@@ -33,12 +33,29 @@ ...@@ -33,12 +33,29 @@
<Card v-show="!showList"> <Card v-show="!showList">
<p slot="title">{{title}}</p> <p slot="title">{{title}}</p>
<i-form ref="formValidate" :model="tbCfArticle" :rules="ruleValidate" :label-width="80"> <i-form ref="formValidate" :model="tbCfArticle" :rules="ruleValidate" :label-width="80">
<Form-item label="文章标题" prop="title"> <Form-item label="文章标题" prop="title" style="width: 800px">
<i-input v-model="tbCfArticle.title" placeholder="文章标题"/> <i-input v-model="tbCfArticle.title" placeholder="文章标题"/>
</Form-item> </Form-item>
<!--<Form-item label="图片" prop="picture"> <!--<Form-item label="图片" prop="picture">
<i-input v-model="tbCfArticle.picture" placeholder="图片"/> <i-input v-model="tbCfArticle.picture" placeholder="图片"/>
</Form-item>--> </Form-item>-->
<!-- <Form-item label="用户类型" prop="authorType" style="width: 800px">-->
<!-- <i-select v-model="tbCfArticle.authorType" style="width:200px" @on-change="changeType" :disabled="disabled">-->
<!-- <i-option v-for="item in typeList" :value="item.value">{{ item.label }}</i-option>-->
<!-- </i-select>-->
<!-- </Form-item>-->
<Form-item label="用户类型" prop="authorType" style="width: 800px">
<i-select placeholder="请选择" v-model="tbCfArticle.authorType" :disabled="disabled"
@on-change="changeType">
<i-option v-for="(el,i) in typeList" :key='i'
:value="el.value">{{el.label}}
</i-option>
</i-select>
</Form-item>
<Form-item label="app账户" prop="author" style="width: 800px" v-show="!account">
<i-input v-model="tbCfArticle.author" placeholder="260977204970 or ctehillah@gmail.com"
@on-blur="queryAccount"/>
</Form-item>
<Form-item label="图片" prop="picture"> <Form-item label="图片" prop="picture">
<!-- <i-input v-model="xPicture.pictureUrl" placeholder="图片地址"/> --> <!-- <i-input v-model="xPicture.pictureUrl" placeholder="图片地址"/> -->
<upload <upload
...@@ -67,7 +84,8 @@ ...@@ -67,7 +84,8 @@
<Form-item> <Form-item>
<i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button> <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
<i-button type="warning" @click="reload" style="margin-left: 8px"/>返回</i-button> <i-button type="warning" @click="reload" style="margin-left: 8px"/>
返回</i-button>
<i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button> <i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
</Form-item> </Form-item>
</i-form> </i-form>
......
...@@ -465,13 +465,22 @@ imageFormat = function (cellvalue, options, rowObject) { ...@@ -465,13 +465,22 @@ imageFormat = function (cellvalue, options, rowObject) {
if (cellvalue.indexOf(';')) { if (cellvalue.indexOf(';')) {
let split = cellvalue.split(';'); let split = cellvalue.split(';');
cellvalue = '<img src="' + split[0] + '" style="width:30px;height:30px;" />'; cellvalue = '<img src="' + split[0] + '" style="width:30px;height:30px;" />';
} else if (cellvalue.indexOf(',')) {
let split = cellvalue.split(',');
cellvalue = '<img src="' + split[0] + '" style="width:30px;height:30px;" />';
} else { } else {
cellvalue = '<img src="' + cellvalue + '" style="width:30px;height:30px;" />'; cellvalue = '<img src="' + cellvalue + '" style="width:30px;height:30px;" />';
} }
} }
return cellvalue; return cellvalue;
}; };
accountFormat = function (cellvalue, options, rowObject) {
if (cellvalue == '' || cellvalue == null) {
cellvalue = '系统用户';
}
return cellvalue;
}
/** /**
* 跳转翻译 * 跳转翻译
* @param cellvalue * @param cellvalue
......
...@@ -4,20 +4,32 @@ $(function () { ...@@ -4,20 +4,32 @@ $(function () {
colModel: [ colModel: [
{label: 'id', name: 'id', index: 'id', key: true, hidden: true}, {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
{label: '文章标题', name: 'title', index: 'title', width: 80}, {label: '文章标题', name: 'title', index: 'title', width: 80},
{label: '图片', name: 'picture', index: 'picture', width: 80}, {label: '图片', name: 'picture', index: 'picture', width: 80, formatter: imageFormat},
{label: '作者', name: 'author', index: 'author', width: 80}, {label: '作者', name: 'account', index: 'account', width: 80, formatter: accountFormat},
{label: '创建时间', name: 'createtime', index: 'createTime', width: 80} {label: '创建时间', name: 'createtime', index: 'createTime', width: 80}
] ]
}); });
}); });
let vm = new Vue({ let vm = new Vue({
el: '#rrapp', el: '#rrapp',
data: { data: {
showList: true, showList: true,
account: true,
uploadList: [], uploadList: [],
title: null, title: null,
tbCfArticle: {}, tbCfArticle: {},
typeList: [
{
value: 0,
label: '系统用户'
},
{
value: 1,
label: 'app用户'
}
],
ruleValidate: { ruleValidate: {
name: [ name: [
{required: true, message: '名称不能为空', trigger: 'blur'} {required: true, message: '名称不能为空', trigger: 'blur'}
...@@ -25,13 +37,44 @@ let vm = new Vue({ ...@@ -25,13 +37,44 @@ let vm = new Vue({
}, },
q: { q: {
name: '' name: ''
} },
disabled: false,
flag: true
}, },
methods: { methods: {
changeType: function () {
let type = this.tbCfArticle.authorType;
if (type == '0') {
vm.account = true;
} else if (type == '1') {
vm.account = false;
}
},
queryAccount: function () {
let flag = vm.flag;
let url = '../tbcfuserinfo/queryByAccount?account=' + this.tbCfArticle.author;
Ajax.request({
url: url,
type: "GET",
contentType: "application/json",
successCallback: function (r) {
let userId = r.userId;
if (userId == null || userId == '') {
flag = false
}
// alert('操作成功', function (index) {
// vm.reload();
// });
}
});
return flag;
},
query: function () { query: function () {
vm.reload(); vm.reload();
}, },
add: function () { add: function () {
vm.disabled = false;
vm.showList = false; vm.showList = false;
vm.title = "新增"; vm.title = "新增";
vm.tbCfArticle = {}; vm.tbCfArticle = {};
...@@ -39,6 +82,7 @@ let vm = new Vue({ ...@@ -39,6 +82,7 @@ let vm = new Vue({
UE.getEditor('content').setContent(''); UE.getEditor('content').setContent('');
}, },
update: function (event) { update: function (event) {
vm.disabled = true;
let id = getSelectedRow("#jqGrid"); let id = getSelectedRow("#jqGrid");
if (id == null) { if (id == null) {
return; return;
...@@ -49,8 +93,10 @@ let vm = new Vue({ ...@@ -49,8 +93,10 @@ let vm = new Vue({
vm.getInfo(id); vm.getInfo(id);
}, },
saveOrUpdate: function (event) { saveOrUpdate: function (event) {
let flag = this.queryAccount();
if (flag) {
let url = vm.tbCfArticle.id == null ? "../tbcfarticle/save" : "../tbcfarticle/update"; let url = vm.tbCfArticle.id == null ? "../tbcfarticle/save" : "../tbcfarticle/update";
vm.tbCfArticle.picture=this.uploadList.map(res=>res).join(','); vm.tbCfArticle.picture = this.uploadList.map(res => res).join(',');
vm.tbCfArticle.content = encodeURI(UE.getEditor('content').getContent()); // 富文本取值 vm.tbCfArticle.content = encodeURI(UE.getEditor('content').getContent()); // 富文本取值
vm.tbCfArticle.content = vm.tbCfArticle.content.replace(/&nbsp;/g, " "); vm.tbCfArticle.content = vm.tbCfArticle.content.replace(/&nbsp;/g, " ");
Ajax.request({ Ajax.request({
...@@ -64,10 +110,14 @@ let vm = new Vue({ ...@@ -64,10 +110,14 @@ let vm = new Vue({
}); });
} }
}); });
} else {
alert('此用户不存在')
}
}, },
del: function (event) { del: function (event) {
let ids = getSelectedRows("#jqGrid"); let ids = getSelectedRows("#jqGrid");
if (ids == null){ if (ids == null) {
return; return;
} }
...@@ -85,17 +135,18 @@ let vm = new Vue({ ...@@ -85,17 +135,18 @@ let vm = new Vue({
}); });
}); });
}, },
getInfo: function(id){ getInfo: function (id) {
Ajax.request({ Ajax.request({
url: "../tbcfarticle/info/"+id, url: "../tbcfarticle/info/" + id,
async: true, async: true,
successCallback: function (r) { successCallback: function (r) {
vm.account = true;
vm.tbCfArticle = r.tbCfArticle; vm.tbCfArticle = r.tbCfArticle;
let content = vm.tbCfArticle.content; let content = vm.tbCfArticle.content;
vm.uploadList = vm.tbCfArticle.picture.split(','); vm.uploadList = vm.tbCfArticle.picture.split(',');
if(content!=null){ if (content != null) {
UE.getEditor('content').setContent(content); UE.getEditor('content').setContent(content);
}else { } else {
UE.getEditor('content').setContent(''); UE.getEditor('content').setContent('');
} }
} }
...@@ -110,7 +161,7 @@ let vm = new Vue({ ...@@ -110,7 +161,7 @@ let vm = new Vue({
}).trigger("reloadGrid"); }).trigger("reloadGrid");
vm.handleReset('formValidate'); vm.handleReset('formValidate');
}, },
reloadSearch: function() { reloadSearch: function () {
vm.q = { vm.q = {
name: '' name: ''
}; };
...@@ -130,7 +181,7 @@ let vm = new Vue({ ...@@ -130,7 +181,7 @@ let vm = new Vue({
alert('请上传不超过5M的图片'); alert('请上传不超过5M的图片');
return false; return false;
} }
console.log(123456,this.uploadList) console.log(123456, this.uploadList)
const check = this.uploadList.length < 9; const check = this.uploadList.length < 9;
if (!check) { if (!check) {
this.$Notice.warning({ this.$Notice.warning({
......
...@@ -10,6 +10,15 @@ public class Constant { ...@@ -10,6 +10,15 @@ public class Constant {
*/ */
public static final String SUPER_ADMIN = "1"; public static final String SUPER_ADMIN = "1";
/**
* 管理员
*/
public static final String SUPER_ITEM="2";
/**
* 管理员
*/
public static final String SUPER_USER="3";
/** /**
* 默认系统domainId 业务系统 * 默认系统domainId 业务系统
*/ */
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论