Browse Source

修改公告移动端页面

lwx_dev
erdanergou 3 years ago
parent
commit
45a130a8b2
  1. 2
      src/main/java/com/dreamchaser/depository_manage/config/QyWxConfig.java
  2. 11
      src/main/java/com/dreamchaser/depository_manage/controller/NoticeController.java
  3. 11
      src/main/java/com/dreamchaser/depository_manage/controller/PageController.java
  4. 5
      src/main/java/com/dreamchaser/depository_manage/entity/Notice.java
  5. 18
      src/main/java/com/dreamchaser/depository_manage/mapper/NoticeMapper.java
  6. 81
      src/main/java/com/dreamchaser/depository_manage/mapper/NoticeMapper.xml
  7. 6
      src/main/java/com/dreamchaser/depository_manage/pojo/NoticeP.java
  8. 25
      src/main/java/com/dreamchaser/depository_manage/service/NoticeService.java
  9. 2
      src/main/java/com/dreamchaser/depository_manage/service/impl/CompanyServiceImpl.java
  10. 139
      src/main/java/com/dreamchaser/depository_manage/service/impl/NoticeServiceImpl.java
  11. 199
      src/main/resources/templates/pages/notice/notice-out_mobile.html
  12. 197
      src/main/resources/templates/pages/notice/notice-out_user_mobile.html
  13. 33
      src/main/resources/templates/pages/other/welcome_mobile.html
  14. 81
      target/classes/com/dreamchaser/depository_manage/mapper/NoticeMapper.xml
  15. 33
      target/classes/templates/pages/other/welcome_mobile.html

2
src/main/java/com/dreamchaser/depository_manage/config/QyWxConfig.java

@ -251,7 +251,7 @@ public class QyWxConfig {
public static List<String> getQyWxDepartmentUserList(String UserAgent, Integer id) { public static List<String> getQyWxDepartmentUserList(String UserAgent, Integer id) {
String tempToken = GetQYWXToken(UserAgent); String tempToken = GetQYWXToken(UserAgent);
String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?access_token=%s&department_id=%s", tempToken, id); String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?access_token=%s&department_id=%s&fetch_child=1", tempToken, id);
String get = HttpUtils.doGet(url); String get = HttpUtils.doGet(url);
JSONObject jsonObject = JSONObject.parseObject(get); JSONObject jsonObject = JSONObject.parseObject(get);
Integer errcode = jsonObject.getInteger("errcode"); Integer errcode = jsonObject.getInteger("errcode");

11
src/main/java/com/dreamchaser/depository_manage/controller/NoticeController.java

@ -73,7 +73,7 @@ public class NoticeController {
String header = request.getHeader("user-agent"); String header = request.getHeader("user-agent");
String crypt = Md5.crypt(header); String crypt = Md5.crypt(header);
map.put("userAgent", crypt); map.put("userAgent", crypt);
List<NoticeP> noticeByCondition = noticeService.findNoticeByCondition(map, userToken); List<NoticeP> noticeByCondition = noticeService.findAllNoticeForUser(map, userToken);
return new RestResponse(noticeByCondition); return new RestResponse(noticeByCondition);
} }
@ -92,6 +92,15 @@ public class NoticeController {
} }
} }
@PostMapping("/readNoticeForUser")
public void readNoticeForUser(@RequestBody Map<String,Object> map,HttpServletRequest request){
if(map.containsKey("id")){
noticeService.readNoticeForUser(map);
}else{
throw new MyException("缺少必要参数");
}
}
// 用于修改公告信息 // 用于修改公告信息
@PostMapping("/noticeEdit") @PostMapping("/noticeEdit")

11
src/main/java/com/dreamchaser/depository_manage/controller/PageController.java

@ -188,6 +188,8 @@ public class PageController {
List<SimpleTaskP> list = getUserSimpleTaskP(userToken); List<SimpleTaskP> list = getUserSimpleTaskP(userToken);
mv.addObject("myTaskList", list); mv.addObject("myTaskList", list);
if (b) { if (b) {
List<NoticeP> noticeByUnRead = noticeService.findNoticeByUnRead(userToken);
mv.addObject("notices", noticeByUnRead);
mv.setViewName("pages/other/welcome_mobile"); mv.setViewName("pages/other/welcome_mobile");
} else { } else {
mv.setViewName("pages/other/welcome"); mv.setViewName("pages/other/welcome");
@ -3075,6 +3077,12 @@ public class PageController {
public ModelAndView noticeAll(HttpServletRequest request) { public ModelAndView noticeAll(HttpServletRequest request) {
ModelAndView mv = new ModelAndView(); ModelAndView mv = new ModelAndView();
mv.setViewName("pages/notice/notice-out_user"); mv.setViewName("pages/notice/notice-out_user");
String userAgent = request.getHeader("user-agent");
// 判断当前使用的设备为移动端还是pc端
boolean b = DeviceUtil.checkAgentIsMobile(userAgent);
if (b) {
mv.setViewName("pages/notice/notice-out_user_mobile");
}
String token = request.getHeader("user-token"); String token = request.getHeader("user-token");
if (token == null) { if (token == null) {
token = (String) request.getSession().getAttribute("userToken"); token = (String) request.getSession().getAttribute("userToken");
@ -3087,6 +3095,9 @@ public class PageController {
} }
if (role == 4) { if (role == 4) {
mv.setViewName("pages/notice/notice-out"); mv.setViewName("pages/notice/notice-out");
if (b) {
mv.setViewName("pages/notice/notice-out_mobile");
}
} }
return mv; return mv;
} }

5
src/main/java/com/dreamchaser/depository_manage/entity/Notice.java

@ -33,6 +33,11 @@ public class Notice implements java.io.Serializable {
*/ */
private Integer userId; private Integer userId;
/**
* 读取公告id
*/
private Integer readId;
/** /**
* 公告状态 * 公告状态
*/ */

18
src/main/java/com/dreamchaser/depository_manage/mapper/NoticeMapper.java

@ -1,6 +1,8 @@
package com.dreamchaser.depository_manage.mapper; package com.dreamchaser.depository_manage.mapper;
import com.dreamchaser.depository_manage.entity.Notice; import com.dreamchaser.depository_manage.entity.Notice;
import com.dreamchaser.depository_manage.entity.UserByPort;
import com.dreamchaser.depository_manage.pojo.NoticeP;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.aspectj.weaver.ast.Not; import org.aspectj.weaver.ast.Not;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -59,6 +61,22 @@ public interface NoticeMapper {
List<Notice> findNoticeByCondition(Map<String,Object> map); List<Notice> findNoticeByCondition(Map<String,Object> map);
/**
* 根据条件查询符合条件的公告信息
* @param map 参数map
* @return 符合条件的公告列表
*/
List<Notice> findNoticeByUser(Map<String,Object> map);
/**
* 将该公告设置为已读状态
* @param map 待修改数据
* @return
*/
Integer readNoticeForUser(Map<String,Object> map);
/** /**
* 根据主键删除公告 * 根据主键删除公告
* @param id 待删除公告id * @param id 待删除公告id

81
src/main/java/com/dreamchaser/depository_manage/mapper/NoticeMapper.xml

@ -13,6 +13,7 @@
<result column="time" property="time" jdbcType="INTEGER" /> <result column="time" property="time" jdbcType="INTEGER" />
<result column="state" property="state" jdbcType="INTEGER" /> <result column="state" property="state" jdbcType="INTEGER" />
<result column="userId" property="userId" jdbcType="INTEGER" /> <result column="userId" property="userId" jdbcType="INTEGER" />
<result column="readId" property="readId" jdbcType="INTEGER" />
</resultMap> </resultMap>
<!-- 表查询字段 --> <!-- 表查询字段 -->
@ -20,6 +21,10 @@
n.id, n.title, n.content, n.time,n.state,n.userId,n.viewRangeId n.id, n.title, n.content, n.time,n.state,n.userId,n.viewRangeId
</sql> </sql>
<sql id="allColumnsForView">
id,title,content,time,userId,state,viewRangeId,uid,readState,readTime,readId
</sql>
<!-- 查询所有 --> <!-- 查询所有 -->
<select id="findNoticeAll" resultMap="noticeMap"> <select id="findNoticeAll" resultMap="noticeMap">
SELECT SELECT
@ -56,6 +61,40 @@
</if> </if>
</select> </select>
<select id="findNoticeByUser" resultMap="noticeMap" parameterType="map">
select
<include refid="allColumnsForView"/>
from noticeInfo
where 1 = 1
<if test="title != null and title != ''">
AND title LIKE CONCAT('%', #{title}, '%')
</if>
<if test="content != null and content != ''">
AND content LIKE CONCAT('%', #{content}, '%')
</if>
<if test="startDate != null and startDate != ''">
AND time &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
AND time &lt;= #{endDate}
</if>
<if test="userId != null and userId != ''">
and uid = #{userId}
</if>
<if test="state != null and state != ''">
and state = #{state}
</if>
<if test="readState != null and readState != ''">
and readState = #{readState}
</if>
order by time DESC
<if test="begin != null and size != null">
LIMIT #{begin},#{size}
</if>
</select>
<select id="findNoticeById" resultMap="noticeMap" parameterType="int"> <select id="findNoticeById" resultMap="noticeMap" parameterType="int">
SELECT SELECT
<include refid="allColumns" /> <include refid="allColumns" />
@ -86,6 +125,25 @@
) )
</insert> </insert>
<insert id="addNoticeRead">
INSERT INTO noticeread (
id, nid, uid,state,readTime
)
values
<foreach collection="list" index="index" item="item" separator=",">
(
#{id},
#{nid},
#{item},
#{state},
#{readTime}
)
</foreach>
</insert>
<!-- 批量新增信息 --> <!-- 批量新增信息 -->
@ -130,6 +188,29 @@
where id = #{id} where id = #{id}
</update> </update>
<update id="readNoticeForUser">
update noticeread
<set>
<if test="nid != null and nid != ''">
nid = #{nid},
</if>
<if test="state != '' and state != null">
state = #{state},
</if>
<if test="uid != null and uid != ''">
uid = #{uid},
</if>
<if test="state != null and state != ''">
state = #{state},
</if>
<if test="readTime != null and readTime != ''">
readTime = #{readTime}
</if>
</set>
where id = #{id}
</update>
<!-- 批量修改信息 --> <!-- 批量修改信息 -->
<update id="updateNotices" parameterType="list"> <update id="updateNotices" parameterType="list">
<foreach collection="list" index="index" item="item" separator=";"> <foreach collection="list" index="index" item="item" separator=";">

6
src/main/java/com/dreamchaser/depository_manage/pojo/NoticeP.java

@ -43,6 +43,11 @@ public class NoticeP {
*/ */
private String viewRangeName; private String viewRangeName;
/**
* 读取公告id
*/
private Integer readId;
public NoticeP(Notice notice) { public NoticeP(Notice notice) {
this.id = notice.getId(); this.id = notice.getId();
@ -52,5 +57,6 @@ public class NoticeP {
this.userId = notice.getUserId(); this.userId = notice.getUserId();
this.state = notice.getState(); this.state = notice.getState();
this.viewRangeId = notice.getViewRangeId(); this.viewRangeId = notice.getViewRangeId();
this.readId = notice.getReadId();
} }
} }

25
src/main/java/com/dreamchaser/depository_manage/service/NoticeService.java

@ -25,6 +25,23 @@ public interface NoticeService {
*/ */
List<NoticeP> findNoticeByCondition(Map<String,Object> map, UserByPort userByPort); List<NoticeP> findNoticeByCondition(Map<String,Object> map, UserByPort userByPort);
/**
* 根据条件查询符合条件的用户可见的公告信息
* @param map 参数map
* @return 符合条件的公告列表
*/
List<NoticeP> findAllNoticeForUser(Map<String,Object> map, UserByPort userByPort);
/**
* 查询当前用户未读取的公告
* @param userByPort
* @return
*/
List<NoticeP> findNoticeByUnRead(UserByPort userByPort);
/** /**
* 根据主键id获取公告信息 * 根据主键id获取公告信息
* @param id 待查询id * @param id 待查询id
@ -74,4 +91,12 @@ public interface NoticeService {
* @return * @return
*/ */
Integer updateNoticeState(Map<String,Object> map); Integer updateNoticeState(Map<String,Object> map);
/**
* 将该公告设置为已读状态
* @param
* @return
*/
Integer readNoticeForUser(Map<String,Object> map);
} }

2
src/main/java/com/dreamchaser/depository_manage/service/impl/CompanyServiceImpl.java

@ -197,7 +197,7 @@ public class CompanyServiceImpl implements CompanyService {
@Override @Override
public List<Object> BuildQyWxAdministrationTreeMenus(UserByPort userByPort,String UserAgent) { public List<Object> BuildQyWxAdministrationTreeMenus(UserByPort userByPort,String UserAgent) {
// 获取所有企业微信的部门列表 // 获取所有企业微信的部门列表
List<qywxDepartment> qyWxDepartmentListAll = QyWxConfig.getQyWxDepartmentList(UserAgent, 3); List<qywxDepartment> qyWxDepartmentListAll = QyWxConfig.getQyWxDepartmentList(UserAgent, 51);
// 设置用于开启线程的部门列表 // 设置用于开启线程的部门列表
List<qywxDepartment> qyWxDepartmentList = new ArrayList<>(); List<qywxDepartment> qyWxDepartmentList = new ArrayList<>();

139
src/main/java/com/dreamchaser/depository_manage/service/impl/NoticeServiceImpl.java

@ -35,14 +35,24 @@ public class NoticeServiceImpl implements NoticeService {
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public Integer addNotice(Map<String, Object> map,String userAgent) { public Integer addNotice(Map<String, Object> map, String userAgent) {
// 设置当前时间 // 设置当前时间
map.put("time", System.currentTimeMillis()); map.put("time", System.currentTimeMillis());
Integer integer = noticeMapper.addNotice(map); Integer integer = noticeMapper.addNotice(map);
Integer viewRangeId = ObjectFormatUtil.toInteger(map.get("viewRangeId")); String viewRangeIdString = (String) map.get("viewRangeId");
List<String> qyWxDepartmentUserList = QyWxConfig.getQyWxDepartmentUserList(userAgent, viewRangeId); String[] split = viewRangeIdString.split(",");
Map<String, Object> param = new HashMap<>(); List<String> list = new ArrayList<>();
for (int i = 0; i < split.length; i++) {
Integer viewRangeId = ObjectFormatUtil.toInteger(split[i]);
List<String> qyWxDepartmentUserList = QyWxConfig.getQyWxDepartmentUserList(userAgent, viewRangeId);
list.addAll(qyWxDepartmentUserList);
}
Map<String, Object> param = new HashMap<>();
param.put("nid", map.get("id"));
param.put("list", list);
param.put("state", 2);
noticeMapper.addNoticeRead(param);
return integer; return integer;
} }
@ -55,14 +65,14 @@ public class NoticeServiceImpl implements NoticeService {
@Override @Override
public List<NoticeP> findNoticeByCondition(Map<String, Object> map, UserByPort userByPort) { public List<NoticeP> findNoticeByCondition(Map<String, Object> map, UserByPort userByPort) {
Integer size = 10,page=1; Integer size = 10, page = 1;
if (map.containsKey("size")){ if (map.containsKey("size")) {
size= ObjectFormatUtil.toInteger(map.get("size")); size = ObjectFormatUtil.toInteger(map.get("size"));
map.put("size", size); map.put("size", size);
} }
if (map.containsKey("page")){ if (map.containsKey("page")) {
page=ObjectFormatUtil.toInteger(map.get("page")); page = ObjectFormatUtil.toInteger(map.get("page"));
map.put("begin",(page-1)*size); map.put("begin", (page - 1) * size);
} }
if (map.containsKey("startDate")) { if (map.containsKey("startDate")) {
@ -76,10 +86,10 @@ public class NoticeServiceImpl implements NoticeService {
} }
Object state = 1; Object state = 1;
if(map.containsKey("state")){ if (map.containsKey("state")) {
state = map.get("state"); state = map.get("state");
} }
map.put("state",state); map.put("state", state);
List<Notice> notice = noticeMapper.findNoticeByCondition(map); List<Notice> notice = noticeMapper.findNoticeByCondition(map);
List<NoticeP> result = new ArrayList<>(); List<NoticeP> result = new ArrayList<>();
String userAgent = (String) map.get("userAgent"); String userAgent = (String) map.get("userAgent");
@ -108,6 +118,82 @@ public class NoticeServiceImpl implements NoticeService {
return result; return result;
} }
/**
* 根据条件查询符合条件的用户可见的公告信息
*
* @param map 参数map
* @return 符合条件的公告列表
*/
@Override
public List<NoticeP> findAllNoticeForUser(Map<String, Object> map, UserByPort userByPort) {
Integer size = 10, page = 1;
if (map.containsKey("size")) {
size = ObjectFormatUtil.toInteger(map.get("size"));
map.put("size", size);
}
if (map.containsKey("page")) {
page = ObjectFormatUtil.toInteger(map.get("page"));
map.put("begin", (page - 1) * size);
}
if (map.containsKey("startDate")) {
String startDate = (String) map.get("startDate");
map.put("startDate", DateUtil.DateTimeByMonthToTimeStamp(startDate));
}
if (map.containsKey("endDate")) {
String endDate = (String) map.get("endDate");
map.put("endDate", DateUtil.DateTimeByMonthToTimeStamp(endDate));
}
Object state = 1;
if (map.containsKey("state")) {
state = map.get("state");
}
map.put("state", state);
String workwechat = userByPort.getWorkwechat();
if (workwechat == null || "".equals(workwechat)) {
workwechat = userByPort.getWechat();
}
map.put("userId", workwechat);
List<Notice> notice = noticeMapper.findNoticeByUser(map);
List<NoticeP> result = new ArrayList<>();
for (Notice value : notice) {
UserByPort user = LinkInterfaceUtil.FindUserById(value.getUserId(), null);
NoticeP np = new NoticeP(value);
np.setUserName(user.getName());
result.add(np);
}
return result;
}
/**
* 查询当前用户未读取的公告
*
* @param userByPort
* @return
*/
@Override
public List<NoticeP> findNoticeByUnRead(UserByPort userByPort) {
Map<String, Object> map = new HashMap<>();
String workwechat = userByPort.getWorkwechat();
if (workwechat == null || "".equals(workwechat)) {
workwechat = userByPort.getWechat();
}
map.put("userId", workwechat);
map.put("readState", 2);
List<Notice> noticeByUser = noticeMapper.findNoticeByUser(map);
List<NoticeP> result = new ArrayList<>();
for (Notice value : noticeByUser) {
UserByPort user = LinkInterfaceUtil.FindUserById(value.getUserId(), null);
// 获取可见范围的
NoticeP np = new NoticeP(value);
np.setUserName(user.getName());
result.add(np);
}
return result;
}
/** /**
* 根据主键id获取公告信息 * 根据主键id获取公告信息
@ -128,18 +214,20 @@ public class NoticeServiceImpl implements NoticeService {
/** /**
* 用于修改公告信息 * 用于修改公告信息
*
* @param map 参数map * @param map 参数map
* @return * @return
*/ */
@Override @Override
public Integer updateNotice(Map<String, Object> map) { public Integer updateNotice(Map<String, Object> map) {
map.put("time",System.currentTimeMillis()); map.put("time", System.currentTimeMillis());
return noticeMapper.updateNotice(map); return noticeMapper.updateNotice(map);
} }
/** /**
* 用于根据主键删除公告信息软删除 * 用于根据主键删除公告信息软删除
*
* @param id 待删除主键 * @param id 待删除主键
* @return * @return
*/ */
@ -155,14 +243,15 @@ public class NoticeServiceImpl implements NoticeService {
/** /**
* 用于根据主键批量删除公告信息软删除 * 用于根据主键批量删除公告信息软删除
*
* @param ids 待删除主键列表 * @param ids 待删除主键列表
* @return * @return
*/ */
@Override @Override
public Integer delNoticeForSoftByIds(List<Integer> ids) { public Integer delNoticeForSoftByIds(List<Integer> ids) {
List<Notice> noticeByIds = noticeMapper.findNoticeByIds(ids); List<Notice> noticeByIds = noticeMapper.findNoticeByIds(ids);
for (Notice n:noticeByIds for (Notice n : noticeByIds
) { ) {
n.setState(3); n.setState(3);
} }
return noticeMapper.updateNotices(noticeByIds); return noticeMapper.updateNotices(noticeByIds);
@ -170,6 +259,7 @@ public class NoticeServiceImpl implements NoticeService {
/** /**
* 用于根据主键删除公告信息 * 用于根据主键删除公告信息
*
* @param id 待删除主键 * @param id 待删除主键
* @return * @return
*/ */
@ -180,6 +270,7 @@ public class NoticeServiceImpl implements NoticeService {
/** /**
* 用于根据主键批量删除公告信息 * 用于根据主键批量删除公告信息
*
* @param ids 待删除主键id列表 * @param ids 待删除主键id列表
* @return * @return
*/ */
@ -190,6 +281,7 @@ public class NoticeServiceImpl implements NoticeService {
/** /**
* 用于修改公告状态 * 用于修改公告状态
*
* @param map 待修改条件 * @param map 待修改条件
* @return * @return
*/ */
@ -198,11 +290,24 @@ public class NoticeServiceImpl implements NoticeService {
Integer id = ObjectFormatUtil.toInteger(map.get("id")); Integer id = ObjectFormatUtil.toInteger(map.get("id"));
// 获取当前主键对应的公告信息 // 获取当前主键对应的公告信息
Notice noticeById = noticeMapper.findNoticeById(id); Notice noticeById = noticeMapper.findNoticeById(id);
if(map.containsKey("state")){ if (map.containsKey("state")) {
noticeById.setState(1); noticeById.setState(1);
}else{ } else {
noticeById.setState(2); noticeById.setState(2);
} }
return noticeMapper.updateNotice(noticeById); return noticeMapper.updateNotice(noticeById);
} }
/**
* 将该公告设置为已读状态
*
* @param
* @return
*/
@Override
public Integer readNoticeForUser(Map<String, Object> map) {
map.put("state", 1);
map.put("readTime", System.currentTimeMillis());
return noticeMapper.readNoticeForUser(map);
}
} }

199
src/main/resources/templates/pages/notice/notice-out_mobile.html

@ -0,0 +1,199 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>layui</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all">
<link rel="stylesheet" href="/static/css/public.css" media="all">
<link rel="stylesheet" href="/static/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
</head>
<body>
<div class="layuimini-container">
<div class="layuimini-main">
<div class="layui-collapse">
<div class="layui-colla-item">
<h2 class="layui-colla-title">搜索</h2>
<div class="layui-colla-content">
<div style="margin: 10px 10px 10px 10px">
<form class="layui-form layui-form-pane" action="">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">标题</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" id="title" name="title"
autocomplete="off"/>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">发布日期</label>
<div class="layui-input-inline">
<input type="text" name="startDate" id="startDate" placeholder="请选择开始日期"
autocomplete="off" class="layui-input">
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="endDate" id="endDate" placeholder="请选择开始日期"
autocomplete="off"
class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">状态</label>
<div class="layui-input-inline">
<select name="state">
<option value="">请选择状态</option>
<option value="1">启用</option>
<option value="2">禁用</option>
</select>
</div>
</div>
<div class="layui-inline">
<button type="submit" class="layui-btn layui-btn-primary" lay-submit
lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<ul class="flow-default" id="LAY_notice"></ul>
</div>
</div>
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
layui.use(['form', 'flow', 'laydate'], function () {
var $ = layui.jquery,
form = layui.form,
laydate = layui.laydate,
flow = layui.flow;
let takingPre = 0;
let size = 8;
laydate.render({
elem: '#startDate'
});
laydate.render({
elem: '#endDate'
});
flow.load({
elem: '#LAY_notice' //流加载容器
, done: function (page, next) { //执行下一页的回调
let result;
let lis = [];
$.get('/notice/findAllNotices?page=' + page + '&size=' + size, function (res) {
result = res.data;
lis.push("<div class='clearfix'>");
for (let i = 0; i < result.length; i++) {
lis.push('<li style="width:100%;margin-top: 10px;float:left;border: 1px solid #9999996e;"><div class="layui-card my-shadow my-card flow1" onclick="showDetail('
+ result[i].id + ')"><div class="layui-card-header"><h2>' + "标题:"+result[i].title + '</h2></div>');
lis.push('<div class="layui-col-md4 my-info" style="margin-left: 15px; color: #999;font-size: 15px;">'
+ '<p>' + "内容:"+result[i].content + '</p>'
+ '<p>' +"发布人:"+ result[i].userName + '</p>'
+ '</div></div></li>');
}
lis.push('</div>');
takingPre += result.length;
//执行下一页渲染,第二参数为:满足“加载更多”的条件,即后面仍有分页
//pages为Ajax返回的总页数,只有当前页小于总页数的情况下,才会继续出现加载更多
next(lis.join(''), takingPre < res.count);
});
}
});
updateFlow = function (req) {
$("#LAY_material").empty();
takingPre = 0;
flow.load({
elem: '#LAY_material' //流加载容器
, done: function (page, next) { //执行下一页的回调
let result;
let lis = [];
req.page = page;
req.size = size;
$.ajax({
url: "/material/material",
type: "get",
data: req,
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (res) {
result = res.data;
lis.push("<div class='clearfix'>");
for (let i = 0; i < result.length; i++) {
lis.push('<li style="width:100%;margin-top: 10px;float:left;border: 1px solid #9999996e;"><div class="layui-card my-shadow my-card flow1" onclick="showDetail('
+ result[i].id + ')"><div class="layui-card-header"><h2>' + "标题:"+result[i].title + '</h2></div>');
lis.push('<div class="layui-col-md4 my-info" style="margin-left: 15px; color: #999;font-size: 15px;">'
+ '<p>' + "内容:"+result[i].content + '</p>'
+ '<p>' +"发布人:"+ result[i].userName + '</p>'
+ '</div></div></li>');
}
lis.push('</div>');
takingPre += result.length;
//执行下一页渲染,第二参数为:满足“加载更多”的条件,即后面仍有分页
//pages为Ajax返回的总页数,只有当前页小于总页数的情况下,才会继续出现加载更多
next(lis.join(''), takingPre < res.count);
}
});
}
});
};
// 监听搜索操作
form.on('submit(data-search-btn)', function (data) {
var req = {};
data = data.field;
req.type = 1;
if (data.title !== '') {
req.title = data.title;
}
if (data.state !== '') {
req.state = data.state;
}
if (data.startDate !== '') {
req.startDate = data.startDate;
}
if (data.endDate !== '') {
req.endDate = data.endDate;
}
//执行搜索重载
updateFlow(req);
return false;
});
showDetail = function(data){
let req = {};
var index = layer.open({
title: '公告详情',
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: true,
area: ['100%', '100%'],
content: '/noticeView?id=' + data,
});
$(window).on("resize", function () {
layer.full(index);
});
return false;
}
})
</script>
</body>
</html>

197
src/main/resources/templates/pages/notice/notice-out_user_mobile.html

@ -0,0 +1,197 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>layui</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all">
<link rel="stylesheet" href="/static/css/public.css" media="all">
<link rel="stylesheet" href="/static/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
</head>
<body>
<div class="layuimini-container">
<div class="layuimini-main">
<div class="layui-collapse">
<div class="layui-colla-item">
<h2 class="layui-colla-title">搜索</h2>
<div class="layui-colla-content">
<div style="margin: 10px 10px 10px 10px">
<form class="layui-form layui-form-pane" action="">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">标题</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" id="title" name="title"
autocomplete="off"/>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">发布日期</label>
<div class="layui-input-inline">
<input type="text" name="startDate" id="startDate" placeholder="请选择开始日期"
autocomplete="off" class="layui-input">
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="endDate" id="endDate" placeholder="请选择开始日期"
autocomplete="off"
class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">状态</label>
<div class="layui-input-inline">
<select name="state">
<option value="">请选择状态</option>
<option value="1">启用</option>
<option value="2">禁用</option>
</select>
</div>
</div>
<div class="layui-inline">
<button type="submit" class="layui-btn layui-btn-primary" lay-submit
lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<ul class="flow-default" id="LAY_notice"></ul>
</div>
</div>
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
layui.use(['form', 'flow', 'laydate'], function () {
var $ = layui.jquery,
form = layui.form,
laydate = layui.laydate,
flow = layui.flow;
let takingPre = 0;
let size = 8;
laydate.render({
elem: '#startDate'
});
laydate.render({
elem: '#endDate'
});
flow.load({
elem: '#LAY_notice' //流加载容器
, done: function (page, next) { //执行下一页的回调
let result;
let lis = [];
$.get('/notice/findAllNotices?page=' + page + '&size=' + size, function (res) {
result = res.data;
lis.push("<div class='clearfix'>");
for (let i = 0; i < result.length; i++) {
lis.push('<li style="width:100%;margin-top: 10px;float:left;border: 1px solid #9999996e;"><div class="layui-card my-shadow my-card flow1" onclick="showDetail('
+ result[i].id + ')"><div class="layui-card-header"><h2>' + "标题:"+result[i].title + '</h2></div>');
lis.push('<div class="layui-col-md4 my-info" style="margin-left: 15px; color: #999;font-size: 15px;">'
+ '<p>' + "内容:"+result[i].content + '</p>'
+ '<p>' +"发布人:"+ result[i].userName + '</p>'
+ '</div></div></li>');
}
lis.push('</div>');
takingPre += result.length;
//执行下一页渲染,第二参数为:满足“加载更多”的条件,即后面仍有分页
//pages为Ajax返回的总页数,只有当前页小于总页数的情况下,才会继续出现加载更多
next(lis.join(''), takingPre < res.count);
});
}
});
// 监听搜索操作
form.on('submit(data-search-btn)', function (data) {
var req = {};
data = data.field;
req.type = 1;
if (data.title !== '') {
req.title = data.title;
}
if (data.state !== '') {
req.state = data.state;
}
if (data.startDate !== '') {
req.startDate = data.startDate;
}
if (data.endDate !== '') {
req.endDate = data.endDate;
}
updateFlow();
return false;
});
updateFlow = function (req) {
$("#LAY_material").empty();
takingPre = 0;
flow.load({
elem: '#LAY_material' //流加载容器
, done: function (page, next) { //执行下一页的回调
let result;
let lis = [];
req.page = page;
req.size = size;
$.ajax({
url: "/material/material",
type: "get",
data: req,
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (res) {
result = res.data;
lis.push("<div class='clearfix'>");
for (let i = 0; i < result.length; i++) {
lis.push('<li style="width:100%;margin-top: 10px;float:left;border: 1px solid #9999996e;"><div class="layui-card my-shadow my-card flow1" onclick="showDetail('
+ result[i].id + ')"><div class="layui-card-header"><h2>' + "标题:"+result[i].title + '</h2></div>');
lis.push('<div class="layui-col-md4 my-info" style="margin-left: 15px; color: #999;font-size: 15px;">'
+ '<p>' + "内容:"+result[i].content + '</p>'
+ '<p>' +"发布人:"+ result[i].userName + '</p>'
+ '</div></div></li>');
}
lis.push('</div>');
takingPre += result.length;
//执行下一页渲染,第二参数为:满足“加载更多”的条件,即后面仍有分页
//pages为Ajax返回的总页数,只有当前页小于总页数的情况下,才会继续出现加载更多
next(lis.join(''), takingPre < res.count);
}
});
}
});
};
showDetail = function(data){
let req = {};
var index = layer.open({
title: '公告详情',
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: true,
area: ['100%', '100%'],
content: '/noticeView?id=' + data,
});
$(window).on("resize", function () {
layer.full(index);
});
return false;
}
});
</script>
</body>
</html>

33
src/main/resources/templates/pages/other/welcome_mobile.html

@ -170,6 +170,27 @@
</div> </div>
</div> </div>
</div> </div>
<div class="layui-col-md4">
<div class="layui-card">
<div class="layui-card-header">
<i class="fa fa-bullhorn icon icon-tip"></i>系统公告
<i class="fa fa-chevron-right" aria-hidden="true" style="right: 7px;top: 13px;position: absolute;" onclick="showAllNotice()"></i>
</div>
<div class="layui-card-body layui-text">
<div class="layuimini-notice" th:each="notice,iterStat:${notices}">
<input id="noticeId" style="display:none;" th:value="${notice.getId()}"/>
<input id="readId" style="display:none;" th:value="${notice.getReadId()}"/>
<div class="layuimini-notice-title" th:text="${notice.getTitle()}">修改选项卡样式</div>
<div class="layuimini-notice-extra" th:text="${notice.getTime()}">2019-07-11 23:06</div>
<div class="layuimini-notice-content layui-hide" th:text="${notice.getContent()}">
</div>
</div>
</div>
</div>
</div>
<div class="layui-col-md8"> <div class="layui-col-md8">
<div class="layui-row layui-col-space15"> <div class="layui-row layui-col-space15">
@ -352,12 +373,19 @@
area: '300px;', area: '300px;',
shade: 0.8, shade: 0.8,
id: 'layuimini-notice', id: 'layuimini-notice',
btn: ['查看', '取消'], btn: ['详情', '取消'],
btnAlign: 'c', btnAlign: 'c',
moveType: 1, moveType: 1,
content: html, content: html,
success: function (layero) { success: function (layero) {
var btn = layero.find('.layui-layer-btn'); var btn = layero.find('.layui-layer-btn');
$.ajax({
url:"/notice/readNoticeForUser",
type:"post",
dataType: 'json',
contentType: "application/json;charset=utf-8",
data:JSON.stringify({"id":$("#readId").val()})
});
btn.find('.layui-layer-btn0').click(function () { btn.find('.layui-layer-btn0').click(function () {
layer.open({ layer.open({
type: 2, type: 2,
@ -373,6 +401,9 @@
} }
); );
},
end:function() {
location.reload()
} }
}); });
}); });

81
target/classes/com/dreamchaser/depository_manage/mapper/NoticeMapper.xml

@ -13,6 +13,7 @@
<result column="time" property="time" jdbcType="INTEGER" /> <result column="time" property="time" jdbcType="INTEGER" />
<result column="state" property="state" jdbcType="INTEGER" /> <result column="state" property="state" jdbcType="INTEGER" />
<result column="userId" property="userId" jdbcType="INTEGER" /> <result column="userId" property="userId" jdbcType="INTEGER" />
<result column="readId" property="readId" jdbcType="INTEGER" />
</resultMap> </resultMap>
<!-- 表查询字段 --> <!-- 表查询字段 -->
@ -20,6 +21,10 @@
n.id, n.title, n.content, n.time,n.state,n.userId,n.viewRangeId n.id, n.title, n.content, n.time,n.state,n.userId,n.viewRangeId
</sql> </sql>
<sql id="allColumnsForView">
id,title,content,time,userId,state,viewRangeId,uid,readState,readTime,readId
</sql>
<!-- 查询所有 --> <!-- 查询所有 -->
<select id="findNoticeAll" resultMap="noticeMap"> <select id="findNoticeAll" resultMap="noticeMap">
SELECT SELECT
@ -56,6 +61,40 @@
</if> </if>
</select> </select>
<select id="findNoticeByUser" resultMap="noticeMap" parameterType="map">
select
<include refid="allColumnsForView"/>
from noticeInfo
where 1 = 1
<if test="title != null and title != ''">
AND title LIKE CONCAT('%', #{title}, '%')
</if>
<if test="content != null and content != ''">
AND content LIKE CONCAT('%', #{content}, '%')
</if>
<if test="startDate != null and startDate != ''">
AND time &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
AND time &lt;= #{endDate}
</if>
<if test="userId != null and userId != ''">
and uid = #{userId}
</if>
<if test="state != null and state != ''">
and state = #{state}
</if>
<if test="readState != null and readState != ''">
and readState = #{readState}
</if>
order by time DESC
<if test="begin != null and size != null">
LIMIT #{begin},#{size}
</if>
</select>
<select id="findNoticeById" resultMap="noticeMap" parameterType="int"> <select id="findNoticeById" resultMap="noticeMap" parameterType="int">
SELECT SELECT
<include refid="allColumns" /> <include refid="allColumns" />
@ -86,6 +125,25 @@
) )
</insert> </insert>
<insert id="addNoticeRead">
INSERT INTO noticeread (
id, nid, uid,state,readTime
)
values
<foreach collection="list" index="index" item="item" separator=",">
(
#{id},
#{nid},
#{item},
#{state},
#{readTime}
)
</foreach>
</insert>
<!-- 批量新增信息 --> <!-- 批量新增信息 -->
@ -130,6 +188,29 @@
where id = #{id} where id = #{id}
</update> </update>
<update id="readNoticeForUser">
update noticeread
<set>
<if test="nid != null and nid != ''">
nid = #{nid},
</if>
<if test="state != '' and state != null">
state = #{state},
</if>
<if test="uid != null and uid != ''">
uid = #{uid},
</if>
<if test="state != null and state != ''">
state = #{state},
</if>
<if test="readTime != null and readTime != ''">
readTime = #{readTime}
</if>
</set>
where id = #{id}
</update>
<!-- 批量修改信息 --> <!-- 批量修改信息 -->
<update id="updateNotices" parameterType="list"> <update id="updateNotices" parameterType="list">
<foreach collection="list" index="index" item="item" separator=";"> <foreach collection="list" index="index" item="item" separator=";">

33
target/classes/templates/pages/other/welcome_mobile.html

@ -170,6 +170,27 @@
</div> </div>
</div> </div>
</div> </div>
<div class="layui-col-md4">
<div class="layui-card">
<div class="layui-card-header">
<i class="fa fa-bullhorn icon icon-tip"></i>系统公告
<i class="fa fa-chevron-right" aria-hidden="true" style="right: 7px;top: 13px;position: absolute;" onclick="showAllNotice()"></i>
</div>
<div class="layui-card-body layui-text">
<div class="layuimini-notice" th:each="notice,iterStat:${notices}">
<input id="noticeId" style="display:none;" th:value="${notice.getId()}"/>
<input id="readId" style="display:none;" th:value="${notice.getReadId()}"/>
<div class="layuimini-notice-title" th:text="${notice.getTitle()}">修改选项卡样式</div>
<div class="layuimini-notice-extra" th:text="${notice.getTime()}">2019-07-11 23:06</div>
<div class="layuimini-notice-content layui-hide" th:text="${notice.getContent()}">
</div>
</div>
</div>
</div>
</div>
<div class="layui-col-md8"> <div class="layui-col-md8">
<div class="layui-row layui-col-space15"> <div class="layui-row layui-col-space15">
@ -352,12 +373,19 @@
area: '300px;', area: '300px;',
shade: 0.8, shade: 0.8,
id: 'layuimini-notice', id: 'layuimini-notice',
btn: ['查看', '取消'], btn: ['详情', '取消'],
btnAlign: 'c', btnAlign: 'c',
moveType: 1, moveType: 1,
content: html, content: html,
success: function (layero) { success: function (layero) {
var btn = layero.find('.layui-layer-btn'); var btn = layero.find('.layui-layer-btn');
$.ajax({
url:"/notice/readNoticeForUser",
type:"post",
dataType: 'json',
contentType: "application/json;charset=utf-8",
data:JSON.stringify({"id":$("#readId").val()})
});
btn.find('.layui-layer-btn0').click(function () { btn.find('.layui-layer-btn0').click(function () {
layer.open({ layer.open({
type: 2, type: 2,
@ -373,6 +401,9 @@
} }
); );
},
end:function() {
location.reload()
} }
}); });
}); });

Loading…
Cancel
Save