package com.engine.htsc.hrm.web;

import com.alibaba.fastjson.JSONObject;
import com.engine.htsc.workflow.util.WorkflowUtil;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.group.HrmGroupTreeComInfo;
import weaver.hrm.orggroup.HrmOrgGroupComInfo;
import weaver.hrm.resource.ResourceComInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 */
public class HrmGroupAction {


    /**
     * 人力资源分组成员删除
     * @param request
     * @param response
     * @return
     */
    @POST
    @Path("/members/delete")
    @Produces({MediaType.TEXT_PLAIN})
    public String deleteGroupMember(@Context HttpServletRequest request, @Context HttpServletResponse response){

        Map<String, Object> apidatas = new HashMap<String, Object>();
        String groupid = request.getParameter("groupid");
        String userids = request.getParameter("userids");
        try {
            String dataSql = " delete from HrmGroupMembers where groupid=? and userid in ("+userids+") ";
            RecordSet rs = new RecordSet();
            boolean res = rs.executeUpdate(dataSql,new Object[]{groupid});
           if (res){
               apidatas.put("success", true);
           }else{
               apidatas.put("success", false);
           }

        } catch (Exception e) {
            e.printStackTrace();
            apidatas.put("success", false);
        }
        return JSONObject.toJSONString(apidatas);
    }



}
