|
@@ -1,8 +1,14 @@
|
|
|
package com.mokamrp.privates.controller;
|
|
package com.mokamrp.privates.controller;
|
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.mokamrp.privates.constant.Constants;
|
|
|
|
|
+import com.mokamrp.privates.constant.HttpStatus;
|
|
|
|
|
+import com.mokamrp.privates.entity.AddHandle;
|
|
|
|
|
+import com.mokamrp.privates.entity.DelHandle;
|
|
|
import com.mokamrp.privates.entity.GetEmployeeTagHandle;
|
|
import com.mokamrp.privates.entity.GetEmployeeTagHandle;
|
|
|
import com.mokamrp.privates.help.AjaxResult;
|
|
import com.mokamrp.privates.help.AjaxResult;
|
|
|
import com.mokamrp.privates.mapper.pojo.Tag;
|
|
import com.mokamrp.privates.mapper.pojo.Tag;
|
|
|
|
|
+import com.mokamrp.privates.mapper.vo.WorkEmployeeVo;
|
|
|
import com.mokamrp.privates.service.TagService;
|
|
import com.mokamrp.privates.service.TagService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.BindingResult;
|
|
import org.springframework.validation.BindingResult;
|
|
@@ -12,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* <p>
|
|
* <p>
|
|
@@ -32,5 +39,64 @@ public class TagController extends BaseController<Tag> {
|
|
|
Object res = tagService.selectEmployeeTag(getEmployeeTagHandle);
|
|
Object res = tagService.selectEmployeeTag(getEmployeeTagHandle);
|
|
|
return AjaxResult.success(res);
|
|
return AjaxResult.success(res);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/add")
|
|
|
|
|
+ public Object add(@Valid @RequestBody AddHandle<Tag> addHandle, BindingResult bindingResult) {
|
|
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
|
|
+ return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ Boolean res;
|
|
|
|
|
+ Date date = new Date();
|
|
|
|
|
+
|
|
|
|
|
+ QueryWrapper<Tag> obj = new QueryWrapper<Tag>();
|
|
|
|
|
+ obj.eq("tag_name",addHandle.getRaw().getTagName() );
|
|
|
|
|
+ obj.eq("tag_type",addHandle.getRaw().getTagType() );
|
|
|
|
|
+
|
|
|
|
|
+ Tag tag = service.getOne(obj);
|
|
|
|
|
+ if(tag != null){
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改
|
|
|
|
|
+ */
|
|
|
|
|
+ tag.setTagGroupId(addHandle.getRaw().getTagGroupId() );
|
|
|
|
|
+ res = service.updateById(tag);
|
|
|
|
|
+
|
|
|
|
|
+ return AjaxResult.success(Constants.SUCCESS, res);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新增
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ res = service.save(addHandle.getRaw());
|
|
|
|
|
+ if (res) {
|
|
|
|
|
+ return AjaxResult.success(Constants.SUCCESS, res);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return AjaxResult.error("新增失败", res);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/del")
|
|
|
|
|
+ public Object delete(@Valid @RequestBody DelHandle<Tag> delHandle, BindingResult bindingResult) {
|
|
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
|
|
+ return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ QueryWrapper<Tag> obj = new QueryWrapper<Tag>();
|
|
|
|
|
+ obj.eq("id",delHandle.getIds());
|
|
|
|
|
+
|
|
|
|
|
+ Tag tag = service.getOne(obj);
|
|
|
|
|
+ if(tag !=null){
|
|
|
|
|
+ tag.setTagGroupId(0);
|
|
|
|
|
+ boolean res = service.updateById(tag);
|
|
|
|
|
+ if (!res) {
|
|
|
|
|
+ return AjaxResult.error("删除失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return AjaxResult.success(Constants.SUCCESS, null);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|