DeptAPIService.java 2.55 KB
package com.huaheng.api.U8.Service;


import com.huaheng.api.U8.domain.ICSDepartmentModel;
import com.huaheng.api.general.Controller.BasicDataApi;
import com.huaheng.api.general.service.BasicDataApiService;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.general.company.domain.WarehouseCompany;
import com.huaheng.pc.general.company.mapper.WarehouseCompanyMapperAuto;
import com.huaheng.pc.system.dept.domain.Dept;
import com.huaheng.pc.system.dept.service.IDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class DeptAPIService {
    @Autowired
    IDeptService iDeptService;

    @Resource
    private WarehouseCompanyMapperAuto warehouseCompanyMapperAuto;

    @Autowired
    BasicDataApiService basicDataApiService;

    @Transactional
    public AjaxResult ICSDepartment(ICSDepartmentModel ICSDepartment) {
        Dept dept = new Dept();
        dept.setCode(ICSDepartment.getcDepCode());
        dept.setDeptName(ICSDepartment.getcDepName());
        dept.setCreateTime(new Date());
        dept.setUpdateTime(new Date());
        AjaxResult ajaxResult = basicDataApiService.dept(dept);
        return ajaxResult;

//        int result = 0
//        判断部门中是否有该部门,如果没有则新增,有则更新
//        if (iDeptService.selectDepts(ICSDepartment.getcDepCode()) == null) {
//            Dept dept = new Dept();
//            dept.setCode(ICSDepartment.getcDepCode());
//            dept.setDeptName(ICSDepartment.getcDepName());
//            dept.setCreateTime(new Date());
//            dept.setUpdateTime(new Date());
//            result = iDeptService.insertDepts(dept);
//            if (result < 1) {
//                throw new ServiceException("新增部门档案失败!");
//            } else {
//                return AjaxResult.success("新增部门档案成功");
//            }
//        } else {
//            Dept dept = new Dept();
//            dept.setCode(ICSDepartment.getcDepCode());
//            dept.setDeptName(ICSDepartment.getcDepName());
//            dept.setUpdateTime(new Date());
//            result = iDeptService.insertDepts(dept);
//            if (result < 1) {
//                throw new ServiceException("更新部门档案失败!");
//            }else {
//                return AjaxResult.success("更新部门档案成功");
//            }
//        }

    }
}