|
@@ -0,0 +1,205 @@
|
|
|
+package org.jeecg.ctop.finance.policy.controller;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLDecoder;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
|
+import java.util.Date;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+
|
|
|
+import org.jeecg.ctop.finance.policy.entity.CwjsSaleAssistantInfo;
|
|
|
+import org.jeecg.ctop.finance.policy.service.ICwjsSaleAssistantInfoService;
|
|
|
+import org.jeecg.ctop.finance.policy.utils.Check;
|
|
|
+import org.jeecg.modules.system.service.ISysRoleService;
|
|
|
+import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
+import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
+import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
|
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * aaa
|
|
|
+ * @author jeecg-boot
|
|
|
+ * @date 2021-10-18
|
|
|
+ * @version V1.0
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Api(tags="销售与销售助理关系")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/cwjsSaleAssistantInfo")
|
|
|
+public class CwjsSaleAssistantInfoController {
|
|
|
+ @Autowired
|
|
|
+ private ICwjsSaleAssistantInfoService cwjsSaleAssistantInfoService;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysRoleService roleService;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页列表查询
|
|
|
+ * @param cwjsSaleAssistantInfo
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value="销售与销售助理关系-分页列表查询", notes="销售与销售助理对应关系-分页列表查询")
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ public Result<IPage<CwjsSaleAssistantInfo>> queryPageList(CwjsSaleAssistantInfo cwjsSaleAssistantInfo,
|
|
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ Result<IPage<CwjsSaleAssistantInfo>> result = new Result<>();
|
|
|
+ QueryWrapper<CwjsSaleAssistantInfo> queryWrapper = QueryGenerator.initQueryWrapper(cwjsSaleAssistantInfo, req.getParameterMap());
|
|
|
+ Page<CwjsSaleAssistantInfo> page = new Page<CwjsSaleAssistantInfo>(pageNo, pageSize);
|
|
|
+ IPage<CwjsSaleAssistantInfo> pageList = cwjsSaleAssistantInfoService.page(page, queryWrapper);
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(pageList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ * @param cwjsSaleAssistantInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value="销售与销售助理对应关系-添加", notes="销售与销售助理对应关系-添加")
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ public Result<CwjsSaleAssistantInfo> add(@RequestBody CwjsSaleAssistantInfo cwjsSaleAssistantInfo) {
|
|
|
+ Result<CwjsSaleAssistantInfo> result = new Result<>();
|
|
|
+ try {
|
|
|
+ cwjsSaleAssistantInfoService.save(cwjsSaleAssistantInfo);
|
|
|
+ result.success("添加成功!");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ result.error500("操作失败");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ * @param cwjsSaleAssistantInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value="销售与销售助理对应关系-编辑", notes="销售与销售助理对应关系-编辑")
|
|
|
+ @PostMapping(value = "/edit")
|
|
|
+ public Result<CwjsSaleAssistantInfo> edit(@RequestBody CwjsSaleAssistantInfo cwjsSaleAssistantInfo) {
|
|
|
+ Result<CwjsSaleAssistantInfo> result = new Result<CwjsSaleAssistantInfo>();
|
|
|
+ CwjsSaleAssistantInfo cwjsSaleAssistantInfoEntity = cwjsSaleAssistantInfoService.getById(cwjsSaleAssistantInfo.getId());
|
|
|
+ if(cwjsSaleAssistantInfoEntity==null) {
|
|
|
+ result.error500("未找到对应实体");
|
|
|
+ }else {
|
|
|
+ boolean ok = cwjsSaleAssistantInfoService.updateById(cwjsSaleAssistantInfo);
|
|
|
+ if(ok) {
|
|
|
+ result.success("修改成功!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id删除
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value="销售与销售助理对应关系-通过id删除", notes="销售与销售助理对应关系-通过id删除")
|
|
|
+ @GetMapping(value = "/delete")
|
|
|
+ public Result<?> delete(@RequestParam(name="id") String id) {
|
|
|
+ try {
|
|
|
+ cwjsSaleAssistantInfoService.removeById(id);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("删除失败",e.getMessage());
|
|
|
+ return Result.error("删除失败!");
|
|
|
+ }
|
|
|
+ return Result.ok("删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value="销售与销售助理对应关系-批量删除", notes="销售与销售助理对应关系-批量删除")
|
|
|
+ @DeleteMapping(value = "/deleteBatch")
|
|
|
+ public Result<CwjsSaleAssistantInfo> deleteBatch(@RequestParam(name="ids") String ids) {
|
|
|
+ Result<CwjsSaleAssistantInfo> result = new Result<>();
|
|
|
+ if(ids==null || "".equals(ids.trim())) {
|
|
|
+ result.error500("参数不识别!");
|
|
|
+ }else {
|
|
|
+ this.cwjsSaleAssistantInfoService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
+ result.success("删除成功!");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value="销售与销售助理对应关系-通过id查询", notes="销售与销售助理对应关系-通过id查询")
|
|
|
+ @GetMapping(value = "/queryById")
|
|
|
+ public Result<CwjsSaleAssistantInfo> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
+ Result<CwjsSaleAssistantInfo> result = new Result<>();
|
|
|
+ CwjsSaleAssistantInfo cwjsSaleAssistantInfo = cwjsSaleAssistantInfoService.getById(id);
|
|
|
+ if(cwjsSaleAssistantInfo==null) {
|
|
|
+ result.error500("未找到对应实体");
|
|
|
+ }else {
|
|
|
+ result.setResult(cwjsSaleAssistantInfo);
|
|
|
+ result.setSuccess(true);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value="销售/销售助理下拉框", notes="销售/销售助理下拉框")
|
|
|
+ @GetMapping(value = "/getSaleListByUserDepart")
|
|
|
+ public Result<IPage<CwjsSaleAssistantInfo>> getSaleListByUserDepart(@RequestParam(name="userId") String userId) {
|
|
|
+ //查询用户角色
|
|
|
+ String roleCode = roleService.getRoleCodeByUserId(userId);
|
|
|
+ //管理员 查询全部
|
|
|
+ if (StringUtils.equals("admin",roleCode)){
|
|
|
+ userId = null;
|
|
|
+ }
|
|
|
+ return cwjsSaleAssistantInfoService.getSaleListByUserDepart(userId);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value="政策新增-销售回显下拉框", notes="政策新增-销售回显下拉框")
|
|
|
+ @GetMapping(value = "/getCwSaleAndAssistantList")
|
|
|
+ public Result<IPage<CwjsSaleAssistantInfo>> getCwSaleAndAssistantList(@RequestParam(name="userId") String userId) {
|
|
|
+ return cwjsSaleAssistantInfoService.getCwSaleAndAssistantList(userId);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|