/**
 * long description for the file
 *
 * @summary 用户权限分配
 * @author wu <308822989@qq.com>
 *
 * Created at     : 2018-08-01 18:01:57
 * Last modified  : 2018-08-27 14:55:50
 */

import axios from '@/config/axios.js';
import { proPath } from '@/config/config.js';

const state = {
}

const getters = {
}

const mutations = {
}
const actions = {
  //  用户查询角色
  sysuserroles ({ commit, state }, form) {
    let res = axios.get(proPath + 'v1/sysuserroles/', {
      params: form
    });
    return res;
  },
  //  用户查询岗位
  sysuserposts ({ commit, state }, form) {
    let res = axios.get(proPath + 'v1/sysuserposts/', {
      params: form
    });
    return res;
  },
  //  用户绑定角色
  batchInsert ({ commit, state }, obj) {
    let res = axios.post(proPath + 'v1/sysuserroles/batchInsert/' + obj.userId + '/' + obj.userCode + '/' + (obj.roleId ? obj.roleId : 'null'));
    return res;
  },
  //  用户绑定岗位
  insertUserPosts ({ commit, state }, obj) {
    let res = axios.put(proPath + 'v1/sysuserposts/insertUserPosts/' + obj.userId, obj.form);
    return res;
  },
  //   用户权限查询 - 用户查询关联中间表
  findAuthorizeByUserId ({ commit, state }, userId) {
    let res = axios.get(proPath + 'v1/sysauthorizes/findAuthorizeByUserId/' + userId);
    return res;
  }
}

//
export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}
