|
@@ -1,11 +1,18 @@
|
|
package cn.com.ctop.okr.controller;
|
|
package cn.com.ctop.okr.controller;
|
|
|
|
|
|
|
|
+import cn.com.ctop.okr.entity.OkrKrInfo;
|
|
import cn.com.ctop.okr.service.IKrAlignInfoService;
|
|
import cn.com.ctop.okr.service.IKrAlignInfoService;
|
|
|
|
+import cn.com.ctop.okr.service.IKrInfoservice;
|
|
|
|
+import cn.com.ctop.okr.utils.StringUtils;
|
|
|
|
+import cn.com.ctop.okr.vo.Result;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@@ -13,12 +20,139 @@ import java.util.Map;
|
|
public class OkrKrController {
|
|
public class OkrKrController {
|
|
@Autowired
|
|
@Autowired
|
|
private IKrAlignInfoService alignInfoService;
|
|
private IKrAlignInfoService alignInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKrInfoservice krInfoservice;
|
|
|
|
+ @PostMapping("alignList")
|
|
|
|
+ public Map<String,Object>alignList(Long originId){
|
|
|
|
+ return alignInfoService.alignListByParams(originId);
|
|
|
|
+ }
|
|
|
|
+
|
|
@PostMapping("addAlign")
|
|
@PostMapping("addAlign")
|
|
- public Map<String,Object>addAlign(Long originId,Long alignId){
|
|
|
|
|
|
+ public Map<String,Object>addAlign(Long originId, String alignId){
|
|
return alignInfoService.addAlign(originId,alignId);
|
|
return alignInfoService.addAlign(originId,alignId);
|
|
}
|
|
}
|
|
@PostMapping("deleteAlign")
|
|
@PostMapping("deleteAlign")
|
|
public Map<String,Object>deleteAlign(Long originId,Long alignId){
|
|
public Map<String,Object>deleteAlign(Long originId,Long alignId){
|
|
return alignInfoService.deleteAlign(originId,alignId);
|
|
return alignInfoService.deleteAlign(originId,alignId);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页列表查询
|
|
|
|
+ *
|
|
|
|
+ * @param krInfo
|
|
|
|
+ * @param pageNo
|
|
|
|
+ * @param pageSize
|
|
|
|
+ * @param req
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/list")
|
|
|
|
+ public Result<IPage<OkrKrInfo>> queryPageList(OkrKrInfo krInfo,
|
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
|
|
|
+ Result<IPage<OkrKrInfo>> result = new Result<>();
|
|
|
|
+ QueryWrapper<OkrKrInfo> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ if(null!=krInfo.getUserId()&&!krInfo.getUserId().trim().equals("")){
|
|
|
|
+ queryWrapper.eq("user_id",krInfo.getUserId());
|
|
|
|
+ }
|
|
|
|
+ queryWrapper.eq("year",krInfo.getYear());
|
|
|
|
+ queryWrapper.eq("quarter",krInfo.getQuarter());
|
|
|
|
+ Page<OkrKrInfo> page = new Page<>(pageNo, pageSize);
|
|
|
|
+ IPage<OkrKrInfo> pageList = krInfoservice.page(page, queryWrapper);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(pageList);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加
|
|
|
|
+ *
|
|
|
|
+ * @param fileInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "/add")
|
|
|
|
+ public Result<OkrKrInfo> add(@RequestBody OkrKrInfo fileInfo) {
|
|
|
|
+ Result<OkrKrInfo> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ krInfoservice.save(fileInfo);
|
|
|
|
+ result.success("添加成功!");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ result.error500("操作失败");
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 编辑
|
|
|
|
+ *
|
|
|
|
+ * @param fileInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PutMapping(value = "/edit")
|
|
|
|
+ public Result<OkrKrInfo> edit(@RequestBody OkrKrInfo fileInfo) {
|
|
|
|
+ Result<OkrKrInfo> result = new Result<>();
|
|
|
|
+ OkrKrInfo fileInfoEntity = krInfoservice.getById(fileInfo.getId());
|
|
|
|
+ if (fileInfoEntity == null) {
|
|
|
|
+ result.error500("未找到对应实体");
|
|
|
|
+ } else {
|
|
|
|
+ boolean ok = krInfoservice.updateById(fileInfo);
|
|
|
|
+ if (ok) {
|
|
|
|
+ result.success("修改成功!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 通过id删除
|
|
|
|
+ *
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @DeleteMapping(value = "/delete")
|
|
|
|
+ public Result<Object> delete(@RequestParam(name = "id", required = true) String id) {
|
|
|
|
+ try {
|
|
|
|
+ krInfoservice.removeById(id);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ return Result.error("删除失败!");
|
|
|
|
+ }
|
|
|
|
+ return Result.ok("删除成功!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批量删除
|
|
|
|
+ *
|
|
|
|
+ * @param ids
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @DeleteMapping(value = "/deleteBatch")
|
|
|
|
+ public Result<OkrKrInfo> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
|
|
|
+ Result<OkrKrInfo> result = new Result<>();
|
|
|
|
+ if (ids == null || "".equals(ids.trim())) {
|
|
|
|
+ result.error500("参数不识别!");
|
|
|
|
+ } else {
|
|
|
|
+ krInfoservice.removeByIds(Arrays.asList(ids.split(StringUtils.COMMA)));
|
|
|
|
+ result.success("删除成功!");
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 通过id查询
|
|
|
|
+ *
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/queryById")
|
|
|
|
+ public Result<OkrKrInfo> queryById(@RequestParam(name = "id", required = true) String id) {
|
|
|
|
+ Result<OkrKrInfo> result = new Result<>();
|
|
|
|
+ OkrKrInfo fileInfo = krInfoservice.getById(id);
|
|
|
|
+ if (fileInfo == null) {
|
|
|
|
+ result.error500("未找到对应实体");
|
|
|
|
+ } else {
|
|
|
|
+ result.setResult(fileInfo);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
}
|
|
}
|