Kaynağa Gözat

消息提醒设置

yeshijie 7 yıl önce
ebeveyn
işleme
f18045de5f

+ 139 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/message/MessageNoticeSetting.java

@ -0,0 +1,139 @@
package com.yihu.wlyy.entity.message;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 消息提醒设置
 * @author yeshijie on 2017/11/27.
 *
 */
@Entity
@Table(name = "wlyy_message_notice_setting")
public class MessageNoticeSetting extends IdEntity{
    private String user;//'用户code'
    private String type;// '类型(1医生,2居民)'
    private Integer masterSwitch;// '总开关' (1开,0关)
    private Integer imSwitch;//'im消息开关'(1开,0关)
    private Integer familyTopicSwitch;// '健管师邀请后推送开关'(1开,0关)
    private Integer signSwitch;// '签约消息开关'(1开,0关)
    private Integer healthSignSwitch;// '体征消息开关'(1开,0关)
    private Integer systemSwitch;// '系统消息开关'(1开,0关)
    private Integer prescriptionSwitch;// '续方消息开关'(1开,0关)
    private Integer soundSwitch;// '铃声提醒开关'(1开,0关)
    private Integer vibrationSwitch;// '振动提醒开关'(1开,0关)
    private Integer coordinationSwitch;// '协同消息开关'(1开,0关)
    private Date createTime;// '创建时间'
    public String getUser() {
        return user;
    }
    public void setUser(String user) {
        this.user = user;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public Integer getMasterSwitch() {
        return masterSwitch;
    }
    public void setMasterSwitch(Integer masterSwitch) {
        this.masterSwitch = masterSwitch;
    }
    public Integer getImSwitch() {
        return imSwitch;
    }
    public void setImSwitch(Integer imSwitch) {
        this.imSwitch = imSwitch;
    }
    public Integer getFamilyTopicSwitch() {
        return familyTopicSwitch;
    }
    public void setFamilyTopicSwitch(Integer familyTopicSwitch) {
        this.familyTopicSwitch = familyTopicSwitch;
    }
    public Integer getSignSwitch() {
        return signSwitch;
    }
    public void setSignSwitch(Integer signSwitch) {
        this.signSwitch = signSwitch;
    }
    public Integer getHealthSignSwitch() {
        return healthSignSwitch;
    }
    public void setHealthSignSwitch(Integer healthSignSwitch) {
        this.healthSignSwitch = healthSignSwitch;
    }
    public Integer getSystemSwitch() {
        return systemSwitch;
    }
    public void setSystemSwitch(Integer systemSwitch) {
        this.systemSwitch = systemSwitch;
    }
    public Integer getPrescriptionSwitch() {
        return prescriptionSwitch;
    }
    public void setPrescriptionSwitch(Integer prescriptionSwitch) {
        this.prescriptionSwitch = prescriptionSwitch;
    }
    public Integer getSoundSwitch() {
        return soundSwitch;
    }
    public void setSoundSwitch(Integer soundSwitch) {
        this.soundSwitch = soundSwitch;
    }
    public Integer getVibrationSwitch() {
        return vibrationSwitch;
    }
    public void setVibrationSwitch(Integer vibrationSwitch) {
        this.vibrationSwitch = vibrationSwitch;
    }
    public Integer getCoordinationSwitch() {
        return coordinationSwitch;
    }
    public void setCoordinationSwitch(Integer coordinationSwitch) {
        this.coordinationSwitch = coordinationSwitch;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name="create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageNoticeSettingDao.java

@ -0,0 +1,19 @@
package com.yihu.wlyy.repository.message;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/11/27.
 */
public interface MessageNoticeSettingDao extends PagingAndSortingRepository<MessageNoticeSetting, Long>, JpaSpecificationExecutor<MessageNoticeSetting> {
    @Query("from MessageNoticeSetting a where a.user = ?1 and a.type=?2")
    MessageNoticeSetting findByUserAndType(String user,String type);
    @Query("from MessageNoticeSetting a where a.id = ?1")
    MessageNoticeSetting findById(Long id);
}

+ 44 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -3,10 +3,12 @@ package com.yihu.wlyy.service.app.message;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.message.MessageNoticeSettingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
@ -52,6 +54,8 @@ public class MessageService extends BaseService {
    private DevicePatientHealthIndexDao devicePatientHealthIndexDao;
    @Autowired
    private HttpClientUtil HttpClientUtil;
    @Autowired
    private MessageNoticeSettingDao messageNoticeSettingDao;
    @Value("${im.im_list_get}")
    private String im_list_get;
@ -485,4 +489,44 @@ public class MessageService extends BaseService {
            messageDao.setMessageReaded(doctor, type);
        }
    }
    /**
     * 获取消息提醒设置
     * @param user
     * @param type
     * @return
     */
    public MessageNoticeSetting getMessageNoticSetting(String user,String type){
        MessageNoticeSetting messageNoticeSetting = messageNoticeSettingDao.findByUserAndType(user,type);
        if(messageNoticeSetting == null){
            messageNoticeSetting = new MessageNoticeSetting();
            messageNoticeSetting.setCreateTime(new Date());
            messageNoticeSetting.setFamilyTopicSwitch(1);
            messageNoticeSetting.setCoordinationSwitch(1);
            messageNoticeSetting.setHealthSignSwitch(1);
            messageNoticeSetting.setImSwitch(1);
            messageNoticeSetting.setMasterSwitch(1);
            messageNoticeSetting.setPrescriptionSwitch(1);
            messageNoticeSetting.setSignSwitch(1);
            messageNoticeSetting.setSoundSwitch(1);
            messageNoticeSetting.setSystemSwitch(1);
            messageNoticeSetting.setType(type);
            messageNoticeSetting.setUser(user);
            messageNoticeSetting.setVibrationSwitch(1);
            messageNoticeSettingDao.save(messageNoticeSetting);
        }
        return messageNoticeSetting;
    }
    /**
     * 更新消息提醒设置
     * @param messageNoticeSetting
     */
    public void saveMessageNoticeSetting(MessageNoticeSetting messageNoticeSetting){
        MessageNoticeSetting oldSetting = messageNoticeSettingDao.findById(messageNoticeSetting.getId());
        messageNoticeSetting.setUser(oldSetting.getUser());
        messageNoticeSetting.setCreateTime(oldSetting.getCreateTime());
        messageNoticeSetting.setType(oldSetting.getType());
        messageNoticeSettingDao.save(messageNoticeSetting);
    }
}

+ 39 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java

@ -1,7 +1,13 @@
package com.yihu.wlyy.web.doctor.message;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -16,11 +22,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import java.util.List;
import java.util.Map;
@ -31,6 +32,7 @@ public class DoctorMessageController extends BaseController {
    @Autowired
    private MessageService messageService;
    private ObjectMapper objectMapper = new ObjectMapper();
    @RequestMapping(value = "messages")
    @ResponseBody
@ -366,4 +368,36 @@ public class DoctorMessageController extends BaseController {
            return error(-1, "设置失败");
        }
    }
    @RequestMapping(value = "getMessageNoticeSetting",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取消息设置")
    public String getMessageNoticeSetting(){
        try {
            MessageNoticeSetting messageNoticeSetting = messageService.getMessageNoticSetting(getUID(),"1");
            return write(200,"查询成功","data",messageNoticeSetting);
        } catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "saveMessageNoticeSettion",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("保存消息提醒设置")
    @ObserverRequired
    public String saveMessageNoticeSettion(@ApiParam(name = "json", value = "数据json")
                                           @RequestParam(value = "json", required = true) String json){
        try {
            MessageNoticeSetting messageNoticeSetting = objectMapper.readValue(json, MessageNoticeSetting.class);
            if(messageNoticeSetting.getId()==null){
                return error(-1, "参数错误");
            }
            messageService.saveMessageNoticeSetting(messageNoticeSetting);
            return write(200, "设置成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "设置失败");
        }
    }
}