2022-05-16 11:33:19 +08:00
package com.engine.organization.service.impl ;
import com.api.browser.bean.SearchConditionGroup ;
import com.api.browser.bean.SearchConditionItem ;
import com.engine.core.impl.Service ;
import com.engine.organization.entity.TopTab ;
2022-05-16 14:29:11 +08:00
import com.engine.organization.service.GroupService ;
2022-09-01 16:57:06 +08:00
import com.engine.organization.thread.GroupTriggerRunnable ;
2022-06-07 12:02:36 +08:00
import com.engine.organization.util.HasRightUtil ;
2022-05-16 11:33:19 +08:00
import com.engine.organization.util.MenuBtn ;
2022-05-17 16:12:31 +08:00
import com.engine.organization.util.OrganizationAssert ;
2022-05-16 11:33:19 +08:00
import com.engine.organization.util.OrganizationFormItemUtil ;
import weaver.conn.RecordSet ;
import weaver.general.StringUtil ;
import weaver.general.Util ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.List ;
import java.util.Map ;
/ * *
2022-06-14 11:07:48 +08:00
* @description :
2022-05-16 11:33:19 +08:00
* @author : dxfeng
* @createTime : 2022 / 05 / 16
* @version : 1 . 0
* /
2022-05-16 14:29:11 +08:00
public class GroupServiceImpl extends Service implements GroupService {
2022-06-07 12:02:36 +08:00
private static final String RIGHT_NAME = " Group:All " ;
2022-05-16 11:33:19 +08:00
@Override
2022-05-16 14:29:11 +08:00
public Map < String , Object > getGroupFormField ( Map < String , Object > params ) {
2022-05-16 11:33:19 +08:00
Map < String , Object > apiDatas = new HashMap < > ( ) ;
List < SearchConditionItem > selectItems = new ArrayList < > ( ) ;
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
2022-08-22 15:04:38 +08:00
SearchConditionItem companyNameItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 3 , 50 , " 总部名称 " , " companyname " ) ;
companyNameItem . setRules ( " required|string " ) ;
SearchConditionItem companyDescItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , " 总部全称 " , " companydesc " ) ;
SearchConditionItem companyWebItem = OrganizationFormItemUtil . textareaItem ( user , 2 , 16 , true , 2 , 60 , " 公司网站 " , " companyweb " ) ;
2022-05-16 11:33:19 +08:00
// 赋值
String id = Util . null2String ( params . get ( " id " ) ) ;
if ( ! StringUtil . isEmpty ( id ) ) {
RecordSet rs = new RecordSet ( ) ;
String sql = " select * from HrmCompany where id in( " + id + " ) " ;
rs . executeQuery ( sql ) ;
int colcount = rs . getColCounts ( ) ;
while ( rs . next ( ) ) {
2022-09-01 16:57:06 +08:00
Map < String , Object > row = new HashMap < > ( ) ;
2022-05-16 11:33:19 +08:00
for ( int i = 1 ; i < = colcount ; i + + ) {
row . put ( rs . getColumnName ( i ) . toLowerCase ( ) , Util . null2String ( rs . getString ( i ) ) ) ;
}
// 赋值
companyNameItem . setValue ( row . get ( " companyname " ) ) ;
companyDescItem . setValue ( row . get ( " companydesc " ) ) ;
companyWebItem . setValue ( row . get ( " companyweb " ) ) ;
}
}
// 设置编辑属性
2022-08-22 15:04:38 +08:00
if ( " 1 " . equals ( Util . null2String ( params . get ( " viewattr " ) ) ) ) {
companyNameItem . setViewAttr ( 1 ) ;
companyDescItem . setViewAttr ( 1 ) ;
companyWebItem . setViewAttr ( 1 ) ;
2022-05-16 11:33:19 +08:00
}
selectItems . add ( companyNameItem ) ;
selectItems . add ( companyDescItem ) ;
selectItems . add ( companyWebItem ) ;
addGroups . add ( new SearchConditionGroup ( " 基本信息 " , true , selectItems ) ) ;
apiDatas . put ( " condition " , addGroups ) ;
return apiDatas ;
}
2022-05-17 16:12:31 +08:00
@Override
public boolean updateGroup ( Map < String , Object > params ) {
2022-06-07 12:02:36 +08:00
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
2022-05-17 16:12:31 +08:00
String id = Util . null2String ( params . get ( " id " ) ) ;
OrganizationAssert . notNull ( id , " 数据有误 " ) ;
String companyname = ( String ) params . get ( " companyname " ) ;
String companydesc = ( String ) params . get ( " companydesc " ) ;
String companyweb = ( String ) params . get ( " companyweb " ) ;
RecordSet rs = new RecordSet ( ) ;
2022-09-01 16:57:06 +08:00
boolean executeUpdate = rs . executeUpdate ( " update HrmCompany set COMPANYNAME = ?,COMPANYDESC=?,COMPANYWEB=? where id = ? " , companyname , companydesc , companyweb , id ) ;
2022-10-27 19:11:58 +08:00
new GroupTriggerRunnable ( params ) . run ( ) ;
2022-09-01 16:57:06 +08:00
return executeUpdate ;
2022-05-17 16:12:31 +08:00
}
2022-05-16 11:33:19 +08:00
@Override
public Map < String , Object > getHasRight ( ) {
Map < String , Object > btnDatas = new HashMap < > ( ) ;
ArrayList < MenuBtn > topMenuList = new ArrayList < > ( ) ;
ArrayList < MenuBtn > rightMenuList = new ArrayList < > ( ) ;
// 编辑
topMenuList . add ( MenuBtn . builder ( ) . isTop ( " 1 " ) . menuFun ( " doEdit " ) . menuIcon ( " icon-coms-edit " ) . menuName ( " 编辑 " ) . type ( " BTN_EDIT " ) . build ( ) ) ;
btnDatas . put ( " topMenu " , topMenuList ) ;
// 编辑
rightMenuList . add ( MenuBtn . builder ( ) . isTop ( " 1 " ) . menuFun ( " doEdit " ) . menuIcon ( " icon-coms-edit " ) . menuName ( " 编辑 " ) . type ( " BTN_EDIT " ) . build ( ) ) ;
btnDatas . put ( " rightMenu " , rightMenuList ) ;
2022-06-07 16:28:19 +08:00
btnDatas . put ( " hasRight " , HasRightUtil . hasRight ( user , RIGHT_NAME , true ) ) ;
2022-05-16 11:33:19 +08:00
return btnDatas ;
}
@Override
public Map < String , Object > getTabInfo ( ) {
Map < String , Object > apiDatas = new HashMap < > ( ) ;
List < TopTab > topTabs = new ArrayList < > ( ) ;
topTabs . add ( TopTab . builder ( ) . title ( " 总部信息 " ) . viewCondition ( " 1 " ) . build ( ) ) ;
apiDatas . put ( " topTabs " , topTabs ) ;
return apiDatas ;
}
2022-06-06 19:19:28 +08:00
2022-05-16 11:33:19 +08:00
}