收藏夹功能

hunan
liuguijing 2 years ago
parent 86b3317c26
commit a534352e01

@ -39,8 +39,8 @@ public class FavorController extends BaseController {
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/addFavorList")
@Log(title = "新增收藏夹接口", type = "新增")
public ResponseReult<DyLineTreeListModel> addFavorList( @RequestBody FavorVo vo) {
ServiceBody<DyLineTreeListModel> serviceBody = favorService.addFavorList(vo);
public ResponseReult<String> addFavorList( @RequestBody FavorVo vo) {
ServiceBody<String> serviceBody = favorService.addFavorList(vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
} else {

@ -276,4 +276,16 @@ public class TerminalController extends BaseController {
EasyExcelUtil.createExcel(response,"设备在线表",serviceBody.getData(), TerminalAndLastPicListExcelModel.class);
}
@ApiOperation(value = "新增收藏夹接口", notes = "新增收藏夹接口", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/addFavorList")
@Log(title = "新增收藏夹接口", type = "新增")
public ResponseReult<String> addFavorList( @RequestBody FavorVo vo) {
ServiceBody<String> serviceBody = terminalService.addFavorList(vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
} }
}

@ -50,6 +50,8 @@ public class TerminalsWithHeart implements Serializable {
private Integer protocol;
private Integer isfavor;
private static final long serialVersionUID = 1L;

@ -0,0 +1,17 @@
package com.shxy.xymanager_common.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class TerminalFavs implements Serializable {
private Integer termId;
private Date createTime;
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,38 @@
package com.shxy.xymanager_common.entity;
import java.io.Serializable;
import java.util.Date;
public class TerminalFavs implements Serializable {
private Integer userId;
private Integer termId;
private Date createTime;
private static final long serialVersionUID = 1L;
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getTermId() {
return termId;
}
public void setTermId(Integer termId) {
this.termId = termId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}

@ -23,6 +23,9 @@ public class DyLineTreeListModel implements Serializable {
@ApiModelProperty(value = "电压列表", example = "[]")
private List<DyListBean> list;
@ApiModelProperty(value = "收藏列表", example = "[]")
private List<TerminalBean> favorlist;
@Data
public static class DyListBean {
@ApiModelProperty(value = "电压编号", example = "123456")
@ -85,5 +88,8 @@ public class DyLineTreeListModel implements Serializable {
@ApiModelProperty(value = "在线状态", example = "0--掉线1--在线")
private Integer onlinestatus;
@ApiModelProperty(value = "是否收藏", example = "0--未收藏 1--已收藏")
private Integer isfavor;
}
}

@ -15,18 +15,9 @@ public class FavorVo {
@NotEmpty(message = "不能传入空值")
@ApiModelProperty(value = "收藏对象数组", required = true, example = "A0001")
private List<FavorVo.TowerItem> list;
@Data
public static class TowerItem {
@ApiModelProperty(value = "装置编号", example = "123456")
@NotNull(message = "装置编号不能缺少")
private List<Integer> termId;
@ApiModelProperty(value = "是否收藏", example = "0--删除收藏 1--收藏")
private Integer type;
}
private List<Integer> list;
@ApiModelProperty(value = "是否收藏", example = "0--删除收藏 1--收藏")
private Integer type;
}

@ -0,0 +1,16 @@
package com.shxy.xymanager_dao.dao;
import com.shxy.xymanager_common.entity.TerminalFavs;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
public interface TerminalFavsDao {
List<TerminalFavs> selectList();
int insertOrUpdateList(@Param("list") List<Integer> list,@Param("createat") Date createat);
int deleteList(@Param("list") List<Integer> list);
}

@ -48,4 +48,6 @@ public interface TerminalsDao {
int updateCmd(TerminalIdUpdateVo vo);
int updateFavor(@Param("list") List<Integer> list ,@Param("status") Integer status);
}

@ -245,9 +245,17 @@
<!-- &lt;!&ndash; <property name="useActualColumnNames" value="false"/>&ndash;&gt;-->
<!-- </table>-->
<table tableName="global_params"
domainObjectName="GlobalParams"
mapperName="GlobalParamsDao"
<!-- <table tableName="global_params"-->
<!-- domainObjectName="GlobalParams"-->
<!-- mapperName="GlobalParamsDao"-->
<!-- enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"-->
<!-- enableSelectByExample="false" selectByExampleQueryId="false">-->
<!-- &lt;!&ndash; <property name="useActualColumnNames" value="false"/>&ndash;&gt;-->
<!-- </table>-->
<table tableName="terminal_favs"
domainObjectName="TerminalFavs"
mapperName="TerminalFavsDao"
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false">
<!-- <property name="useActualColumnNames" value="false"/>-->

@ -31,6 +31,7 @@
<result column="model" jdbcType="VARCHAR" property="model"/>
<result column="last_heartbeat" jdbcType="BIGINT" property="lastheartbeat"/>
<result column="has_pan" jdbcType="INTEGER" property="hasPan"/>
<result column="isfavor" jdbcType="INTEGER" property="isfavor"/>
</collection>
</collection>
</resultMap>
@ -195,6 +196,7 @@
d.model as model,
d.protocol as protocol,
d.has_pan as has_pan,
d.isfavor as isfavor,
e.last_heartbeat as last_heartbeat
from ((((dy_level a left join `lines` b on a.id = b.dy_level_id )
left join towers c on b.id = c.line_id )

@ -0,0 +1,34 @@
<?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.shxy.xymanager_dao.dao.TerminalFavsDao">
<resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.TerminalFavs">
<result column="term_id" jdbcType="INTEGER" property="termId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<select id="selectList" resultMap="BaseResultMap">
select
term_id
from terminal_favs
</select>
<insert id="insertOrUpdateList" >
insert into terminal_favs
(term_id,create_time)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item},#{createat}})
</foreach>
ON DUPLICATE KEY UPDATE
term_id = values(term_id)
</insert>
<delete id="deleteList">
delete from schedule_details
where term_id in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</delete>
</mapper>

@ -648,4 +648,13 @@
set cmdid = #{newCmdId,jdbcType=VARCHAR}
where cmdid = #{cmdId,jdbcType=VARCHAR}
</update>
<update id="updateFavor">
update terminals
set isfavor = #{status}
where id in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
</mapper>

@ -16,10 +16,7 @@ import com.shxy.xymanager_common.page.PageUtils;
import com.shxy.xymanager_common.util.MyDateUtils;
import com.shxy.xymanager_common.util.xinyin.TerminalUtils;
import com.shxy.xymanager_common.vo.LastTowerVo;
import com.shxy.xymanager_dao.dao.DyLevelDao;
import com.shxy.xymanager_dao.dao.TerminalChannelMapperDao;
import com.shxy.xymanager_dao.dao.TerminalImgAlarmsDao;
import com.shxy.xymanager_dao.dao.TerminalPhotoDao;
import com.shxy.xymanager_dao.dao.*;
import com.shxy.xymanager_service.service.CacheService;
import com.shxy.xymanager_service.service.DyLevelService;
import lombok.extern.slf4j.Slf4j;
@ -62,6 +59,7 @@ public class DyLevelServiceImpl implements DyLevelService {
@Override
public ServiceBody<DyLineTreeListModel> getdyTreeList(Integer type) {
DyLineTreeListModel model = new DyLineTreeListModel();
ArrayList<DyLineTreeListModel.TerminalBean> favorList = new ArrayList<>();
List<DyLineAndTerminalWithHeartDto> list = dyLevelDao.selectTreeList(CommonStatus.EFFECTIVE.value());
boolean empty = CollectionUtil.isEmpty(list);
if (empty) {
@ -106,6 +104,8 @@ public class DyLevelServiceImpl implements DyLevelService {
bean.setModel(terminalsWithHeart.getModel());
bean.setName(terminalsWithHeart.getName());
bean.setTowerid(terminalsWithHeart.getTowerid());
Integer isfavor = terminalsWithHeart.getIsfavor();
bean.setIsfavor(isfavor);
BigInteger lastheartbeat = terminalsWithHeart.getLastheartbeat();
boolean b = TerminalUtils.judgeTerminalStatus(lastheartbeat);
if (type == null || type.intValue() == -1) {//查询全部
@ -133,6 +133,9 @@ public class DyLevelServiceImpl implements DyLevelService {
bean.setOnlinestatus(CommonStatus.DELETE.value());
}
}
if (isfavor!=null && isfavor.intValue() == CommonStatus.EFFECTIVE.value()) {
favorList.add(bean);
}
}
lineBean.setList(beanlist);
lineBeans.add(lineBean);
@ -143,6 +146,7 @@ public class DyLevelServiceImpl implements DyLevelService {
model.setOnlineNum(onlinenum);
model.setTotalNum(totalnum);
model.setList(dyListBeans);
model.setFavorlist(favorList);
}
return Asserts.success(model);
}

@ -1,11 +1,22 @@
package com.shxy.xymanager_service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.enums.CommonStatus;
import com.shxy.xymanager_common.exception.Asserts;
import com.shxy.xymanager_common.model.DyLineTreeListModel;
import com.shxy.xymanager_common.vo.FavorVo;
import com.shxy.xymanager_dao.dao.TerminalFavsDao;
import com.shxy.xymanager_dao.dao.TerminalsDao;
import com.shxy.xymanager_service.service.FavorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.util.Date;
import java.util.List;
/**
*
@ -15,10 +26,27 @@ import org.springframework.stereotype.Service;
public class FavorServiceImpl implements FavorService {
@Override
public ServiceBody<DyLineTreeListModel> addFavorList(FavorVo vo) {
@Autowired
TerminalFavsDao terminalFavsDao;
return null;
@Autowired
TerminalsDao terminalsDao;
@Override
@Transactional
public ServiceBody<String> addFavorList(FavorVo vo) {
Integer type = vo.getType();
List<Integer> list = vo.getList();
if (CollectionUtil.isEmpty(list)) {
if (type == null || type.intValue() == 0) {
int i = terminalFavsDao.deleteList(list);
terminalsDao.updateFavor(list, CommonStatus.DELETE.value());
} else {
int i = terminalFavsDao.insertOrUpdateList(list,new Date());
terminalsDao.updateFavor(list, CommonStatus.EFFECTIVE.value());
}
}
return Asserts.success("修改成功");
}
}

@ -681,6 +681,20 @@ public class TerminalServiceImpl implements TerminalService {
return Asserts.success(modellist);
}
@Override
public ServiceBody<String> addFavorList(FavorVo vo) {
Integer type = vo.getType();
List<Integer> list = vo.getList();
if (CollectionUtil.isEmpty(list)) {
if (type == null || type.intValue() == 0) {
terminalsDao.updateFavor(list, CommonStatus.DELETE.value());
} else {
terminalsDao.updateFavor(list, CommonStatus.EFFECTIVE.value());
}
}
return Asserts.success("修改成功");
}
}

@ -18,7 +18,7 @@ public interface FavorService {
*
* @return
*/
ServiceBody<DyLineTreeListModel> addFavorList(FavorVo vo);
ServiceBody<String> addFavorList(FavorVo vo);

@ -130,4 +130,10 @@ public interface TerminalService {
*/
ServiceBody<List<TerminalAndLastPicListExcelModel>> getOnlineTerminalList(Integer type);
/**
*
* @param vo
* @return
*/
ServiceBody<String> addFavorList(FavorVo vo);
}

Loading…
Cancel
Save