提交 37467713 authored 作者: 吴德鹏's avatar 吴德鹏

话题管理

上级 47438e6f
package com.platform.controller;
import com.platform.entity.HashtagEntity;
import com.platform.service.HashtagService;
import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
/**
* Controller
*
* @author lipengjun
* @date 2020-06-18 10:51:01
*/
@Controller
@RequestMapping("hashtag")
public class HashtagController {
@Autowired
private HashtagService hashtagService;
/**
* 查看列表
*/
@RequestMapping("/list")
@RequiresPermissions("hashtag:list")
@ResponseBody
public R list(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
List<HashtagEntity> hashtagList = hashtagService.queryList(query);
int total = hashtagService.queryTotal(query);
PageUtils pageUtil = new PageUtils(hashtagList, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil);
}
/**
* 查看信息
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("hashtag:info")
@ResponseBody
public R info(@PathVariable("id") String id) {
HashtagEntity hashtag = hashtagService.queryObject(id);
return R.ok().put("hashtag", hashtag);
}
/**
* 保存
*/
@RequestMapping("/save")
@RequiresPermissions("hashtag:save")
@ResponseBody
public R save(@RequestBody HashtagEntity hashtag) {
hashtagService.save(hashtag);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("hashtag:update")
@ResponseBody
public R update(@RequestBody HashtagEntity hashtag) {
hashtagService.update(hashtag);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
@RequiresPermissions("hashtag:delete")
@ResponseBody
public R delete(@RequestBody String[] ids) {
hashtagService.deleteBatch(ids);
return R.ok();
}
/**
* 查看所有列表
*/
@RequestMapping("/queryAll")
@ResponseBody
public R queryAll(@RequestParam Map<String, Object> params) {
List<HashtagEntity> list = hashtagService.queryList(params);
return R.ok().put("list", list);
}
}
package com.platform.controller;
import com.platform.entity.PostHashtagEntity;
import com.platform.service.PostHashtagService;
import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
/**
* Controller
*
* @author lipengjun
* @date 2020-06-18 10:28:56
*/
@Controller
@RequestMapping("posthashtag")
public class PostHashtagController {
@Autowired
private PostHashtagService postHashtagService;
/**
* 查看列表
*/
@RequestMapping("/list")
@RequiresPermissions("posthashtag:list")
@ResponseBody
public R list(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
List<PostHashtagEntity> postHashtagList = postHashtagService.queryList(query);
int total = postHashtagService.queryTotal(query);
PageUtils pageUtil = new PageUtils(postHashtagList, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil);
}
/**
* 查看信息
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("posthashtag:info")
@ResponseBody
public R info(@PathVariable("id") Long id) {
PostHashtagEntity postHashtag = postHashtagService.queryObject(id);
return R.ok().put("postHashtag", postHashtag);
}
/**
* 保存
*/
@RequestMapping("/save")
@RequiresPermissions("posthashtag:save")
@ResponseBody
public R save(@RequestBody PostHashtagEntity postHashtag) {
postHashtagService.save(postHashtag);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("posthashtag:update")
@ResponseBody
public R update(@RequestBody PostHashtagEntity postHashtag) {
postHashtagService.update(postHashtag);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
@RequiresPermissions("posthashtag:delete")
@ResponseBody
public R delete(@RequestBody Long[] ids) {
postHashtagService.deleteBatch(ids);
return R.ok();
}
/**
* 查看所有列表
*/
@RequestMapping("/queryAll")
@ResponseBody
public R queryAll(@RequestParam Map<String, Object> params) {
List<PostHashtagEntity> list = postHashtagService.queryList(params);
return R.ok().put("list", list);
}
}
package com.platform.dao;
import com.platform.entity.HashtagEntity;
/**
* Dao
*
* @author lipengjun
* @date 2020-06-18 10:51:01
*/
public interface HashtagDao extends BaseDao<HashtagEntity> {
}
package com.platform.dao;
import com.platform.entity.PostHashtagEntity;
/**
* Dao
*
* @author lipengjun
* @date 2020-06-18 10:28:56
*/
public interface PostHashtagDao extends BaseDao<PostHashtagEntity> {
}
package com.platform.entity;
import java.io.Serializable;
import java.util.Date;
/**
* 实体
* 表名 hashtag
*
* @author lipengjun
* @date 2020-06-18 10:51:01
*/
public class HashtagEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 话题ID
*/
private String id;
/**
* 0:已删除 1:正常
*/
private Integer archived;
/**
* 删除人
*/
private String archivedBy;
/**
* 删除时间
*/
private Date archivedDate;
/**
* 创建时间
*/
private Date createDate;
/**
* 创建人
*/
private String createdBy;
/**
* 更新时间
*/
private Date updateDate;
/**
* 更新人
*/
private String updatedBy;
/**
* 版本
*/
private Integer version;
/**
* 话题
*/
private String name;
/**
* 用户ID
*/
private String userId;
private Integer count;
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Integer getArchived() {
return archived;
}
public void setArchived(Integer archived) {
this.archived = archived;
}
/**
* 设置:删除人
*/
public void setArchivedBy(String archivedBy) {
this.archivedBy = archivedBy;
}
/**
* 获取:删除人
*/
public String getArchivedBy() {
return archivedBy;
}
/**
* 设置:删除时间
*/
public void setArchivedDate(Date archivedDate) {
this.archivedDate = archivedDate;
}
/**
* 获取:删除时间
*/
public Date getArchivedDate() {
return archivedDate;
}
/**
* 设置:创建时间
*/
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
/**
* 获取:创建时间
*/
public Date getCreateDate() {
return createDate;
}
/**
* 设置:创建人
*/
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
/**
* 获取:创建人
*/
public String getCreatedBy() {
return createdBy;
}
/**
* 设置:更新时间
*/
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
/**
* 获取:更新时间
*/
public Date getUpdateDate() {
return updateDate;
}
/**
* 设置:更新人
*/
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
/**
* 获取:更新人
*/
public String getUpdatedBy() {
return updatedBy;
}
/**
* 设置:版本
*/
public void setVersion(Integer version) {
this.version = version;
}
/**
* 获取:版本
*/
public Integer getVersion() {
return version;
}
/**
* 设置:话题
*/
public void setName(String name) {
this.name = name;
}
/**
* 获取:话题
*/
public String getName() {
return name;
}
/**
* 设置:用户ID
*/
public void setUserId(String userId) {
this.userId = userId;
}
/**
* 获取:用户ID
*/
public String getUserId() {
return userId;
}
}
package com.platform.service;
import com.platform.entity.HashtagEntity;
import java.util.List;
import java.util.Map;
/**
* Service接口
*
* @author lipengjun
* @date 2020-06-18 10:51:01
*/
public interface HashtagService {
/**
* 根据主键查询实体
*
* @param id 主键
* @return 实体
*/
HashtagEntity queryObject(String id);
/**
* 分页查询
*
* @param map 参数
* @return list
*/
List<HashtagEntity> queryList(Map<String, Object> map);
/**
* 分页统计总数
*
* @param map 参数
* @return 总数
*/
int queryTotal(Map<String, Object> map);
/**
* 保存实体
*
* @param hashtag 实体
* @return 保存条数
*/
int save(HashtagEntity hashtag);
/**
* 根据主键更新实体
*
* @param hashtag 实体
* @return 更新条数
*/
int update(HashtagEntity hashtag);
/**
* 根据主键删除
*
* @param id
* @return 删除条数
*/
int delete(Long id);
/**
* 根据主键批量删除
*
* @param ids
* @return 删除条数
*/
int deleteBatch(String[] ids);
}
package com.platform.service;
import com.platform.entity.PostHashtagEntity;
import java.util.List;
import java.util.Map;
/**
* Service接口
*
* @author lipengjun
* @date 2020-06-18 10:28:56
*/
public interface PostHashtagService {
/**
* 根据主键查询实体
*
* @param id 主键
* @return 实体
*/
PostHashtagEntity queryObject(Long id);
/**
* 分页查询
*
* @param map 参数
* @return list
*/
List<PostHashtagEntity> queryList(Map<String, Object> map);
/**
* 分页统计总数
*
* @param map 参数
* @return 总数
*/
int queryTotal(Map<String, Object> map);
/**
* 保存实体
*
* @param postHashtag 实体
* @return 保存条数
*/
int save(PostHashtagEntity postHashtag);
/**
* 根据主键更新实体
*
* @param postHashtag 实体
* @return 更新条数
*/
int update(PostHashtagEntity postHashtag);
/**
* 根据主键删除
*
* @param id
* @return 删除条数
*/
int delete(Long id);
/**
* 根据主键批量删除
*
* @param ids
* @return 删除条数
*/
int deleteBatch(Long[] ids);
}
package com.platform.service.impl;
import com.platform.dao.HashtagDao;
import com.platform.dao.SysUserDao;
import com.platform.dao.TbCfUserInfoDao;
import com.platform.entity.HashtagEntity;
import com.platform.entity.SysUserEntity;
import com.platform.entity.TbCfUserInfoEntity;
import com.platform.service.HashtagService;
import com.platform.utils.IdUtil;
import com.platform.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* Service实现类
*
* @author lipengjun
* @date 2020-06-18 10:51:01
*/
@Service("hashtagService")
public class HashtagServiceImpl implements HashtagService {
@Autowired
private HashtagDao hashtagDao;
@Autowired
private TbCfUserInfoDao tbCfUserInfoDao;
@Autowired
private SysUserDao sysUserDao;
@Override
public HashtagEntity queryObject(String id) {
return hashtagDao.queryObject(id);
}
@Override
public List<HashtagEntity> queryList(Map<String, Object> map) {
List<HashtagEntity> tagList = new ArrayList<>();
List<HashtagEntity> list = hashtagDao.queryList(map);
list.forEach(tag -> {
String userId = tag.getUserId();
TbCfUserInfoEntity user = tbCfUserInfoDao.queryObject(userId);
if (user == null) {
SysUserEntity sysUser = sysUserDao.queryObject(userId);
tag.setCreatedBy(sysUser.getUserName());
} else {
tag.setCreatedBy(user.getNick());
}
tagList.add(tag);
});
return tagList;
}
@Override
public int queryTotal(Map<String, Object> map) {
return hashtagDao.queryTotal(map);
}
@Override
public int save(HashtagEntity hashtag) {
hashtag.setId(IdUtil.createIdbyUUID());
hashtag.setCreateDate(new Date());
hashtag.setUpdateDate(new Date());
hashtag.setArchived(1);
hashtag.setVersion(1);
hashtag.setUserId(ShiroUtils.getUserId());
return hashtagDao.save(hashtag);
}
@Override
public int update(HashtagEntity hashtag) {
HashtagEntity tag = new HashtagEntity();
tag.setId(hashtag.getId());
tag.setUpdateDate(new Date());
tag.setUpdatedBy(ShiroUtils.getUserId());
tag.setVersion(hashtag.getVersion() + 1);
tag.setName(hashtag.getName());
return hashtagDao.update(tag);
}
@Override
public int delete(Long id) {
return hashtagDao.delete(id);
}
@Override
public int deleteBatch(String[] ids) {
return hashtagDao.deleteBatch(ids);
}
}
package com.platform.service.impl;
import com.platform.dao.PostHashtagDao;
import com.platform.entity.PostHashtagEntity;
import com.platform.service.PostHashtagService;
import com.platform.utils.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* Service实现类
*
* @author lipengjun
* @date 2020-06-18 10:28:56
*/
@Service("postHashtagService")
public class PostHashtagServiceImpl implements PostHashtagService {
@Autowired
private PostHashtagDao postHashtagDao;
@Override
public PostHashtagEntity queryObject(Long id) {
return postHashtagDao.queryObject(id);
}
@Override
public List<PostHashtagEntity> queryList(Map<String, Object> map) {
return postHashtagDao.queryList(map);
}
@Override
public int queryTotal(Map<String, Object> map) {
return postHashtagDao.queryTotal(map);
}
@Override
public int save(PostHashtagEntity postHashtag) {
postHashtag.setId(Long.parseLong(IdUtil.createIdbyUUID()));
return postHashtagDao.save(postHashtag);
}
@Override
public int update(PostHashtagEntity postHashtag) {
return postHashtagDao.update(postHashtag);
}
@Override
public int delete(Long id) {
return postHashtagDao.delete(id);
}
@Override
public int deleteBatch(Long[] ids) {
return postHashtagDao.deleteBatch(ids);
}
}
<?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.platform.dao.HashtagDao">
<resultMap type="com.platform.entity.HashtagEntity" id="hashtagMap">
<result property="id" column="id"/>
<result property="archived" column="archived"/>
<result property="archivedBy" column="archived_by"/>
<result property="archivedDate" column="archived_date"/>
<result property="createDate" column="create_date"/>
<result property="createdBy" column="created_by"/>
<result property="updateDate" column="update_date"/>
<result property="updatedBy" column="updated_by"/>
<result property="version" column="version"/>
<result property="name" column="name"/>
<result property="userId" column="user_id"/>
</resultMap>
<select id="queryObject" resultType="com.platform.entity.HashtagEntity">
select
`id`,
`archived`,
`archived_by`,
`archived_date`,
`create_date`,
`created_by`,
`update_date`,
`updated_by`,
`version`,
`name`,
`user_id`
from hashtag
where id = #{id}
</select>
<select id="queryList" resultType="com.platform.entity.HashtagEntity">
SELECT
t.*,
u.nick createdBy,
IFNULL( p.count, 0 ) count
FROM
hashtag t
LEFT JOIN tb_cf_user_info u ON t.user_id = u.user_id
LEFT JOIN ( SELECT hashtag_id, count( 1 ) count FROM post_hashtag GROUP BY hashtag_id ) p ON t.id = p.hashtag_id
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by create_date desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from hashtag
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
</select>
<insert id="save" parameterType="com.platform.entity.HashtagEntity">
insert into hashtag(
`id`,
`archived`,
`archived_by`,
`archived_date`,
`create_date`,
`created_by`,
`update_date`,
`updated_by`,
`version`,
`name`,
`user_id`)
values(
#{id},
#{archived},
#{archivedBy},
#{archivedDate},
#{createDate},
#{createdBy},
#{updateDate},
#{updatedBy},
#{version},
#{name},
#{userId})
</insert>
<update id="update" parameterType="com.platform.entity.HashtagEntity">
update hashtag
<set>
<if test="archived != null">`archived` = #{archived},</if>
<if test="archivedBy != null">`archived_by` = #{archivedBy},</if>
<if test="archivedDate != null">`archived_date` = #{archivedDate},</if>
<if test="createDate != null">`create_date` = #{createDate},</if>
<if test="createdBy != null">`created_by` = #{createdBy},</if>
<if test="updateDate != null">`update_date` = #{updateDate},</if>
<if test="updatedBy != null">`updated_by` = #{updatedBy},</if>
<if test="version != null">`version` = #{version},</if>
<if test="name != null">`name` = #{name},</if>
<if test="userId != null">`user_id` = #{userId}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
delete from hashtag where id = #{value}
</delete>
<delete id="deleteBatch">
delete from hashtag where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
<?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.platform.dao.PostHashtagDao">
<resultMap type="com.platform.entity.PostHashtagEntity" id="postHashtagMap">
<result property="id" column="id"/>
<result property="archived" column="archived"/>
<result property="archivedBy" column="archived_by"/>
<result property="archivedDate" column="archived_date"/>
<result property="createDate" column="create_date"/>
<result property="createdBy" column="created_by"/>
<result property="updateDate" column="update_date"/>
<result property="updatedBy" column="updated_by"/>
<result property="version" column="version"/>
<result property="hashtagId" column="hashtag_id"/>
<result property="postId" column="post_id"/>
</resultMap>
<select id="queryObject" resultType="com.platform.entity.PostHashtagEntity">
select
`id`,
`archived`,
`archived_by`,
`archived_date`,
`create_date`,
`created_by`,
`update_date`,
`updated_by`,
`version`,
`hashtag_id`,
`post_id`
from post_hashtag
where id = #{id}
</select>
<select id="queryList" resultType="com.platform.entity.PostHashtagEntity">
select
`id`,
`archived`,
`archived_by`,
`archived_date`,
`create_date`,
`created_by`,
`update_date`,
`updated_by`,
`version`,
`hashtag_id`,
`post_id`
from post_hashtag
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from post_hashtag
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
</select>
<insert id="save" parameterType="com.platform.entity.PostHashtagEntity" useGeneratedKeys="true" keyProperty="id">
insert into post_hashtag(
`archived`,
`archived_by`,
`archived_date`,
`create_date`,
`created_by`,
`update_date`,
`updated_by`,
`version`,
`hashtag_id`,
`post_id`)
values(
#{archived},
#{archivedBy},
#{archivedDate},
#{createDate},
#{createdBy},
#{updateDate},
#{updatedBy},
#{version},
#{hashtagId},
#{postId})
</insert>
<update id="update" parameterType="com.platform.entity.PostHashtagEntity">
update post_hashtag
<set>
<if test="archived != null">`archived` = #{archived}, </if>
<if test="archivedBy != null">`archived_by` = #{archivedBy}, </if>
<if test="archivedDate != null">`archived_date` = #{archivedDate}, </if>
<if test="createDate != null">`create_date` = #{createDate}, </if>
<if test="createdBy != null">`created_by` = #{createdBy}, </if>
<if test="updateDate != null">`update_date` = #{updateDate}, </if>
<if test="updatedBy != null">`updated_by` = #{updatedBy}, </if>
<if test="version != null">`version` = #{version}, </if>
<if test="hashtagId != null">`hashtag_id` = #{hashtagId}, </if>
<if test="postId != null">`post_id` = #{postId}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
delete from post_hashtag where id = #{value}
</delete>
<delete id="deleteBatch">
delete from post_hashtag where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title></title>
#parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak style="height: calc(100% - 15px);">
<div v-show="showList" style="height: 100%;">
<Row :gutter="16">
<div class="search-group">
<i-col span="4">
<i-input v-model="q.name" @on-enter="query" placeholder="话题"/>
</i-col>
<i-button @click="query">查询</i-button>
<i-button @click="reloadSearch">重置</i-button>
</div>
<div class="buttons-group">
#if($shiro.hasPermission("hashtag:save"))
<i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
#end
#if($shiro.hasPermission("hashtag:update"))
<i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
#end
#if($shiro.hasPermission("hashtag:delete"))
<i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
#end
</div>
</Row>
<table id="jqGrid"></table>
</div>
<Card v-show="!showList">
<p slot="title">{{title}}</p>
<i-form ref="formValidate" :model="hashtag" :rules="ruleValidate" :label-width="80">
<Form-item label="话题" prop="name">
<i-input v-model="hashtag.name" placeholder="话题" style="width:160px"/>
</Form-item>
<Form-item>
<i-button type="primary" @click="handleSubmit('formValidate')">提交</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>
</Form-item>
</i-form>
</Card>
</div>
<script src="${rc.contextPath}/js/sys/hashtag.js?_${date.systemTime}"></script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title></title>
#parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak style="height: calc(100% - 15px);">
<div v-show="showList" style="height: 100%;">
<Row :gutter="16">
<div class="search-group">
<i-col span="4">
<i-input v-model="q.name" @on-enter="query" placeholder="名称"/>
</i-col>
<i-button @click="query">查询</i-button>
<i-button @click="reloadSearch">重置</i-button>
</div>
<div class="buttons-group">
#if($shiro.hasPermission("posthashtag:save"))
<i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
#end
#if($shiro.hasPermission("posthashtag:update"))
<i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
#end
#if($shiro.hasPermission("posthashtag:delete"))
<i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
#end
</div>
</Row>
<table id="jqGrid"></table>
</div>
<Card v-show="!showList">
<p slot="title">{{title}}</p>
<i-form ref="formValidate" :model="postHashtag" :rules="ruleValidate" :label-width="80">
<Form-item label="0:已删除 1:正常" prop="archived">
<i-input v-model="postHashtag.archived" placeholder="0:已删除 1:正常"/>
</Form-item>
<Form-item label="删除人" prop="archivedBy">
<i-input v-model="postHashtag.archivedBy" placeholder="删除人"/>
</Form-item>
<Form-item label="删除时间" prop="archivedDate">
<i-input v-model="postHashtag.archivedDate" placeholder="删除时间"/>
</Form-item>
<Form-item label="创建时间" prop="createDate">
<i-input v-model="postHashtag.createDate" placeholder="创建时间"/>
</Form-item>
<Form-item label="创建人" prop="createdBy">
<i-input v-model="postHashtag.createdBy" placeholder="创建人"/>
</Form-item>
<Form-item label="更新时间" prop="updateDate">
<i-input v-model="postHashtag.updateDate" placeholder="更新时间"/>
</Form-item>
<Form-item label="更新人" prop="updatedBy">
<i-input v-model="postHashtag.updatedBy" placeholder="更新人"/>
</Form-item>
<Form-item label="版本" prop="version">
<i-input v-model="postHashtag.version" placeholder="版本"/>
</Form-item>
<Form-item label="标签ID" prop="hashtagId">
<i-input v-model="postHashtag.hashtagId" placeholder="标签ID"/>
</Form-item>
<Form-item label="帖子ID" prop="postId">
<i-input v-model="postHashtag.postId" placeholder="帖子ID"/>
</Form-item>
<Form-item>
<i-button type="primary" @click="handleSubmit('formValidate')">提交</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>
</Form-item>
</i-form>
</Card>
</div>
<script src="${rc.contextPath}/js/sys/posthashtag.js?_${date.systemTime}"></script>
</body>
</html>
\ No newline at end of file
......@@ -590,6 +590,17 @@ statusFormat = function (cellvalue) {
return cellvalue == 0 ? '正常' : '已删除';
};
/**
* 状态
* @param cellvalue
* @returns {string}
*/
status1Format = function (cellvalue) {
return cellvalue == 1 ? '正常' : '已删除';
};
/**
* 是否为注册就送优惠券
* @param cellvalue
......
$(function () {
$("#jqGrid").Grid({
url: '../hashtag/list',
colModel: [
{label: 'id', name: 'id', index: 'id', key: true, hidden: true},
{label: '话题', name: 'name', index: 'name', width: 80},
{label: '创建人', name: 'createdBy', index: 'created_by', width: 80},
{label: '用户ID', name: 'userId', index: 'user_id', width: 80},
{label: '帖子数量', name: 'count', index: 'count', width: 80},
{label: '状态', name: 'archived', index: 'archived', width: 80, formatter: status1Format},
{label: '创建时间', name: 'createDate', index: 'create_date', width: 80}
]
});
});
let vm = new Vue({
el: '#rrapp',
data: {
showList: true,
title: null,
hashtag: {},
ruleValidate: {
name: [
{required: true, message: '名称不能为空', trigger: 'blur'}
]
},
q: {
name: ''
}
},
methods: {
query: function () {
vm.reload();
},
add: function () {
vm.showList = false;
vm.title = "新增";
vm.hashtag = {};
},
update: function (event) {
let id = getSelectedRow("#jqGrid");
if (id == null) {
return;
}
vm.showList = false;
vm.title = "修改";
vm.getInfo(id);
},
saveOrUpdate: function (event) {
let url = vm.hashtag.id == null ? "../hashtag/save" : "../hashtag/update";
Ajax.request({
url: url,
params: JSON.stringify(vm.hashtag),
type: "POST",
contentType: "application/json",
successCallback: function (r) {
alert('操作成功', function (index) {
vm.reload();
});
}
});
},
del: function (event) {
let ids = getSelectedRows("#jqGrid");
if (ids == null) {
return;
}
confirm('确定要删除选中的记录?', function () {
Ajax.request({
url: "../hashtag/delete",
params: JSON.stringify(ids),
type: "POST",
contentType: "application/json",
successCallback: function () {
alert('操作成功', function (index) {
vm.reload();
});
}
});
});
},
getInfo: function (id) {
Ajax.request({
url: "../hashtag/info/" + id,
async: true,
successCallback: function (r) {
vm.hashtag = r.hashtag;
}
});
},
reload: function (event) {
vm.showList = true;
let page = $("#jqGrid").jqGrid('getGridParam', 'page');
$("#jqGrid").jqGrid('setGridParam', {
postData: {'name': vm.q.name},
page: page
}).trigger("reloadGrid");
vm.handleReset('formValidate');
},
reloadSearch: function () {
vm.q = {
name: ''
};
vm.reload();
},
handleSubmit: function (name) {
handleSubmitValidate(this, name, function () {
vm.saveOrUpdate()
});
},
handleReset: function (name) {
handleResetForm(this, name);
}
}
});
\ No newline at end of file
$(function () {
$("#jqGrid").Grid({
url: '../posthashtag/list',
colModel: [
{label: 'id', name: 'id', index: 'id', key: true, hidden: true},
{label: '0:已删除 1:正常', name: 'archived', index: 'archived', width: 80},
{label: '删除人', name: 'archivedBy', index: 'archived_by', width: 80},
{label: '删除时间', name: 'archivedDate', index: 'archived_date', width: 80},
{label: '创建时间', name: 'createDate', index: 'create_date', width: 80},
{label: '创建人', name: 'createdBy', index: 'created_by', width: 80},
{label: '更新时间', name: 'updateDate', index: 'update_date', width: 80},
{label: '更新人', name: 'updatedBy', index: 'updated_by', width: 80},
{label: '版本', name: 'version', index: 'version', width: 80},
{label: '标签ID', name: 'hashtagId', index: 'hashtag_id', width: 80},
{label: '帖子ID', name: 'postId', index: 'post_id', width: 80}]
});
});
let vm = new Vue({
el: '#rrapp',
data: {
showList: true,
title: null,
postHashtag: {},
ruleValidate: {
name: [
{required: true, message: '名称不能为空', trigger: 'blur'}
]
},
q: {
name: ''
}
},
methods: {
query: function () {
vm.reload();
},
add: function () {
vm.showList = false;
vm.title = "新增";
vm.postHashtag = {};
},
update: function (event) {
let id = getSelectedRow("#jqGrid");
if (id == null) {
return;
}
vm.showList = false;
vm.title = "修改";
vm.getInfo(id);
},
saveOrUpdate: function (event) {
let url = vm.postHashtag.id == null ? "../posthashtag/save" : "../posthashtag/update";
Ajax.request({
url: url,
params: JSON.stringify(vm.postHashtag),
type: "POST",
contentType: "application/json",
successCallback: function (r) {
alert('操作成功', function (index) {
vm.reload();
});
}
});
},
del: function (event) {
let ids = getSelectedRows("#jqGrid");
if (ids == null){
return;
}
confirm('确定要删除选中的记录?', function () {
Ajax.request({
url: "../posthashtag/delete",
params: JSON.stringify(ids),
type: "POST",
contentType: "application/json",
successCallback: function () {
alert('操作成功', function (index) {
vm.reload();
});
}
});
});
},
getInfo: function(id){
Ajax.request({
url: "../posthashtag/info/"+id,
async: true,
successCallback: function (r) {
vm.postHashtag = r.postHashtag;
}
});
},
reload: function (event) {
vm.showList = true;
let page = $("#jqGrid").jqGrid('getGridParam', 'page');
$("#jqGrid").jqGrid('setGridParam', {
postData: {'name': vm.q.name},
page: page
}).trigger("reloadGrid");
vm.handleReset('formValidate');
},
reloadSearch: function() {
vm.q = {
name: ''
};
vm.reload();
},
handleSubmit: function (name) {
handleSubmitValidate(this, name, function () {
vm.saveOrUpdate()
});
},
handleReset: function (name) {
handleResetForm(this, name);
}
}
});
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论