This commit is contained in:
kuang.yife 2024-07-24 18:22:08 +08:00
parent 7dc117b2ae
commit cbcfd50553
17 changed files with 202 additions and 10 deletions

View File

@ -1,9 +1,12 @@
package com.playlet.web.controller.system;
import java.util.List;
import java.util.stream.Collectors;
import com.playlet.common.core.domain.entity.SysDept;
import com.playlet.common.core.domain.entity.SysUser;
import com.playlet.system.domain.PlayletPublicDetail;
import com.playlet.system.service.ISysDeptService;
import com.playlet.system.service.ISysUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
@ -34,6 +37,9 @@ public class PlayletPublicAccountController extends BaseController
@Autowired
private IPlayletPublicAccountService playletPublicAccountService;
@Autowired
private ISysDeptService deptService;
@Autowired
private ISysUserService sysUserService;
@ -71,6 +77,10 @@ public class PlayletPublicAccountController extends BaseController
@ResponseBody
public TableDataInfo list(PlayletPublicAccount playletPublicAccount)
{
// 判断是否是管理员
if(!this.getSysUser().isAdmin()){
playletPublicAccount.setManagerId(this.getUserId());
}
startPage();
List<PlayletPublicAccount> list = playletPublicAccountService.selectPlayletPublicAccountList(playletPublicAccount);
list.forEach(model->{
@ -114,6 +124,19 @@ public class PlayletPublicAccountController extends BaseController
@ResponseBody
public AjaxResult addSave(PlayletPublicAccount playletPublicAccount)
{
// 查询用户部门信息
SysDept dept = deptService.selectDeptById(this.getSysUser().getDeptId());
SysUser param = new SysUser();
param.setDeptId(dept.getDeptId());
// 查询部门下所有员工
List<SysUser> list = sysUserService.selectUserList(param);
List<Long> userIds = list.stream().map(SysUser::getUserId).collect(Collectors.toList());
long count = playletPublicAccountService.lambdaQuery()
.in(PlayletPublicAccount::getManagerId, userIds)
.count();
if(count >= dept.getPublicAccountLimit()){
return error("新增公众号'" + playletPublicAccount.getName() + "'失败,公众号数量已达上限");
}
return toAjax(playletPublicAccountService.insertPlayletPublicAccount(playletPublicAccount));
}

View File

@ -1,7 +1,10 @@
package com.playlet.web.controller.system;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import com.playlet.common.utils.StringUtils;
import com.playlet.system.domain.PlayletPublicAccount;
import com.playlet.system.domain.PublicDetailComment;
@ -96,6 +99,16 @@ public class PlayletPublicDetailController extends BaseController
@ResponseBody
public TableDataInfo list(PlayletPublicDetail playletPublicDetail)
{
if(!this.getSysUser().isAdmin()){
List<PlayletPublicAccount> accounts = playletPublicAccountService.lambdaQuery().select(PlayletPublicAccount::getId)
.eq(PlayletPublicAccount::getManagerId, this.getUserId())
.list();
if(CollectionUtil.isEmpty(accounts)){
return getDataTable(new ArrayList<>());
}
List<Long> ids = accounts.stream().map(PlayletPublicAccount::getId).collect(Collectors.toList());
playletPublicDetail.setPublicIds(ids);
}
startPage();
List<PlayletPublicDetail> list = playletPublicDetailService.selectPlayletPublicDetailList(playletPublicDetail);
list.forEach(model->{
@ -128,7 +141,14 @@ public class PlayletPublicDetailController extends BaseController
public String add(ModelMap modelMap)
{
modelMap.put("playletItems", playletItemService.lambdaQuery().list());
modelMap.put("publicAccounts", playletPublicAccountService.selectPlayletPublicAccountList(new PlayletPublicAccount()));
if(!this.getSysUser().isAdmin()){
List<PlayletPublicAccount> accounts = playletPublicAccountService.lambdaQuery()
.eq(PlayletPublicAccount::getManagerId, this.getUserId())
.list();
modelMap.put("publicAccounts", accounts);
}else {
modelMap.put("publicAccounts", playletPublicAccountService.selectPlayletPublicAccountList(new PlayletPublicAccount()));
}
return prefix + "/add";
}
@ -155,7 +175,14 @@ public class PlayletPublicDetailController extends BaseController
public String edit(@PathVariable("id") Long id, ModelMap mmap)
{
PlayletPublicDetail playletPublicDetail = playletPublicDetailService.selectPlayletPublicDetailById(id);
mmap.put("publicAccounts", playletPublicAccountService.selectPlayletPublicAccountList(new PlayletPublicAccount()));
if(!this.getSysUser().isAdmin()){
List<PlayletPublicAccount> accounts = playletPublicAccountService.lambdaQuery()
.eq(PlayletPublicAccount::getManagerId, this.getUserId())
.list();
mmap.put("publicAccounts", accounts);
}else {
mmap.put("publicAccounts", playletPublicAccountService.selectPlayletPublicAccountList(new PlayletPublicAccount()));
}
mmap.put("playletPublicDetail", playletPublicDetail);
return prefix + "/edit";
}

View File

@ -1,13 +1,15 @@
package com.playlet.web.controller.system;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import com.playlet.common.core.domain.entity.SysUser;
import com.playlet.system.domain.PlayletPublicAccount;
import com.playlet.system.domain.PlayletPublicDetail;
import com.playlet.system.domain.PublicCommentResponse;
import com.playlet.system.service.IPlayletPublicDetailService;
import com.playlet.system.service.IPublicCommentResponseService;
import com.playlet.system.service.IPublicDetailShareService;
import com.playlet.system.service.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -20,7 +22,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.playlet.common.annotation.Log;
import com.playlet.common.enums.BusinessType;
import com.playlet.system.domain.PublicDetailComment;
import com.playlet.system.service.IPublicDetailCommentService;
import com.playlet.common.core.controller.BaseController;
import com.playlet.common.core.domain.AjaxResult;
import com.playlet.common.utils.poi.ExcelUtil;
@ -44,6 +45,8 @@ public class PublicDetailCommentController extends BaseController
private IPlayletPublicDetailService publicDetailService;
@Autowired
private IPublicCommentResponseService publicCommentResponseService;
@Autowired
private IPlayletPublicAccountService playletPublicAccountService;
@RequiresPermissions("public:comment:view")
@GetMapping()
@ -60,6 +63,26 @@ public class PublicDetailCommentController extends BaseController
@ResponseBody
public TableDataInfo list(PublicDetailComment publicDetailComment)
{
if(!this.getSysUser().isAdmin()){
// 公众号
List<PlayletPublicAccount> accounts = playletPublicAccountService.lambdaQuery().select(PlayletPublicAccount::getId)
.eq(PlayletPublicAccount::getManagerId, this.getUserId())
.list();
if(CollectionUtil.isEmpty(accounts)){
return getDataTable(new ArrayList<>());
}
// 公众号列表
List<Long> ids = accounts.stream().map(PlayletPublicAccount::getId).collect(Collectors.toList());
// 文章列表
List<PlayletPublicDetail> publicDetails = publicDetailService.lambdaQuery().select(PlayletPublicDetail::getId)
.in(PlayletPublicDetail::getPublicId, ids).list();
//
if(CollectionUtil.isEmpty(publicDetails)){
return getDataTable(new ArrayList<>());
}
List<Long> detailIds = publicDetails.stream().map(PlayletPublicDetail::getId).collect(Collectors.toList());
publicDetailComment.setDetailIds(detailIds);
}
startPage();
List<PublicDetailComment> list = publicDetailCommentService.selectPublicDetailCommentList(publicDetailComment);
list.forEach(model->{

View File

@ -142,6 +142,19 @@ public class SysUserController extends BaseController
{
return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
}
// 校验部门是否填写
if(user.getDeptId() == null){
return error("新增用户'" + user.getLoginName() + "'失败,部门不能为空");
}
// 校验部门员工数量是否超了
SysDept dept = deptService.selectDeptById(user.getDeptId());
int limit = dept.getStaffLimit();
SysUser param = new SysUser();
param.setDeptId(dept.getDeptId());
List<SysUser> list = userService.selectUserList(param);
if(list.size() >= limit){
return error("新增用户'" + user.getLoginName() + "'失败,员工数量已达上限");
}
user.setSalt(ShiroUtils.randomSalt());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
user.setPwdUpdateDate(DateUtils.getNowDate());

View File

@ -2,8 +2,8 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="referrer" content="same-origin">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<title>麻雀系统首页</title>
<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">

View File

@ -22,6 +22,18 @@
<input class="form-control" type="text" name="deptName" id="deptName" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">使用账号数:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="staffLimit">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">公众号数量:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="publicAccountLimit">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">显示排序:</label>
<div class="col-sm-8">

View File

@ -71,7 +71,17 @@
title: '部门名称',
align: "left"
},
{
{
field: 'staffLimit',
title: '使用账号数',
align: "left"
},
{
field: 'publicAccountLimit',
title: '公众号数量',
align: "left"
},
{
field: 'orderNum',
title: '排序',
align: "left"

View File

@ -23,6 +23,18 @@
<input class="form-control" type="text" name="deptName" th:field="*{deptName}" id="deptName" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">使用账号数:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="staffLimit" th:field="*{staffLimit}" id="staffLimit" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">公众号数量:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="publicAccountLimit" th:field="*{publicAccountLimit}" id="publicAccountLimit" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">显示排序:</label>
<div class="col-sm-8">

View File

@ -2,6 +2,7 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<meta name="referrer" content="same-origin">
<th:block th:include="include :: header('新增公众号文章详情')" />
<th:block th:include="include :: summernote-css" />
<th:block th:include="include :: bootstrap-fileinput-css" />
@ -321,11 +322,19 @@
autoresize_min_height: 700, //编辑区域的最小高度
remove_trailing_brs: false,
branding: false, //tiny技术支持信息是否显示
extended_valid_elements: 'br',
plugins: ' preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media code codesample table charmap pagebreak nonbreaking anchor insertdatetime advlist lists wordcount autosave',
toolbar: 'fullscreen undo redo restoredraft | cut copy paste pastetext | forecolor backcolor bold italic underline strikethrough link anchor | alignleft aligncenter alignright alignjustify outdent indent | \
styleselect formatselect fontselect fontsizeselect | bullist numlist | blockquote subscript superscript removeformat | \
table image media charmap hr pagebreak insertdatetime preview | code selectall searchreplace visualblocks | indent2em lineheight formatpainter axupimgs',
toolbar_mode: 'wrap',
paste_retain_style_properties: "all",
paste_word_valid_elements: "*[*]", //word需要它
paste_convert_word_fake_lists: true, // 插入word文档需要该属性
paste_webkit_styles: "all",
paste_merge_formats: true,
nonbreaking_force_tab: false,
paste_auto_cleanup_on_paste: false,
paste_data_images: true, //图片是否可粘贴
images_upload_handler: (blobInfo) => {
return new Promise(async (resolve, reject) => {

View File

@ -2,6 +2,7 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<meta name="referrer" content="same-origin">
<th:block th:include="include :: header('修改公众号文章详情')" />
<th:block th:include="include :: summernote-css" />
<th:block th:include="include :: bootstrap-fileinput-css" />
@ -252,11 +253,20 @@
autoresize_min_height: 700, //编辑区域的最小高度
remove_trailing_brs: false,
branding: false, //tiny技术支持信息是否显示
extended_valid_elements: 'br',
plugins: ' preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media code codesample table charmap pagebreak nonbreaking anchor insertdatetime advlist lists wordcount autosave',
toolbar: 'fullscreen undo redo restoredraft | cut copy paste pastetext | forecolor backcolor bold italic underline strikethrough link anchor | alignleft aligncenter alignright alignjustify outdent indent | \
styleselect formatselect fontselect fontsizeselect | bullist numlist | blockquote subscript superscript removeformat | \
table image media charmap hr pagebreak insertdatetime preview | code selectall searchreplace visualblocks | indent2em lineheight formatpainter axupimgs',
toolbar_mode: 'wrap',
paste_retain_style_properties: "all",
paste_word_valid_elements: "*[*]", //word需要它
paste_convert_word_fake_lists: true, // 插入word文档需要该属性
paste_webkit_styles: "all",
paste_merge_formats: true,
nonbreaking_force_tab: false,
paste_auto_cleanup_on_paste: false,
paste_data_images: true, //图片是否可粘贴
paste_data_images: true, //图片是否可粘贴
images_upload_handler: (blobInfo) => {
return new Promise(async (resolve, reject) => {

View File

@ -54,6 +54,26 @@ public class SysDept extends BaseEntity
/** 排除编号 */
private Long excludeId;
private Integer staffLimit;
private Integer publicAccountLimit;
public Integer getStaffLimit() {
return staffLimit;
}
public void setStaffLimit(Integer staffLimit) {
this.staffLimit = staffLimit;
}
public Integer getPublicAccountLimit() {
return publicAccountLimit;
}
public void setPublicAccountLimit(Integer publicAccountLimit) {
this.publicAccountLimit = publicAccountLimit;
}
public Long getDeptId()
{
return deptId;
@ -198,6 +218,8 @@ public class SysDept extends BaseEntity
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("staffLimit", getStaffLimit())
.append("publicAccountLimit", getPublicAccountLimit())
.toString();
}
}

View File

@ -11,6 +11,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import com.playlet.common.annotation.Excel;
import java.util.List;
/**
* 公众号文章详情对象 playlet_public_detail
*
@ -38,6 +40,9 @@ public class PlayletPublicDetail extends BaseEntity
@ApiModelProperty(value = "公众号id")
private Long publicId;
@TableField(exist = false)
private List<Long> publicIds;
@TableField(exist = false)
private String publicName;

View File

@ -11,6 +11,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import com.playlet.common.annotation.Excel;
import java.util.List;
/**
* 文章评论对象 public_detail_comment
*
@ -34,6 +36,9 @@ public class PublicDetailComment extends BaseEntity
@ApiModelProperty(value = "文章id")
private Long detailId;
@TableField(exist = false)
private List<Long> detailIds;
@TableField(exist = false)
private String authorAlias;

View File

@ -32,6 +32,7 @@
<include refid="selectPlayletPublicAccountVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="managerId != null"> and manager_id = #{managerId}</if>
<if test="introduction != null and introduction != ''"> and introduction = #{introduction}</if>
<if test="authorAlias != null and authorAlias != ''"> and author_alias = #{authorAlias}</if>
<if test="logoUrl != null and logoUrl != ''"> and logo_url = #{logoUrl}</if>

View File

@ -57,6 +57,12 @@
<include refid="selectPlayletPublicDetailVoNoContent"/>
<where>
<if test="publicId != null "> and public_id = #{publicId}</if>
<if test="publicIds != null and publicIds.size() > 0">
and public_id in
<foreach item="item" collection="publicIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="type != null "> and type = #{type}</if>
<if test="readCount != null "> and read_count = #{readCount}</if>
<if test="topStatus != null "> and top_status = #{topStatus}</if>

View File

@ -27,6 +27,12 @@
<select id="selectPublicDetailCommentList" parameterType="PublicDetailComment" resultMap="PublicDetailCommentResult">
<include refid="selectPublicDetailCommentVo"/>
<where>
<if test="detailIds != null and detailIds.size() > 0">
and detail_id in
<foreach item="item" collection="detailIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="detailId != null "> and detail_id = #{detailId}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>

View File

@ -16,6 +16,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="parentName" column="parent_name" />
<result property="staffLimit" column="staff_limit" />
<result property="publicAccountLimit" column="public_account_limit" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
@ -23,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
select d.dept_id, d.staff_limit, d.public_account_limit, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
from sys_dept d
</sql>
@ -72,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,
select d.dept_id, d.parent_id, d.ancestors, d.staff_limit, d.public_account_limit, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
from sys_dept d
where d.dept_id = #{deptId}
@ -97,6 +99,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="phone != null and phone != ''">phone,</if>
<if test="email != null and email != ''">email,</if>
<if test="status != null">status,</if>
<if test="staffLimit != null">staff_limit,</if>
<if test="publicAccountLimit != null">public_account_limit,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
@ -109,6 +113,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="phone != null and phone != ''">#{phone},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if>
<if test="staffLimit != null">#{staffLimit},</if>
<if test="publicAccountLimit != null">#{publicAccountLimit},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
@ -125,6 +131,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="phone != null">phone = #{phone},</if>
<if test="email != null">email = #{email},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="staffLimit != null">staff_limit = #{staffLimit},</if>
<if test="publicAccountLimit != null">public_account_limit = #{publicAccountLimit},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>