diff --git a/src/com/engine/salary/biz/SICategoryBiz.java b/src/com/engine/salary/biz/SICategoryBiz.java index bf60175fa..c88b067f4 100644 --- a/src/com/engine/salary/biz/SICategoryBiz.java +++ b/src/com/engine/salary/biz/SICategoryBiz.java @@ -1,13 +1,20 @@ package com.engine.salary.biz; +import com.engine.salary.entity.sicategory.bo.ICategoryBO; import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO; import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.enums.sicategory.IsPaymentEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.util.SalaryEnumUtil; import com.mzlion.core.utils.BeanUtils; +import org.apache.commons.collections4.CollectionUtils; import org.apache.ibatis.session.SqlSession; import weaver.conn.mybatis.MyBatisFactory; +import java.util.Date; +import java.util.List; import java.util.Objects; /** @@ -45,7 +52,7 @@ public class SICategoryBiz { * @param id * @return */ - private ICategoryPO getByID(Long id) { + public ICategoryPO getByID(Long id) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); @@ -56,4 +63,117 @@ public class SICategoryBiz { sqlSession.close(); } } + + /** + * 保存 + * @param iCategoryFormDTO + * @param employeeId DataTypeEnum.SYSTEM.getValue() + */ + public void save(ICategoryFormDTO iCategoryFormDTO, long employeeId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); + List iCategoryPOS = listByName(iCategoryFormDTO.getInsuranceName()); + if (CollectionUtils.isNotEmpty(iCategoryPOS)) { + throw new SalaryRunTimeException("福利名称不允许重复"); + } + ICategoryPO iCategoryPO = ICategoryBO.convertToInsuranceCategoryPO(iCategoryFormDTO, employeeId); + iCategoryMapper.insert(iCategoryPO); + + sqlSession.commit(); + + } finally { + sqlSession.close(); + } + + + } + + /** + * 根据名称获取 + * @param insuranceName + * @return + */ + public List listByName(String insuranceName) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + + try{ + ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); + List iCategoryPOS = iCategoryMapper.listByName(insuranceName); + return iCategoryPOS; + + } finally { + sqlSession.close(); + } + } + + /** + * 更新 + * @param iCategoryFormDTO + * @param employeeId + */ + public void update(ICategoryFormDTO iCategoryFormDTO, long employeeId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try{ + if (iCategoryFormDTO.getId() == null) { + throw new SalaryRunTimeException("id is required"); + } + + ICategoryPO iCategoryPO = getByID(iCategoryFormDTO.getId()); + if (Objects.isNull(iCategoryPO)) { + throw new SalaryRunTimeException("数据不存在"); + } + + List iCategoryPOS = listByName(iCategoryFormDTO.getInsuranceName()); + if (CollectionUtils.isNotEmpty(iCategoryPOS)) { + throw new SalaryRunTimeException("福利名称不允许重复"); + } + + iCategoryPO.setInsuranceName(iCategoryFormDTO.getInsuranceName()); + iCategoryPO.setWelfareType(iCategoryFormDTO.getWelfareType().getValue()); + iCategoryPO.setPaymentScope(SalaryEnumUtil.enumArrToString(iCategoryFormDTO.getPaymentScope())); + iCategoryPO.setUpdateTime(new Date()); + ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); + iCategoryMapper.update(iCategoryPO); + + sqlSession.commit(); + } finally { + sqlSession.close(); + } + + } + + /** + * 更新状态 + * @param id + * @param isUse + * @param employeeId + */ + public void updateStatusById(Long id, Integer isUse, long employeeId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + if(id == null) { + throw new SalaryRunTimeException("id is required"); + } + if (isUse == null) { + throw new SalaryRunTimeException("isUse is required"); + } + List insuranceSchemeDetailPOS = new SISchemeBiz().queryListByInsuranceIdIsPayment(id, IsPaymentEnum.YES.getValue()); + if(CollectionUtils.isNotEmpty(insuranceSchemeDetailPOS)) { + throw new SalaryRunTimeException("该福利开启缴费,不可删除(或停用"); + } + ICategoryPO iCategoryPO = getByID(id); + if (Objects.isNull(iCategoryPO)) { + throw new SalaryRunTimeException("数据记录不存在"); + } + iCategoryPO.setIsUse(isUse); + ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); + iCategoryMapper.updateById(iCategoryPO); + + sqlSession.commit(); + }finally { + sqlSession.close(); + } + + } } diff --git a/src/com/engine/salary/biz/SISchemeBiz.java b/src/com/engine/salary/biz/SISchemeBiz.java index 3a716d675..89626b24a 100644 --- a/src/com/engine/salary/biz/SISchemeBiz.java +++ b/src/com/engine/salary/biz/SISchemeBiz.java @@ -138,6 +138,10 @@ public class SISchemeBiz { } //福利方案名称重复(待写) + List insuranceSchemePOList = insuranceSchemeMapper.listByName(updateParam.getInsuranceScheme().getSchemeName()); + if (CollectionUtils.isNotEmpty(insuranceSchemePOList)) { + throw new SalaryRunTimeException("福利方案名称重复"); + } //更新福利方案主表 InsuranceSchemePO insuranceSchemePO1 = InsuranceSchemeBO.buildInsuranceSchemePO(insuranceSchemePO, updateParam.getInsuranceScheme()); @@ -229,11 +233,27 @@ public class SISchemeBiz { detailPOS.forEach(insuranceSchemeDetailMapper::insert); } - - sqlSession.commit(); }finally { sqlSession.close(); } } + + /** + * 根据险种id和是否缴费查询社保方案明细表 + * @param insuranceId 险种id + * @param isPayment 是否缴费 + * @return list + */ + public List queryListByInsuranceIdIsPayment(Long insuranceId, Integer isPayment) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class); + List insuranceSchemeDetailPOList = insuranceSchemeDetailMapper.queryListByInsuranceIdIsPayment(insuranceId,isPayment); + return insuranceSchemeDetailPOList; + }finally { + sqlSession.close(); + } + + } } diff --git a/src/com/engine/salary/cmd/sischeme/SICategoryGetFormCmd.java b/src/com/engine/salary/cmd/sicategory/SICategoryGetFormCmd.java similarity index 98% rename from src/com/engine/salary/cmd/sischeme/SICategoryGetFormCmd.java rename to src/com/engine/salary/cmd/sicategory/SICategoryGetFormCmd.java index a0f46c277..19509d28b 100644 --- a/src/com/engine/salary/cmd/sischeme/SICategoryGetFormCmd.java +++ b/src/com/engine/salary/cmd/sicategory/SICategoryGetFormCmd.java @@ -1,4 +1,4 @@ -package com.engine.salary.cmd.sischeme; +package com.engine.salary.cmd.sicategory; import com.api.browser.bean.SearchConditionItem; import com.api.browser.bean.SearchConditionOption; diff --git a/src/com/engine/salary/cmd/sicategory/SICategoryInsertCmd.java b/src/com/engine/salary/cmd/sicategory/SICategoryInsertCmd.java new file mode 100644 index 000000000..7402e6f90 --- /dev/null +++ b/src/com/engine/salary/cmd/sicategory/SICategoryInsertCmd.java @@ -0,0 +1,39 @@ +package com.engine.salary.cmd.sicategory; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.SICategoryBiz; +import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/3/9 + * @Version V1.0 + **/ +public class SICategoryInsertCmd extends AbstractCommonCommand> { + + public SICategoryInsertCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap<>(16); + SICategoryBiz siCategoryBiz = new SICategoryBiz(); + ICategoryFormDTO iCategoryFormDTO = (ICategoryFormDTO)params.get("iCategoryFormDTO"); + siCategoryBiz.save(iCategoryFormDTO,(long) user.getUID()); + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/sicategory/SICategoryUpdateCmd.java b/src/com/engine/salary/cmd/sicategory/SICategoryUpdateCmd.java new file mode 100644 index 000000000..de6840f4e --- /dev/null +++ b/src/com/engine/salary/cmd/sicategory/SICategoryUpdateCmd.java @@ -0,0 +1,39 @@ +package com.engine.salary.cmd.sicategory; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.SICategoryBiz; +import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/3/10 + * @Version V1.0 + **/ +public class SICategoryUpdateCmd extends AbstractCommonCommand> { + + public SICategoryUpdateCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + SICategoryBiz siCategoryBiz = new SICategoryBiz(); + ICategoryFormDTO iCategoryFormDTO = (ICategoryFormDTO) params.get("iCategoryFormDTO"); + siCategoryBiz.update(iCategoryFormDTO, (long) user.getUID()); + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/sicategory/SICategoryUpdateStatusByIdCmd.java b/src/com/engine/salary/cmd/sicategory/SICategoryUpdateStatusByIdCmd.java new file mode 100644 index 000000000..d5190fc90 --- /dev/null +++ b/src/com/engine/salary/cmd/sicategory/SICategoryUpdateStatusByIdCmd.java @@ -0,0 +1,40 @@ +package com.engine.salary.cmd.sicategory; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.SICategoryBiz; +import com.engine.salary.entity.sicategory.param.UpdateStatusParam; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/3/10 + * @Version V1.0 + **/ +public class SICategoryUpdateStatusByIdCmd extends AbstractCommonCommand>{ + + public SICategoryUpdateStatusByIdCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + SICategoryBiz siCategoryBiz = new SICategoryBiz(); + Long id = (Long) params.get("id"); + Integer isUse = (Integer) params.get("isUse"); + siCategoryBiz.updateStatusById(id, isUse,(long) user.getUID()); + return apidatas; + } +} diff --git a/src/com/engine/salary/entity/sicategory/bo/ICategoryBO.java b/src/com/engine/salary/entity/sicategory/bo/ICategoryBO.java new file mode 100644 index 000000000..26c12d79b --- /dev/null +++ b/src/com/engine/salary/entity/sicategory/bo/ICategoryBO.java @@ -0,0 +1,39 @@ +package com.engine.salary.entity.sicategory.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.enums.sicategory.DataTypeEnum; +import com.engine.salary.util.SalaryEnumUtil; + +import java.util.Date; +import java.util.Objects; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/3/10 + * @Version V1.0 + **/ +public class ICategoryBO { + + public static ICategoryPO convertToInsuranceCategoryPO(ICategoryFormDTO dto, Long employeeId) { + if (Objects.isNull(dto)) { + return null; + } + return ICategoryPO.builder() + //.id(IdGenerator.generate()) + .paymentScope(SalaryEnumUtil.enumArrToString(dto.getPaymentScope())) + .welfareType(dto.getWelfareType().getValue()) + .insuranceName(dto.getInsuranceName()) + .isUse(dto.getIsUse()) + .dataType(DataTypeEnum.CUSTOM.getValue()) + .createTime(new Date()) + .updateTime(new Date()) + .creator(employeeId) + .dataType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + + } +} diff --git a/src/com/engine/salary/entity/sicategory/param/UpdateStatusParam.java b/src/com/engine/salary/entity/sicategory/param/UpdateStatusParam.java new file mode 100644 index 000000000..f8797083d --- /dev/null +++ b/src/com/engine/salary/entity/sicategory/param/UpdateStatusParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.sicategory.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * @Description: TODO 自定义福利状态更新 + * @Date 2022/3/10 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UpdateStatusParam { + + /** + * id + */ + private Long id; + + /** + * 状态 + */ + private Integer isUse; +} diff --git a/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java index 7b6ceb429..f8925d7a3 100644 --- a/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java +++ b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java @@ -2,6 +2,8 @@ package com.engine.salary.mapper.sicategory; import com.engine.salary.entity.sicategory.po.ICategoryPO; +import java.util.List; + /** * @Author weaver_cl * @Description: TODO @@ -18,4 +20,34 @@ public interface ICategoryMapper { * @return 返回记录,没有返回null */ ICategoryPO getById(Long id); + + /** + * 根据福利名称获取 + * @param insuranceName + * @return + */ + List listByName(String insuranceName); + + /** + * 新增,插入所有字段 + * + * @param iCategoryPO 新增的记录 + * @return 返回影响行数 + */ + int insert(ICategoryPO iCategoryPO); + + /** + * 更新,更新修改的字段 + * @param iCategoryPO + * @return + */ + void update(ICategoryPO iCategoryPO); + + + /** + * 根据id更新状态 + * @param iCategoryPO + */ + void updateById(ICategoryPO iCategoryPO); + } diff --git a/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml index c68dc1ffd..22a636afc 100644 --- a/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml +++ b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml @@ -39,6 +39,67 @@ WHERE id = #{id} AND delete_type = 0 + + + INSERT INTO hrsa_insurance_category + + id, + insurance_name, + welfare_type, + is_use, + payment_scope, + data_type, + create_time, + update_time, + creator, + delete_type, + tenant_key, + + + #{id}, + #{insuranceName}, + #{welfareType}, + #{isUse}, + #{paymentScope}, + #{dataType}, + #{createTime}, + #{updateTime}, + #{creator}, + #{deleteType}, + #{tenantKey}, + + + + + + + + + UPDATE hrsa_insurance_category + + update_time=#{updateTime}, + insurance_name=#{insuranceName}, + welfare_type=#{welfareType}, + payment_scope=#{paymentScope}, + + WHERE id = #{id} AND delete_type = 0 + + + + + UPDATE hrsa_insurance_category + SET is_use = #{isUse} + WHERE id = #{id} + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java index cfe208506..5a73c1a95 100644 --- a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java +++ b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java @@ -14,7 +14,11 @@ import java.util.List; **/ public interface InsuranceSchemeDetailMapper { - + /** + * 查询当前方案下面配置的福利类型明细 + * + * @return list + */ List listByPrimaryId(Long primaryId); /** @@ -31,4 +35,14 @@ public interface InsuranceSchemeDetailMapper { * @param primaryIds */ void batchDeleteByPrimaryIds(@Param("primaryIds") Collection primaryIds); + + /** + * 根据险种id和是否缴费查询社保方案明细表 + * + * @param insuranceId 险种id + * @param isPayment 是否缴费 + * @return list + */ + List queryListByInsuranceIdIsPayment(@Param("insuranceId") Long insuranceId, @Param("isPayment") Integer isPayment); + } diff --git a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.xml b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.xml index 76a73160d..a1d1c86b6 100644 --- a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.xml +++ b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.xml @@ -110,6 +110,14 @@ + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java index 48e8caded..d64095dd2 100644 --- a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java +++ b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java @@ -2,6 +2,8 @@ package com.engine.salary.mapper.sischeme; import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; +import java.util.List; + /** * @Author weaver_cl * @Description: TODO @@ -31,4 +33,11 @@ public interface InsuranceSchemeMapper { * @return */ int update(InsuranceSchemePO insuranceSchemePO); + + /** + * 根据名称查询 + * @param schemeName + * @return + */ + List listByName(String schemeName); } diff --git a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.xml b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.xml index b41552ed0..d673ad89d 100644 --- a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.xml +++ b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.xml @@ -41,6 +41,16 @@ WHERE id = #{id} AND delete_type = 0 + + + + getForm(Map params); + + Map insert(Map params); + + Map update(Map params); + + Map updateStatusById(Map params); } diff --git a/src/com/engine/salary/service/SISchemeService.java b/src/com/engine/salary/service/SISchemeService.java index fb1589b49..68f567b41 100644 --- a/src/com/engine/salary/service/SISchemeService.java +++ b/src/com/engine/salary/service/SISchemeService.java @@ -1,5 +1,8 @@ package com.engine.salary.service; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; + +import java.util.List; import java.util.Map; /** @@ -19,4 +22,6 @@ public interface SISchemeService { Map delete(Map params); Map copyScheme(Map params); + + List queryListByInsuranceIdIsPayment(Long insuranceId, Integer isPayment); } diff --git a/src/com/engine/salary/service/impl/SICategoryServiceImpl.java b/src/com/engine/salary/service/impl/SICategoryServiceImpl.java index 52250107f..5225bc9b8 100644 --- a/src/com/engine/salary/service/impl/SICategoryServiceImpl.java +++ b/src/com/engine/salary/service/impl/SICategoryServiceImpl.java @@ -1,7 +1,10 @@ package com.engine.salary.service.impl; import com.engine.core.impl.Service; -import com.engine.salary.cmd.sischeme.SICategoryGetFormCmd; +import com.engine.salary.cmd.sicategory.SICategoryGetFormCmd; +import com.engine.salary.cmd.sicategory.SICategoryInsertCmd; +import com.engine.salary.cmd.sicategory.SICategoryUpdateCmd; +import com.engine.salary.cmd.sicategory.SICategoryUpdateStatusByIdCmd; import com.engine.salary.service.SICategoryService; import java.util.Map; @@ -18,4 +21,19 @@ public class SICategoryServiceImpl extends Service implements SICategoryService public Map getForm(Map params) { return commandExecutor.execute(new SICategoryGetFormCmd(params,user)); } + + @Override + public Map insert(Map params) { + return commandExecutor.execute(new SICategoryInsertCmd(params,user)); + } + + @Override + public Map update(Map params) { + return commandExecutor.execute(new SICategoryUpdateCmd(params,user)); + } + + @Override + public Map updateStatusById(Map params) { + return commandExecutor.execute(new SICategoryUpdateStatusByIdCmd(params,user)); + } } diff --git a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java index 7e86960bc..b55d41e13 100644 --- a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java @@ -1,9 +1,12 @@ package com.engine.salary.service.impl; import com.engine.core.impl.Service; +import com.engine.salary.biz.SISchemeBiz; import com.engine.salary.cmd.sischeme.*; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; import com.engine.salary.service.SISchemeService; +import java.util.List; import java.util.Map; /** @@ -38,4 +41,9 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { public Map copyScheme(Map params) { return commandExecutor.execute(new SISchemeCopyCmd(params,user)); } + + @Override + public List queryListByInsuranceIdIsPayment(Long insuranceId, Integer isPayment) { + return new SISchemeBiz().queryListByInsuranceIdIsPayment(insuranceId,isPayment); + } } diff --git a/src/com/engine/salary/web/SICategoryController.java b/src/com/engine/salary/web/SICategoryController.java index 83ac33499..74e561b5e 100644 --- a/src/com/engine/salary/web/SICategoryController.java +++ b/src/com/engine/salary/web/SICategoryController.java @@ -2,20 +2,21 @@ package com.engine.salary.web; import com.engine.common.util.ParamUtil; import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO; +import com.engine.salary.entity.sicategory.param.UpdateStatusParam; import com.engine.salary.service.SICategoryService; import com.engine.salary.service.impl.SICategoryServiceImpl; import com.engine.salary.util.ResponseResult; +import io.swagger.v3.oas.annotations.parameters.RequestBody; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import java.util.Collection; import java.util.Map; /** @@ -38,7 +39,7 @@ public class SICategoryController { * @return */ @GET - @Path("/getForm") + @Path("/customCategoryForm") @Produces(MediaType.APPLICATION_JSON) public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { @@ -47,4 +48,69 @@ public class SICategoryController { map.put("id",id); return ResponseResult.run(getService(user)::getForm, map); } + + + /** + * 新增 + * @param request + * @param response + * @return + */ + @POST + @Path("/createSICategory") + @Produces(MediaType.APPLICATION_JSON) + public String insert(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ICategoryFormDTO iCategoryFormDTO) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("iCategoryFormDTO",iCategoryFormDTO); + return ResponseResult.run(getService(user)::insert, map); + } + + /** + * 编辑 + * @param request + * @param response + * @param iCategoryFormDTO + * @return + */ + @POST + @Path("/updateCustomCategory") + @Produces(MediaType.APPLICATION_JSON) + public String update(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody ICategoryFormDTO iCategoryFormDTO) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("iCategoryFormDTO",iCategoryFormDTO); + return ResponseResult.run(getService(user)::update, map); + } + + /** + * 该接口暂时没用,删除福利类型对档案和台账核算都有很大的影响,暂时还没考虑好怎么做 + * 删除福利类型 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/deleteCustomCategory") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSoftById(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return null; + //return ResponseResult.run(getService(user)::delete, map); + } + + + + @POST + @Path("/updateCustomCategoryStatus") + @Produces(MediaType.APPLICATION_JSON) + public String updateStatusById(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody UpdateStatusParam updateStatusParam) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("id",updateStatusParam.getId()); + map.put("isUse",updateStatusParam.getIsUse()); + return ResponseResult.run(getService(user)::updateStatusById, map); + } + }