xufenglei
2017-12-07 7214ae59e03b79372a923eae8206082efc3fab85
app 接口
3 files deleted
8 files added
22 files modified
628 ■■■■■ changed files
src/main/java/com/moral/config/InjectionConfig.java 22 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/config/MessageSourceConfig.java 22 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/MobileController.java 25 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/ScreenController.java 4 ●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/Account.java 45 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/Device.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/MonitorPoint.java 97 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/OperateUser.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/Organization.java 81 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/OrganizationRelation.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/AccountMapper.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/MonitorPointMapper.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/OrganizationMapper.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/AccountService.java 5 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/DeviceService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/MonitorPointService.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/OperateUserService.java 4 ●●● patch | view | raw | blame | history
src/main/java/com/moral/service/OrganizationService.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/AccountServiceImpl.java 29 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/DeviceServiceImpl.java 34 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java 23 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/OperateUserServiceImpl.java 22 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/OrganizationServiceImpl.java 14 ●●●●● patch | view | raw | blame | history
src/main/resources/application.yml 6 ●●●● patch | view | raw | blame | history
src/main/resources/i18n/exceptions_zh_CN.properties 8 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/AccountMapper.xml 13 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/DeviceMapper.xml 20 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/HistoryMapper.xml 16 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/MonitorPointMapper.xml 14 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/OperateUserMapper.xml 17 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/OrganizationMapper.xml 32 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/OrganizationRelationMapper.xml 9 ●●●●● patch | view | raw | blame | history
src/test/java/com/moral/MybatisConfig.java 23 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/config/InjectionConfig.java
New file
@@ -0,0 +1,22 @@
package com.moral.config;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Component;
import com.moral.common.util.ValidateUtil;
@Component
public class InjectionConfig {
    @Resource
    MessageSource resources;
    @PostConstruct
    private void init() {
        ValidateUtil.setResources(resources);
    }
}
src/main/java/com/moral/config/MessageSourceConfig.java
New file
@@ -0,0 +1,22 @@
package com.moral.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
@Configuration
public class MessageSourceConfig {
    @Bean(name="localeResolver")
    public LocaleResolver localeResolverBean() {
        return new SessionLocaleResolver();
    }
    @Bean(name="messageSource")
    public ResourceBundleMessageSource resourceBundleMessageSource(){
        ResourceBundleMessageSource source=new ResourceBundleMessageSource();
        source.setBasename("i18n/exceptions");
        return source;
    }
}
src/main/java/com/moral/controller/MobileController.java
@@ -9,13 +9,15 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.PageHelper;
import com.moral.common.bean.PageBean;
import com.moral.common.bean.ResultBean;
import com.moral.entity.Device;
import com.moral.entity.MonitorPoint;
import com.moral.entity.OperateUser;
import com.moral.entity.Organization;
import com.moral.service.DeviceService;
import com.moral.service.MonitorPointService;
import com.moral.service.OperateUserService;
import com.moral.service.OrganizationService;
@RestController
@RequestMapping(value = "mobile")
@@ -27,6 +29,12 @@
    @Resource
    private DeviceService deviceService;
    @Resource
    private OrganizationService organizationService;
    @Resource
    private MonitorPointService monitorPointService;
    // 1登录
    @GetMapping(value = "accountlogin")
@@ -57,15 +65,20 @@
    }
    @GetMapping(value = "getEquInfoByMac")
    public void getEquInfoByMac(String mac) {
    public ResultBean<Device> getDeviceByMac(String mac) {
        Device device = deviceService.getDeviceByMac(mac);
        return new ResultBean<Device>(device);
    }
    @GetMapping(value = "getMpointsByAreaName")
    public void getMpointsByAreaName(String areaName) {
    public ResultBean<List<MonitorPoint>> getMonitorPointsByAreaName(String areaName) {
        List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByAreaName(areaName);
        return new ResultBean<List<MonitorPoint>>(monitorPoints);
    }
    @GetMapping(value = "getOrgsByAreaName")
    public void getOrgsByAreaName(String areaName) {
    public ResultBean<List<Organization>> getOrganizationsByAreaName(String areaName) {
        List<Organization> organizations = organizationService.getOrganizationsByAreaName(areaName);
        return new ResultBean<List<Organization>>(organizations);
    }
}
src/main/java/com/moral/controller/ScreenController.java
@@ -4,7 +4,6 @@
import static com.moral.common.util.RedisUtil.hasKey;
import static com.moral.common.util.ResourceUtil.getValue;
import static com.moral.common.util.WebUtils.getParametersStartingWith;
import static org.springframework.util.ObjectUtils.isEmpty;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -26,7 +25,6 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONReader;
import com.alibaba.fastjson.TypeReference;
import com.moral.common.exception.BusinessException;
import com.moral.common.util.ValidateUtil;
import com.moral.service.AccountService;
import com.moral.service.DeviceService;
@@ -138,8 +136,8 @@
     */
    @GetMapping("sensor-standard")
    public Map<String, Object> getStandardBySensor(@RequestParam("macKey") String macKey) {
        ValidateUtil.notEmpty(macKey, "param.is.null");
        Map<String, Object> result = new HashMap<String, Object>();
        ValidateUtil.notEmpty(macKey, "参数不能为空!");
        result.put("standard", getValue(macKey + "-standard"));
        return result;
    }
src/main/java/com/moral/entity/Account.java
@@ -2,28 +2,71 @@
import java.util.Date;
import javax.persistence.Id;
import lombok.Data;
@Data
public class Account {
    private Integer id;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column account.id
     * @mbggenerated  Thu Dec 07 16:17:21 CST 2017
     */
    @Id
    private Integer id;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column account.account_name
     * @mbggenerated  Thu Dec 07 16:17:21 CST 2017
     */
    private String accountName;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column account.password
     * @mbggenerated  Thu Dec 07 16:17:21 CST 2017
     */
    private String password;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column account.organization_id
     * @mbggenerated  Thu Dec 07 16:17:21 CST 2017
     */
    private Integer organizationId;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column account.email
     * @mbggenerated  Thu Dec 07 16:17:21 CST 2017
     */
    private String email;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column account.mobile
     * @mbggenerated  Thu Dec 07 16:17:21 CST 2017
     */
    private String mobile;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column account.weixin
     * @mbggenerated  Thu Dec 07 16:17:21 CST 2017
     */
    private String weixin;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column account.is_delete
     * @mbggenerated  Thu Dec 07 16:17:21 CST 2017
     */
    private String isDelete;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column account.create_time
     * @mbggenerated  Thu Dec 07 16:17:21 CST 2017
     */
    private Date createTime;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column account.expire_time
     * @mbggenerated  Thu Dec 07 16:17:21 CST 2017
     */
    private Date expireTime;
}
src/main/java/com/moral/entity/Device.java
@@ -2,6 +2,8 @@
import java.util.Date;
import javax.persistence.Id;
import lombok.Data;
@@ -13,6 +15,7 @@
     * This field was generated by MyBatis Generator. This field corresponds to the database column device.id
     * @mbggenerated  Wed Nov 29 16:17:59 CST 2017
     */
    @Id
    private Integer id;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column device.name
src/main/java/com/moral/entity/MonitorPoint.java
New file
@@ -0,0 +1,97 @@
package com.moral.entity;
import javax.persistence.Id;
import lombok.Data;
@Data
public class MonitorPoint {
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column monitor_point.id
     *
     * @mbggenerated Thu Dec 07 16:40:22 CST 2017
     */
    @Id
    private Integer id;
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column monitor_point.name
     *
     * @mbggenerated Thu Dec 07 16:40:22 CST 2017
     */
    private String name;
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column monitor_point.longitude
     *
     * @mbggenerated Thu Dec 07 16:40:22 CST 2017
     */
    private Float longitude;
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column monitor_point.latitude
     *
     * @mbggenerated Thu Dec 07 16:40:22 CST 2017
     */
    private Float latitude;
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column monitor_point.province_code
     *
     * @mbggenerated Thu Dec 07 16:40:22 CST 2017
     */
    private Integer provinceCode;
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column monitor_point.city_code
     *
     * @mbggenerated Thu Dec 07 16:40:22 CST 2017
     */
    private Integer cityCode;
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column monitor_point.area_code
     *
     * @mbggenerated Thu Dec 07 16:40:22 CST 2017
     */
    private Integer areaCode;
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column monitor_point.organization_id
     *
     * @mbggenerated Thu Dec 07 16:40:22 CST 2017
     */
    private Integer organizationId;
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column monitor_point.address
     *
     * @mbggenerated Thu Dec 07 16:40:22 CST 2017
     */
    private String address;
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column monitor_point.is_delete
     *
     * @mbggenerated Thu Dec 07 16:40:22 CST 2017
     */
    private String isDelete;
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column monitor_point.description
     *
     * @mbggenerated Thu Dec 07 16:40:22 CST 2017
     */
    private String description;
}
src/main/java/com/moral/entity/OperateUser.java
@@ -2,10 +2,13 @@
import java.util.Date;
import javax.persistence.Id;
import lombok.Data;
@Data
public class OperateUser {
    @Id
    private Integer id;
    private String jobNumber;
src/main/java/com/moral/entity/Organization.java
@@ -2,34 +2,89 @@
import java.util.Date;
import javax.persistence.Id;
import lombok.Data;
@Data
public class Organization {
    private Integer id;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column organization.id
     * @mbggenerated  Thu Dec 07 15:18:16 CST 2017
     */
    @Id
    private Integer id;
    private String name;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column organization.name
     * @mbggenerated  Thu Dec 07 15:18:16 CST 2017
     */
    private String name;
    private Integer rank;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column organization.rank
     * @mbggenerated  Thu Dec 07 15:18:16 CST 2017
     */
    private Integer rank;
    private Integer provinceCode;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column organization.province_code
     * @mbggenerated  Thu Dec 07 15:18:16 CST 2017
     */
    private Integer provinceCode;
    private Integer cityCode;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column organization.city_code
     * @mbggenerated  Thu Dec 07 15:18:16 CST 2017
     */
    private Integer cityCode;
    private Integer areaCode;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column organization.area_code
     * @mbggenerated  Thu Dec 07 15:18:16 CST 2017
     */
    private Integer areaCode;
    private String address;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column organization.address
     * @mbggenerated  Thu Dec 07 15:18:16 CST 2017
     */
    private String address;
    private String telephone;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column organization.telephone
     * @mbggenerated  Thu Dec 07 15:18:16 CST 2017
     */
    private String telephone;
    private String email;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column organization.email
     * @mbggenerated  Thu Dec 07 15:18:16 CST 2017
     */
    private String email;
    private String isDelete;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column organization.is_delete
     * @mbggenerated  Thu Dec 07 15:18:16 CST 2017
     */
    private String isDelete;
    private Date createTime;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column organization.create_time
     * @mbggenerated  Thu Dec 07 15:18:16 CST 2017
     */
    private Date createTime;
    private Date expireTime;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column organization.expire_time
     * @mbggenerated  Thu Dec 07 15:18:16 CST 2017
     */
    private Date expireTime;
    private String description;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column organization.description
     * @mbggenerated  Thu Dec 07 15:18:16 CST 2017
     */
    private String description;
}
src/main/java/com/moral/entity/OrganizationRelation.java
@@ -1,9 +1,12 @@
package com.moral.entity;
import javax.persistence.Id;
import lombok.Data;
@Data
public class OrganizationRelation {
    @Id
    private Integer id;
    private Integer parentId;
src/main/java/com/moral/mapper/AccountMapper.java
@@ -7,6 +7,5 @@
import com.moral.entity.Account;
public interface AccountMapper extends BaseMapper<Account> {
    List<Map<String, Object>> getRoleNameByAccountId(Integer accountId);
}
src/main/java/com/moral/mapper/MonitorPointMapper.java
New file
@@ -0,0 +1,11 @@
package com.moral.mapper;
import java.util.List;
import com.moral.common.mapper.BaseMapper;
import com.moral.entity.MonitorPoint;
public interface MonitorPointMapper extends BaseMapper<MonitorPoint>{
    List<MonitorPoint> getMonitorPointsByAreaName(String areaName);
}
src/main/java/com/moral/mapper/OrganizationMapper.java
@@ -1,7 +1,11 @@
package com.moral.mapper;
import java.util.List;
import com.moral.common.mapper.BaseMapper;
import com.moral.entity.Organization;
public interface OrganizationMapper extends BaseMapper<Organization> {
    List<Organization> getOrganizationsByAreaName(String areaName);
}
src/main/java/com/moral/service/AccountService.java
@@ -1,6 +1,5 @@
package com.moral.service;
import java.util.List;
import java.util.Map;
import com.moral.entity.Account;
@@ -9,9 +8,7 @@
    Map<String, Object> screenLogin(Map<String, Object> parameters);
    List<Account> getAccountLists(String account, String password);
    List<Account> getAccountList(String account);
    Account getAccountByAccountName(String account);
    void setOrgIdsByAccount(Map<String, Object> parameters);
src/main/java/com/moral/service/DeviceService.java
@@ -14,4 +14,6 @@
    void saveOrUpdateDevice(Device device);
    List<Device> getInstallDevicesByOperateUser(Integer uid, Integer pageIndex, Integer pageSize);
    Device getDeviceByMac(String mac);
}
src/main/java/com/moral/service/MonitorPointService.java
New file
@@ -0,0 +1,11 @@
package com.moral.service;
import java.util.List;
import com.moral.entity.MonitorPoint;
public interface MonitorPointService {
    List<MonitorPoint> getMonitorPointsByAreaName(String areaName);
}
src/main/java/com/moral/service/OperateUserService.java
@@ -1,12 +1,10 @@
package com.moral.service;
import java.util.List;
import com.moral.entity.OperateUser;
public interface OperateUserService {
    List<OperateUser> getUserList(String mobile);
    OperateUser getOperateUserByMobile(String mobile);
    OperateUser mobileLogin(String mobile, String password);
src/main/java/com/moral/service/OrganizationService.java
@@ -1,9 +1,14 @@
package com.moral.service;
import java.util.List;
import java.util.Set;
import com.moral.entity.Organization;
public interface OrganizationService {
    Set<Integer> getChildOrganizationIds(Integer orgId);
    List<Organization> getOrganizationsByAreaName(String areaName);
}
src/main/java/com/moral/service/impl/AccountServiceImpl.java
@@ -8,7 +8,6 @@
import static org.springframework.util.ObjectUtils.isEmpty;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -22,8 +21,6 @@
import com.moral.service.AccountService;
import com.moral.service.OrganizationService;
import tk.mybatis.mapper.entity.Example;
@Service
public class AccountServiceImpl implements AccountService {
@@ -36,14 +33,13 @@
    @Override
    public Map<String, Object> screenLogin(Map<String, Object> parameters) {
        Map<String, Object> result = new HashMap<String, Object>();
        Example example = new Example(Account.class);
        String password = md5((String) parameters.get("account"));
        example.or().andEqualTo("accountName",parameters.get("account")).andEqualTo("password",password);
        List<Account> accounts = accountMapper.selectByExample(example);
        if (isEmpty(accounts) || accounts.size() != 1) {
        Account account = new Account();
        account.setAccountName((String) parameters.get("account"));
        account.setPassword(md5((String) parameters.get("password")));
        account = accountMapper.selectOne(account);
        if (isEmpty(account)) {
            result.put("msg", "用户名及密码输入错误!");
        } else {
            Account account = accounts.get(0);
            if (IS_DELETE_FALSE.equals(account.getIsDelete())) {
                result.put("msg", "登录成功!");
                result.put("accountId", account.getId());
@@ -56,17 +52,10 @@
    }
    @Override
    public List<Account> getAccountLists(String accountName, String password) {
        Example example = new Example(Account.class);
        example.or().andEqualTo("accountName",accountName).andEqualTo("password",password);
        return accountMapper.selectByExample(example);
    }
    @Override
    public List<Account> getAccountList(String accountName) {
        Example example = new Example(Account.class);
        example.or().andEqualTo("accountName",accountName);
        return accountMapper.selectByExample(example);
    public Account getAccountByAccountName(String accountName) {
        Account account = new Account();
        account.setAccountName(accountName);
        return accountMapper.selectOne(account);
    }
    @Override
src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -11,14 +11,11 @@
import org.springframework.util.ObjectUtils;
import com.github.pagehelper.PageHelper;
import com.moral.common.exception.BusinessException;
import com.moral.common.util.ValidateUtil;
import com.moral.entity.Device;
import com.moral.mapper.DeviceMapper;
import com.moral.service.AccountService;
import com.moral.service.DeviceService;
import tk.mybatis.mapper.entity.Example;
@Service
public class DeviceServiceImpl implements DeviceService {
@@ -63,32 +60,39 @@
    @Override
    public void saveOrUpdateDevice(Device device) {
        ValidateUtil.notNull(device, "参数不可为空");
        ValidateUtil.notEmpty(device.getMac(), "参数不可为空");
        Example example = new Example(Device.class);
        example.or().andEqualTo("mac",device.getMac());
        List<Device> devices = deviceMapper.selectByExample(example);
        ValidateUtil.notNull(device, "param.is.null");
        ValidateUtil.notEmpty(device.getMac(), "param.is.null");
        Device queryDevice = new Device();
        queryDevice.setMac(device.getMac());
        queryDevice = deviceMapper.selectOne(queryDevice);
        Date operateDate = new Date();
        device.setInstallTime(operateDate);
        if (ObjectUtils.isEmpty(devices)) {
        if (ObjectUtils.isEmpty(queryDevice)) {
            device.setCreateTime(operateDate);
            device.setState("4");
            deviceMapper.insertSelective(device);
        }else if (devices.size() > 1) {
            throw new BusinessException("设备信息异常,联系管理员!");
        }else {
            device.setId(devices.get(0).getId());
            device.setId(queryDevice.getId());
            deviceMapper.updateByPrimaryKeySelective(device);
        }
    }
    @Override
    public List<Device> getInstallDevicesByOperateUser(Integer uid, Integer pageIndex, Integer pageSize) {
        Example example = new Example(Device.class);
        example.or().andEqualTo("operateUserId",uid);
        Device device = new Device();
        device.setOperateUserId(uid);
        PageHelper.startPage(pageIndex, pageSize);
        List<Device> devices = deviceMapper.selectByExample(example);
        List<Device> devices = deviceMapper.select(device);
        return devices;
    }
    @Override
    public Device getDeviceByMac(String mac) {
        ValidateUtil.notEmpty(mac, "param.is.null");
        Device device = new Device();
        device.setMac(mac);
        device = deviceMapper.selectOne(device);
        return device;
    }
}
src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java
New file
@@ -0,0 +1,23 @@
package com.moral.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.moral.entity.MonitorPoint;
import com.moral.mapper.MonitorPointMapper;
import com.moral.service.MonitorPointService;
@Service
public class MonitorPointServiceImpl implements MonitorPointService {
    @Resource
    private MonitorPointMapper monitorPointMapper;
    @Override
    public List<MonitorPoint> getMonitorPointsByAreaName(String areaName) {
        return monitorPointMapper.getMonitorPointsByAreaName(areaName);
    }
}
src/main/java/com/moral/service/impl/OperateUserServiceImpl.java
@@ -1,7 +1,5 @@
package com.moral.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
@@ -13,8 +11,6 @@
import com.moral.mapper.OperateUserMapper;
import com.moral.service.OperateUserService;
import tk.mybatis.mapper.entity.Example;
@Service
public class OperateUserServiceImpl implements OperateUserService {
@@ -22,21 +18,21 @@
    private OperateUserMapper operateUserMapper;
    @Override
    public List<OperateUser> getUserList(String mobile) {
        Example example = new Example(OperateUser.class);
        example.or().andEqualTo("mobile", mobile);
        return operateUserMapper.selectByExample(example);
    public OperateUser getOperateUserByMobile(String mobile) {
        OperateUser operateUser = new OperateUser();
        operateUser.setMobile(mobile);
        return operateUserMapper.selectOne(operateUser);
    }
    @Override
    public OperateUser mobileLogin(String mobile, String password) {
        Example example = new Example(OperateUser.class);
        example.or().andEqualTo("mobile", mobile).andEqualTo("password", Crypto.md5(password));
        List<OperateUser> operateUsers = operateUserMapper.selectByExample(example);
        if (ObjectUtils.isEmpty(operateUsers) || operateUsers.size() > 1) {
        OperateUser operateUser = new OperateUser();
        operateUser.setMobile(mobile);
        operateUser.setPassword(Crypto.md5(password));
        operateUser = operateUserMapper.selectOne(operateUser);
        if (ObjectUtils.isEmpty(operateUser)) {
            throw new BusinessException("用户名或密码错误,登陆失败!");
        }else {
            OperateUser operateUser = operateUsers.get(0);
            operateUser.setPassword(password);
            return operateUser;
        }
src/main/java/com/moral/service/impl/OrganizationServiceImpl.java
@@ -16,8 +16,6 @@
import com.moral.mapper.OrganizationRelationMapper;
import com.moral.service.OrganizationService;
import tk.mybatis.mapper.entity.Example;
@Service
public class OrganizationServiceImpl implements OrganizationService {
@@ -31,11 +29,11 @@
    public Set<Integer> getChildOrganizationIds(Integer orgId){
        Set<Integer> orgIds = new HashSet<Integer>();
        orgIds.add(orgId);
        Example example = new Example(OrganizationRelation.class);
        example.or().andEqualTo("parentId",orgId);
        OrganizationRelation relation = new OrganizationRelation();
        relation.setParentId(orgId);
        Organization organization = organizationMapper.selectByPrimaryKey(orgId);
        if (IS_DELETE_FALSE.equals(organization.getIsDelete())) {
            List<OrganizationRelation> organizationRelations = organizationRelationMapper.selectByExample(example);
            List<OrganizationRelation> organizationRelations = organizationRelationMapper.select(relation);
            for (OrganizationRelation organizationRelation : organizationRelations) {
                Set<Integer> organizationIds = getChildOrganizationIds(organizationRelation.getParentId());
                orgIds.addAll(organizationIds);
@@ -44,4 +42,10 @@
        return orgIds;
    }
    @Override
    public List<Organization> getOrganizationsByAreaName(String areaName) {
        List<Organization> organizations = organizationMapper.getOrganizationsByAreaName(areaName);
        return organizations;
    }
}
src/main/resources/application.yml
@@ -61,6 +61,6 @@
    mongodb:
      uri: mongodb://47.96.171.62:27017/monitor
#mybatis:
#  mapper-locations: classpath*:/mapper/*Mapper.xml
#  type-aliases-package: com.moral.entity
mybatis:
  mapper-locations: classpath*:/mapper/*Mapper.xml
  type-aliases-package: com.moral.entity
src/main/resources/i18n/exceptions_zh_CN.properties
New file
@@ -0,0 +1,8 @@
param.is.null=\u53C2\u6570\u4E3A\u7A7A
name.is.null=\u540D\u79F0\u4E3A\u7A7A
value.is.null=\u53D6\u503C\u4E3A\u7A7A
id.error=\u975E\u6CD5\u7684id\uFF1A{0}
name.repeat=\u540D\u79F0\u5DF2\u7ECF\u5B58\u5728
no.permission=\u6CA1\u6709\u6743\u9650
src/main/resources/mapper/AccountMapper.xml
@@ -1,19 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.mapper.AccountMapper">
  <resultMap id="BaseResultMap" type="com.moral.entity.Account">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="account_name" jdbcType="VARCHAR" property="accountName" />
    <result column="password" jdbcType="VARCHAR" property="password" />
    <result column="organization_id" jdbcType="INTEGER" property="organizationId" />
    <result column="email" jdbcType="VARCHAR" property="email" />
    <result column="mobile" jdbcType="VARCHAR" property="mobile" />
    <result column="weixin" jdbcType="VARCHAR" property="weixin" />
    <result column="is_delete" jdbcType="CHAR" property="isDelete" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
  </resultMap>
    <select id="getRoleNameByAccountId" resultType="map">
        SELECT
            r.role_name
src/main/resources/mapper/DeviceMapper.xml
@@ -1,25 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.mapper.DeviceMapper">
  <resultMap id="BaseResultMap" type="com.moral.entity.Device">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Nov 29 16:17:59 CST 2017.
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="address" jdbcType="VARCHAR" property="address" />
    <result column="longitude" jdbcType="REAL" property="longitude" />
    <result column="latitude" jdbcType="REAL" property="latitude" />
    <result column="mac" jdbcType="VARCHAR" property="mac" />
    <result column="operate_user_id" jdbcType="INTEGER" property="operateUserId" />
    <result column="state" jdbcType="CHAR" property="state" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="install_time" jdbcType="TIMESTAMP" property="installTime" />
    <result column="monitor_point_id" jdbcType="INTEGER" property="monitorPointId" />
    <result column="device_version_id" jdbcType="INTEGER" property="deviceVersionId" />
  </resultMap>
     <select id="getDeviceStatesByAccount" resultType="map">
        SELECT
            COUNT( d.state ) count,
@@ -37,6 +18,7 @@
        </if>
        GROUP BY d.state
    </select>
    <select id="getSensorsByDevice" resultType="map">
        SELECT
            s.`key`,
src/main/resources/mapper/HistoryMapper.xml
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.mapper.HistoryMapper">
  <select id="getDayAQIByDevice" resultType="map">
    <select id="getDayAQIByDevice" resultType="map">
        SELECT
            AVG(value -> '$.e1') e1,
            AVG(value -> '$.e2') e2,
@@ -14,9 +13,9 @@
            history
        WHERE
            mac = #{mac}
        AND time &gt; #{start}
        AND time >= #{start}
        AND time &lt; #{end}
  </select>
    </select>
    <select id="getAllSensorAverageByDevice" resultType="java.util.LinkedHashMap">
        SELECT
@@ -28,13 +27,13 @@
        <if test="orgIds != null and orgIds.size &gt; 0">
            LEFT JOIN monitor_point_organization mpo ON mpo.monitor_point_id = mp.id 
            AND mpo.organization_id IN
            <foreach close=")" collection="orgIds" item="listItem" open="(" separator=",">
            <foreach collection="orgIds" open="(" separator="," close=")" item="listItem">
                #{listItem}
            </foreach>
        </if>
        WHERE
            mp.area_code = #{areaCode} 
            AND h.time > #{start}
            AND h.time >= #{start}
            AND h.time &lt; #{end}
            AND h.mac = d.mac 
            AND d.monitor_point_id = mp.id 
@@ -55,11 +54,11 @@
            monitor_point mp
        WHERE
            mp.area_code = #{areaCode} 
            AND h.time > #{start}
            AND h.time >= #{start}
            AND h.time &lt; #{end}
        <if test="orgIds != null and orgIds.size &gt; 0">
            AND mp.organization_id IN
            <foreach  collection="orgIds" open="(" separator="," close=")" item="listItem" >
            <foreach  collection="orgIds" open="(" separator="," close=")" item="listItem">
                #{listItem}
            </foreach>
        </if>
@@ -86,5 +85,4 @@
        ORDER BY
            time
    </select>
</mapper>
src/main/resources/mapper/MonitorPointMapper.xml
New file
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.moral.mapper.MonitorPointMapper" >
    <select id="getMonitorPointsByAreaName" resultType="com.moral.entity.MonitorPoint">
        SELECT
            mp.*
        FROM
            monitor_point mp,
            area a
        WHERE
            mp.area_code = a.area_code
        AND a.area_name = #{areaName}
    </select>
</mapper>
src/main/resources/mapper/OperateUserMapper.xml
File was deleted
src/main/resources/mapper/OrganizationMapper.xml
@@ -1,20 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.moral.mapper.OrganizationMapper" >
  <resultMap id="BaseResultMap" type="com.moral.entity.Organization" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="rank" property="rank" jdbcType="INTEGER" />
    <result column="province_code" property="provinceCode" jdbcType="INTEGER" />
    <result column="city_code" property="cityCode" jdbcType="INTEGER" />
    <result column="area_code" property="areaCode" jdbcType="INTEGER" />
    <result column="address" property="address" jdbcType="VARCHAR" />
    <result column="telephone" property="telephone" jdbcType="VARCHAR" />
    <result column="email" property="email" jdbcType="VARCHAR" />
    <result column="is_delete" property="isDelete" jdbcType="CHAR" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="expire_time" property="expireTime" jdbcType="TIMESTAMP" />
    <result column="description" property="description" jdbcType="VARCHAR" />
  </resultMap>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.mapper.OrganizationMapper">
    <select id="getOrganizationsByAreaName" resultType="com.moral.entity.Organization">
        SELECT
            o.*
        FROM
            organization o,
            area a
        WHERE
            o.area_code = a.area_code
        AND a.area_name = #{areaName}
    </select>
</mapper>
src/main/resources/mapper/OrganizationRelationMapper.xml
File was deleted
src/test/java/com/moral/MybatisConfig.java
File was deleted