| | |
| | | private UserCustomSettingsMapper userCustomSettingsMapper;
|
| | |
|
| | | @Override
|
| | | public void saveModuleState(Long uid, Integer type, Integer state) throws UserCustomSettingsException{
|
| | | 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 {
|
| | | 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(settings);
|
| | | }
|
| | |
|
| | | }
|