| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserCustomSettingsMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.UserCustomSettings;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserCustomSettingsMapper userCustomSettingsMapper;
|
| | | |
| | |
|
| | | @Override
|
| | | public void saveModuleState(Long uid, Integer type, Integer state) throws UserCustomSettingsException{
|
| | | @Transactional
|
| | | public void saveModuleState(Long uid, String type, Integer state) throws UserCustomSettingsException {
|
| | | if (uid == null || type == null || state == null || state > 1 || state < 0) {
|
| | | throw new UserCustomSettingsException(1, "传递参数不正确");
|
| | | }
|
| | | |
| | | String typeNum = null;
|
| | | UserSettingTypeEnum mineTypeNum = null;
|
| | | |
| | | switch(type) {
|
| | | case 1:
|
| | | typeNum = UserSettingTypeEnum.cancelNotice.name();
|
| | | mineTypeNum = UserSettingTypeEnum.cancelNotice;
|
| | | break;
|
| | | case 2:
|
| | | typeNum = UserSettingTypeEnum.noNewsRedDot.name();
|
| | | mineTypeNum = UserSettingTypeEnum.noNewsRedDot;
|
| | | break;
|
| | | case 3:
|
| | | typeNum = UserSettingTypeEnum.noBonusCount.name();
|
| | | mineTypeNum = UserSettingTypeEnum.noBonusCount;
|
| | | break;
|
| | | case 4:
|
| | | typeNum = UserSettingTypeEnum.noShareRecordAndStorage.name();
|
| | | mineTypeNum = UserSettingTypeEnum.noShareRecordAndStorage;
|
| | | break;
|
| | | case 5:
|
| | | typeNum = UserSettingTypeEnum.noInvitationBonus.name();
|
| | | mineTypeNum = UserSettingTypeEnum.noInvitationBonus;
|
| | | break;
|
| | | default:
|
| | | throw new UserCustomSettingsException(1, "参数类型不匹配"); |
| | |
|
| | | UserSettingTypeEnum mineTypeNum = null;
|
| | | if (type.equals(UserSettingTypeEnum.cancelNotice.name())) {
|
| | | mineTypeNum = UserSettingTypeEnum.cancelNotice;
|
| | | } else if (type.equals(UserSettingTypeEnum.noNewsRedDot.name())) {
|
| | | mineTypeNum = UserSettingTypeEnum.noNewsRedDot;
|
| | | } else if (type.equals(UserSettingTypeEnum.noBonusCount.name())) {
|
| | | mineTypeNum = UserSettingTypeEnum.noBonusCount;
|
| | | } else if (type.equals(UserSettingTypeEnum.noShareRecordAndStorage.name())) {
|
| | | mineTypeNum = UserSettingTypeEnum.noShareRecordAndStorage;
|
| | | } else if (type.equals(UserSettingTypeEnum.noInvitationBonus.name())) {
|
| | | mineTypeNum = UserSettingTypeEnum.noInvitationBonus;
|
| | | } else if (type.equals(UserSettingTypeEnum.openSpreadHongBao.name())) {
|
| | | mineTypeNum = UserSettingTypeEnum.openSpreadHongBao;
|
| | | } else if (type.equals(UserSettingTypeEnum.noDisplayPhoneNum.name())) {
|
| | | mineTypeNum = UserSettingTypeEnum.noDisplayPhoneNum;
|
| | | } else {
|
| | | throw new UserCustomSettingsException(1, "参数类型不匹配");
|
| | | }
|
| | | |
| | | UserCustomSettings settings = userCustomSettingsMapper.getSettingsByUidAndType(uid, typeNum);
|
| | | if (settings == null) { // 插入
|
| | |
|
| | | UserCustomSettings settings = userCustomSettingsMapper.getSettingsByUidAndType(uid, type);
|
| | | if (settings != null) {
|
| | | // 更新
|
| | | UserCustomSettings record = new UserCustomSettings();
|
| | | record.setId(settings.getId());
|
| | | record.setState(state);
|
| | | record.setUpdateTime(new Date());
|
| | | userCustomSettingsMapper.updateByPrimaryKeySelective(record);
|
| | | } else {
|
| | | // 插入
|
| | | settings = new UserCustomSettings();
|
| | | settings.setState(state);
|
| | | settings.setType(mineTypeNum);
|
| | |
| | | settings.setUpdateTime(new Date());
|
| | | settings.setCreateTime(new Date());
|
| | | userCustomSettingsMapper.insertSelective(settings);
|
| | | } else { // 更新
|
| | | UserCustomSettings record = new UserCustomSettings();
|
| | | record.setId(settings.getId());
|
| | | record.setState(state);
|
| | | record.setType(mineTypeNum);
|
| | | record.setUpdateTime(new Date());
|
| | | userCustomSettingsMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<UserCustomSettings> getSettingsByUid(Long uid) throws UserCustomSettingsException{
|
| | | public List<UserCustomSettings> getSettingsByUid(Long uid) throws UserCustomSettingsException {
|
| | | if (uid == null) {
|
| | | throw new UserCustomSettingsException(1, "uid不能为空");
|
| | | }
|
| | | |
| | | return userCustomSettingsMapper.getSettingsByUid(uid);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public UserCustomSettings getSettingsByUidAndType(Long uid, String type) throws UserCustomSettingsException{
|
| | | |
| | | if (uid == null || type == null || type.trim().length() == 0 ) {
|
| | | public UserCustomSettings getSettingsByUidAndType(Long uid, String type) throws UserCustomSettingsException {
|
| | | if (uid == null || type == null || type.trim().length() == 0) {
|
| | | throw new UserCustomSettingsException(1, "传递的参数不能为空");
|
| | | }
|
| | | |
| | |
|
| | | return userCustomSettingsMapper.getSettingsByUidAndType(uid, type);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public UserSettingsVO getMySettings(Long uid) throws UserCustomSettingsException{
|
| | | |
| | | public UserSettingsVO getMySettings(Long uid) throws UserCustomSettingsException {
|
| | |
|
| | | UserSettingsVO userSettingsVO = new UserSettingsVO();
|
| | | |
| | |
|
| | | List<UserCustomSettings> list = getSettingsByUid(uid);
|
| | | |
| | |
|
| | | if (list != null && list.size() > 0) {
|
| | | |
| | | for (UserCustomSettings userCustomSettings: list) {
|
| | | |
| | |
|
| | | for (UserCustomSettings userCustomSettings : list) {
|
| | |
|
| | | Integer state = userCustomSettings.getState();
|
| | | if (state == null) {
|
| | | continue;
|
| | | }
|
| | | |
| | |
|
| | | UserSettingTypeEnum typeEnum = userCustomSettings.getType();
|
| | | |
| | | if (typeEnum.equals(UserSettingTypeEnum.cancelNotice) ) {
|
| | |
|
| | | if (typeEnum.equals(UserSettingTypeEnum.cancelNotice)) {
|
| | | userSettingsVO.setCancelNotice(state);
|
| | | } else if (typeEnum.equals(UserSettingTypeEnum.noNewsRedDot)){
|
| | | } else if (typeEnum.equals(UserSettingTypeEnum.noNewsRedDot)) {
|
| | | userSettingsVO.setNoNewsRedDot(state);
|
| | | } else if (typeEnum.equals(UserSettingTypeEnum.noBonusCount)){
|
| | | } else if (typeEnum.equals(UserSettingTypeEnum.noBonusCount)) {
|
| | | userSettingsVO.setNoBonusCount(state);
|
| | | } else if (typeEnum.equals(UserSettingTypeEnum.noShareRecordAndStorage)){
|
| | | } else if (typeEnum.equals(UserSettingTypeEnum.noShareRecordAndStorage)) {
|
| | | userSettingsVO.setNoShareRecordAndStorage(state);
|
| | | } else if (typeEnum.equals(UserSettingTypeEnum.noInvitationBonus)){
|
| | | } else if (typeEnum.equals(UserSettingTypeEnum.noInvitationBonus)) {
|
| | | userSettingsVO.setNoInvitationBonus(state);
|
| | | } |
| | | |
| | | } else if (typeEnum.equals(UserSettingTypeEnum.openSpreadHongBao)) {
|
| | | userSettingsVO.setOpenSpreadHongBao(state);
|
| | | } else if (typeEnum.equals(UserSettingTypeEnum.noDisplayPhoneNum)) {
|
| | | userSettingsVO.setNoDisplayPhoneNum(state);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | return userSettingsVO;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public List<Long> getCancelNoticeUsers(){
|
| | | public List<Long> getCancelNoticeUsers() {
|
| | | return userCustomSettingsMapper.getUserID(UserSettingTypeEnum.cancelNotice.name());
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public boolean validateCancelNoticeByUid(Long uid){
|
| | | public boolean validateCancelNoticeByUid(Long uid) {
|
| | | boolean ispush = true;
|
| | | |
| | |
|
| | | UserCustomSettings settings = userCustomSettingsMapper.getSettingsByUidAndType(uid,
|
| | | UserSettingTypeEnum.cancelNotice.name());
|
| | | |
| | |
|
| | | if (settings != null && settings.getState() != null && settings.getState() == 1) {
|
| | | ispush = false;
|
| | | }
|
| | | |
| | |
|
| | | return ispush;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<UserCustomSettings> listByUidListAndTypeAndState(List<Long> uidList, String type, Integer state) {
|
| | | return userCustomSettingsMapper.listByUidListAndTypeAndState(uidList, type, state);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public boolean validateDisplayPhoneByUid(Long uid) {
|
| | | UserCustomSettings settings = userCustomSettingsMapper.getSettingsByUidAndType(uid,
|
| | | UserSettingTypeEnum.noDisplayPhoneNum.name());
|
| | | if (settings != null && settings.getState() != null && settings.getState() == 1) {
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | }
|