| | |
| | | import com.moral.monitor.listener.message.Captcha;
|
| | | import com.moral.monitor.service.ApiService;
|
| | | import com.moral.monitor.util.ApiData;
|
| | | import com.moral.monitor.util.Crypto;
|
| | | import com.moral.monitor.util.DateConvert;
|
| | | import com.taobao.api.ApiException;
|
| | | import net.sf.json.JSONArray;
|
| | |
| | | @RequestParam(value ="mac") String mac ){
|
| | |
|
| | | try {
|
| | | System.out.println("");
|
| | | System.out.println("");
|
| | | System.out.println("");
|
| | | request.setCharacterEncoding("UTF-8");
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | //插入或更新设备表信息
|
| | | ApiData apiData = new ApiData();
|
| | | if(StringUtils.isBlank(mac)){
|
| | |
| | | return apiData;
|
| | | }
|
| | |
|
| | |
|
| | | if (StringUtils.isBlank(longitude)){ longitude="0"; }
|
| | | if (StringUtils.isBlank(latitude)) { latitude="0"; }
|
| | |
|
| | | Equipment equipment = apiService.selectFromequipmentBymac(mac);
|
| | | if (equipment==null){
|
| | | if (StringUtils.isBlank(longitude)){ longitude="0"; }
|
| | | if (StringUtils.isBlank(latitude)) { latitude="0"; }
|
| | | //插入
|
| | | if (equipment==null){ //插入
|
| | | apiService.insertIntoequipment(device_name,address,longitude,latitude,uid,mac);
|
| | | apiData.setData("");
|
| | | apiData.setMessage("添加设备成功");
|
| | | apiData.setErrno(0);
|
| | | return apiData;
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | //更新
|
| | | if (!StringUtils.isBlank(mac)) {
|
| | |
|
| | | if (StringUtils.isBlank(longitude)){ longitude="0"; }
|
| | | if (StringUtils.isBlank(latitude)) { latitude="0"; }
|
| | |
|
| | | } else { //更新
|
| | | apiService.updateFromequipmentBymac(device_name, address, longitude, latitude, uid, mac);
|
| | | apiData.setData("");
|
| | | apiData.setMessage("更新设备成功");
|
| | | apiData.setErrno(0);
|
| | | return apiData;
|
| | | }
|
| | |
|
| | | return null;
|
| | | return apiData;
|
| | | }
|
| | |
|
| | |
|
| | |
| | | ApiData apiData = new ApiData();
|
| | |
|
| | | //查找用户
|
| | | User user = apiService.selectFromuserBynameAndpassword(username, password);//username为mobile
|
| | | User user = apiService.selectFromuserBynameAndpassword(username, Crypto.md5(password));//username为mobile
|
| | | if (user==null){
|
| | | apiData.setErrno(1);
|
| | | apiData.setMessage("登陆失败,账号或密码错误");
|
| | |
| | | }
|
| | |
|
| | | if (user.getCode().equals(code)){
|
| | | apiService.updateuserByid(password,String.valueOf(user.getId()));
|
| | | apiService.updateuserByid(Crypto.md5(password),String.valueOf(user.getId()));
|
| | | apiData.setErrno(0);
|
| | | apiData.setMessage("重置密码成功");
|
| | | apiData.setData("{}");
|
| | |
| | | public ApiData upPassword(String uid,String password,String newpassword){
|
| | | ApiData apiData = new ApiData();
|
| | | //根据uid 和 password 查找用户
|
| | | User user = apiService.selectFromuserByidAndpassword(uid, password);
|
| | | User user = apiService.selectFromuserByidAndpassword(uid, Crypto.md5(password));
|
| | | JSONObject jsonObject = JSONObject.fromObject(user);
|
| | | String s = jsonObject.toString();
|
| | |
|
| | | if (user!=null){
|
| | | //更新password字段
|
| | | apiService.updateuserByid(newpassword,uid);
|
| | | apiService.updateuserByid(Crypto.md5(newpassword),uid);
|
| | | apiData.setErrno(0);
|
| | | apiData.setMessage("修密码改成功");
|
| | | apiData.setData(s);
|