|
|
@@ -26,11 +26,13 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
26
|
26
|
{
|
|
27
|
27
|
|
|
28
|
28
|
private readonly IBus_ProductRepository _productRepository;
|
|
29
|
|
- private readonly IBus_ProductClassRepository _productClassRepository;
|
|
30
|
|
- public ProductController(IBus_ProductRepository productRepository, IBus_ProductClassRepository productClassRepository)
|
|
|
29
|
+ private readonly IBus_ProductClassRepository _productClassRepository;
|
|
|
30
|
+ private readonly IBus_TagRepository _tagRepository;
|
|
|
31
|
+ public ProductController(IBus_ProductRepository productRepository, IBus_ProductClassRepository productClassRepository, IBus_TagRepository tagRepository)
|
|
31
|
32
|
{
|
|
32
|
33
|
_productRepository = productRepository;
|
|
33
|
34
|
_productClassRepository = productClassRepository;
|
|
|
35
|
+ _tagRepository = tagRepository;
|
|
34
|
36
|
}
|
|
35
|
37
|
[AllowAnonymous]
|
|
36
|
38
|
[HttpGet("/api/test")]
|
|
|
@@ -658,6 +660,167 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
658
|
660
|
|
|
659
|
661
|
#endregion
|
|
660
|
662
|
|
|
|
663
|
+
|
|
|
664
|
+
|
|
|
665
|
+ #region 标签操作
|
|
|
666
|
+
|
|
|
667
|
+ /// <summary>
|
|
|
668
|
+ /// 新增标签
|
|
|
669
|
+ /// </summary>
|
|
|
670
|
+ /// <param name="input"></param>
|
|
|
671
|
+ /// <returns></returns>
|
|
|
672
|
+ [HttpPost("addtag")]
|
|
|
673
|
+ public async Task<IActionResult> AddTag(TagInput input)
|
|
|
674
|
+ {
|
|
|
675
|
+
|
|
|
676
|
+ #region 验证 参数
|
|
|
677
|
+
|
|
|
678
|
+
|
|
|
679
|
+ if (string.IsNullOrEmpty(input.TagName))
|
|
|
680
|
+ return Error("请输入分类名称");
|
|
|
681
|
+ if (input.CLass<1)
|
|
|
682
|
+ return Error("请输入标签分类");
|
|
|
683
|
+ if (input.Type < 0)
|
|
|
684
|
+ input.Type = 1;
|
|
|
685
|
+
|
|
|
686
|
+ #endregion
|
|
|
687
|
+ Expression<Func<T_Bus_Tag, bool>> eq = a => a.F_TagName == input.TagName;
|
|
|
688
|
+
|
|
|
689
|
+ if (await _tagRepository.GetCount(eq.And(b => b.F_Type == input.Type)) > 0)
|
|
|
690
|
+ {
|
|
|
691
|
+ return Error("标签名称重复");
|
|
|
692
|
+ }
|
|
|
693
|
+ T_Bus_Tag T_Bus_TagModel = new T_Bus_Tag();
|
|
|
694
|
+
|
|
|
695
|
+ T_Bus_TagModel.F_Type = input.Type;
|
|
|
696
|
+ T_Bus_TagModel.F_TagName = input.TagName;
|
|
|
697
|
+ T_Bus_TagModel.F_Sort = 100;
|
|
|
698
|
+ T_Bus_TagModel.F_CLass = input.CLass;
|
|
|
699
|
+ T_Bus_TagModel.F_UserName = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Name).Value;
|
|
|
700
|
+ T_Bus_TagModel.F_UserId = int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.PrimarySid).Value, 0);
|
|
|
701
|
+ T_Bus_TagModel.F_UpdateTime = DateTime.Now;
|
|
|
702
|
+
|
|
|
703
|
+ if (await _tagRepository.Add(T_Bus_TagModel) > 0)
|
|
|
704
|
+ {
|
|
|
705
|
+ return Success("新增标签成功");
|
|
|
706
|
+ }
|
|
|
707
|
+ else
|
|
|
708
|
+ {
|
|
|
709
|
+ return Error("标签重复或失败,请重试!");
|
|
|
710
|
+ }
|
|
|
711
|
+ }
|
|
|
712
|
+
|
|
|
713
|
+
|
|
|
714
|
+ /// <summary>
|
|
|
715
|
+ /// 更新标签
|
|
|
716
|
+ /// </summary>
|
|
|
717
|
+ /// <param name="input"></param>
|
|
|
718
|
+ /// <returns></returns>
|
|
|
719
|
+ [HttpPost("updatetag")]
|
|
|
720
|
+ public async Task<IActionResult> UpdateTag(TagInput input)
|
|
|
721
|
+ {
|
|
|
722
|
+
|
|
|
723
|
+ #region 验证 参数
|
|
|
724
|
+
|
|
|
725
|
+
|
|
|
726
|
+ if (string.IsNullOrEmpty(input.TagName))
|
|
|
727
|
+ return Error("请输入原标签名称");
|
|
|
728
|
+ if (string.IsNullOrEmpty(input.NewTagName))
|
|
|
729
|
+ return Error("请输入标签名称");
|
|
|
730
|
+ if (input.Type < 0)
|
|
|
731
|
+ input.Type = 1;
|
|
|
732
|
+ if (input.Sort <1)
|
|
|
733
|
+ return Error("请输入标签排序序号");
|
|
|
734
|
+
|
|
|
735
|
+ #endregion
|
|
|
736
|
+
|
|
|
737
|
+ Expression<Func<T_Bus_Tag, bool>> eq = a => a.F_TagName == input.TagName;
|
|
|
738
|
+
|
|
|
739
|
+ T_Bus_Tag T_Bus_TagModel = await _tagRepository.GetSingle(eq.And(b=>b.F_Type== input.Type));
|
|
|
740
|
+ //除非某固定权限 定之后再加
|
|
|
741
|
+ if (T_Bus_TagModel.F_CLass == 1)
|
|
|
742
|
+ {
|
|
|
743
|
+ return Error("系统标签不能更改");
|
|
|
744
|
+ }
|
|
|
745
|
+ T_Bus_TagModel.F_TagName = input.NewTagName;
|
|
|
746
|
+ T_Bus_TagModel.F_Sort = input.Sort;
|
|
|
747
|
+
|
|
|
748
|
+
|
|
|
749
|
+ T_Bus_TagModel.F_UserName = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Name).Value;
|
|
|
750
|
+ T_Bus_TagModel.F_UserId = int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.PrimarySid).Value, 0);
|
|
|
751
|
+ T_Bus_TagModel.F_UpdateTime = DateTime.Now;
|
|
|
752
|
+
|
|
|
753
|
+ if (await _tagRepository.Update(T_Bus_TagModel))
|
|
|
754
|
+ {
|
|
|
755
|
+ return Success("更新标签成功");
|
|
|
756
|
+ }
|
|
|
757
|
+ else
|
|
|
758
|
+ {
|
|
|
759
|
+ return Error("标签重复或失败,请重试!");
|
|
|
760
|
+ }
|
|
|
761
|
+ }
|
|
|
762
|
+
|
|
|
763
|
+ /// <summary>
|
|
|
764
|
+ /// 删除标签
|
|
|
765
|
+ /// </summary>
|
|
|
766
|
+ /// <param name="tagName"></param>
|
|
|
767
|
+ /// <returns></returns>
|
|
|
768
|
+ [HttpPost("deletetag")]
|
|
|
769
|
+ public async Task<IActionResult> DeleteTag(TagInput input)
|
|
|
770
|
+ {
|
|
|
771
|
+
|
|
|
772
|
+
|
|
|
773
|
+ if (string.IsNullOrEmpty(input.TagName))
|
|
|
774
|
+ return Error("请选择标签");
|
|
|
775
|
+ if (input.CLass<2)
|
|
|
776
|
+ return Error("系统标签不能删除");
|
|
|
777
|
+
|
|
|
778
|
+
|
|
|
779
|
+ Expression<Func<T_Bus_Tag, bool>> eq = a => a.F_TagName == input.TagName;
|
|
|
780
|
+ //非系统标签可以随意删除,与商品没有关联
|
|
|
781
|
+ if (await _tagRepository.Delete(eq.And(b=>b.F_Type==input.Type)))
|
|
|
782
|
+ {
|
|
|
783
|
+ return Success("删除标签成功");
|
|
|
784
|
+ }
|
|
|
785
|
+ else
|
|
|
786
|
+ {
|
|
|
787
|
+ return Error("删除标签失败,请重试!");
|
|
|
788
|
+ }
|
|
|
789
|
+ }
|
|
|
790
|
+
|
|
|
791
|
+ /// <summary>
|
|
|
792
|
+ /// 查询符合条件所有标签
|
|
|
793
|
+ /// </summary>
|
|
|
794
|
+ /// <param name="input"></param>
|
|
|
795
|
+ /// <returns></returns>
|
|
|
796
|
+ [HttpPost("gettagall")]
|
|
|
797
|
+ public async Task<IActionResult> GetTagAll(TagInput input)
|
|
|
798
|
+ {
|
|
|
799
|
+
|
|
|
800
|
+
|
|
|
801
|
+ #region 拼接条件
|
|
|
802
|
+
|
|
|
803
|
+ Expression<Func<T_Bus_Tag, bool>> eq = a => a.F_Type == 1;
|
|
|
804
|
+
|
|
|
805
|
+ //if (input.Type > 0)
|
|
|
806
|
+ // eq = eq.And(a => a.F_Type == input.Type);
|
|
|
807
|
+ if (input.CLass > 0)
|
|
|
808
|
+ {
|
|
|
809
|
+ eq = eq.And(a => a.F_CLass == input.CLass);
|
|
|
810
|
+ }
|
|
|
811
|
+
|
|
|
812
|
+
|
|
|
813
|
+ #endregion
|
|
|
814
|
+
|
|
|
815
|
+
|
|
|
816
|
+ List<T_Bus_Tag> list = await _tagRepository.GetListALL(eq,c=>c.F_Sort,OrderByType.Asc);
|
|
|
817
|
+
|
|
|
818
|
+ return Success("成功", list);
|
|
|
819
|
+
|
|
|
820
|
+ }
|
|
|
821
|
+
|
|
|
822
|
+ #endregion
|
|
|
823
|
+
|
|
661
|
824
|
#region 库存对接
|
|
662
|
825
|
|
|
663
|
826
|
/// <summary>
|