| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public Integer getSex(String device) {
|
| | | DeviceSex deviceSex = deviceSexDao.get(device);
|
| | | if (deviceSex != null) {
|
| | | return deviceSex.getSex();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteSex(String device) {
|
| | | deviceSexDao.delete(device);
|
| | | }
|
| | | |
| | | @Override
|
| | | public int changeDeviceSex(Integer sex, String device) {
|
| | | if (sex == null || sex < 0 || sex > 2) {
|
| | | sex = 0;
|
| | | }
|
| | | |
| | | Integer sexDevice = getSex(device);
|
| | | if (sexDevice == null) {
|
| | | sexDevice = 0;
|
| | | }
|
| | | |
| | | if (sex == 0 && sexDevice != 0) {
|
| | | deleteSex(device);
|
| | | } |
| | | |
| | | if(sex > 0 && sex != sexDevice) {
|
| | | save(device, sex);
|
| | | }
|
| | | return sex;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public int getDeviceSex(String device) {
|
| | | Integer sexDevice = getSex(device);
|
| | | if (sexDevice == null) {
|
| | | sexDevice = 0;
|
| | | DeviceSex deviceSex = deviceSexDao.get(device);
|
| | | if (deviceSex == null || deviceSex.getSex() == null) {
|
| | | return 0;
|
| | | }
|
| | | return sexDevice;
|
| | | return deviceSex.getSex();
|
| | | }
|
| | | }
|