diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java new file mode 100644 index 0000000000..bc0555f95b --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java @@ -0,0 +1,101 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.Date; + + +/** + * 社会组织管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-18 + */ +@Data +public class AddSocietyOrgFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + /** + * 客户Id + */ + private String customerId; + /** + * 组织Id + */ + private String agencyId; + /** + * agency_id的所有上级 + */ + private String pids; + /** + * 社会组织名称 + */ + @NotBlank(message = "社会组织名称不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) + private String societyName; + /** + * 服务事项 + */ + @NotBlank(message = "服务事项不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) + private String serviceMatters; + /** + * 负责人 + */ + @NotBlank(message = "负责人名称不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) + private String personInCharge; + /** + * 负责人电话 + */ + @NotBlank(message = "负责人电话不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) + private String mobile; + /** + * 起始服务时间 + */ + @NotBlank(message = "起始服务时间不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) + private Date serviceStartTime; + /** + * 终止服务时间 + */ + @NotBlank(message = "终止服务时间不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) + private Date serviceEndTime; + /** + * 绑定管理员[组织下录入的工作人员] + */ + @NotBlank(message = "绑定管理员名称不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) + private String adminStaffId; + /** + * 地址 + */ + private String address; + /** + * 经度 + */ + private String longitude; + /** + * 维度 + */ + private String dimension; + //token中userId + private String staffId; + + public interface Add {} + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/SocietyOrgController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/SocietyOrgController.java index 315b568a9d..0eb23cde7d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/SocietyOrgController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/SocietyOrgController.java @@ -17,23 +17,17 @@ package com.epmet.controller; -import com.epmet.commons.tools.page.PageData; -import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; -import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; -import com.epmet.commons.tools.validator.group.DefaultGroup; -import com.epmet.dto.SocietyOrgDTO; -import com.epmet.excel.SocietyOrgExcel; +import com.epmet.dto.form.AddSocietyOrgFormDTO; import com.epmet.service.SocietyOrgService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletResponse; -import java.util.List; -import java.util.Map; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; /** @@ -49,46 +43,17 @@ public class SocietyOrgController { @Autowired private SocietyOrgService societyOrgService; - @GetMapping("page") - public Result> page(@RequestParam Map params){ - PageData page = societyOrgService.page(params); - return new Result>().ok(page); - } - - @GetMapping("{id}") - public Result get(@PathVariable("id") String id){ - SocietyOrgDTO data = societyOrgService.get(id); - return new Result().ok(data); - } - - @PostMapping - public Result save(@RequestBody SocietyOrgDTO dto){ - //效验数据 - ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - societyOrgService.save(dto); + /** + * @Author sun + * @Description 新增社会组织 + **/ + @PostMapping("add") + public Result add(@LoginUser TokenDto tokenDto, @RequestBody AddSocietyOrgFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, AddSocietyOrgFormDTO.Add.class); + formDTO.setCustomerId(tokenDto.getToken()); + formDTO.setStaffId(tokenDto.getUserId()); + societyOrgService.add(formDTO); return new Result(); } - @PutMapping - public Result update(@RequestBody SocietyOrgDTO dto){ - //效验数据 - ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); - societyOrgService.update(dto); - return new Result(); - } - - @DeleteMapping - public Result delete(@RequestBody String[] ids){ - //效验数据 - AssertUtils.isArrayEmpty(ids, "id"); - societyOrgService.delete(ids); - return new Result(); - } - - @GetMapping("export") - public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { - List list = societyOrgService.list(params); - ExcelUtils.exportExcelToTarget(response, null, list, SocietyOrgExcel.class); - } - } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/SocietyOrgService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/SocietyOrgService.java index da73dc29d0..846e07777f 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/SocietyOrgService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/SocietyOrgService.java @@ -18,13 +18,9 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; -import com.epmet.commons.tools.page.PageData; -import com.epmet.dto.SocietyOrgDTO; +import com.epmet.dto.form.AddSocietyOrgFormDTO; import com.epmet.entity.SocietyOrgEntity; -import java.util.List; -import java.util.Map; - /** * 社会组织管理 * @@ -34,62 +30,8 @@ import java.util.Map; public interface SocietyOrgService extends BaseService { /** - * 默认分页 - * - * @param params - * @return PageData - * @author generator - * @date 2021-11-18 - */ - PageData page(Map params); - - /** - * 默认查询 - * - * @param params - * @return java.util.List - * @author generator - * @date 2021-11-18 - */ - List list(Map params); - - /** - * 单条查询 - * - * @param id - * @return SocietyOrgDTO - * @author generator - * @date 2021-11-18 - */ - SocietyOrgDTO get(String id); - - /** - * 默认保存 - * - * @param dto - * @return void - * @author generator - * @date 2021-11-18 - */ - void save(SocietyOrgDTO dto); - - /** - * 默认更新 - * - * @param dto - * @return void - * @author generator - * @date 2021-11-18 - */ - void update(SocietyOrgDTO dto); - - /** - * 批量删除 - * - * @param ids - * @return void - * @author generator - * @date 2021-11-18 - */ - void delete(String[] ids); + * @Author sun + * @Description 新增社会组织 + **/ + void add(AddSocietyOrgFormDTO dto); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/SocietyOrgServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/SocietyOrgServiceImpl.java index 235c8f1c53..5f2c284be2 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/SocietyOrgServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/SocietyOrgServiceImpl.java @@ -17,24 +17,19 @@ package com.epmet.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; -import com.epmet.commons.tools.constant.FieldConstant; -import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.SocietyOrgDao; -import com.epmet.dto.SocietyOrgDTO; +import com.epmet.dto.form.AddSocietyOrgFormDTO; import com.epmet.entity.SocietyOrgEntity; import com.epmet.service.SocietyOrgService; -import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - /** * 社会组织管理 * @@ -43,58 +38,19 @@ import java.util.Map; */ @Service public class SocietyOrgServiceImpl extends BaseServiceImpl implements SocietyOrgService { + private static final Logger log = LoggerFactory.getLogger(SocietyOrgServiceImpl.class); - - @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, FieldConstant.CREATED_TIME, false), - getWrapper(params) - ); - return getPageData(page, SocietyOrgDTO.class); - } - - @Override - public List list(Map params) { - List entityList = baseDao.selectList(getWrapper(params)); - - return ConvertUtils.sourceToTarget(entityList, SocietyOrgDTO.class); - } - - private QueryWrapper getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); - - return wrapper; - } - - @Override - public SocietyOrgDTO get(String id) { - SocietyOrgEntity entity = baseDao.selectById(id); - return ConvertUtils.sourceToTarget(entity, SocietyOrgDTO.class); - } - + /** + * @Author sun + * @Description 新增社会组织 + **/ @Override @Transactional(rollbackFor = Exception.class) - public void save(SocietyOrgDTO dto) { + public void add(AddSocietyOrgFormDTO dto) { SocietyOrgEntity entity = ConvertUtils.sourceToTarget(dto, SocietyOrgEntity.class); + CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(dto.getCustomerId(), dto.getStaffId()); + entity.setPids(staffInfoCache.getAgencyPIds()); insert(entity); } - @Override - @Transactional(rollbackFor = Exception.class) - public void update(SocietyOrgDTO dto) { - SocietyOrgEntity entity = ConvertUtils.sourceToTarget(dto, SocietyOrgEntity.class); - updateById(entity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(String[] ids) { - // 逻辑删除(@TableLogic 注解) - baseDao.deleteBatchIds(Arrays.asList(ids)); - } - } \ No newline at end of file